babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. /**
  431. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  432. */
  433. export class WebRequest implements IWebRequest {
  434. private _xhr;
  435. /**
  436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  437. * i.e. when loading files, where the server/service expects an Authorization header
  438. */
  439. static CustomRequestHeaders: {
  440. [key: string]: string;
  441. };
  442. /**
  443. * Add callback functions in this array to update all the requests before they get sent to the network
  444. */
  445. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  446. private _injectCustomRequestHeaders;
  447. /**
  448. * Gets or sets a function to be called when loading progress changes
  449. */
  450. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  451. /**
  452. * Returns client's state
  453. */
  454. readonly readyState: number;
  455. /**
  456. * Returns client's status
  457. */
  458. readonly status: number;
  459. /**
  460. * Returns client's status as a text
  461. */
  462. readonly statusText: string;
  463. /**
  464. * Returns client's response
  465. */
  466. readonly response: any;
  467. /**
  468. * Returns client's response url
  469. */
  470. readonly responseURL: string;
  471. /**
  472. * Returns client's response as text
  473. */
  474. readonly responseText: string;
  475. /**
  476. * Gets or sets the expected response type
  477. */
  478. responseType: XMLHttpRequestResponseType;
  479. /** @hidden */
  480. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  481. /** @hidden */
  482. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  483. /**
  484. * Cancels any network activity
  485. */
  486. abort(): void;
  487. /**
  488. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  489. * @param body defines an optional request body
  490. */
  491. send(body?: Document | BodyInit | null): void;
  492. /**
  493. * Sets the request method, request URL
  494. * @param method defines the method to use (GET, POST, etc..)
  495. * @param url defines the url to connect with
  496. */
  497. open(method: string, url: string): void;
  498. }
  499. }
  500. declare module "babylonjs/Misc/fileRequest" {
  501. import { Observable } from "babylonjs/Misc/observable";
  502. /**
  503. * File request interface
  504. */
  505. export interface IFileRequest {
  506. /**
  507. * Raised when the request is complete (success or error).
  508. */
  509. onCompleteObservable: Observable<IFileRequest>;
  510. /**
  511. * Aborts the request for a file.
  512. */
  513. abort: () => void;
  514. }
  515. }
  516. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  517. /**
  518. * Define options used to create a render target texture
  519. */
  520. export class RenderTargetCreationOptions {
  521. /**
  522. * Specifies is mipmaps must be generated
  523. */
  524. generateMipMaps?: boolean;
  525. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  526. generateDepthBuffer?: boolean;
  527. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  528. generateStencilBuffer?: boolean;
  529. /** Defines texture type (int by default) */
  530. type?: number;
  531. /** Defines sampling mode (trilinear by default) */
  532. samplingMode?: number;
  533. /** Defines format (RGBA by default) */
  534. format?: number;
  535. }
  536. }
  537. declare module "babylonjs/Instrumentation/timeToken" {
  538. import { Nullable } from "babylonjs/types";
  539. /**
  540. * @hidden
  541. **/
  542. export class _TimeToken {
  543. _startTimeQuery: Nullable<WebGLQuery>;
  544. _endTimeQuery: Nullable<WebGLQuery>;
  545. _timeElapsedQuery: Nullable<WebGLQuery>;
  546. _timeElapsedQueryEnded: boolean;
  547. }
  548. }
  549. declare module "babylonjs/Engines/constants" {
  550. /** Defines the cross module used constants to avoid circular dependncies */
  551. export class Constants {
  552. /** Defines that alpha blending is disabled */
  553. static readonly ALPHA_DISABLE: number;
  554. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  555. static readonly ALPHA_ADD: number;
  556. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  557. static readonly ALPHA_COMBINE: number;
  558. /** Defines that alpha blending to DEST - SRC * DEST */
  559. static readonly ALPHA_SUBTRACT: number;
  560. /** Defines that alpha blending to SRC * DEST */
  561. static readonly ALPHA_MULTIPLY: number;
  562. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  563. static readonly ALPHA_MAXIMIZED: number;
  564. /** Defines that alpha blending to SRC + DEST */
  565. static readonly ALPHA_ONEONE: number;
  566. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  567. static readonly ALPHA_PREMULTIPLIED: number;
  568. /**
  569. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  570. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  571. */
  572. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  573. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  574. static readonly ALPHA_INTERPOLATE: number;
  575. /**
  576. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  577. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  578. */
  579. static readonly ALPHA_SCREENMODE: number;
  580. /**
  581. * Defines that alpha blending to SRC + DST
  582. * Alpha will be set to SRC ALPHA + DST ALPHA
  583. */
  584. static readonly ALPHA_ONEONE_ONEONE: number;
  585. /**
  586. * Defines that alpha blending to SRC * DST ALPHA + DST
  587. * Alpha will be set to 0
  588. */
  589. static readonly ALPHA_ALPHATOCOLOR: number;
  590. /**
  591. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  592. */
  593. static readonly ALPHA_REVERSEONEMINUS: number;
  594. /**
  595. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  596. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  597. */
  598. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  599. /**
  600. * Defines that alpha blending to SRC + DST
  601. * Alpha will be set to SRC ALPHA
  602. */
  603. static readonly ALPHA_ONEONE_ONEZERO: number;
  604. /** Defines that alpha blending equation a SUM */
  605. static readonly ALPHA_EQUATION_ADD: number;
  606. /** Defines that alpha blending equation a SUBSTRACTION */
  607. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  608. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  609. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  610. /** Defines that alpha blending equation a MAX operation */
  611. static readonly ALPHA_EQUATION_MAX: number;
  612. /** Defines that alpha blending equation a MIN operation */
  613. static readonly ALPHA_EQUATION_MIN: number;
  614. /**
  615. * Defines that alpha blending equation a DARKEN operation:
  616. * It takes the min of the src and sums the alpha channels.
  617. */
  618. static readonly ALPHA_EQUATION_DARKEN: number;
  619. /** Defines that the ressource is not delayed*/
  620. static readonly DELAYLOADSTATE_NONE: number;
  621. /** Defines that the ressource was successfully delay loaded */
  622. static readonly DELAYLOADSTATE_LOADED: number;
  623. /** Defines that the ressource is currently delay loading */
  624. static readonly DELAYLOADSTATE_LOADING: number;
  625. /** Defines that the ressource is delayed and has not started loading */
  626. static readonly DELAYLOADSTATE_NOTLOADED: number;
  627. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  628. static readonly NEVER: number;
  629. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  630. static readonly ALWAYS: number;
  631. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  632. static readonly LESS: number;
  633. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  634. static readonly EQUAL: number;
  635. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  636. static readonly LEQUAL: number;
  637. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  638. static readonly GREATER: number;
  639. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  640. static readonly GEQUAL: number;
  641. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  642. static readonly NOTEQUAL: number;
  643. /** Passed to stencilOperation to specify that stencil value must be kept */
  644. static readonly KEEP: number;
  645. /** Passed to stencilOperation to specify that stencil value must be replaced */
  646. static readonly REPLACE: number;
  647. /** Passed to stencilOperation to specify that stencil value must be incremented */
  648. static readonly INCR: number;
  649. /** Passed to stencilOperation to specify that stencil value must be decremented */
  650. static readonly DECR: number;
  651. /** Passed to stencilOperation to specify that stencil value must be inverted */
  652. static readonly INVERT: number;
  653. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  654. static readonly INCR_WRAP: number;
  655. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  656. static readonly DECR_WRAP: number;
  657. /** Texture is not repeating outside of 0..1 UVs */
  658. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  659. /** Texture is repeating outside of 0..1 UVs */
  660. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  661. /** Texture is repeating and mirrored */
  662. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  663. /** ALPHA */
  664. static readonly TEXTUREFORMAT_ALPHA: number;
  665. /** LUMINANCE */
  666. static readonly TEXTUREFORMAT_LUMINANCE: number;
  667. /** LUMINANCE_ALPHA */
  668. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  669. /** RGB */
  670. static readonly TEXTUREFORMAT_RGB: number;
  671. /** RGBA */
  672. static readonly TEXTUREFORMAT_RGBA: number;
  673. /** RED */
  674. static readonly TEXTUREFORMAT_RED: number;
  675. /** RED (2nd reference) */
  676. static readonly TEXTUREFORMAT_R: number;
  677. /** RG */
  678. static readonly TEXTUREFORMAT_RG: number;
  679. /** RED_INTEGER */
  680. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  681. /** RED_INTEGER (2nd reference) */
  682. static readonly TEXTUREFORMAT_R_INTEGER: number;
  683. /** RG_INTEGER */
  684. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  685. /** RGB_INTEGER */
  686. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  687. /** RGBA_INTEGER */
  688. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  689. /** UNSIGNED_BYTE */
  690. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  691. /** UNSIGNED_BYTE (2nd reference) */
  692. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  693. /** FLOAT */
  694. static readonly TEXTURETYPE_FLOAT: number;
  695. /** HALF_FLOAT */
  696. static readonly TEXTURETYPE_HALF_FLOAT: number;
  697. /** BYTE */
  698. static readonly TEXTURETYPE_BYTE: number;
  699. /** SHORT */
  700. static readonly TEXTURETYPE_SHORT: number;
  701. /** UNSIGNED_SHORT */
  702. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  703. /** INT */
  704. static readonly TEXTURETYPE_INT: number;
  705. /** UNSIGNED_INT */
  706. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  707. /** UNSIGNED_SHORT_4_4_4_4 */
  708. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  709. /** UNSIGNED_SHORT_5_5_5_1 */
  710. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  711. /** UNSIGNED_SHORT_5_6_5 */
  712. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  713. /** UNSIGNED_INT_2_10_10_10_REV */
  714. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  715. /** UNSIGNED_INT_24_8 */
  716. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  717. /** UNSIGNED_INT_10F_11F_11F_REV */
  718. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  719. /** UNSIGNED_INT_5_9_9_9_REV */
  720. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  721. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  722. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  723. /** nearest is mag = nearest and min = nearest and mip = linear */
  724. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  725. /** Bilinear is mag = linear and min = linear and mip = nearest */
  726. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  727. /** Trilinear is mag = linear and min = linear and mip = linear */
  728. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  729. /** nearest is mag = nearest and min = nearest and mip = linear */
  730. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  731. /** Bilinear is mag = linear and min = linear and mip = nearest */
  732. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  733. /** Trilinear is mag = linear and min = linear and mip = linear */
  734. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  735. /** mag = nearest and min = nearest and mip = nearest */
  736. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  737. /** mag = nearest and min = linear and mip = nearest */
  738. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  739. /** mag = nearest and min = linear and mip = linear */
  740. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  741. /** mag = nearest and min = linear and mip = none */
  742. static readonly TEXTURE_NEAREST_LINEAR: number;
  743. /** mag = nearest and min = nearest and mip = none */
  744. static readonly TEXTURE_NEAREST_NEAREST: number;
  745. /** mag = linear and min = nearest and mip = nearest */
  746. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  747. /** mag = linear and min = nearest and mip = linear */
  748. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  749. /** mag = linear and min = linear and mip = none */
  750. static readonly TEXTURE_LINEAR_LINEAR: number;
  751. /** mag = linear and min = nearest and mip = none */
  752. static readonly TEXTURE_LINEAR_NEAREST: number;
  753. /** Explicit coordinates mode */
  754. static readonly TEXTURE_EXPLICIT_MODE: number;
  755. /** Spherical coordinates mode */
  756. static readonly TEXTURE_SPHERICAL_MODE: number;
  757. /** Planar coordinates mode */
  758. static readonly TEXTURE_PLANAR_MODE: number;
  759. /** Cubic coordinates mode */
  760. static readonly TEXTURE_CUBIC_MODE: number;
  761. /** Projection coordinates mode */
  762. static readonly TEXTURE_PROJECTION_MODE: number;
  763. /** Skybox coordinates mode */
  764. static readonly TEXTURE_SKYBOX_MODE: number;
  765. /** Inverse Cubic coordinates mode */
  766. static readonly TEXTURE_INVCUBIC_MODE: number;
  767. /** Equirectangular coordinates mode */
  768. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  769. /** Equirectangular Fixed coordinates mode */
  770. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  771. /** Equirectangular Fixed Mirrored coordinates mode */
  772. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  773. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  774. static readonly SCALEMODE_FLOOR: number;
  775. /** Defines that texture rescaling will look for the nearest power of 2 size */
  776. static readonly SCALEMODE_NEAREST: number;
  777. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  778. static readonly SCALEMODE_CEILING: number;
  779. /**
  780. * The dirty texture flag value
  781. */
  782. static readonly MATERIAL_TextureDirtyFlag: number;
  783. /**
  784. * The dirty light flag value
  785. */
  786. static readonly MATERIAL_LightDirtyFlag: number;
  787. /**
  788. * The dirty fresnel flag value
  789. */
  790. static readonly MATERIAL_FresnelDirtyFlag: number;
  791. /**
  792. * The dirty attribute flag value
  793. */
  794. static readonly MATERIAL_AttributesDirtyFlag: number;
  795. /**
  796. * The dirty misc flag value
  797. */
  798. static readonly MATERIAL_MiscDirtyFlag: number;
  799. /**
  800. * The all dirty flag value
  801. */
  802. static readonly MATERIAL_AllDirtyFlag: number;
  803. /**
  804. * Returns the triangle fill mode
  805. */
  806. static readonly MATERIAL_TriangleFillMode: number;
  807. /**
  808. * Returns the wireframe mode
  809. */
  810. static readonly MATERIAL_WireFrameFillMode: number;
  811. /**
  812. * Returns the point fill mode
  813. */
  814. static readonly MATERIAL_PointFillMode: number;
  815. /**
  816. * Returns the point list draw mode
  817. */
  818. static readonly MATERIAL_PointListDrawMode: number;
  819. /**
  820. * Returns the line list draw mode
  821. */
  822. static readonly MATERIAL_LineListDrawMode: number;
  823. /**
  824. * Returns the line loop draw mode
  825. */
  826. static readonly MATERIAL_LineLoopDrawMode: number;
  827. /**
  828. * Returns the line strip draw mode
  829. */
  830. static readonly MATERIAL_LineStripDrawMode: number;
  831. /**
  832. * Returns the triangle strip draw mode
  833. */
  834. static readonly MATERIAL_TriangleStripDrawMode: number;
  835. /**
  836. * Returns the triangle fan draw mode
  837. */
  838. static readonly MATERIAL_TriangleFanDrawMode: number;
  839. /**
  840. * Stores the clock-wise side orientation
  841. */
  842. static readonly MATERIAL_ClockWiseSideOrientation: number;
  843. /**
  844. * Stores the counter clock-wise side orientation
  845. */
  846. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  847. /**
  848. * Nothing
  849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  850. */
  851. static readonly ACTION_NothingTrigger: number;
  852. /**
  853. * On pick
  854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  855. */
  856. static readonly ACTION_OnPickTrigger: number;
  857. /**
  858. * On left pick
  859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  860. */
  861. static readonly ACTION_OnLeftPickTrigger: number;
  862. /**
  863. * On right pick
  864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  865. */
  866. static readonly ACTION_OnRightPickTrigger: number;
  867. /**
  868. * On center pick
  869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  870. */
  871. static readonly ACTION_OnCenterPickTrigger: number;
  872. /**
  873. * On pick down
  874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  875. */
  876. static readonly ACTION_OnPickDownTrigger: number;
  877. /**
  878. * On double pick
  879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  880. */
  881. static readonly ACTION_OnDoublePickTrigger: number;
  882. /**
  883. * On pick up
  884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  885. */
  886. static readonly ACTION_OnPickUpTrigger: number;
  887. /**
  888. * On pick out.
  889. * This trigger will only be raised if you also declared a OnPickDown
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_OnPickOutTrigger: number;
  893. /**
  894. * On long press
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnLongPressTrigger: number;
  898. /**
  899. * On pointer over
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnPointerOverTrigger: number;
  903. /**
  904. * On pointer out
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnPointerOutTrigger: number;
  908. /**
  909. * On every frame
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnEveryFrameTrigger: number;
  913. /**
  914. * On intersection enter
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnIntersectionEnterTrigger: number;
  918. /**
  919. * On intersection exit
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnIntersectionExitTrigger: number;
  923. /**
  924. * On key down
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnKeyDownTrigger: number;
  928. /**
  929. * On key up
  930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  931. */
  932. static readonly ACTION_OnKeyUpTrigger: number;
  933. /**
  934. * Billboard mode will only apply to Y axis
  935. */
  936. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  937. /**
  938. * Billboard mode will apply to all axes
  939. */
  940. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  941. /**
  942. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  943. */
  944. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  945. /**
  946. * Gets or sets base Assets URL
  947. */
  948. static PARTICLES_BaseAssetsUrl: string;
  949. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  950. * Test order :
  951. * Is the bounding sphere outside the frustum ?
  952. * If not, are the bounding box vertices outside the frustum ?
  953. * It not, then the cullable object is in the frustum.
  954. */
  955. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  956. /** Culling strategy : Bounding Sphere Only.
  957. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  958. * It's also less accurate than the standard because some not visible objects can still be selected.
  959. * Test : is the bounding sphere outside the frustum ?
  960. * If not, then the cullable object is in the frustum.
  961. */
  962. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  963. /** Culling strategy : Optimistic Inclusion.
  964. * This in an inclusion test first, then the standard exclusion test.
  965. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  966. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  967. * Anyway, it's as accurate as the standard strategy.
  968. * Test :
  969. * Is the cullable object bounding sphere center in the frustum ?
  970. * If not, apply the default culling strategy.
  971. */
  972. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  973. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  974. * This in an inclusion test first, then the bounding sphere only exclusion test.
  975. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  976. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  977. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  978. * Test :
  979. * Is the cullable object bounding sphere center in the frustum ?
  980. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  981. */
  982. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  983. /**
  984. * No logging while loading
  985. */
  986. static readonly SCENELOADER_NO_LOGGING: number;
  987. /**
  988. * Minimal logging while loading
  989. */
  990. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  991. /**
  992. * Summary logging while loading
  993. */
  994. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  995. /**
  996. * Detailled logging while loading
  997. */
  998. static readonly SCENELOADER_DETAILED_LOGGING: number;
  999. }
  1000. }
  1001. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1002. import { Nullable } from "babylonjs/types";
  1003. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1004. /**
  1005. * This represents the required contract to create a new type of texture loader.
  1006. */
  1007. export interface IInternalTextureLoader {
  1008. /**
  1009. * Defines wether the loader supports cascade loading the different faces.
  1010. */
  1011. supportCascades: boolean;
  1012. /**
  1013. * This returns if the loader support the current file information.
  1014. * @param extension defines the file extension of the file being loaded
  1015. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1016. * @param fallback defines the fallback internal texture if any
  1017. * @param isBase64 defines whether the texture is encoded as a base64
  1018. * @param isBuffer defines whether the texture data are stored as a buffer
  1019. * @returns true if the loader can load the specified file
  1020. */
  1021. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1022. /**
  1023. * Transform the url before loading if required.
  1024. * @param rootUrl the url of the texture
  1025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1026. * @returns the transformed texture
  1027. */
  1028. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1029. /**
  1030. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1031. * @param rootUrl the url of the texture
  1032. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1033. * @returns the fallback texture
  1034. */
  1035. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1036. /**
  1037. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1038. * @param data contains the texture data
  1039. * @param texture defines the BabylonJS internal texture
  1040. * @param createPolynomials will be true if polynomials have been requested
  1041. * @param onLoad defines the callback to trigger once the texture is ready
  1042. * @param onError defines the callback to trigger in case of error
  1043. */
  1044. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1045. /**
  1046. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1047. * @param data contains the texture data
  1048. * @param texture defines the BabylonJS internal texture
  1049. * @param callback defines the method to call once ready to upload
  1050. */
  1051. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1052. }
  1053. }
  1054. declare module "babylonjs/Engines/IPipelineContext" {
  1055. /**
  1056. * Class used to store and describe the pipeline context associated with an effect
  1057. */
  1058. export interface IPipelineContext {
  1059. /**
  1060. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1061. */
  1062. isAsync: boolean;
  1063. /**
  1064. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1065. */
  1066. isReady: boolean;
  1067. /** @hidden */
  1068. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1069. }
  1070. }
  1071. declare module "babylonjs/Meshes/dataBuffer" {
  1072. /**
  1073. * Class used to store gfx data (like WebGLBuffer)
  1074. */
  1075. export class DataBuffer {
  1076. /**
  1077. * Gets or sets the number of objects referencing this buffer
  1078. */
  1079. references: number;
  1080. /** Gets or sets the size of the underlying buffer */
  1081. capacity: number;
  1082. /**
  1083. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1084. */
  1085. is32Bits: boolean;
  1086. /**
  1087. * Gets the underlying buffer
  1088. */
  1089. readonly underlyingResource: any;
  1090. }
  1091. }
  1092. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1093. /** @hidden */
  1094. export interface IShaderProcessor {
  1095. attributeProcessor?: (attribute: string) => string;
  1096. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1097. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1098. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1099. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1100. lineProcessor?: (line: string, isFragment: boolean) => string;
  1101. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1102. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1103. }
  1104. }
  1105. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1106. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1107. /** @hidden */
  1108. export interface ProcessingOptions {
  1109. defines: string[];
  1110. indexParameters: any;
  1111. isFragment: boolean;
  1112. shouldUseHighPrecisionShader: boolean;
  1113. supportsUniformBuffers: boolean;
  1114. shadersRepository: string;
  1115. includesShadersStore: {
  1116. [key: string]: string;
  1117. };
  1118. processor?: IShaderProcessor;
  1119. version: string;
  1120. platformName: string;
  1121. lookForClosingBracketForUniformBuffer?: boolean;
  1122. }
  1123. }
  1124. declare module "babylonjs/Misc/stringTools" {
  1125. /**
  1126. * Helper to manipulate strings
  1127. */
  1128. export class StringTools {
  1129. /**
  1130. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  1131. * @param str Source string
  1132. * @param suffix Suffix to search for in the source string
  1133. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1134. */
  1135. static EndsWith(str: string, suffix: string): boolean;
  1136. /**
  1137. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  1138. * @param str Source string
  1139. * @param suffix Suffix to search for in the source string
  1140. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  1141. */
  1142. static StartsWith(str: string, suffix: string): boolean;
  1143. }
  1144. }
  1145. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1146. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1147. /** @hidden */
  1148. export class ShaderCodeNode {
  1149. line: string;
  1150. children: ShaderCodeNode[];
  1151. additionalDefineKey?: string;
  1152. additionalDefineValue?: string;
  1153. isValid(preprocessors: {
  1154. [key: string]: string;
  1155. }): boolean;
  1156. process(preprocessors: {
  1157. [key: string]: string;
  1158. }, options: ProcessingOptions): string;
  1159. }
  1160. }
  1161. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1162. /** @hidden */
  1163. export class ShaderCodeCursor {
  1164. private _lines;
  1165. lineIndex: number;
  1166. readonly currentLine: string;
  1167. readonly canRead: boolean;
  1168. lines: string[];
  1169. }
  1170. }
  1171. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1172. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1173. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1174. /** @hidden */
  1175. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1176. process(preprocessors: {
  1177. [key: string]: string;
  1178. }, options: ProcessingOptions): string;
  1179. }
  1180. }
  1181. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1182. /** @hidden */
  1183. export class ShaderDefineExpression {
  1184. isTrue(preprocessors: {
  1185. [key: string]: string;
  1186. }): boolean;
  1187. }
  1188. }
  1189. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1190. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1191. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1192. /** @hidden */
  1193. export class ShaderCodeTestNode extends ShaderCodeNode {
  1194. testExpression: ShaderDefineExpression;
  1195. isValid(preprocessors: {
  1196. [key: string]: string;
  1197. }): boolean;
  1198. }
  1199. }
  1200. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1201. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1202. /** @hidden */
  1203. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1204. define: string;
  1205. not: boolean;
  1206. constructor(define: string, not?: boolean);
  1207. isTrue(preprocessors: {
  1208. [key: string]: string;
  1209. }): boolean;
  1210. }
  1211. }
  1212. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1213. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1214. /** @hidden */
  1215. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1216. leftOperand: ShaderDefineExpression;
  1217. rightOperand: ShaderDefineExpression;
  1218. isTrue(preprocessors: {
  1219. [key: string]: string;
  1220. }): boolean;
  1221. }
  1222. }
  1223. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1224. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1225. /** @hidden */
  1226. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1227. leftOperand: ShaderDefineExpression;
  1228. rightOperand: ShaderDefineExpression;
  1229. isTrue(preprocessors: {
  1230. [key: string]: string;
  1231. }): boolean;
  1232. }
  1233. }
  1234. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1235. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1236. /** @hidden */
  1237. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1238. define: string;
  1239. operand: string;
  1240. testValue: string;
  1241. constructor(define: string, operand: string, testValue: string);
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. }
  1246. }
  1247. declare module "babylonjs/Misc/loadFileError" {
  1248. import { WebRequest } from "babylonjs/Misc/webRequest";
  1249. /**
  1250. * @ignore
  1251. * Application error to support additional information when loading a file
  1252. */
  1253. export class LoadFileError extends Error {
  1254. /** defines the optional web request */
  1255. request?: WebRequest | undefined;
  1256. private static _setPrototypeOf;
  1257. /**
  1258. * Creates a new LoadFileError
  1259. * @param message defines the message of the error
  1260. * @param request defines the optional web request
  1261. */
  1262. constructor(message: string,
  1263. /** defines the optional web request */
  1264. request?: WebRequest | undefined);
  1265. }
  1266. }
  1267. declare module "babylonjs/Offline/IOfflineProvider" {
  1268. /**
  1269. * Class used to enable access to offline support
  1270. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1271. */
  1272. export interface IOfflineProvider {
  1273. /**
  1274. * Gets a boolean indicating if scene must be saved in the database
  1275. */
  1276. enableSceneOffline: boolean;
  1277. /**
  1278. * Gets a boolean indicating if textures must be saved in the database
  1279. */
  1280. enableTexturesOffline: boolean;
  1281. /**
  1282. * Open the offline support and make it available
  1283. * @param successCallback defines the callback to call on success
  1284. * @param errorCallback defines the callback to call on error
  1285. */
  1286. open(successCallback: () => void, errorCallback: () => void): void;
  1287. /**
  1288. * Loads an image from the offline support
  1289. * @param url defines the url to load from
  1290. * @param image defines the target DOM image
  1291. */
  1292. loadImage(url: string, image: HTMLImageElement): void;
  1293. /**
  1294. * Loads a file from offline support
  1295. * @param url defines the URL to load from
  1296. * @param sceneLoaded defines a callback to call on success
  1297. * @param progressCallBack defines a callback to call when progress changed
  1298. * @param errorCallback defines a callback to call on error
  1299. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1300. */
  1301. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1302. }
  1303. }
  1304. declare module "babylonjs/Misc/filesInputStore" {
  1305. /**
  1306. * Class used to help managing file picking and drag'n'drop
  1307. * File Storage
  1308. */
  1309. export class FilesInputStore {
  1310. /**
  1311. * List of files ready to be loaded
  1312. */
  1313. static FilesToLoad: {
  1314. [key: string]: File;
  1315. };
  1316. }
  1317. }
  1318. declare module "babylonjs/Misc/retryStrategy" {
  1319. import { WebRequest } from "babylonjs/Misc/webRequest";
  1320. /**
  1321. * Class used to define a retry strategy when error happens while loading assets
  1322. */
  1323. export class RetryStrategy {
  1324. /**
  1325. * Function used to defines an exponential back off strategy
  1326. * @param maxRetries defines the maximum number of retries (3 by default)
  1327. * @param baseInterval defines the interval between retries
  1328. * @returns the strategy function to use
  1329. */
  1330. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1331. }
  1332. }
  1333. declare module "babylonjs/Misc/fileTools" {
  1334. import { WebRequest } from "babylonjs/Misc/webRequest";
  1335. import { Nullable } from "babylonjs/types";
  1336. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1337. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1338. /**
  1339. * @hidden
  1340. */
  1341. export class FileTools {
  1342. /**
  1343. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1344. */
  1345. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1346. /**
  1347. * Gets or sets the base URL to use to load assets
  1348. */
  1349. static BaseUrl: string;
  1350. /**
  1351. * Default behaviour for cors in the application.
  1352. * It can be a string if the expected behavior is identical in the entire app.
  1353. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1354. */
  1355. static CorsBehavior: string | ((url: string | string[]) => string);
  1356. /**
  1357. * Gets or sets a function used to pre-process url before using them to load assets
  1358. */
  1359. static PreprocessUrl: (url: string) => string;
  1360. /**
  1361. * Removes unwanted characters from an url
  1362. * @param url defines the url to clean
  1363. * @returns the cleaned url
  1364. */
  1365. private static _CleanUrl;
  1366. /**
  1367. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1368. * @param url define the url we are trying
  1369. * @param element define the dom element where to configure the cors policy
  1370. */
  1371. static SetCorsBehavior(url: string | string[], element: {
  1372. crossOrigin: string | null;
  1373. }): void;
  1374. private static _ArrayBufferToBase64;
  1375. /**
  1376. * Loads an image as an HTMLImageElement.
  1377. * @param input url string, ArrayBuffer, or Blob to load
  1378. * @param onLoad callback called when the image successfully loads
  1379. * @param onError callback called when the image fails to load
  1380. * @param offlineProvider offline provider for caching
  1381. * @param mimeType optional mime type
  1382. * @returns the HTMLImageElement of the loaded image
  1383. */
  1384. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): HTMLImageElement;
  1385. /**
  1386. * Loads a file
  1387. * @param fileToLoad defines the file to load
  1388. * @param callback defines the callback to call when data is loaded
  1389. * @param progressCallBack defines the callback to call during loading process
  1390. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1391. * @returns a file request object
  1392. */
  1393. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  1394. /**
  1395. * Loads a file
  1396. * @param url url string, ArrayBuffer, or Blob to load
  1397. * @param onSuccess callback called when the file successfully loads
  1398. * @param onProgress callback called while file is loading (if the server supports this mode)
  1399. * @param offlineProvider defines the offline provider for caching
  1400. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1401. * @param onError callback called when the file fails to load
  1402. * @returns a file request object
  1403. */
  1404. 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;
  1405. /**
  1406. * Checks if the loaded document was accessed via `file:`-Protocol.
  1407. * @returns boolean
  1408. */
  1409. static IsFileURL(): boolean;
  1410. }
  1411. }
  1412. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1413. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1414. /** @hidden */
  1415. export class ShaderProcessor {
  1416. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1417. private static _ProcessPrecision;
  1418. private static _ExtractOperation;
  1419. private static _BuildSubExpression;
  1420. private static _BuildExpression;
  1421. private static _MoveCursorWithinIf;
  1422. private static _MoveCursor;
  1423. private static _EvaluatePreProcessors;
  1424. private static _PreparePreProcessors;
  1425. private static _ProcessShaderConversion;
  1426. private static _ProcessIncludes;
  1427. }
  1428. }
  1429. declare module "babylonjs/Maths/math.like" {
  1430. import { float, int, DeepImmutable } from "babylonjs/types";
  1431. /**
  1432. * @hidden
  1433. */
  1434. export interface IColor4Like {
  1435. r: float;
  1436. g: float;
  1437. b: float;
  1438. a: float;
  1439. }
  1440. /**
  1441. * @hidden
  1442. */
  1443. export interface IColor3Like {
  1444. r: float;
  1445. g: float;
  1446. b: float;
  1447. }
  1448. /**
  1449. * @hidden
  1450. */
  1451. export interface IVector4Like {
  1452. x: float;
  1453. y: float;
  1454. z: float;
  1455. w: float;
  1456. }
  1457. /**
  1458. * @hidden
  1459. */
  1460. export interface IVector3Like {
  1461. x: float;
  1462. y: float;
  1463. z: float;
  1464. }
  1465. /**
  1466. * @hidden
  1467. */
  1468. export interface IVector2Like {
  1469. x: float;
  1470. y: float;
  1471. }
  1472. /**
  1473. * @hidden
  1474. */
  1475. export interface IMatrixLike {
  1476. toArray(): DeepImmutable<Float32Array>;
  1477. updateFlag: int;
  1478. }
  1479. /**
  1480. * @hidden
  1481. */
  1482. export interface IViewportLike {
  1483. x: float;
  1484. y: float;
  1485. width: float;
  1486. height: float;
  1487. }
  1488. /**
  1489. * @hidden
  1490. */
  1491. export interface IPlaneLike {
  1492. normal: IVector3Like;
  1493. d: float;
  1494. normalize(): void;
  1495. }
  1496. }
  1497. declare module "babylonjs/Materials/iEffectFallbacks" {
  1498. import { Effect } from "babylonjs/Materials/effect";
  1499. /**
  1500. * Interface used to define common properties for effect fallbacks
  1501. */
  1502. export interface IEffectFallbacks {
  1503. /**
  1504. * Removes the defines that should be removed when falling back.
  1505. * @param currentDefines defines the current define statements for the shader.
  1506. * @param effect defines the current effect we try to compile
  1507. * @returns The resulting defines with defines of the current rank removed.
  1508. */
  1509. reduce(currentDefines: string, effect: Effect): string;
  1510. /**
  1511. * Removes the fallback from the bound mesh.
  1512. */
  1513. unBindMesh(): void;
  1514. /**
  1515. * Checks to see if more fallbacks are still availible.
  1516. */
  1517. hasMoreFallbacks: boolean;
  1518. }
  1519. }
  1520. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1521. /**
  1522. * Class used to evalaute queries containing `and` and `or` operators
  1523. */
  1524. export class AndOrNotEvaluator {
  1525. /**
  1526. * Evaluate a query
  1527. * @param query defines the query to evaluate
  1528. * @param evaluateCallback defines the callback used to filter result
  1529. * @returns true if the query matches
  1530. */
  1531. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1532. private static _HandleParenthesisContent;
  1533. private static _SimplifyNegation;
  1534. }
  1535. }
  1536. declare module "babylonjs/Misc/tags" {
  1537. /**
  1538. * Class used to store custom tags
  1539. */
  1540. export class Tags {
  1541. /**
  1542. * Adds support for tags on the given object
  1543. * @param obj defines the object to use
  1544. */
  1545. static EnableFor(obj: any): void;
  1546. /**
  1547. * Removes tags support
  1548. * @param obj defines the object to use
  1549. */
  1550. static DisableFor(obj: any): void;
  1551. /**
  1552. * Gets a boolean indicating if the given object has tags
  1553. * @param obj defines the object to use
  1554. * @returns a boolean
  1555. */
  1556. static HasTags(obj: any): boolean;
  1557. /**
  1558. * Gets the tags available on a given object
  1559. * @param obj defines the object to use
  1560. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1561. * @returns the tags
  1562. */
  1563. static GetTags(obj: any, asString?: boolean): any;
  1564. /**
  1565. * Adds tags to an object
  1566. * @param obj defines the object to use
  1567. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1568. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1569. */
  1570. static AddTagsTo(obj: any, tagsString: string): void;
  1571. /**
  1572. * @hidden
  1573. */
  1574. static _AddTagTo(obj: any, tag: string): void;
  1575. /**
  1576. * Removes specific tags from a specific object
  1577. * @param obj defines the object to use
  1578. * @param tagsString defines the tags to remove
  1579. */
  1580. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1581. /**
  1582. * @hidden
  1583. */
  1584. static _RemoveTagFrom(obj: any, tag: string): void;
  1585. /**
  1586. * Defines if tags hosted on an object match a given query
  1587. * @param obj defines the object to use
  1588. * @param tagsQuery defines the tag query
  1589. * @returns a boolean
  1590. */
  1591. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1592. }
  1593. }
  1594. declare module "babylonjs/Maths/math.scalar" {
  1595. /**
  1596. * Scalar computation library
  1597. */
  1598. export class Scalar {
  1599. /**
  1600. * Two pi constants convenient for computation.
  1601. */
  1602. static TwoPi: number;
  1603. /**
  1604. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1605. * @param a number
  1606. * @param b number
  1607. * @param epsilon (default = 1.401298E-45)
  1608. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1609. */
  1610. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1611. /**
  1612. * Returns a string : the upper case translation of the number i to hexadecimal.
  1613. * @param i number
  1614. * @returns the upper case translation of the number i to hexadecimal.
  1615. */
  1616. static ToHex(i: number): string;
  1617. /**
  1618. * Returns -1 if value is negative and +1 is value is positive.
  1619. * @param value the value
  1620. * @returns the value itself if it's equal to zero.
  1621. */
  1622. static Sign(value: number): number;
  1623. /**
  1624. * Returns the value itself if it's between min and max.
  1625. * Returns min if the value is lower than min.
  1626. * Returns max if the value is greater than max.
  1627. * @param value the value to clmap
  1628. * @param min the min value to clamp to (default: 0)
  1629. * @param max the max value to clamp to (default: 1)
  1630. * @returns the clamped value
  1631. */
  1632. static Clamp(value: number, min?: number, max?: number): number;
  1633. /**
  1634. * the log2 of value.
  1635. * @param value the value to compute log2 of
  1636. * @returns the log2 of value.
  1637. */
  1638. static Log2(value: number): number;
  1639. /**
  1640. * Loops the value, so that it is never larger than length and never smaller than 0.
  1641. *
  1642. * This is similar to the modulo operator but it works with floating point numbers.
  1643. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1644. * With t = 5 and length = 2.5, the result would be 0.0.
  1645. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1646. * @param value the value
  1647. * @param length the length
  1648. * @returns the looped value
  1649. */
  1650. static Repeat(value: number, length: number): number;
  1651. /**
  1652. * Normalize the value between 0.0 and 1.0 using min and max values
  1653. * @param value value to normalize
  1654. * @param min max to normalize between
  1655. * @param max min to normalize between
  1656. * @returns the normalized value
  1657. */
  1658. static Normalize(value: number, min: number, max: number): number;
  1659. /**
  1660. * Denormalize the value from 0.0 and 1.0 using min and max values
  1661. * @param normalized value to denormalize
  1662. * @param min max to denormalize between
  1663. * @param max min to denormalize between
  1664. * @returns the denormalized value
  1665. */
  1666. static Denormalize(normalized: number, min: number, max: number): number;
  1667. /**
  1668. * Calculates the shortest difference between two given angles given in degrees.
  1669. * @param current current angle in degrees
  1670. * @param target target angle in degrees
  1671. * @returns the delta
  1672. */
  1673. static DeltaAngle(current: number, target: number): number;
  1674. /**
  1675. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1676. * @param tx value
  1677. * @param length length
  1678. * @returns The returned value will move back and forth between 0 and length
  1679. */
  1680. static PingPong(tx: number, length: number): number;
  1681. /**
  1682. * Interpolates between min and max with smoothing at the limits.
  1683. *
  1684. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1685. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1686. * @param from from
  1687. * @param to to
  1688. * @param tx value
  1689. * @returns the smooth stepped value
  1690. */
  1691. static SmoothStep(from: number, to: number, tx: number): number;
  1692. /**
  1693. * Moves a value current towards target.
  1694. *
  1695. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1696. * Negative values of maxDelta pushes the value away from target.
  1697. * @param current current value
  1698. * @param target target value
  1699. * @param maxDelta max distance to move
  1700. * @returns resulting value
  1701. */
  1702. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1703. /**
  1704. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1705. *
  1706. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1707. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1708. * @param current current value
  1709. * @param target target value
  1710. * @param maxDelta max distance to move
  1711. * @returns resulting angle
  1712. */
  1713. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1714. /**
  1715. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1716. * @param start start value
  1717. * @param end target value
  1718. * @param amount amount to lerp between
  1719. * @returns the lerped value
  1720. */
  1721. static Lerp(start: number, end: number, amount: number): number;
  1722. /**
  1723. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1724. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1725. * @param start start value
  1726. * @param end target value
  1727. * @param amount amount to lerp between
  1728. * @returns the lerped value
  1729. */
  1730. static LerpAngle(start: number, end: number, amount: number): number;
  1731. /**
  1732. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1733. * @param a start value
  1734. * @param b target value
  1735. * @param value value between a and b
  1736. * @returns the inverseLerp value
  1737. */
  1738. static InverseLerp(a: number, b: number, value: number): number;
  1739. /**
  1740. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1741. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1742. * @param value1 spline value
  1743. * @param tangent1 spline value
  1744. * @param value2 spline value
  1745. * @param tangent2 spline value
  1746. * @param amount input value
  1747. * @returns hermite result
  1748. */
  1749. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1750. /**
  1751. * Returns a random float number between and min and max values
  1752. * @param min min value of random
  1753. * @param max max value of random
  1754. * @returns random value
  1755. */
  1756. static RandomRange(min: number, max: number): number;
  1757. /**
  1758. * This function returns percentage of a number in a given range.
  1759. *
  1760. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1761. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1762. * @param number to convert to percentage
  1763. * @param min min range
  1764. * @param max max range
  1765. * @returns the percentage
  1766. */
  1767. static RangeToPercent(number: number, min: number, max: number): number;
  1768. /**
  1769. * This function returns number that corresponds to the percentage in a given range.
  1770. *
  1771. * PercentToRange(0.34,0,100) will return 34.
  1772. * @param percent to convert to number
  1773. * @param min min range
  1774. * @param max max range
  1775. * @returns the number
  1776. */
  1777. static PercentToRange(percent: number, min: number, max: number): number;
  1778. /**
  1779. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1780. * @param angle The angle to normalize in radian.
  1781. * @return The converted angle.
  1782. */
  1783. static NormalizeRadians(angle: number): number;
  1784. }
  1785. }
  1786. declare module "babylonjs/Maths/math.constants" {
  1787. /**
  1788. * Constant used to convert a value to gamma space
  1789. * @ignorenaming
  1790. */
  1791. export const ToGammaSpace: number;
  1792. /**
  1793. * Constant used to convert a value to linear space
  1794. * @ignorenaming
  1795. */
  1796. export const ToLinearSpace = 2.2;
  1797. /**
  1798. * Constant used to define the minimal number value in Babylon.js
  1799. * @ignorenaming
  1800. */
  1801. let Epsilon: number;
  1802. export { Epsilon };
  1803. }
  1804. declare module "babylonjs/Maths/math.viewport" {
  1805. /**
  1806. * Class used to represent a viewport on screen
  1807. */
  1808. export class Viewport {
  1809. /** viewport left coordinate */
  1810. x: number;
  1811. /** viewport top coordinate */
  1812. y: number;
  1813. /**viewport width */
  1814. width: number;
  1815. /** viewport height */
  1816. height: number;
  1817. /**
  1818. * Creates a Viewport object located at (x, y) and sized (width, height)
  1819. * @param x defines viewport left coordinate
  1820. * @param y defines viewport top coordinate
  1821. * @param width defines the viewport width
  1822. * @param height defines the viewport height
  1823. */
  1824. constructor(
  1825. /** viewport left coordinate */
  1826. x: number,
  1827. /** viewport top coordinate */
  1828. y: number,
  1829. /**viewport width */
  1830. width: number,
  1831. /** viewport height */
  1832. height: number);
  1833. /**
  1834. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1835. * @param renderWidth defines the rendering width
  1836. * @param renderHeight defines the rendering height
  1837. * @returns a new Viewport
  1838. */
  1839. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1840. /**
  1841. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1842. * @param renderWidth defines the rendering width
  1843. * @param renderHeight defines the rendering height
  1844. * @param ref defines the target viewport
  1845. * @returns the current viewport
  1846. */
  1847. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1848. /**
  1849. * Returns a new Viewport copied from the current one
  1850. * @returns a new Viewport
  1851. */
  1852. clone(): Viewport;
  1853. }
  1854. }
  1855. declare module "babylonjs/Misc/arrayTools" {
  1856. /**
  1857. * Class containing a set of static utilities functions for arrays.
  1858. */
  1859. export class ArrayTools {
  1860. /**
  1861. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1862. * @param size the number of element to construct and put in the array
  1863. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1864. * @returns a new array filled with new objects
  1865. */
  1866. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1867. }
  1868. }
  1869. declare module "babylonjs/Maths/math.vector" {
  1870. import { Viewport } from "babylonjs/Maths/math.viewport";
  1871. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1872. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1873. /**
  1874. * Class representing a vector containing 2 coordinates
  1875. */
  1876. export class Vector2 {
  1877. /** defines the first coordinate */
  1878. x: number;
  1879. /** defines the second coordinate */
  1880. y: number;
  1881. /**
  1882. * Creates a new Vector2 from the given x and y coordinates
  1883. * @param x defines the first coordinate
  1884. * @param y defines the second coordinate
  1885. */
  1886. constructor(
  1887. /** defines the first coordinate */
  1888. x?: number,
  1889. /** defines the second coordinate */
  1890. y?: number);
  1891. /**
  1892. * Gets a string with the Vector2 coordinates
  1893. * @returns a string with the Vector2 coordinates
  1894. */
  1895. toString(): string;
  1896. /**
  1897. * Gets class name
  1898. * @returns the string "Vector2"
  1899. */
  1900. getClassName(): string;
  1901. /**
  1902. * Gets current vector hash code
  1903. * @returns the Vector2 hash code as a number
  1904. */
  1905. getHashCode(): number;
  1906. /**
  1907. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1908. * @param array defines the source array
  1909. * @param index defines the offset in source array
  1910. * @returns the current Vector2
  1911. */
  1912. toArray(array: FloatArray, index?: number): Vector2;
  1913. /**
  1914. * Copy the current vector to an array
  1915. * @returns a new array with 2 elements: the Vector2 coordinates.
  1916. */
  1917. asArray(): number[];
  1918. /**
  1919. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1920. * @param source defines the source Vector2
  1921. * @returns the current updated Vector2
  1922. */
  1923. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1924. /**
  1925. * Sets the Vector2 coordinates with the given floats
  1926. * @param x defines the first coordinate
  1927. * @param y defines the second coordinate
  1928. * @returns the current updated Vector2
  1929. */
  1930. copyFromFloats(x: number, y: number): Vector2;
  1931. /**
  1932. * Sets the Vector2 coordinates with the given floats
  1933. * @param x defines the first coordinate
  1934. * @param y defines the second coordinate
  1935. * @returns the current updated Vector2
  1936. */
  1937. set(x: number, y: number): Vector2;
  1938. /**
  1939. * Add another vector with the current one
  1940. * @param otherVector defines the other vector
  1941. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1942. */
  1943. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1944. /**
  1945. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1946. * @param otherVector defines the other vector
  1947. * @param result defines the target vector
  1948. * @returns the unmodified current Vector2
  1949. */
  1950. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1951. /**
  1952. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1953. * @param otherVector defines the other vector
  1954. * @returns the current updated Vector2
  1955. */
  1956. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1957. /**
  1958. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1959. * @param otherVector defines the other vector
  1960. * @returns a new Vector2
  1961. */
  1962. addVector3(otherVector: Vector3): Vector2;
  1963. /**
  1964. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1965. * @param otherVector defines the other vector
  1966. * @returns a new Vector2
  1967. */
  1968. subtract(otherVector: Vector2): Vector2;
  1969. /**
  1970. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1971. * @param otherVector defines the other vector
  1972. * @param result defines the target vector
  1973. * @returns the unmodified current Vector2
  1974. */
  1975. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1976. /**
  1977. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1978. * @param otherVector defines the other vector
  1979. * @returns the current updated Vector2
  1980. */
  1981. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1982. /**
  1983. * Multiplies in place the current Vector2 coordinates by the given ones
  1984. * @param otherVector defines the other vector
  1985. * @returns the current updated Vector2
  1986. */
  1987. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1988. /**
  1989. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1990. * @param otherVector defines the other vector
  1991. * @returns a new Vector2
  1992. */
  1993. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1994. /**
  1995. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1996. * @param otherVector defines the other vector
  1997. * @param result defines the target vector
  1998. * @returns the unmodified current Vector2
  1999. */
  2000. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2001. /**
  2002. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2003. * @param x defines the first coordinate
  2004. * @param y defines the second coordinate
  2005. * @returns a new Vector2
  2006. */
  2007. multiplyByFloats(x: number, y: number): Vector2;
  2008. /**
  2009. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2010. * @param otherVector defines the other vector
  2011. * @returns a new Vector2
  2012. */
  2013. divide(otherVector: Vector2): Vector2;
  2014. /**
  2015. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2016. * @param otherVector defines the other vector
  2017. * @param result defines the target vector
  2018. * @returns the unmodified current Vector2
  2019. */
  2020. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2021. /**
  2022. * Divides the current Vector2 coordinates by the given ones
  2023. * @param otherVector defines the other vector
  2024. * @returns the current updated Vector2
  2025. */
  2026. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2027. /**
  2028. * Gets a new Vector2 with current Vector2 negated coordinates
  2029. * @returns a new Vector2
  2030. */
  2031. negate(): Vector2;
  2032. /**
  2033. * Multiply the Vector2 coordinates by scale
  2034. * @param scale defines the scaling factor
  2035. * @returns the current updated Vector2
  2036. */
  2037. scaleInPlace(scale: number): Vector2;
  2038. /**
  2039. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2040. * @param scale defines the scaling factor
  2041. * @returns a new Vector2
  2042. */
  2043. scale(scale: number): Vector2;
  2044. /**
  2045. * Scale the current Vector2 values by a factor to a given Vector2
  2046. * @param scale defines the scale factor
  2047. * @param result defines the Vector2 object where to store the result
  2048. * @returns the unmodified current Vector2
  2049. */
  2050. scaleToRef(scale: number, result: Vector2): Vector2;
  2051. /**
  2052. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2053. * @param scale defines the scale factor
  2054. * @param result defines the Vector2 object where to store the result
  2055. * @returns the unmodified current Vector2
  2056. */
  2057. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2058. /**
  2059. * Gets a boolean if two vectors are equals
  2060. * @param otherVector defines the other vector
  2061. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2062. */
  2063. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2064. /**
  2065. * Gets a boolean if two vectors are equals (using an epsilon value)
  2066. * @param otherVector defines the other vector
  2067. * @param epsilon defines the minimal distance to consider equality
  2068. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2069. */
  2070. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2071. /**
  2072. * Gets a new Vector2 from current Vector2 floored values
  2073. * @returns a new Vector2
  2074. */
  2075. floor(): Vector2;
  2076. /**
  2077. * Gets a new Vector2 from current Vector2 floored values
  2078. * @returns a new Vector2
  2079. */
  2080. fract(): Vector2;
  2081. /**
  2082. * Gets the length of the vector
  2083. * @returns the vector length (float)
  2084. */
  2085. length(): number;
  2086. /**
  2087. * Gets the vector squared length
  2088. * @returns the vector squared length (float)
  2089. */
  2090. lengthSquared(): number;
  2091. /**
  2092. * Normalize the vector
  2093. * @returns the current updated Vector2
  2094. */
  2095. normalize(): Vector2;
  2096. /**
  2097. * Gets a new Vector2 copied from the Vector2
  2098. * @returns a new Vector2
  2099. */
  2100. clone(): Vector2;
  2101. /**
  2102. * Gets a new Vector2(0, 0)
  2103. * @returns a new Vector2
  2104. */
  2105. static Zero(): Vector2;
  2106. /**
  2107. * Gets a new Vector2(1, 1)
  2108. * @returns a new Vector2
  2109. */
  2110. static One(): Vector2;
  2111. /**
  2112. * Gets a new Vector2 set from the given index element of the given array
  2113. * @param array defines the data source
  2114. * @param offset defines the offset in the data source
  2115. * @returns a new Vector2
  2116. */
  2117. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2118. /**
  2119. * Sets "result" from the given index element of the given array
  2120. * @param array defines the data source
  2121. * @param offset defines the offset in the data source
  2122. * @param result defines the target vector
  2123. */
  2124. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2125. /**
  2126. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2127. * @param value1 defines 1st point of control
  2128. * @param value2 defines 2nd point of control
  2129. * @param value3 defines 3rd point of control
  2130. * @param value4 defines 4th point of control
  2131. * @param amount defines the interpolation factor
  2132. * @returns a new Vector2
  2133. */
  2134. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2135. /**
  2136. * 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".
  2137. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2138. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2139. * @param value defines the value to clamp
  2140. * @param min defines the lower limit
  2141. * @param max defines the upper limit
  2142. * @returns a new Vector2
  2143. */
  2144. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2145. /**
  2146. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2147. * @param value1 defines the 1st control point
  2148. * @param tangent1 defines the outgoing tangent
  2149. * @param value2 defines the 2nd control point
  2150. * @param tangent2 defines the incoming tangent
  2151. * @param amount defines the interpolation factor
  2152. * @returns a new Vector2
  2153. */
  2154. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2155. /**
  2156. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2157. * @param start defines the start vector
  2158. * @param end defines the end vector
  2159. * @param amount defines the interpolation factor
  2160. * @returns a new Vector2
  2161. */
  2162. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2163. /**
  2164. * Gets the dot product of the vector "left" and the vector "right"
  2165. * @param left defines first vector
  2166. * @param right defines second vector
  2167. * @returns the dot product (float)
  2168. */
  2169. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2170. /**
  2171. * Returns a new Vector2 equal to the normalized given vector
  2172. * @param vector defines the vector to normalize
  2173. * @returns a new Vector2
  2174. */
  2175. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2176. /**
  2177. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2178. * @param left defines 1st vector
  2179. * @param right defines 2nd vector
  2180. * @returns a new Vector2
  2181. */
  2182. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2183. /**
  2184. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2185. * @param left defines 1st vector
  2186. * @param right defines 2nd vector
  2187. * @returns a new Vector2
  2188. */
  2189. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2190. /**
  2191. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2192. * @param vector defines the vector to transform
  2193. * @param transformation defines the matrix to apply
  2194. * @returns a new Vector2
  2195. */
  2196. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2197. /**
  2198. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2199. * @param vector defines the vector to transform
  2200. * @param transformation defines the matrix to apply
  2201. * @param result defines the target vector
  2202. */
  2203. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2204. /**
  2205. * Determines if a given vector is included in a triangle
  2206. * @param p defines the vector to test
  2207. * @param p0 defines 1st triangle point
  2208. * @param p1 defines 2nd triangle point
  2209. * @param p2 defines 3rd triangle point
  2210. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2211. */
  2212. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2213. /**
  2214. * Gets the distance between the vectors "value1" and "value2"
  2215. * @param value1 defines first vector
  2216. * @param value2 defines second vector
  2217. * @returns the distance between vectors
  2218. */
  2219. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2220. /**
  2221. * Returns the squared distance between the vectors "value1" and "value2"
  2222. * @param value1 defines first vector
  2223. * @param value2 defines second vector
  2224. * @returns the squared distance between vectors
  2225. */
  2226. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2227. /**
  2228. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2229. * @param value1 defines first vector
  2230. * @param value2 defines second vector
  2231. * @returns a new Vector2
  2232. */
  2233. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2234. /**
  2235. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2236. * @param p defines the middle point
  2237. * @param segA defines one point of the segment
  2238. * @param segB defines the other point of the segment
  2239. * @returns the shortest distance
  2240. */
  2241. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2242. }
  2243. /**
  2244. * Classed used to store (x,y,z) vector representation
  2245. * A Vector3 is the main object used in 3D geometry
  2246. * It can represent etiher the coordinates of a point the space, either a direction
  2247. * Reminder: js uses a left handed forward facing system
  2248. */
  2249. export class Vector3 {
  2250. /**
  2251. * Defines the first coordinates (on X axis)
  2252. */
  2253. x: number;
  2254. /**
  2255. * Defines the second coordinates (on Y axis)
  2256. */
  2257. y: number;
  2258. /**
  2259. * Defines the third coordinates (on Z axis)
  2260. */
  2261. z: number;
  2262. private static _UpReadOnly;
  2263. private static _ZeroReadOnly;
  2264. /**
  2265. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2266. * @param x defines the first coordinates (on X axis)
  2267. * @param y defines the second coordinates (on Y axis)
  2268. * @param z defines the third coordinates (on Z axis)
  2269. */
  2270. constructor(
  2271. /**
  2272. * Defines the first coordinates (on X axis)
  2273. */
  2274. x?: number,
  2275. /**
  2276. * Defines the second coordinates (on Y axis)
  2277. */
  2278. y?: number,
  2279. /**
  2280. * Defines the third coordinates (on Z axis)
  2281. */
  2282. z?: number);
  2283. /**
  2284. * Creates a string representation of the Vector3
  2285. * @returns a string with the Vector3 coordinates.
  2286. */
  2287. toString(): string;
  2288. /**
  2289. * Gets the class name
  2290. * @returns the string "Vector3"
  2291. */
  2292. getClassName(): string;
  2293. /**
  2294. * Creates the Vector3 hash code
  2295. * @returns a number which tends to be unique between Vector3 instances
  2296. */
  2297. getHashCode(): number;
  2298. /**
  2299. * Creates an array containing three elements : the coordinates of the Vector3
  2300. * @returns a new array of numbers
  2301. */
  2302. asArray(): number[];
  2303. /**
  2304. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2305. * @param array defines the destination array
  2306. * @param index defines the offset in the destination array
  2307. * @returns the current Vector3
  2308. */
  2309. toArray(array: FloatArray, index?: number): Vector3;
  2310. /**
  2311. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2312. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2313. */
  2314. toQuaternion(): Quaternion;
  2315. /**
  2316. * Adds the given vector to the current Vector3
  2317. * @param otherVector defines the second operand
  2318. * @returns the current updated Vector3
  2319. */
  2320. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2321. /**
  2322. * Adds the given coordinates to the current Vector3
  2323. * @param x defines the x coordinate of the operand
  2324. * @param y defines the y coordinate of the operand
  2325. * @param z defines the z coordinate of the operand
  2326. * @returns the current updated Vector3
  2327. */
  2328. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2329. /**
  2330. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2331. * @param otherVector defines the second operand
  2332. * @returns the resulting Vector3
  2333. */
  2334. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2335. /**
  2336. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2337. * @param otherVector defines the second operand
  2338. * @param result defines the Vector3 object where to store the result
  2339. * @returns the current Vector3
  2340. */
  2341. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2342. /**
  2343. * Subtract the given vector from the current Vector3
  2344. * @param otherVector defines the second operand
  2345. * @returns the current updated Vector3
  2346. */
  2347. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2348. /**
  2349. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2350. * @param otherVector defines the second operand
  2351. * @returns the resulting Vector3
  2352. */
  2353. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2354. /**
  2355. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2356. * @param otherVector defines the second operand
  2357. * @param result defines the Vector3 object where to store the result
  2358. * @returns the current Vector3
  2359. */
  2360. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2361. /**
  2362. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2363. * @param x defines the x coordinate of the operand
  2364. * @param y defines the y coordinate of the operand
  2365. * @param z defines the z coordinate of the operand
  2366. * @returns the resulting Vector3
  2367. */
  2368. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2369. /**
  2370. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2371. * @param x defines the x coordinate of the operand
  2372. * @param y defines the y coordinate of the operand
  2373. * @param z defines the z coordinate of the operand
  2374. * @param result defines the Vector3 object where to store the result
  2375. * @returns the current Vector3
  2376. */
  2377. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2378. /**
  2379. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2380. * @returns a new Vector3
  2381. */
  2382. negate(): Vector3;
  2383. /**
  2384. * Multiplies the Vector3 coordinates by the float "scale"
  2385. * @param scale defines the multiplier factor
  2386. * @returns the current updated Vector3
  2387. */
  2388. scaleInPlace(scale: number): Vector3;
  2389. /**
  2390. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2391. * @param scale defines the multiplier factor
  2392. * @returns a new Vector3
  2393. */
  2394. scale(scale: number): Vector3;
  2395. /**
  2396. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2397. * @param scale defines the multiplier factor
  2398. * @param result defines the Vector3 object where to store the result
  2399. * @returns the current Vector3
  2400. */
  2401. scaleToRef(scale: number, result: Vector3): Vector3;
  2402. /**
  2403. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2404. * @param scale defines the scale factor
  2405. * @param result defines the Vector3 object where to store the result
  2406. * @returns the unmodified current Vector3
  2407. */
  2408. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2409. /**
  2410. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2411. * @param otherVector defines the second operand
  2412. * @returns true if both vectors are equals
  2413. */
  2414. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2415. /**
  2416. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2417. * @param otherVector defines the second operand
  2418. * @param epsilon defines the minimal distance to define values as equals
  2419. * @returns true if both vectors are distant less than epsilon
  2420. */
  2421. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2422. /**
  2423. * Returns true if the current Vector3 coordinates equals the given floats
  2424. * @param x defines the x coordinate of the operand
  2425. * @param y defines the y coordinate of the operand
  2426. * @param z defines the z coordinate of the operand
  2427. * @returns true if both vectors are equals
  2428. */
  2429. equalsToFloats(x: number, y: number, z: number): boolean;
  2430. /**
  2431. * Multiplies the current Vector3 coordinates by the given ones
  2432. * @param otherVector defines the second operand
  2433. * @returns the current updated Vector3
  2434. */
  2435. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2436. /**
  2437. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2438. * @param otherVector defines the second operand
  2439. * @returns the new Vector3
  2440. */
  2441. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2442. /**
  2443. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2444. * @param otherVector defines the second operand
  2445. * @param result defines the Vector3 object where to store the result
  2446. * @returns the current Vector3
  2447. */
  2448. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2449. /**
  2450. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2451. * @param x defines the x coordinate of the operand
  2452. * @param y defines the y coordinate of the operand
  2453. * @param z defines the z coordinate of the operand
  2454. * @returns the new Vector3
  2455. */
  2456. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2457. /**
  2458. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2459. * @param otherVector defines the second operand
  2460. * @returns the new Vector3
  2461. */
  2462. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2463. /**
  2464. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2465. * @param otherVector defines the second operand
  2466. * @param result defines the Vector3 object where to store the result
  2467. * @returns the current Vector3
  2468. */
  2469. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2470. /**
  2471. * Divides the current Vector3 coordinates by the given ones.
  2472. * @param otherVector defines the second operand
  2473. * @returns the current updated Vector3
  2474. */
  2475. divideInPlace(otherVector: Vector3): Vector3;
  2476. /**
  2477. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2478. * @param other defines the second operand
  2479. * @returns the current updated Vector3
  2480. */
  2481. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2482. /**
  2483. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2484. * @param other defines the second operand
  2485. * @returns the current updated Vector3
  2486. */
  2487. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2488. /**
  2489. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2490. * @param x defines the x coordinate of the operand
  2491. * @param y defines the y coordinate of the operand
  2492. * @param z defines the z coordinate of the operand
  2493. * @returns the current updated Vector3
  2494. */
  2495. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2496. /**
  2497. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2498. * @param x defines the x coordinate of the operand
  2499. * @param y defines the y coordinate of the operand
  2500. * @param z defines the z coordinate of the operand
  2501. * @returns the current updated Vector3
  2502. */
  2503. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2504. /**
  2505. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2506. * Check if is non uniform within a certain amount of decimal places to account for this
  2507. * @param epsilon the amount the values can differ
  2508. * @returns if the the vector is non uniform to a certain number of decimal places
  2509. */
  2510. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2511. /**
  2512. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2513. */
  2514. readonly isNonUniform: boolean;
  2515. /**
  2516. * Gets a new Vector3 from current Vector3 floored values
  2517. * @returns a new Vector3
  2518. */
  2519. floor(): Vector3;
  2520. /**
  2521. * Gets a new Vector3 from current Vector3 floored values
  2522. * @returns a new Vector3
  2523. */
  2524. fract(): Vector3;
  2525. /**
  2526. * Gets the length of the Vector3
  2527. * @returns the length of the Vector3
  2528. */
  2529. length(): number;
  2530. /**
  2531. * Gets the squared length of the Vector3
  2532. * @returns squared length of the Vector3
  2533. */
  2534. lengthSquared(): number;
  2535. /**
  2536. * Normalize the current Vector3.
  2537. * Please note that this is an in place operation.
  2538. * @returns the current updated Vector3
  2539. */
  2540. normalize(): Vector3;
  2541. /**
  2542. * Reorders the x y z properties of the vector in place
  2543. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2544. * @returns the current updated vector
  2545. */
  2546. reorderInPlace(order: string): this;
  2547. /**
  2548. * Rotates the vector around 0,0,0 by a quaternion
  2549. * @param quaternion the rotation quaternion
  2550. * @param result vector to store the result
  2551. * @returns the resulting vector
  2552. */
  2553. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2554. /**
  2555. * Rotates a vector around a given point
  2556. * @param quaternion the rotation quaternion
  2557. * @param point the point to rotate around
  2558. * @param result vector to store the result
  2559. * @returns the resulting vector
  2560. */
  2561. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2562. /**
  2563. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2564. * The cross product is then orthogonal to both current and "other"
  2565. * @param other defines the right operand
  2566. * @returns the cross product
  2567. */
  2568. cross(other: Vector3): Vector3;
  2569. /**
  2570. * Normalize the current Vector3 with the given input length.
  2571. * Please note that this is an in place operation.
  2572. * @param len the length of the vector
  2573. * @returns the current updated Vector3
  2574. */
  2575. normalizeFromLength(len: number): Vector3;
  2576. /**
  2577. * Normalize the current Vector3 to a new vector
  2578. * @returns the new Vector3
  2579. */
  2580. normalizeToNew(): Vector3;
  2581. /**
  2582. * Normalize the current Vector3 to the reference
  2583. * @param reference define the Vector3 to update
  2584. * @returns the updated Vector3
  2585. */
  2586. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2587. /**
  2588. * Creates a new Vector3 copied from the current Vector3
  2589. * @returns the new Vector3
  2590. */
  2591. clone(): Vector3;
  2592. /**
  2593. * Copies the given vector coordinates to the current Vector3 ones
  2594. * @param source defines the source Vector3
  2595. * @returns the current updated Vector3
  2596. */
  2597. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2598. /**
  2599. * Copies the given floats to the current Vector3 coordinates
  2600. * @param x defines the x coordinate of the operand
  2601. * @param y defines the y coordinate of the operand
  2602. * @param z defines the z coordinate of the operand
  2603. * @returns the current updated Vector3
  2604. */
  2605. copyFromFloats(x: number, y: number, z: number): Vector3;
  2606. /**
  2607. * Copies the given floats to the current Vector3 coordinates
  2608. * @param x defines the x coordinate of the operand
  2609. * @param y defines the y coordinate of the operand
  2610. * @param z defines the z coordinate of the operand
  2611. * @returns the current updated Vector3
  2612. */
  2613. set(x: number, y: number, z: number): Vector3;
  2614. /**
  2615. * Copies the given float to the current Vector3 coordinates
  2616. * @param v defines the x, y and z coordinates of the operand
  2617. * @returns the current updated Vector3
  2618. */
  2619. setAll(v: number): Vector3;
  2620. /**
  2621. * Get the clip factor between two vectors
  2622. * @param vector0 defines the first operand
  2623. * @param vector1 defines the second operand
  2624. * @param axis defines the axis to use
  2625. * @param size defines the size along the axis
  2626. * @returns the clip factor
  2627. */
  2628. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2629. /**
  2630. * Get angle between two vectors
  2631. * @param vector0 angle between vector0 and vector1
  2632. * @param vector1 angle between vector0 and vector1
  2633. * @param normal direction of the normal
  2634. * @return the angle between vector0 and vector1
  2635. */
  2636. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2637. /**
  2638. * Returns a new Vector3 set from the index "offset" of the given array
  2639. * @param array defines the source array
  2640. * @param offset defines the offset in the source array
  2641. * @returns the new Vector3
  2642. */
  2643. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2644. /**
  2645. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2646. * This function is deprecated. Use FromArray instead
  2647. * @param array defines the source array
  2648. * @param offset defines the offset in the source array
  2649. * @returns the new Vector3
  2650. */
  2651. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2652. /**
  2653. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2654. * @param array defines the source array
  2655. * @param offset defines the offset in the source array
  2656. * @param result defines the Vector3 where to store the result
  2657. */
  2658. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2659. /**
  2660. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2661. * This function is deprecated. Use FromArrayToRef instead.
  2662. * @param array defines the source array
  2663. * @param offset defines the offset in the source array
  2664. * @param result defines the Vector3 where to store the result
  2665. */
  2666. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2667. /**
  2668. * Sets the given vector "result" with the given floats.
  2669. * @param x defines the x coordinate of the source
  2670. * @param y defines the y coordinate of the source
  2671. * @param z defines the z coordinate of the source
  2672. * @param result defines the Vector3 where to store the result
  2673. */
  2674. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2675. /**
  2676. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2677. * @returns a new empty Vector3
  2678. */
  2679. static Zero(): Vector3;
  2680. /**
  2681. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2682. * @returns a new unit Vector3
  2683. */
  2684. static One(): Vector3;
  2685. /**
  2686. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2687. * @returns a new up Vector3
  2688. */
  2689. static Up(): Vector3;
  2690. /**
  2691. * Gets a up Vector3 that must not be updated
  2692. */
  2693. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2694. /**
  2695. * Gets a zero Vector3 that must not be updated
  2696. */
  2697. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2698. /**
  2699. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2700. * @returns a new down Vector3
  2701. */
  2702. static Down(): Vector3;
  2703. /**
  2704. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2705. * @returns a new forward Vector3
  2706. */
  2707. static Forward(): Vector3;
  2708. /**
  2709. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2710. * @returns a new forward Vector3
  2711. */
  2712. static Backward(): Vector3;
  2713. /**
  2714. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2715. * @returns a new right Vector3
  2716. */
  2717. static Right(): Vector3;
  2718. /**
  2719. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2720. * @returns a new left Vector3
  2721. */
  2722. static Left(): Vector3;
  2723. /**
  2724. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2725. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2726. * @param vector defines the Vector3 to transform
  2727. * @param transformation defines the transformation matrix
  2728. * @returns the transformed Vector3
  2729. */
  2730. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2731. /**
  2732. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2733. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2734. * @param vector defines the Vector3 to transform
  2735. * @param transformation defines the transformation matrix
  2736. * @param result defines the Vector3 where to store the result
  2737. */
  2738. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2739. /**
  2740. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2741. * This method computes tranformed coordinates only, not transformed direction vectors
  2742. * @param x define the x coordinate of the source vector
  2743. * @param y define the y coordinate of the source vector
  2744. * @param z define the z coordinate of the source vector
  2745. * @param transformation defines the transformation matrix
  2746. * @param result defines the Vector3 where to store the result
  2747. */
  2748. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2749. /**
  2750. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2751. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2752. * @param vector defines the Vector3 to transform
  2753. * @param transformation defines the transformation matrix
  2754. * @returns the new Vector3
  2755. */
  2756. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2757. /**
  2758. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2759. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2760. * @param vector defines the Vector3 to transform
  2761. * @param transformation defines the transformation matrix
  2762. * @param result defines the Vector3 where to store the result
  2763. */
  2764. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2765. /**
  2766. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2767. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2768. * @param x define the x coordinate of the source vector
  2769. * @param y define the y coordinate of the source vector
  2770. * @param z define the z coordinate of the source vector
  2771. * @param transformation defines the transformation matrix
  2772. * @param result defines the Vector3 where to store the result
  2773. */
  2774. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2775. /**
  2776. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2777. * @param value1 defines the first control point
  2778. * @param value2 defines the second control point
  2779. * @param value3 defines the third control point
  2780. * @param value4 defines the fourth control point
  2781. * @param amount defines the amount on the spline to use
  2782. * @returns the new Vector3
  2783. */
  2784. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2785. /**
  2786. * 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"
  2787. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2788. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2789. * @param value defines the current value
  2790. * @param min defines the lower range value
  2791. * @param max defines the upper range value
  2792. * @returns the new Vector3
  2793. */
  2794. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2795. /**
  2796. * 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"
  2797. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2798. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2799. * @param value defines the current value
  2800. * @param min defines the lower range value
  2801. * @param max defines the upper range value
  2802. * @param result defines the Vector3 where to store the result
  2803. */
  2804. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2805. /**
  2806. * Checks if a given vector is inside a specific range
  2807. * @param v defines the vector to test
  2808. * @param min defines the minimum range
  2809. * @param max defines the maximum range
  2810. */
  2811. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2812. /**
  2813. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2814. * @param value1 defines the first control point
  2815. * @param tangent1 defines the first tangent vector
  2816. * @param value2 defines the second control point
  2817. * @param tangent2 defines the second tangent vector
  2818. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2819. * @returns the new Vector3
  2820. */
  2821. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2822. /**
  2823. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2824. * @param start defines the start value
  2825. * @param end defines the end value
  2826. * @param amount max defines amount between both (between 0 and 1)
  2827. * @returns the new Vector3
  2828. */
  2829. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2830. /**
  2831. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2832. * @param start defines the start value
  2833. * @param end defines the end value
  2834. * @param amount max defines amount between both (between 0 and 1)
  2835. * @param result defines the Vector3 where to store the result
  2836. */
  2837. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2838. /**
  2839. * Returns the dot product (float) between the vectors "left" and "right"
  2840. * @param left defines the left operand
  2841. * @param right defines the right operand
  2842. * @returns the dot product
  2843. */
  2844. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2845. /**
  2846. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2847. * The cross product is then orthogonal to both "left" and "right"
  2848. * @param left defines the left operand
  2849. * @param right defines the right operand
  2850. * @returns the cross product
  2851. */
  2852. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2853. /**
  2854. * Sets the given vector "result" with the cross product of "left" and "right"
  2855. * The cross product is then orthogonal to both "left" and "right"
  2856. * @param left defines the left operand
  2857. * @param right defines the right operand
  2858. * @param result defines the Vector3 where to store the result
  2859. */
  2860. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2861. /**
  2862. * Returns a new Vector3 as the normalization of the given vector
  2863. * @param vector defines the Vector3 to normalize
  2864. * @returns the new Vector3
  2865. */
  2866. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2867. /**
  2868. * Sets the given vector "result" with the normalization of the given first vector
  2869. * @param vector defines the Vector3 to normalize
  2870. * @param result defines the Vector3 where to store the result
  2871. */
  2872. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2873. /**
  2874. * Project a Vector3 onto screen space
  2875. * @param vector defines the Vector3 to project
  2876. * @param world defines the world matrix to use
  2877. * @param transform defines the transform (view x projection) matrix to use
  2878. * @param viewport defines the screen viewport to use
  2879. * @returns the new Vector3
  2880. */
  2881. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2882. /** @hidden */
  2883. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2884. /**
  2885. * Unproject from screen space to object space
  2886. * @param source defines the screen space Vector3 to use
  2887. * @param viewportWidth defines the current width of the viewport
  2888. * @param viewportHeight defines the current height of the viewport
  2889. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2890. * @param transform defines the transform (view x projection) matrix to use
  2891. * @returns the new Vector3
  2892. */
  2893. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2894. /**
  2895. * Unproject from screen space to object space
  2896. * @param source defines the screen space Vector3 to use
  2897. * @param viewportWidth defines the current width of the viewport
  2898. * @param viewportHeight defines the current height of the viewport
  2899. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2900. * @param view defines the view matrix to use
  2901. * @param projection defines the projection matrix to use
  2902. * @returns the new Vector3
  2903. */
  2904. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2905. /**
  2906. * Unproject from screen space to object space
  2907. * @param source defines the screen space Vector3 to use
  2908. * @param viewportWidth defines the current width of the viewport
  2909. * @param viewportHeight defines the current height of the viewport
  2910. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2911. * @param view defines the view matrix to use
  2912. * @param projection defines the projection matrix to use
  2913. * @param result defines the Vector3 where to store the result
  2914. */
  2915. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2916. /**
  2917. * Unproject from screen space to object space
  2918. * @param sourceX defines the screen space x coordinate to use
  2919. * @param sourceY defines the screen space y coordinate to use
  2920. * @param sourceZ defines the screen space z coordinate to use
  2921. * @param viewportWidth defines the current width of the viewport
  2922. * @param viewportHeight defines the current height of the viewport
  2923. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2924. * @param view defines the view matrix to use
  2925. * @param projection defines the projection matrix to use
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2929. /**
  2930. * Gets the minimal coordinate values between two Vector3
  2931. * @param left defines the first operand
  2932. * @param right defines the second operand
  2933. * @returns the new Vector3
  2934. */
  2935. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2936. /**
  2937. * Gets the maximal coordinate values between two Vector3
  2938. * @param left defines the first operand
  2939. * @param right defines the second operand
  2940. * @returns the new Vector3
  2941. */
  2942. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2943. /**
  2944. * Returns the distance between the vectors "value1" and "value2"
  2945. * @param value1 defines the first operand
  2946. * @param value2 defines the second operand
  2947. * @returns the distance
  2948. */
  2949. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2950. /**
  2951. * Returns the squared distance between the vectors "value1" and "value2"
  2952. * @param value1 defines the first operand
  2953. * @param value2 defines the second operand
  2954. * @returns the squared distance
  2955. */
  2956. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2957. /**
  2958. * Returns a new Vector3 located at the center between "value1" and "value2"
  2959. * @param value1 defines the first operand
  2960. * @param value2 defines the second operand
  2961. * @returns the new Vector3
  2962. */
  2963. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2964. /**
  2965. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2966. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2967. * to something in order to rotate it from its local system to the given target system
  2968. * Note: axis1, axis2 and axis3 are normalized during this operation
  2969. * @param axis1 defines the first axis
  2970. * @param axis2 defines the second axis
  2971. * @param axis3 defines the third axis
  2972. * @returns a new Vector3
  2973. */
  2974. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2975. /**
  2976. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2977. * @param axis1 defines the first axis
  2978. * @param axis2 defines the second axis
  2979. * @param axis3 defines the third axis
  2980. * @param ref defines the Vector3 where to store the result
  2981. */
  2982. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2983. }
  2984. /**
  2985. * Vector4 class created for EulerAngle class conversion to Quaternion
  2986. */
  2987. export class Vector4 {
  2988. /** x value of the vector */
  2989. x: number;
  2990. /** y value of the vector */
  2991. y: number;
  2992. /** z value of the vector */
  2993. z: number;
  2994. /** w value of the vector */
  2995. w: number;
  2996. /**
  2997. * Creates a Vector4 object from the given floats.
  2998. * @param x x value of the vector
  2999. * @param y y value of the vector
  3000. * @param z z value of the vector
  3001. * @param w w value of the vector
  3002. */
  3003. constructor(
  3004. /** x value of the vector */
  3005. x: number,
  3006. /** y value of the vector */
  3007. y: number,
  3008. /** z value of the vector */
  3009. z: number,
  3010. /** w value of the vector */
  3011. w: number);
  3012. /**
  3013. * Returns the string with the Vector4 coordinates.
  3014. * @returns a string containing all the vector values
  3015. */
  3016. toString(): string;
  3017. /**
  3018. * Returns the string "Vector4".
  3019. * @returns "Vector4"
  3020. */
  3021. getClassName(): string;
  3022. /**
  3023. * Returns the Vector4 hash code.
  3024. * @returns a unique hash code
  3025. */
  3026. getHashCode(): number;
  3027. /**
  3028. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3029. * @returns the resulting array
  3030. */
  3031. asArray(): number[];
  3032. /**
  3033. * Populates the given array from the given index with the Vector4 coordinates.
  3034. * @param array array to populate
  3035. * @param index index of the array to start at (default: 0)
  3036. * @returns the Vector4.
  3037. */
  3038. toArray(array: FloatArray, index?: number): Vector4;
  3039. /**
  3040. * Adds the given vector to the current Vector4.
  3041. * @param otherVector the vector to add
  3042. * @returns the updated Vector4.
  3043. */
  3044. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3045. /**
  3046. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3047. * @param otherVector the vector to add
  3048. * @returns the resulting vector
  3049. */
  3050. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3051. /**
  3052. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3053. * @param otherVector the vector to add
  3054. * @param result the vector to store the result
  3055. * @returns the current Vector4.
  3056. */
  3057. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3058. /**
  3059. * Subtract in place the given vector from the current Vector4.
  3060. * @param otherVector the vector to subtract
  3061. * @returns the updated Vector4.
  3062. */
  3063. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3064. /**
  3065. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3066. * @param otherVector the vector to add
  3067. * @returns the new vector with the result
  3068. */
  3069. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3070. /**
  3071. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3072. * @param otherVector the vector to subtract
  3073. * @param result the vector to store the result
  3074. * @returns the current Vector4.
  3075. */
  3076. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3077. /**
  3078. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3079. */
  3080. /**
  3081. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3082. * @param x value to subtract
  3083. * @param y value to subtract
  3084. * @param z value to subtract
  3085. * @param w value to subtract
  3086. * @returns new vector containing the result
  3087. */
  3088. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3089. /**
  3090. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3091. * @param x value to subtract
  3092. * @param y value to subtract
  3093. * @param z value to subtract
  3094. * @param w value to subtract
  3095. * @param result the vector to store the result in
  3096. * @returns the current Vector4.
  3097. */
  3098. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3099. /**
  3100. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3101. * @returns a new vector with the negated values
  3102. */
  3103. negate(): Vector4;
  3104. /**
  3105. * Multiplies the current Vector4 coordinates by scale (float).
  3106. * @param scale the number to scale with
  3107. * @returns the updated Vector4.
  3108. */
  3109. scaleInPlace(scale: number): Vector4;
  3110. /**
  3111. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3112. * @param scale the number to scale with
  3113. * @returns a new vector with the result
  3114. */
  3115. scale(scale: number): Vector4;
  3116. /**
  3117. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3118. * @param scale the number to scale with
  3119. * @param result a vector to store the result in
  3120. * @returns the current Vector4.
  3121. */
  3122. scaleToRef(scale: number, result: Vector4): Vector4;
  3123. /**
  3124. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3125. * @param scale defines the scale factor
  3126. * @param result defines the Vector4 object where to store the result
  3127. * @returns the unmodified current Vector4
  3128. */
  3129. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3130. /**
  3131. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3132. * @param otherVector the vector to compare against
  3133. * @returns true if they are equal
  3134. */
  3135. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3136. /**
  3137. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3138. * @param otherVector vector to compare against
  3139. * @param epsilon (Default: very small number)
  3140. * @returns true if they are equal
  3141. */
  3142. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3143. /**
  3144. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3145. * @param x x value to compare against
  3146. * @param y y value to compare against
  3147. * @param z z value to compare against
  3148. * @param w w value to compare against
  3149. * @returns true if equal
  3150. */
  3151. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3152. /**
  3153. * Multiplies in place the current Vector4 by the given one.
  3154. * @param otherVector vector to multiple with
  3155. * @returns the updated Vector4.
  3156. */
  3157. multiplyInPlace(otherVector: Vector4): Vector4;
  3158. /**
  3159. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3160. * @param otherVector vector to multiple with
  3161. * @returns resulting new vector
  3162. */
  3163. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3164. /**
  3165. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3166. * @param otherVector vector to multiple with
  3167. * @param result vector to store the result
  3168. * @returns the current Vector4.
  3169. */
  3170. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3171. /**
  3172. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3173. * @param x x value multiply with
  3174. * @param y y value multiply with
  3175. * @param z z value multiply with
  3176. * @param w w value multiply with
  3177. * @returns resulting new vector
  3178. */
  3179. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3180. /**
  3181. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3182. * @param otherVector vector to devide with
  3183. * @returns resulting new vector
  3184. */
  3185. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3186. /**
  3187. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3188. * @param otherVector vector to devide with
  3189. * @param result vector to store the result
  3190. * @returns the current Vector4.
  3191. */
  3192. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3193. /**
  3194. * Divides the current Vector3 coordinates by the given ones.
  3195. * @param otherVector vector to devide with
  3196. * @returns the updated Vector3.
  3197. */
  3198. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3199. /**
  3200. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3201. * @param other defines the second operand
  3202. * @returns the current updated Vector4
  3203. */
  3204. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3205. /**
  3206. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3207. * @param other defines the second operand
  3208. * @returns the current updated Vector4
  3209. */
  3210. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3211. /**
  3212. * Gets a new Vector4 from current Vector4 floored values
  3213. * @returns a new Vector4
  3214. */
  3215. floor(): Vector4;
  3216. /**
  3217. * Gets a new Vector4 from current Vector3 floored values
  3218. * @returns a new Vector4
  3219. */
  3220. fract(): Vector4;
  3221. /**
  3222. * Returns the Vector4 length (float).
  3223. * @returns the length
  3224. */
  3225. length(): number;
  3226. /**
  3227. * Returns the Vector4 squared length (float).
  3228. * @returns the length squared
  3229. */
  3230. lengthSquared(): number;
  3231. /**
  3232. * Normalizes in place the Vector4.
  3233. * @returns the updated Vector4.
  3234. */
  3235. normalize(): Vector4;
  3236. /**
  3237. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3238. * @returns this converted to a new vector3
  3239. */
  3240. toVector3(): Vector3;
  3241. /**
  3242. * Returns a new Vector4 copied from the current one.
  3243. * @returns the new cloned vector
  3244. */
  3245. clone(): Vector4;
  3246. /**
  3247. * Updates the current Vector4 with the given one coordinates.
  3248. * @param source the source vector to copy from
  3249. * @returns the updated Vector4.
  3250. */
  3251. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3252. /**
  3253. * Updates the current Vector4 coordinates with the given floats.
  3254. * @param x float to copy from
  3255. * @param y float to copy from
  3256. * @param z float to copy from
  3257. * @param w float to copy from
  3258. * @returns the updated Vector4.
  3259. */
  3260. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3261. /**
  3262. * Updates the current Vector4 coordinates with the given floats.
  3263. * @param x float to set from
  3264. * @param y float to set from
  3265. * @param z float to set from
  3266. * @param w float to set from
  3267. * @returns the updated Vector4.
  3268. */
  3269. set(x: number, y: number, z: number, w: number): Vector4;
  3270. /**
  3271. * Copies the given float to the current Vector3 coordinates
  3272. * @param v defines the x, y, z and w coordinates of the operand
  3273. * @returns the current updated Vector3
  3274. */
  3275. setAll(v: number): Vector4;
  3276. /**
  3277. * Returns a new Vector4 set from the starting index of the given array.
  3278. * @param array the array to pull values from
  3279. * @param offset the offset into the array to start at
  3280. * @returns the new vector
  3281. */
  3282. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3283. /**
  3284. * Updates the given vector "result" from the starting index of the given array.
  3285. * @param array the array to pull values from
  3286. * @param offset the offset into the array to start at
  3287. * @param result the vector to store the result in
  3288. */
  3289. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3290. /**
  3291. * Updates the given vector "result" from the starting index of the given Float32Array.
  3292. * @param array the array to pull values from
  3293. * @param offset the offset into the array to start at
  3294. * @param result the vector to store the result in
  3295. */
  3296. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3297. /**
  3298. * Updates the given vector "result" coordinates from the given floats.
  3299. * @param x float to set from
  3300. * @param y float to set from
  3301. * @param z float to set from
  3302. * @param w float to set from
  3303. * @param result the vector to the floats in
  3304. */
  3305. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3306. /**
  3307. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3308. * @returns the new vector
  3309. */
  3310. static Zero(): Vector4;
  3311. /**
  3312. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3313. * @returns the new vector
  3314. */
  3315. static One(): Vector4;
  3316. /**
  3317. * Returns a new normalized Vector4 from the given one.
  3318. * @param vector the vector to normalize
  3319. * @returns the vector
  3320. */
  3321. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3322. /**
  3323. * Updates the given vector "result" from the normalization of the given one.
  3324. * @param vector the vector to normalize
  3325. * @param result the vector to store the result in
  3326. */
  3327. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3328. /**
  3329. * Returns a vector with the minimum values from the left and right vectors
  3330. * @param left left vector to minimize
  3331. * @param right right vector to minimize
  3332. * @returns a new vector with the minimum of the left and right vector values
  3333. */
  3334. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3335. /**
  3336. * Returns a vector with the maximum values from the left and right vectors
  3337. * @param left left vector to maximize
  3338. * @param right right vector to maximize
  3339. * @returns a new vector with the maximum of the left and right vector values
  3340. */
  3341. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3342. /**
  3343. * Returns the distance (float) between the vectors "value1" and "value2".
  3344. * @param value1 value to calulate the distance between
  3345. * @param value2 value to calulate the distance between
  3346. * @return the distance between the two vectors
  3347. */
  3348. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3349. /**
  3350. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3351. * @param value1 value to calulate the distance between
  3352. * @param value2 value to calulate the distance between
  3353. * @return the distance between the two vectors squared
  3354. */
  3355. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3356. /**
  3357. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3358. * @param value1 value to calulate the center between
  3359. * @param value2 value to calulate the center between
  3360. * @return the center between the two vectors
  3361. */
  3362. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3365. * This methods computes transformed normalized direction vectors only.
  3366. * @param vector the vector to transform
  3367. * @param transformation the transformation matrix to apply
  3368. * @returns the new vector
  3369. */
  3370. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3371. /**
  3372. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3373. * This methods computes transformed normalized direction vectors only.
  3374. * @param vector the vector to transform
  3375. * @param transformation the transformation matrix to apply
  3376. * @param result the vector to store the result in
  3377. */
  3378. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3379. /**
  3380. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3381. * This methods computes transformed normalized direction vectors only.
  3382. * @param x value to transform
  3383. * @param y value to transform
  3384. * @param z value to transform
  3385. * @param w value to transform
  3386. * @param transformation the transformation matrix to apply
  3387. * @param result the vector to store the results in
  3388. */
  3389. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3390. /**
  3391. * Creates a new Vector4 from a Vector3
  3392. * @param source defines the source data
  3393. * @param w defines the 4th component (default is 0)
  3394. * @returns a new Vector4
  3395. */
  3396. static FromVector3(source: Vector3, w?: number): Vector4;
  3397. }
  3398. /**
  3399. * Class used to store quaternion data
  3400. * @see https://en.wikipedia.org/wiki/Quaternion
  3401. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3402. */
  3403. export class Quaternion {
  3404. /** defines the first component (0 by default) */
  3405. x: number;
  3406. /** defines the second component (0 by default) */
  3407. y: number;
  3408. /** defines the third component (0 by default) */
  3409. z: number;
  3410. /** defines the fourth component (1.0 by default) */
  3411. w: number;
  3412. /**
  3413. * Creates a new Quaternion from the given floats
  3414. * @param x defines the first component (0 by default)
  3415. * @param y defines the second component (0 by default)
  3416. * @param z defines the third component (0 by default)
  3417. * @param w defines the fourth component (1.0 by default)
  3418. */
  3419. constructor(
  3420. /** defines the first component (0 by default) */
  3421. x?: number,
  3422. /** defines the second component (0 by default) */
  3423. y?: number,
  3424. /** defines the third component (0 by default) */
  3425. z?: number,
  3426. /** defines the fourth component (1.0 by default) */
  3427. w?: number);
  3428. /**
  3429. * Gets a string representation for the current quaternion
  3430. * @returns a string with the Quaternion coordinates
  3431. */
  3432. toString(): string;
  3433. /**
  3434. * Gets the class name of the quaternion
  3435. * @returns the string "Quaternion"
  3436. */
  3437. getClassName(): string;
  3438. /**
  3439. * Gets a hash code for this quaternion
  3440. * @returns the quaternion hash code
  3441. */
  3442. getHashCode(): number;
  3443. /**
  3444. * Copy the quaternion to an array
  3445. * @returns a new array populated with 4 elements from the quaternion coordinates
  3446. */
  3447. asArray(): number[];
  3448. /**
  3449. * Check if two quaternions are equals
  3450. * @param otherQuaternion defines the second operand
  3451. * @return true if the current quaternion and the given one coordinates are strictly equals
  3452. */
  3453. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3454. /**
  3455. * Clone the current quaternion
  3456. * @returns a new quaternion copied from the current one
  3457. */
  3458. clone(): Quaternion;
  3459. /**
  3460. * Copy a quaternion to the current one
  3461. * @param other defines the other quaternion
  3462. * @returns the updated current quaternion
  3463. */
  3464. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3465. /**
  3466. * Updates the current quaternion with the given float coordinates
  3467. * @param x defines the x coordinate
  3468. * @param y defines the y coordinate
  3469. * @param z defines the z coordinate
  3470. * @param w defines the w coordinate
  3471. * @returns the updated current quaternion
  3472. */
  3473. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3474. /**
  3475. * Updates the current quaternion from the given float coordinates
  3476. * @param x defines the x coordinate
  3477. * @param y defines the y coordinate
  3478. * @param z defines the z coordinate
  3479. * @param w defines the w coordinate
  3480. * @returns the updated current quaternion
  3481. */
  3482. set(x: number, y: number, z: number, w: number): Quaternion;
  3483. /**
  3484. * Adds two quaternions
  3485. * @param other defines the second operand
  3486. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3487. */
  3488. add(other: DeepImmutable<Quaternion>): Quaternion;
  3489. /**
  3490. * Add a quaternion to the current one
  3491. * @param other defines the quaternion to add
  3492. * @returns the current quaternion
  3493. */
  3494. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3495. /**
  3496. * Subtract two quaternions
  3497. * @param other defines the second operand
  3498. * @returns a new quaternion as the subtraction result of the given one from the current one
  3499. */
  3500. subtract(other: Quaternion): Quaternion;
  3501. /**
  3502. * Multiplies the current quaternion by a scale factor
  3503. * @param value defines the scale factor
  3504. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3505. */
  3506. scale(value: number): Quaternion;
  3507. /**
  3508. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3509. * @param scale defines the scale factor
  3510. * @param result defines the Quaternion object where to store the result
  3511. * @returns the unmodified current quaternion
  3512. */
  3513. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3514. /**
  3515. * Multiplies in place the current quaternion by a scale factor
  3516. * @param value defines the scale factor
  3517. * @returns the current modified quaternion
  3518. */
  3519. scaleInPlace(value: number): Quaternion;
  3520. /**
  3521. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3522. * @param scale defines the scale factor
  3523. * @param result defines the Quaternion object where to store the result
  3524. * @returns the unmodified current quaternion
  3525. */
  3526. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3527. /**
  3528. * Multiplies two quaternions
  3529. * @param q1 defines the second operand
  3530. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3531. */
  3532. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3533. /**
  3534. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3535. * @param q1 defines the second operand
  3536. * @param result defines the target quaternion
  3537. * @returns the current quaternion
  3538. */
  3539. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3540. /**
  3541. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3542. * @param q1 defines the second operand
  3543. * @returns the currentupdated quaternion
  3544. */
  3545. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3546. /**
  3547. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3548. * @param ref defines the target quaternion
  3549. * @returns the current quaternion
  3550. */
  3551. conjugateToRef(ref: Quaternion): Quaternion;
  3552. /**
  3553. * Conjugates in place (1-q) the current quaternion
  3554. * @returns the current updated quaternion
  3555. */
  3556. conjugateInPlace(): Quaternion;
  3557. /**
  3558. * Conjugates in place (1-q) the current quaternion
  3559. * @returns a new quaternion
  3560. */
  3561. conjugate(): Quaternion;
  3562. /**
  3563. * Gets length of current quaternion
  3564. * @returns the quaternion length (float)
  3565. */
  3566. length(): number;
  3567. /**
  3568. * Normalize in place the current quaternion
  3569. * @returns the current updated quaternion
  3570. */
  3571. normalize(): Quaternion;
  3572. /**
  3573. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3574. * @param order is a reserved parameter and is ignore for now
  3575. * @returns a new Vector3 containing the Euler angles
  3576. */
  3577. toEulerAngles(order?: string): Vector3;
  3578. /**
  3579. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3580. * @param result defines the vector which will be filled with the Euler angles
  3581. * @param order is a reserved parameter and is ignore for now
  3582. * @returns the current unchanged quaternion
  3583. */
  3584. toEulerAnglesToRef(result: Vector3): Quaternion;
  3585. /**
  3586. * Updates the given rotation matrix with the current quaternion values
  3587. * @param result defines the target matrix
  3588. * @returns the current unchanged quaternion
  3589. */
  3590. toRotationMatrix(result: Matrix): Quaternion;
  3591. /**
  3592. * Updates the current quaternion from the given rotation matrix values
  3593. * @param matrix defines the source matrix
  3594. * @returns the current updated quaternion
  3595. */
  3596. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3597. /**
  3598. * Creates a new quaternion from a rotation matrix
  3599. * @param matrix defines the source matrix
  3600. * @returns a new quaternion created from the given rotation matrix values
  3601. */
  3602. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3603. /**
  3604. * Updates the given quaternion with the given rotation matrix values
  3605. * @param matrix defines the source matrix
  3606. * @param result defines the target quaternion
  3607. */
  3608. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3609. /**
  3610. * Returns the dot product (float) between the quaternions "left" and "right"
  3611. * @param left defines the left operand
  3612. * @param right defines the right operand
  3613. * @returns the dot product
  3614. */
  3615. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3616. /**
  3617. * Checks if the two quaternions are close to each other
  3618. * @param quat0 defines the first quaternion to check
  3619. * @param quat1 defines the second quaternion to check
  3620. * @returns true if the two quaternions are close to each other
  3621. */
  3622. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3623. /**
  3624. * Creates an empty quaternion
  3625. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3626. */
  3627. static Zero(): Quaternion;
  3628. /**
  3629. * Inverse a given quaternion
  3630. * @param q defines the source quaternion
  3631. * @returns a new quaternion as the inverted current quaternion
  3632. */
  3633. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3634. /**
  3635. * Inverse a given quaternion
  3636. * @param q defines the source quaternion
  3637. * @param result the quaternion the result will be stored in
  3638. * @returns the result quaternion
  3639. */
  3640. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3641. /**
  3642. * Creates an identity quaternion
  3643. * @returns the identity quaternion
  3644. */
  3645. static Identity(): Quaternion;
  3646. /**
  3647. * Gets a boolean indicating if the given quaternion is identity
  3648. * @param quaternion defines the quaternion to check
  3649. * @returns true if the quaternion is identity
  3650. */
  3651. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3652. /**
  3653. * Creates a quaternion from a rotation around an axis
  3654. * @param axis defines the axis to use
  3655. * @param angle defines the angle to use
  3656. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3657. */
  3658. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3659. /**
  3660. * Creates a rotation around an axis and stores it into the given quaternion
  3661. * @param axis defines the axis to use
  3662. * @param angle defines the angle to use
  3663. * @param result defines the target quaternion
  3664. * @returns the target quaternion
  3665. */
  3666. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3667. /**
  3668. * Creates a new quaternion from data stored into an array
  3669. * @param array defines the data source
  3670. * @param offset defines the offset in the source array where the data starts
  3671. * @returns a new quaternion
  3672. */
  3673. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3674. /**
  3675. * Create a quaternion from Euler rotation angles
  3676. * @param x Pitch
  3677. * @param y Yaw
  3678. * @param z Roll
  3679. * @returns the new Quaternion
  3680. */
  3681. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3682. /**
  3683. * Updates a quaternion from Euler rotation angles
  3684. * @param x Pitch
  3685. * @param y Yaw
  3686. * @param z Roll
  3687. * @param result the quaternion to store the result
  3688. * @returns the updated quaternion
  3689. */
  3690. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3691. /**
  3692. * Create a quaternion from Euler rotation vector
  3693. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3694. * @returns the new Quaternion
  3695. */
  3696. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3697. /**
  3698. * Updates a quaternion from Euler rotation vector
  3699. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3700. * @param result the quaternion to store the result
  3701. * @returns the updated quaternion
  3702. */
  3703. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3704. /**
  3705. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3706. * @param yaw defines the rotation around Y axis
  3707. * @param pitch defines the rotation around X axis
  3708. * @param roll defines the rotation around Z axis
  3709. * @returns the new quaternion
  3710. */
  3711. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3712. /**
  3713. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3714. * @param yaw defines the rotation around Y axis
  3715. * @param pitch defines the rotation around X axis
  3716. * @param roll defines the rotation around Z axis
  3717. * @param result defines the target quaternion
  3718. */
  3719. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3720. /**
  3721. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3722. * @param alpha defines the rotation around first axis
  3723. * @param beta defines the rotation around second axis
  3724. * @param gamma defines the rotation around third axis
  3725. * @returns the new quaternion
  3726. */
  3727. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3728. /**
  3729. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3730. * @param alpha defines the rotation around first axis
  3731. * @param beta defines the rotation around second axis
  3732. * @param gamma defines the rotation around third axis
  3733. * @param result defines the target quaternion
  3734. */
  3735. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3736. /**
  3737. * 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)
  3738. * @param axis1 defines the first axis
  3739. * @param axis2 defines the second axis
  3740. * @param axis3 defines the third axis
  3741. * @returns the new quaternion
  3742. */
  3743. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3744. /**
  3745. * 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
  3746. * @param axis1 defines the first axis
  3747. * @param axis2 defines the second axis
  3748. * @param axis3 defines the third axis
  3749. * @param ref defines the target quaternion
  3750. */
  3751. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3752. /**
  3753. * Interpolates between two quaternions
  3754. * @param left defines first quaternion
  3755. * @param right defines second quaternion
  3756. * @param amount defines the gradient to use
  3757. * @returns the new interpolated quaternion
  3758. */
  3759. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3760. /**
  3761. * Interpolates between two quaternions and stores it into a target quaternion
  3762. * @param left defines first quaternion
  3763. * @param right defines second quaternion
  3764. * @param amount defines the gradient to use
  3765. * @param result defines the target quaternion
  3766. */
  3767. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3768. /**
  3769. * Interpolate between two quaternions using Hermite interpolation
  3770. * @param value1 defines first quaternion
  3771. * @param tangent1 defines the incoming tangent
  3772. * @param value2 defines second quaternion
  3773. * @param tangent2 defines the outgoing tangent
  3774. * @param amount defines the target quaternion
  3775. * @returns the new interpolated quaternion
  3776. */
  3777. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3778. }
  3779. /**
  3780. * Class used to store matrix data (4x4)
  3781. */
  3782. export class Matrix {
  3783. private static _updateFlagSeed;
  3784. private static _identityReadOnly;
  3785. private _isIdentity;
  3786. private _isIdentityDirty;
  3787. private _isIdentity3x2;
  3788. private _isIdentity3x2Dirty;
  3789. /**
  3790. * Gets the update flag of the matrix which is an unique number for the matrix.
  3791. * It will be incremented every time the matrix data change.
  3792. * You can use it to speed the comparison between two versions of the same matrix.
  3793. */
  3794. updateFlag: number;
  3795. private readonly _m;
  3796. /**
  3797. * Gets the internal data of the matrix
  3798. */
  3799. readonly m: DeepImmutable<Float32Array>;
  3800. /** @hidden */
  3801. _markAsUpdated(): void;
  3802. /** @hidden */
  3803. private _updateIdentityStatus;
  3804. /**
  3805. * Creates an empty matrix (filled with zeros)
  3806. */
  3807. constructor();
  3808. /**
  3809. * Check if the current matrix is identity
  3810. * @returns true is the matrix is the identity matrix
  3811. */
  3812. isIdentity(): boolean;
  3813. /**
  3814. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3815. * @returns true is the matrix is the identity matrix
  3816. */
  3817. isIdentityAs3x2(): boolean;
  3818. /**
  3819. * Gets the determinant of the matrix
  3820. * @returns the matrix determinant
  3821. */
  3822. determinant(): number;
  3823. /**
  3824. * Returns the matrix as a Float32Array
  3825. * @returns the matrix underlying array
  3826. */
  3827. toArray(): DeepImmutable<Float32Array>;
  3828. /**
  3829. * Returns the matrix as a Float32Array
  3830. * @returns the matrix underlying array.
  3831. */
  3832. asArray(): DeepImmutable<Float32Array>;
  3833. /**
  3834. * Inverts the current matrix in place
  3835. * @returns the current inverted matrix
  3836. */
  3837. invert(): Matrix;
  3838. /**
  3839. * Sets all the matrix elements to zero
  3840. * @returns the current matrix
  3841. */
  3842. reset(): Matrix;
  3843. /**
  3844. * Adds the current matrix with a second one
  3845. * @param other defines the matrix to add
  3846. * @returns a new matrix as the addition of the current matrix and the given one
  3847. */
  3848. add(other: DeepImmutable<Matrix>): Matrix;
  3849. /**
  3850. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3851. * @param other defines the matrix to add
  3852. * @param result defines the target matrix
  3853. * @returns the current matrix
  3854. */
  3855. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3856. /**
  3857. * Adds in place the given matrix to the current matrix
  3858. * @param other defines the second operand
  3859. * @returns the current updated matrix
  3860. */
  3861. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3862. /**
  3863. * Sets the given matrix to the current inverted Matrix
  3864. * @param other defines the target matrix
  3865. * @returns the unmodified current matrix
  3866. */
  3867. invertToRef(other: Matrix): Matrix;
  3868. /**
  3869. * add a value at the specified position in the current Matrix
  3870. * @param index the index of the value within the matrix. between 0 and 15.
  3871. * @param value the value to be added
  3872. * @returns the current updated matrix
  3873. */
  3874. addAtIndex(index: number, value: number): Matrix;
  3875. /**
  3876. * mutiply the specified position in the current Matrix by a value
  3877. * @param index the index of the value within the matrix. between 0 and 15.
  3878. * @param value the value to be added
  3879. * @returns the current updated matrix
  3880. */
  3881. multiplyAtIndex(index: number, value: number): Matrix;
  3882. /**
  3883. * Inserts the translation vector (using 3 floats) in the current matrix
  3884. * @param x defines the 1st component of the translation
  3885. * @param y defines the 2nd component of the translation
  3886. * @param z defines the 3rd component of the translation
  3887. * @returns the current updated matrix
  3888. */
  3889. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3890. /**
  3891. * Adds the translation vector (using 3 floats) in the current matrix
  3892. * @param x defines the 1st component of the translation
  3893. * @param y defines the 2nd component of the translation
  3894. * @param z defines the 3rd component of the translation
  3895. * @returns the current updated matrix
  3896. */
  3897. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3898. /**
  3899. * Inserts the translation vector in the current matrix
  3900. * @param vector3 defines the translation to insert
  3901. * @returns the current updated matrix
  3902. */
  3903. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3904. /**
  3905. * Gets the translation value of the current matrix
  3906. * @returns a new Vector3 as the extracted translation from the matrix
  3907. */
  3908. getTranslation(): Vector3;
  3909. /**
  3910. * Fill a Vector3 with the extracted translation from the matrix
  3911. * @param result defines the Vector3 where to store the translation
  3912. * @returns the current matrix
  3913. */
  3914. getTranslationToRef(result: Vector3): Matrix;
  3915. /**
  3916. * Remove rotation and scaling part from the matrix
  3917. * @returns the updated matrix
  3918. */
  3919. removeRotationAndScaling(): Matrix;
  3920. /**
  3921. * Multiply two matrices
  3922. * @param other defines the second operand
  3923. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3924. */
  3925. multiply(other: DeepImmutable<Matrix>): Matrix;
  3926. /**
  3927. * Copy the current matrix from the given one
  3928. * @param other defines the source matrix
  3929. * @returns the current updated matrix
  3930. */
  3931. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3932. /**
  3933. * Populates the given array from the starting index with the current matrix values
  3934. * @param array defines the target array
  3935. * @param offset defines the offset in the target array where to start storing values
  3936. * @returns the current matrix
  3937. */
  3938. copyToArray(array: Float32Array, offset?: number): Matrix;
  3939. /**
  3940. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3941. * @param other defines the second operand
  3942. * @param result defines the matrix where to store the multiplication
  3943. * @returns the current matrix
  3944. */
  3945. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3946. /**
  3947. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3948. * @param other defines the second operand
  3949. * @param result defines the array where to store the multiplication
  3950. * @param offset defines the offset in the target array where to start storing values
  3951. * @returns the current matrix
  3952. */
  3953. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3954. /**
  3955. * Check equality between this matrix and a second one
  3956. * @param value defines the second matrix to compare
  3957. * @returns true is the current matrix and the given one values are strictly equal
  3958. */
  3959. equals(value: DeepImmutable<Matrix>): boolean;
  3960. /**
  3961. * Clone the current matrix
  3962. * @returns a new matrix from the current matrix
  3963. */
  3964. clone(): Matrix;
  3965. /**
  3966. * Returns the name of the current matrix class
  3967. * @returns the string "Matrix"
  3968. */
  3969. getClassName(): string;
  3970. /**
  3971. * Gets the hash code of the current matrix
  3972. * @returns the hash code
  3973. */
  3974. getHashCode(): number;
  3975. /**
  3976. * Decomposes the current Matrix into a translation, rotation and scaling components
  3977. * @param scale defines the scale vector3 given as a reference to update
  3978. * @param rotation defines the rotation quaternion given as a reference to update
  3979. * @param translation defines the translation vector3 given as a reference to update
  3980. * @returns true if operation was successful
  3981. */
  3982. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3983. /**
  3984. * Gets specific row of the matrix
  3985. * @param index defines the number of the row to get
  3986. * @returns the index-th row of the current matrix as a new Vector4
  3987. */
  3988. getRow(index: number): Nullable<Vector4>;
  3989. /**
  3990. * Sets the index-th row of the current matrix to the vector4 values
  3991. * @param index defines the number of the row to set
  3992. * @param row defines the target vector4
  3993. * @returns the updated current matrix
  3994. */
  3995. setRow(index: number, row: Vector4): Matrix;
  3996. /**
  3997. * Compute the transpose of the matrix
  3998. * @returns the new transposed matrix
  3999. */
  4000. transpose(): Matrix;
  4001. /**
  4002. * Compute the transpose of the matrix and store it in a given matrix
  4003. * @param result defines the target matrix
  4004. * @returns the current matrix
  4005. */
  4006. transposeToRef(result: Matrix): Matrix;
  4007. /**
  4008. * Sets the index-th row of the current matrix with the given 4 x float values
  4009. * @param index defines the row index
  4010. * @param x defines the x component to set
  4011. * @param y defines the y component to set
  4012. * @param z defines the z component to set
  4013. * @param w defines the w component to set
  4014. * @returns the updated current matrix
  4015. */
  4016. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4017. /**
  4018. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4019. * @param scale defines the scale factor
  4020. * @returns a new matrix
  4021. */
  4022. scale(scale: number): Matrix;
  4023. /**
  4024. * Scale the current matrix values by a factor to a given result matrix
  4025. * @param scale defines the scale factor
  4026. * @param result defines the matrix to store the result
  4027. * @returns the current matrix
  4028. */
  4029. scaleToRef(scale: number, result: Matrix): Matrix;
  4030. /**
  4031. * Scale the current matrix values by a factor and add the result to a given matrix
  4032. * @param scale defines the scale factor
  4033. * @param result defines the Matrix to store the result
  4034. * @returns the current matrix
  4035. */
  4036. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4037. /**
  4038. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4039. * @param ref matrix to store the result
  4040. */
  4041. toNormalMatrix(ref: Matrix): void;
  4042. /**
  4043. * Gets only rotation part of the current matrix
  4044. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4045. */
  4046. getRotationMatrix(): Matrix;
  4047. /**
  4048. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4049. * @param result defines the target matrix to store data to
  4050. * @returns the current matrix
  4051. */
  4052. getRotationMatrixToRef(result: Matrix): Matrix;
  4053. /**
  4054. * Toggles model matrix from being right handed to left handed in place and vice versa
  4055. */
  4056. toggleModelMatrixHandInPlace(): void;
  4057. /**
  4058. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4059. */
  4060. toggleProjectionMatrixHandInPlace(): void;
  4061. /**
  4062. * Creates a matrix from an array
  4063. * @param array defines the source array
  4064. * @param offset defines an offset in the source array
  4065. * @returns a new Matrix set from the starting index of the given array
  4066. */
  4067. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4068. /**
  4069. * Copy the content of an array into a given matrix
  4070. * @param array defines the source array
  4071. * @param offset defines an offset in the source array
  4072. * @param result defines the target matrix
  4073. */
  4074. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4075. /**
  4076. * Stores an array into a matrix after having multiplied each component by a given factor
  4077. * @param array defines the source array
  4078. * @param offset defines the offset in the source array
  4079. * @param scale defines the scaling factor
  4080. * @param result defines the target matrix
  4081. */
  4082. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4083. /**
  4084. * Gets an identity matrix that must not be updated
  4085. */
  4086. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  4087. /**
  4088. * Stores a list of values (16) inside a given matrix
  4089. * @param initialM11 defines 1st value of 1st row
  4090. * @param initialM12 defines 2nd value of 1st row
  4091. * @param initialM13 defines 3rd value of 1st row
  4092. * @param initialM14 defines 4th value of 1st row
  4093. * @param initialM21 defines 1st value of 2nd row
  4094. * @param initialM22 defines 2nd value of 2nd row
  4095. * @param initialM23 defines 3rd value of 2nd row
  4096. * @param initialM24 defines 4th value of 2nd row
  4097. * @param initialM31 defines 1st value of 3rd row
  4098. * @param initialM32 defines 2nd value of 3rd row
  4099. * @param initialM33 defines 3rd value of 3rd row
  4100. * @param initialM34 defines 4th value of 3rd row
  4101. * @param initialM41 defines 1st value of 4th row
  4102. * @param initialM42 defines 2nd value of 4th row
  4103. * @param initialM43 defines 3rd value of 4th row
  4104. * @param initialM44 defines 4th value of 4th row
  4105. * @param result defines the target matrix
  4106. */
  4107. 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;
  4108. /**
  4109. * Creates new matrix from a list of values (16)
  4110. * @param initialM11 defines 1st value of 1st row
  4111. * @param initialM12 defines 2nd value of 1st row
  4112. * @param initialM13 defines 3rd value of 1st row
  4113. * @param initialM14 defines 4th value of 1st row
  4114. * @param initialM21 defines 1st value of 2nd row
  4115. * @param initialM22 defines 2nd value of 2nd row
  4116. * @param initialM23 defines 3rd value of 2nd row
  4117. * @param initialM24 defines 4th value of 2nd row
  4118. * @param initialM31 defines 1st value of 3rd row
  4119. * @param initialM32 defines 2nd value of 3rd row
  4120. * @param initialM33 defines 3rd value of 3rd row
  4121. * @param initialM34 defines 4th value of 3rd row
  4122. * @param initialM41 defines 1st value of 4th row
  4123. * @param initialM42 defines 2nd value of 4th row
  4124. * @param initialM43 defines 3rd value of 4th row
  4125. * @param initialM44 defines 4th value of 4th row
  4126. * @returns the new matrix
  4127. */
  4128. 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;
  4129. /**
  4130. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4131. * @param scale defines the scale vector3
  4132. * @param rotation defines the rotation quaternion
  4133. * @param translation defines the translation vector3
  4134. * @returns a new matrix
  4135. */
  4136. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4137. /**
  4138. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4139. * @param scale defines the scale vector3
  4140. * @param rotation defines the rotation quaternion
  4141. * @param translation defines the translation vector3
  4142. * @param result defines the target matrix
  4143. */
  4144. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4145. /**
  4146. * Creates a new identity matrix
  4147. * @returns a new identity matrix
  4148. */
  4149. static Identity(): Matrix;
  4150. /**
  4151. * Creates a new identity matrix and stores the result in a given matrix
  4152. * @param result defines the target matrix
  4153. */
  4154. static IdentityToRef(result: Matrix): void;
  4155. /**
  4156. * Creates a new zero matrix
  4157. * @returns a new zero matrix
  4158. */
  4159. static Zero(): Matrix;
  4160. /**
  4161. * Creates a new rotation matrix for "angle" radians around the X axis
  4162. * @param angle defines the angle (in radians) to use
  4163. * @return the new matrix
  4164. */
  4165. static RotationX(angle: number): Matrix;
  4166. /**
  4167. * Creates a new matrix as the invert of a given matrix
  4168. * @param source defines the source matrix
  4169. * @returns the new matrix
  4170. */
  4171. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4172. /**
  4173. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4174. * @param angle defines the angle (in radians) to use
  4175. * @param result defines the target matrix
  4176. */
  4177. static RotationXToRef(angle: number, result: Matrix): void;
  4178. /**
  4179. * Creates a new rotation matrix for "angle" radians around the Y axis
  4180. * @param angle defines the angle (in radians) to use
  4181. * @return the new matrix
  4182. */
  4183. static RotationY(angle: number): Matrix;
  4184. /**
  4185. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4186. * @param angle defines the angle (in radians) to use
  4187. * @param result defines the target matrix
  4188. */
  4189. static RotationYToRef(angle: number, result: Matrix): void;
  4190. /**
  4191. * Creates a new rotation matrix for "angle" radians around the Z axis
  4192. * @param angle defines the angle (in radians) to use
  4193. * @return the new matrix
  4194. */
  4195. static RotationZ(angle: number): Matrix;
  4196. /**
  4197. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4198. * @param angle defines the angle (in radians) to use
  4199. * @param result defines the target matrix
  4200. */
  4201. static RotationZToRef(angle: number, result: Matrix): void;
  4202. /**
  4203. * Creates a new rotation matrix for "angle" radians around the given axis
  4204. * @param axis defines the axis to use
  4205. * @param angle defines the angle (in radians) to use
  4206. * @return the new matrix
  4207. */
  4208. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4209. /**
  4210. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4211. * @param axis defines the axis to use
  4212. * @param angle defines the angle (in radians) to use
  4213. * @param result defines the target matrix
  4214. */
  4215. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4216. /**
  4217. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4218. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4219. * @param from defines the vector to align
  4220. * @param to defines the vector to align to
  4221. * @param result defines the target matrix
  4222. */
  4223. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4224. /**
  4225. * Creates a rotation matrix
  4226. * @param yaw defines the yaw angle in radians (Y axis)
  4227. * @param pitch defines the pitch angle in radians (X axis)
  4228. * @param roll defines the roll angle in radians (X axis)
  4229. * @returns the new rotation matrix
  4230. */
  4231. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4232. /**
  4233. * Creates a rotation matrix and stores it in a given matrix
  4234. * @param yaw defines the yaw angle in radians (Y axis)
  4235. * @param pitch defines the pitch angle in radians (X axis)
  4236. * @param roll defines the roll angle in radians (X axis)
  4237. * @param result defines the target matrix
  4238. */
  4239. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4240. /**
  4241. * Creates a scaling matrix
  4242. * @param x defines the scale factor on X axis
  4243. * @param y defines the scale factor on Y axis
  4244. * @param z defines the scale factor on Z axis
  4245. * @returns the new matrix
  4246. */
  4247. static Scaling(x: number, y: number, z: number): Matrix;
  4248. /**
  4249. * Creates a scaling matrix and stores it in a given matrix
  4250. * @param x defines the scale factor on X axis
  4251. * @param y defines the scale factor on Y axis
  4252. * @param z defines the scale factor on Z axis
  4253. * @param result defines the target matrix
  4254. */
  4255. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4256. /**
  4257. * Creates a translation matrix
  4258. * @param x defines the translation on X axis
  4259. * @param y defines the translation on Y axis
  4260. * @param z defines the translationon Z axis
  4261. * @returns the new matrix
  4262. */
  4263. static Translation(x: number, y: number, z: number): Matrix;
  4264. /**
  4265. * Creates a translation matrix and stores it in a given matrix
  4266. * @param x defines the translation on X axis
  4267. * @param y defines the translation on Y axis
  4268. * @param z defines the translationon Z axis
  4269. * @param result defines the target matrix
  4270. */
  4271. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4272. /**
  4273. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4274. * @param startValue defines the start value
  4275. * @param endValue defines the end value
  4276. * @param gradient defines the gradient factor
  4277. * @returns the new matrix
  4278. */
  4279. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4280. /**
  4281. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4282. * @param startValue defines the start value
  4283. * @param endValue defines the end value
  4284. * @param gradient defines the gradient factor
  4285. * @param result defines the Matrix object where to store data
  4286. */
  4287. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4288. /**
  4289. * Builds a new matrix whose values are computed by:
  4290. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4291. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4292. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4293. * @param startValue defines the first matrix
  4294. * @param endValue defines the second matrix
  4295. * @param gradient defines the gradient between the two matrices
  4296. * @returns the new matrix
  4297. */
  4298. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4299. /**
  4300. * Update a matrix to values which are computed by:
  4301. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4302. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4303. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4304. * @param startValue defines the first matrix
  4305. * @param endValue defines the second matrix
  4306. * @param gradient defines the gradient between the two matrices
  4307. * @param result defines the target matrix
  4308. */
  4309. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4310. /**
  4311. * 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"
  4312. * This function works in left handed mode
  4313. * @param eye defines the final position of the entity
  4314. * @param target defines where the entity should look at
  4315. * @param up defines the up vector for the entity
  4316. * @returns the new matrix
  4317. */
  4318. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4319. /**
  4320. * 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".
  4321. * This function works in left handed mode
  4322. * @param eye defines the final position of the entity
  4323. * @param target defines where the entity should look at
  4324. * @param up defines the up vector for the entity
  4325. * @param result defines the target matrix
  4326. */
  4327. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4328. /**
  4329. * 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"
  4330. * This function works in right handed mode
  4331. * @param eye defines the final position of the entity
  4332. * @param target defines where the entity should look at
  4333. * @param up defines the up vector for the entity
  4334. * @returns the new matrix
  4335. */
  4336. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4337. /**
  4338. * 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".
  4339. * This function works in right handed mode
  4340. * @param eye defines the final position of the entity
  4341. * @param target defines where the entity should look at
  4342. * @param up defines the up vector for the entity
  4343. * @param result defines the target matrix
  4344. */
  4345. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4346. /**
  4347. * Create a left-handed orthographic projection matrix
  4348. * @param width defines the viewport width
  4349. * @param height defines the viewport height
  4350. * @param znear defines the near clip plane
  4351. * @param zfar defines the far clip plane
  4352. * @returns a new matrix as a left-handed orthographic projection matrix
  4353. */
  4354. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4355. /**
  4356. * Store a left-handed orthographic projection to a given matrix
  4357. * @param width defines the viewport width
  4358. * @param height defines the viewport height
  4359. * @param znear defines the near clip plane
  4360. * @param zfar defines the far clip plane
  4361. * @param result defines the target matrix
  4362. */
  4363. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4364. /**
  4365. * Create a left-handed orthographic projection matrix
  4366. * @param left defines the viewport left coordinate
  4367. * @param right defines the viewport right coordinate
  4368. * @param bottom defines the viewport bottom coordinate
  4369. * @param top defines the viewport top coordinate
  4370. * @param znear defines the near clip plane
  4371. * @param zfar defines the far clip plane
  4372. * @returns a new matrix as a left-handed orthographic projection matrix
  4373. */
  4374. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4375. /**
  4376. * Stores a left-handed orthographic projection into a given matrix
  4377. * @param left defines the viewport left coordinate
  4378. * @param right defines the viewport right coordinate
  4379. * @param bottom defines the viewport bottom coordinate
  4380. * @param top defines the viewport top coordinate
  4381. * @param znear defines the near clip plane
  4382. * @param zfar defines the far clip plane
  4383. * @param result defines the target matrix
  4384. */
  4385. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4386. /**
  4387. * Creates a right-handed orthographic projection matrix
  4388. * @param left defines the viewport left coordinate
  4389. * @param right defines the viewport right coordinate
  4390. * @param bottom defines the viewport bottom coordinate
  4391. * @param top defines the viewport top coordinate
  4392. * @param znear defines the near clip plane
  4393. * @param zfar defines the far clip plane
  4394. * @returns a new matrix as a right-handed orthographic projection matrix
  4395. */
  4396. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4397. /**
  4398. * Stores a right-handed orthographic projection into a given matrix
  4399. * @param left defines the viewport left coordinate
  4400. * @param right defines the viewport right coordinate
  4401. * @param bottom defines the viewport bottom coordinate
  4402. * @param top defines the viewport top coordinate
  4403. * @param znear defines the near clip plane
  4404. * @param zfar defines the far clip plane
  4405. * @param result defines the target matrix
  4406. */
  4407. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4408. /**
  4409. * Creates a left-handed perspective projection matrix
  4410. * @param width defines the viewport width
  4411. * @param height defines the viewport height
  4412. * @param znear defines the near clip plane
  4413. * @param zfar defines the far clip plane
  4414. * @returns a new matrix as a left-handed perspective projection matrix
  4415. */
  4416. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4417. /**
  4418. * Creates a left-handed perspective projection matrix
  4419. * @param fov defines the horizontal field of view
  4420. * @param aspect defines the aspect ratio
  4421. * @param znear defines the near clip plane
  4422. * @param zfar defines the far clip plane
  4423. * @returns a new matrix as a left-handed perspective projection matrix
  4424. */
  4425. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4426. /**
  4427. * Stores a left-handed perspective projection into a given matrix
  4428. * @param fov defines the horizontal field of view
  4429. * @param aspect defines the aspect ratio
  4430. * @param znear defines the near clip plane
  4431. * @param zfar defines the far clip plane
  4432. * @param result defines the target matrix
  4433. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4434. */
  4435. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4436. /**
  4437. * Creates a right-handed perspective projection matrix
  4438. * @param fov defines the horizontal field of view
  4439. * @param aspect defines the aspect ratio
  4440. * @param znear defines the near clip plane
  4441. * @param zfar defines the far clip plane
  4442. * @returns a new matrix as a right-handed perspective projection matrix
  4443. */
  4444. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4445. /**
  4446. * Stores a right-handed perspective projection into a given matrix
  4447. * @param fov defines the horizontal field of view
  4448. * @param aspect defines the aspect ratio
  4449. * @param znear defines the near clip plane
  4450. * @param zfar defines the far clip plane
  4451. * @param result defines the target matrix
  4452. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4453. */
  4454. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4455. /**
  4456. * Stores a perspective projection for WebVR info a given matrix
  4457. * @param fov defines the field of view
  4458. * @param znear defines the near clip plane
  4459. * @param zfar defines the far clip plane
  4460. * @param result defines the target matrix
  4461. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4462. */
  4463. static PerspectiveFovWebVRToRef(fov: {
  4464. upDegrees: number;
  4465. downDegrees: number;
  4466. leftDegrees: number;
  4467. rightDegrees: number;
  4468. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4469. /**
  4470. * Computes a complete transformation matrix
  4471. * @param viewport defines the viewport to use
  4472. * @param world defines the world matrix
  4473. * @param view defines the view matrix
  4474. * @param projection defines the projection matrix
  4475. * @param zmin defines the near clip plane
  4476. * @param zmax defines the far clip plane
  4477. * @returns the transformation matrix
  4478. */
  4479. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4480. /**
  4481. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4482. * @param matrix defines the matrix to use
  4483. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4484. */
  4485. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4486. /**
  4487. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4488. * @param matrix defines the matrix to use
  4489. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4490. */
  4491. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4492. /**
  4493. * Compute the transpose of a given matrix
  4494. * @param matrix defines the matrix to transpose
  4495. * @returns the new matrix
  4496. */
  4497. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4498. /**
  4499. * Compute the transpose of a matrix and store it in a target matrix
  4500. * @param matrix defines the matrix to transpose
  4501. * @param result defines the target matrix
  4502. */
  4503. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4504. /**
  4505. * Computes a reflection matrix from a plane
  4506. * @param plane defines the reflection plane
  4507. * @returns a new matrix
  4508. */
  4509. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4510. /**
  4511. * Computes a reflection matrix from a plane
  4512. * @param plane defines the reflection plane
  4513. * @param result defines the target matrix
  4514. */
  4515. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4516. /**
  4517. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4518. * @param xaxis defines the value of the 1st axis
  4519. * @param yaxis defines the value of the 2nd axis
  4520. * @param zaxis defines the value of the 3rd axis
  4521. * @param result defines the target matrix
  4522. */
  4523. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4524. /**
  4525. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4526. * @param quat defines the quaternion to use
  4527. * @param result defines the target matrix
  4528. */
  4529. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4530. }
  4531. /**
  4532. * @hidden
  4533. */
  4534. export class TmpVectors {
  4535. static Vector2: Vector2[];
  4536. static Vector3: Vector3[];
  4537. static Vector4: Vector4[];
  4538. static Quaternion: Quaternion[];
  4539. static Matrix: Matrix[];
  4540. }
  4541. }
  4542. declare module "babylonjs/Maths/math.path" {
  4543. import { DeepImmutable, Nullable } from "babylonjs/types";
  4544. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4545. /**
  4546. * Defines potential orientation for back face culling
  4547. */
  4548. export enum Orientation {
  4549. /**
  4550. * Clockwise
  4551. */
  4552. CW = 0,
  4553. /** Counter clockwise */
  4554. CCW = 1
  4555. }
  4556. /** Class used to represent a Bezier curve */
  4557. export class BezierCurve {
  4558. /**
  4559. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4560. * @param t defines the time
  4561. * @param x1 defines the left coordinate on X axis
  4562. * @param y1 defines the left coordinate on Y axis
  4563. * @param x2 defines the right coordinate on X axis
  4564. * @param y2 defines the right coordinate on Y axis
  4565. * @returns the interpolated value
  4566. */
  4567. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4568. }
  4569. /**
  4570. * Defines angle representation
  4571. */
  4572. export class Angle {
  4573. private _radians;
  4574. /**
  4575. * Creates an Angle object of "radians" radians (float).
  4576. * @param radians the angle in radians
  4577. */
  4578. constructor(radians: number);
  4579. /**
  4580. * Get value in degrees
  4581. * @returns the Angle value in degrees (float)
  4582. */
  4583. degrees(): number;
  4584. /**
  4585. * Get value in radians
  4586. * @returns the Angle value in radians (float)
  4587. */
  4588. radians(): number;
  4589. /**
  4590. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4591. * @param a defines first vector
  4592. * @param b defines second vector
  4593. * @returns a new Angle
  4594. */
  4595. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4596. /**
  4597. * Gets a new Angle object from the given float in radians
  4598. * @param radians defines the angle value in radians
  4599. * @returns a new Angle
  4600. */
  4601. static FromRadians(radians: number): Angle;
  4602. /**
  4603. * Gets a new Angle object from the given float in degrees
  4604. * @param degrees defines the angle value in degrees
  4605. * @returns a new Angle
  4606. */
  4607. static FromDegrees(degrees: number): Angle;
  4608. }
  4609. /**
  4610. * This represents an arc in a 2d space.
  4611. */
  4612. export class Arc2 {
  4613. /** Defines the start point of the arc */
  4614. startPoint: Vector2;
  4615. /** Defines the mid point of the arc */
  4616. midPoint: Vector2;
  4617. /** Defines the end point of the arc */
  4618. endPoint: Vector2;
  4619. /**
  4620. * Defines the center point of the arc.
  4621. */
  4622. centerPoint: Vector2;
  4623. /**
  4624. * Defines the radius of the arc.
  4625. */
  4626. radius: number;
  4627. /**
  4628. * Defines the angle of the arc (from mid point to end point).
  4629. */
  4630. angle: Angle;
  4631. /**
  4632. * Defines the start angle of the arc (from start point to middle point).
  4633. */
  4634. startAngle: Angle;
  4635. /**
  4636. * Defines the orientation of the arc (clock wise/counter clock wise).
  4637. */
  4638. orientation: Orientation;
  4639. /**
  4640. * Creates an Arc object from the three given points : start, middle and end.
  4641. * @param startPoint Defines the start point of the arc
  4642. * @param midPoint Defines the midlle point of the arc
  4643. * @param endPoint Defines the end point of the arc
  4644. */
  4645. constructor(
  4646. /** Defines the start point of the arc */
  4647. startPoint: Vector2,
  4648. /** Defines the mid point of the arc */
  4649. midPoint: Vector2,
  4650. /** Defines the end point of the arc */
  4651. endPoint: Vector2);
  4652. }
  4653. /**
  4654. * Represents a 2D path made up of multiple 2D points
  4655. */
  4656. export class Path2 {
  4657. private _points;
  4658. private _length;
  4659. /**
  4660. * If the path start and end point are the same
  4661. */
  4662. closed: boolean;
  4663. /**
  4664. * Creates a Path2 object from the starting 2D coordinates x and y.
  4665. * @param x the starting points x value
  4666. * @param y the starting points y value
  4667. */
  4668. constructor(x: number, y: number);
  4669. /**
  4670. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4671. * @param x the added points x value
  4672. * @param y the added points y value
  4673. * @returns the updated Path2.
  4674. */
  4675. addLineTo(x: number, y: number): Path2;
  4676. /**
  4677. * 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.
  4678. * @param midX middle point x value
  4679. * @param midY middle point y value
  4680. * @param endX end point x value
  4681. * @param endY end point y value
  4682. * @param numberOfSegments (default: 36)
  4683. * @returns the updated Path2.
  4684. */
  4685. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4686. /**
  4687. * Closes the Path2.
  4688. * @returns the Path2.
  4689. */
  4690. close(): Path2;
  4691. /**
  4692. * Gets the sum of the distance between each sequential point in the path
  4693. * @returns the Path2 total length (float).
  4694. */
  4695. length(): number;
  4696. /**
  4697. * Gets the points which construct the path
  4698. * @returns the Path2 internal array of points.
  4699. */
  4700. getPoints(): Vector2[];
  4701. /**
  4702. * Retreives the point at the distance aways from the starting point
  4703. * @param normalizedLengthPosition the length along the path to retreive the point from
  4704. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4705. */
  4706. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4707. /**
  4708. * Creates a new path starting from an x and y position
  4709. * @param x starting x value
  4710. * @param y starting y value
  4711. * @returns a new Path2 starting at the coordinates (x, y).
  4712. */
  4713. static StartingAt(x: number, y: number): Path2;
  4714. }
  4715. /**
  4716. * Represents a 3D path made up of multiple 3D points
  4717. */
  4718. export class Path3D {
  4719. /**
  4720. * an array of Vector3, the curve axis of the Path3D
  4721. */
  4722. path: Vector3[];
  4723. private _curve;
  4724. private _distances;
  4725. private _tangents;
  4726. private _normals;
  4727. private _binormals;
  4728. private _raw;
  4729. /**
  4730. * new Path3D(path, normal, raw)
  4731. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4732. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4733. * @param path an array of Vector3, the curve axis of the Path3D
  4734. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4735. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4736. */
  4737. constructor(
  4738. /**
  4739. * an array of Vector3, the curve axis of the Path3D
  4740. */
  4741. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4742. /**
  4743. * Returns the Path3D array of successive Vector3 designing its curve.
  4744. * @returns the Path3D array of successive Vector3 designing its curve.
  4745. */
  4746. getCurve(): Vector3[];
  4747. /**
  4748. * Returns an array populated with tangent vectors on each Path3D curve point.
  4749. * @returns an array populated with tangent vectors on each Path3D curve point.
  4750. */
  4751. getTangents(): Vector3[];
  4752. /**
  4753. * Returns an array populated with normal vectors on each Path3D curve point.
  4754. * @returns an array populated with normal vectors on each Path3D curve point.
  4755. */
  4756. getNormals(): Vector3[];
  4757. /**
  4758. * Returns an array populated with binormal vectors on each Path3D curve point.
  4759. * @returns an array populated with binormal vectors on each Path3D curve point.
  4760. */
  4761. getBinormals(): Vector3[];
  4762. /**
  4763. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4764. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4765. */
  4766. getDistances(): number[];
  4767. /**
  4768. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4769. * @param path path which all values are copied into the curves points
  4770. * @param firstNormal which should be projected onto the curve
  4771. * @returns the same object updated.
  4772. */
  4773. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4774. private _compute;
  4775. private _getFirstNonNullVector;
  4776. private _getLastNonNullVector;
  4777. private _normalVector;
  4778. }
  4779. /**
  4780. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4781. * A Curve3 is designed from a series of successive Vector3.
  4782. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4783. */
  4784. export class Curve3 {
  4785. private _points;
  4786. private _length;
  4787. /**
  4788. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4789. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4790. * @param v1 (Vector3) the control point
  4791. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4792. * @param nbPoints (integer) the wanted number of points in the curve
  4793. * @returns the created Curve3
  4794. */
  4795. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4796. /**
  4797. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4798. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4799. * @param v1 (Vector3) the first control point
  4800. * @param v2 (Vector3) the second control point
  4801. * @param v3 (Vector3) the end point of the Cubic Bezier
  4802. * @param nbPoints (integer) the wanted number of points in the curve
  4803. * @returns the created Curve3
  4804. */
  4805. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4806. /**
  4807. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4808. * @param p1 (Vector3) the origin point of the Hermite Spline
  4809. * @param t1 (Vector3) the tangent vector at the origin point
  4810. * @param p2 (Vector3) the end point of the Hermite Spline
  4811. * @param t2 (Vector3) the tangent vector at the end point
  4812. * @param nbPoints (integer) the wanted number of points in the curve
  4813. * @returns the created Curve3
  4814. */
  4815. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4816. /**
  4817. * Returns a Curve3 object along a CatmullRom Spline curve :
  4818. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4819. * @param nbPoints (integer) the wanted number of points between each curve control points
  4820. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4821. * @returns the created Curve3
  4822. */
  4823. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4824. /**
  4825. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4826. * A Curve3 is designed from a series of successive Vector3.
  4827. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4828. * @param points points which make up the curve
  4829. */
  4830. constructor(points: Vector3[]);
  4831. /**
  4832. * @returns the Curve3 stored array of successive Vector3
  4833. */
  4834. getPoints(): Vector3[];
  4835. /**
  4836. * @returns the computed length (float) of the curve.
  4837. */
  4838. length(): number;
  4839. /**
  4840. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4841. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4842. * curveA and curveB keep unchanged.
  4843. * @param curve the curve to continue from this curve
  4844. * @returns the newly constructed curve
  4845. */
  4846. continue(curve: DeepImmutable<Curve3>): Curve3;
  4847. private _computeLength;
  4848. }
  4849. }
  4850. declare module "babylonjs/Animations/easing" {
  4851. /**
  4852. * This represents the main contract an easing function should follow.
  4853. * Easing functions are used throughout the animation system.
  4854. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4855. */
  4856. export interface IEasingFunction {
  4857. /**
  4858. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4859. * of the easing function.
  4860. * The link below provides some of the most common examples of easing functions.
  4861. * @see https://easings.net/
  4862. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4863. * @returns the corresponding value on the curve defined by the easing function
  4864. */
  4865. ease(gradient: number): number;
  4866. }
  4867. /**
  4868. * Base class used for every default easing function.
  4869. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4870. */
  4871. export class EasingFunction implements IEasingFunction {
  4872. /**
  4873. * Interpolation follows the mathematical formula associated with the easing function.
  4874. */
  4875. static readonly EASINGMODE_EASEIN: number;
  4876. /**
  4877. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4878. */
  4879. static readonly EASINGMODE_EASEOUT: number;
  4880. /**
  4881. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4882. */
  4883. static readonly EASINGMODE_EASEINOUT: number;
  4884. private _easingMode;
  4885. /**
  4886. * Sets the easing mode of the current function.
  4887. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4888. */
  4889. setEasingMode(easingMode: number): void;
  4890. /**
  4891. * Gets the current easing mode.
  4892. * @returns the easing mode
  4893. */
  4894. getEasingMode(): number;
  4895. /**
  4896. * @hidden
  4897. */
  4898. easeInCore(gradient: number): number;
  4899. /**
  4900. * Given an input gradient between 0 and 1, this returns the corresponding value
  4901. * of the easing function.
  4902. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4903. * @returns the corresponding value on the curve defined by the easing function
  4904. */
  4905. ease(gradient: number): number;
  4906. }
  4907. /**
  4908. * Easing function with a circle shape (see link below).
  4909. * @see https://easings.net/#easeInCirc
  4910. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4911. */
  4912. export class CircleEase extends EasingFunction implements IEasingFunction {
  4913. /** @hidden */
  4914. easeInCore(gradient: number): number;
  4915. }
  4916. /**
  4917. * Easing function with a ease back shape (see link below).
  4918. * @see https://easings.net/#easeInBack
  4919. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4920. */
  4921. export class BackEase extends EasingFunction implements IEasingFunction {
  4922. /** Defines the amplitude of the function */
  4923. amplitude: number;
  4924. /**
  4925. * Instantiates a back ease easing
  4926. * @see https://easings.net/#easeInBack
  4927. * @param amplitude Defines the amplitude of the function
  4928. */
  4929. constructor(
  4930. /** Defines the amplitude of the function */
  4931. amplitude?: number);
  4932. /** @hidden */
  4933. easeInCore(gradient: number): number;
  4934. }
  4935. /**
  4936. * Easing function with a bouncing shape (see link below).
  4937. * @see https://easings.net/#easeInBounce
  4938. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4939. */
  4940. export class BounceEase extends EasingFunction implements IEasingFunction {
  4941. /** Defines the number of bounces */
  4942. bounces: number;
  4943. /** Defines the amplitude of the bounce */
  4944. bounciness: number;
  4945. /**
  4946. * Instantiates a bounce easing
  4947. * @see https://easings.net/#easeInBounce
  4948. * @param bounces Defines the number of bounces
  4949. * @param bounciness Defines the amplitude of the bounce
  4950. */
  4951. constructor(
  4952. /** Defines the number of bounces */
  4953. bounces?: number,
  4954. /** Defines the amplitude of the bounce */
  4955. bounciness?: number);
  4956. /** @hidden */
  4957. easeInCore(gradient: number): number;
  4958. }
  4959. /**
  4960. * Easing function with a power of 3 shape (see link below).
  4961. * @see https://easings.net/#easeInCubic
  4962. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4963. */
  4964. export class CubicEase extends EasingFunction implements IEasingFunction {
  4965. /** @hidden */
  4966. easeInCore(gradient: number): number;
  4967. }
  4968. /**
  4969. * Easing function with an elastic shape (see link below).
  4970. * @see https://easings.net/#easeInElastic
  4971. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4972. */
  4973. export class ElasticEase extends EasingFunction implements IEasingFunction {
  4974. /** Defines the number of oscillations*/
  4975. oscillations: number;
  4976. /** Defines the amplitude of the oscillations*/
  4977. springiness: number;
  4978. /**
  4979. * Instantiates an elastic easing function
  4980. * @see https://easings.net/#easeInElastic
  4981. * @param oscillations Defines the number of oscillations
  4982. * @param springiness Defines the amplitude of the oscillations
  4983. */
  4984. constructor(
  4985. /** Defines the number of oscillations*/
  4986. oscillations?: number,
  4987. /** Defines the amplitude of the oscillations*/
  4988. springiness?: number);
  4989. /** @hidden */
  4990. easeInCore(gradient: number): number;
  4991. }
  4992. /**
  4993. * Easing function with an exponential shape (see link below).
  4994. * @see https://easings.net/#easeInExpo
  4995. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4996. */
  4997. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  4998. /** Defines the exponent of the function */
  4999. exponent: number;
  5000. /**
  5001. * Instantiates an exponential easing function
  5002. * @see https://easings.net/#easeInExpo
  5003. * @param exponent Defines the exponent of the function
  5004. */
  5005. constructor(
  5006. /** Defines the exponent of the function */
  5007. exponent?: number);
  5008. /** @hidden */
  5009. easeInCore(gradient: number): number;
  5010. }
  5011. /**
  5012. * Easing function with a power shape (see link below).
  5013. * @see https://easings.net/#easeInQuad
  5014. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5015. */
  5016. export class PowerEase extends EasingFunction implements IEasingFunction {
  5017. /** Defines the power of the function */
  5018. power: number;
  5019. /**
  5020. * Instantiates an power base easing function
  5021. * @see https://easings.net/#easeInQuad
  5022. * @param power Defines the power of the function
  5023. */
  5024. constructor(
  5025. /** Defines the power of the function */
  5026. power?: number);
  5027. /** @hidden */
  5028. easeInCore(gradient: number): number;
  5029. }
  5030. /**
  5031. * Easing function with a power of 2 shape (see link below).
  5032. * @see https://easings.net/#easeInQuad
  5033. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5034. */
  5035. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5036. /** @hidden */
  5037. easeInCore(gradient: number): number;
  5038. }
  5039. /**
  5040. * Easing function with a power of 4 shape (see link below).
  5041. * @see https://easings.net/#easeInQuart
  5042. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5043. */
  5044. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5045. /** @hidden */
  5046. easeInCore(gradient: number): number;
  5047. }
  5048. /**
  5049. * Easing function with a power of 5 shape (see link below).
  5050. * @see https://easings.net/#easeInQuint
  5051. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5052. */
  5053. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5054. /** @hidden */
  5055. easeInCore(gradient: number): number;
  5056. }
  5057. /**
  5058. * Easing function with a sin shape (see link below).
  5059. * @see https://easings.net/#easeInSine
  5060. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5061. */
  5062. export class SineEase extends EasingFunction implements IEasingFunction {
  5063. /** @hidden */
  5064. easeInCore(gradient: number): number;
  5065. }
  5066. /**
  5067. * Easing function with a bezier shape (see link below).
  5068. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5069. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5070. */
  5071. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5072. /** Defines the x component of the start tangent in the bezier curve */
  5073. x1: number;
  5074. /** Defines the y component of the start tangent in the bezier curve */
  5075. y1: number;
  5076. /** Defines the x component of the end tangent in the bezier curve */
  5077. x2: number;
  5078. /** Defines the y component of the end tangent in the bezier curve */
  5079. y2: number;
  5080. /**
  5081. * Instantiates a bezier function
  5082. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5083. * @param x1 Defines the x component of the start tangent in the bezier curve
  5084. * @param y1 Defines the y component of the start tangent in the bezier curve
  5085. * @param x2 Defines the x component of the end tangent in the bezier curve
  5086. * @param y2 Defines the y component of the end tangent in the bezier curve
  5087. */
  5088. constructor(
  5089. /** Defines the x component of the start tangent in the bezier curve */
  5090. x1?: number,
  5091. /** Defines the y component of the start tangent in the bezier curve */
  5092. y1?: number,
  5093. /** Defines the x component of the end tangent in the bezier curve */
  5094. x2?: number,
  5095. /** Defines the y component of the end tangent in the bezier curve */
  5096. y2?: number);
  5097. /** @hidden */
  5098. easeInCore(gradient: number): number;
  5099. }
  5100. }
  5101. declare module "babylonjs/Maths/math.color" {
  5102. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5103. /**
  5104. * Class used to hold a RBG color
  5105. */
  5106. export class Color3 {
  5107. /**
  5108. * Defines the red component (between 0 and 1, default is 0)
  5109. */
  5110. r: number;
  5111. /**
  5112. * Defines the green component (between 0 and 1, default is 0)
  5113. */
  5114. g: number;
  5115. /**
  5116. * Defines the blue component (between 0 and 1, default is 0)
  5117. */
  5118. b: number;
  5119. /**
  5120. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5121. * @param r defines the red component (between 0 and 1, default is 0)
  5122. * @param g defines the green component (between 0 and 1, default is 0)
  5123. * @param b defines the blue component (between 0 and 1, default is 0)
  5124. */
  5125. constructor(
  5126. /**
  5127. * Defines the red component (between 0 and 1, default is 0)
  5128. */
  5129. r?: number,
  5130. /**
  5131. * Defines the green component (between 0 and 1, default is 0)
  5132. */
  5133. g?: number,
  5134. /**
  5135. * Defines the blue component (between 0 and 1, default is 0)
  5136. */
  5137. b?: number);
  5138. /**
  5139. * Creates a string with the Color3 current values
  5140. * @returns the string representation of the Color3 object
  5141. */
  5142. toString(): string;
  5143. /**
  5144. * Returns the string "Color3"
  5145. * @returns "Color3"
  5146. */
  5147. getClassName(): string;
  5148. /**
  5149. * Compute the Color3 hash code
  5150. * @returns an unique number that can be used to hash Color3 objects
  5151. */
  5152. getHashCode(): number;
  5153. /**
  5154. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5155. * @param array defines the array where to store the r,g,b components
  5156. * @param index defines an optional index in the target array to define where to start storing values
  5157. * @returns the current Color3 object
  5158. */
  5159. toArray(array: FloatArray, index?: number): Color3;
  5160. /**
  5161. * Returns a new Color4 object from the current Color3 and the given alpha
  5162. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5163. * @returns a new Color4 object
  5164. */
  5165. toColor4(alpha?: number): Color4;
  5166. /**
  5167. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5168. * @returns the new array
  5169. */
  5170. asArray(): number[];
  5171. /**
  5172. * Returns the luminance value
  5173. * @returns a float value
  5174. */
  5175. toLuminance(): number;
  5176. /**
  5177. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5178. * @param otherColor defines the second operand
  5179. * @returns the new Color3 object
  5180. */
  5181. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5182. /**
  5183. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5184. * @param otherColor defines the second operand
  5185. * @param result defines the Color3 object where to store the result
  5186. * @returns the current Color3
  5187. */
  5188. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5189. /**
  5190. * Determines equality between Color3 objects
  5191. * @param otherColor defines the second operand
  5192. * @returns true if the rgb values are equal to the given ones
  5193. */
  5194. equals(otherColor: DeepImmutable<Color3>): boolean;
  5195. /**
  5196. * Determines equality between the current Color3 object and a set of r,b,g values
  5197. * @param r defines the red component to check
  5198. * @param g defines the green component to check
  5199. * @param b defines the blue component to check
  5200. * @returns true if the rgb values are equal to the given ones
  5201. */
  5202. equalsFloats(r: number, g: number, b: number): boolean;
  5203. /**
  5204. * Multiplies in place each rgb value by scale
  5205. * @param scale defines the scaling factor
  5206. * @returns the updated Color3
  5207. */
  5208. scale(scale: number): Color3;
  5209. /**
  5210. * Multiplies the rgb values by scale and stores the result into "result"
  5211. * @param scale defines the scaling factor
  5212. * @param result defines the Color3 object where to store the result
  5213. * @returns the unmodified current Color3
  5214. */
  5215. scaleToRef(scale: number, result: Color3): Color3;
  5216. /**
  5217. * Scale the current Color3 values by a factor and add the result to a given Color3
  5218. * @param scale defines the scale factor
  5219. * @param result defines color to store the result into
  5220. * @returns the unmodified current Color3
  5221. */
  5222. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5223. /**
  5224. * Clamps the rgb values by the min and max values and stores the result into "result"
  5225. * @param min defines minimum clamping value (default is 0)
  5226. * @param max defines maximum clamping value (default is 1)
  5227. * @param result defines color to store the result into
  5228. * @returns the original Color3
  5229. */
  5230. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5231. /**
  5232. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5233. * @param otherColor defines the second operand
  5234. * @returns the new Color3
  5235. */
  5236. add(otherColor: DeepImmutable<Color3>): Color3;
  5237. /**
  5238. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5239. * @param otherColor defines the second operand
  5240. * @param result defines Color3 object to store the result into
  5241. * @returns the unmodified current Color3
  5242. */
  5243. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5244. /**
  5245. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5246. * @param otherColor defines the second operand
  5247. * @returns the new Color3
  5248. */
  5249. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5250. /**
  5251. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5252. * @param otherColor defines the second operand
  5253. * @param result defines Color3 object to store the result into
  5254. * @returns the unmodified current Color3
  5255. */
  5256. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5257. /**
  5258. * Copy the current object
  5259. * @returns a new Color3 copied the current one
  5260. */
  5261. clone(): Color3;
  5262. /**
  5263. * Copies the rgb values from the source in the current Color3
  5264. * @param source defines the source Color3 object
  5265. * @returns the updated Color3 object
  5266. */
  5267. copyFrom(source: DeepImmutable<Color3>): Color3;
  5268. /**
  5269. * Updates the Color3 rgb values from the given floats
  5270. * @param r defines the red component to read from
  5271. * @param g defines the green component to read from
  5272. * @param b defines the blue component to read from
  5273. * @returns the current Color3 object
  5274. */
  5275. copyFromFloats(r: number, g: number, b: number): Color3;
  5276. /**
  5277. * Updates the Color3 rgb values from the given floats
  5278. * @param r defines the red component to read from
  5279. * @param g defines the green component to read from
  5280. * @param b defines the blue component to read from
  5281. * @returns the current Color3 object
  5282. */
  5283. set(r: number, g: number, b: number): Color3;
  5284. /**
  5285. * Compute the Color3 hexadecimal code as a string
  5286. * @returns a string containing the hexadecimal representation of the Color3 object
  5287. */
  5288. toHexString(): string;
  5289. /**
  5290. * Computes a new Color3 converted from the current one to linear space
  5291. * @returns a new Color3 object
  5292. */
  5293. toLinearSpace(): Color3;
  5294. /**
  5295. * Converts current color in rgb space to HSV values
  5296. * @returns a new color3 representing the HSV values
  5297. */
  5298. toHSV(): Color3;
  5299. /**
  5300. * Converts current color in rgb space to HSV values
  5301. * @param result defines the Color3 where to store the HSV values
  5302. */
  5303. toHSVToRef(result: Color3): void;
  5304. /**
  5305. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5306. * @param convertedColor defines the Color3 object where to store the linear space version
  5307. * @returns the unmodified Color3
  5308. */
  5309. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5310. /**
  5311. * Computes a new Color3 converted from the current one to gamma space
  5312. * @returns a new Color3 object
  5313. */
  5314. toGammaSpace(): Color3;
  5315. /**
  5316. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5317. * @param convertedColor defines the Color3 object where to store the gamma space version
  5318. * @returns the unmodified Color3
  5319. */
  5320. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5321. private static _BlackReadOnly;
  5322. /**
  5323. * Convert Hue, saturation and value to a Color3 (RGB)
  5324. * @param hue defines the hue
  5325. * @param saturation defines the saturation
  5326. * @param value defines the value
  5327. * @param result defines the Color3 where to store the RGB values
  5328. */
  5329. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5330. /**
  5331. * Creates a new Color3 from the string containing valid hexadecimal values
  5332. * @param hex defines a string containing valid hexadecimal values
  5333. * @returns a new Color3 object
  5334. */
  5335. static FromHexString(hex: string): Color3;
  5336. /**
  5337. * Creates a new Color3 from the starting index of the given array
  5338. * @param array defines the source array
  5339. * @param offset defines an offset in the source array
  5340. * @returns a new Color3 object
  5341. */
  5342. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5343. /**
  5344. * Creates a new Color3 from integer values (< 256)
  5345. * @param r defines the red component to read from (value between 0 and 255)
  5346. * @param g defines the green component to read from (value between 0 and 255)
  5347. * @param b defines the blue component to read from (value between 0 and 255)
  5348. * @returns a new Color3 object
  5349. */
  5350. static FromInts(r: number, g: number, b: number): Color3;
  5351. /**
  5352. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5353. * @param start defines the start Color3 value
  5354. * @param end defines the end Color3 value
  5355. * @param amount defines the gradient value between start and end
  5356. * @returns a new Color3 object
  5357. */
  5358. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5359. /**
  5360. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5361. * @param left defines the start value
  5362. * @param right defines the end value
  5363. * @param amount defines the gradient factor
  5364. * @param result defines the Color3 object where to store the result
  5365. */
  5366. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5367. /**
  5368. * Returns a Color3 value containing a red color
  5369. * @returns a new Color3 object
  5370. */
  5371. static Red(): Color3;
  5372. /**
  5373. * Returns a Color3 value containing a green color
  5374. * @returns a new Color3 object
  5375. */
  5376. static Green(): Color3;
  5377. /**
  5378. * Returns a Color3 value containing a blue color
  5379. * @returns a new Color3 object
  5380. */
  5381. static Blue(): Color3;
  5382. /**
  5383. * Returns a Color3 value containing a black color
  5384. * @returns a new Color3 object
  5385. */
  5386. static Black(): Color3;
  5387. /**
  5388. * Gets a Color3 value containing a black color that must not be updated
  5389. */
  5390. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5391. /**
  5392. * Returns a Color3 value containing a white color
  5393. * @returns a new Color3 object
  5394. */
  5395. static White(): Color3;
  5396. /**
  5397. * Returns a Color3 value containing a purple color
  5398. * @returns a new Color3 object
  5399. */
  5400. static Purple(): Color3;
  5401. /**
  5402. * Returns a Color3 value containing a magenta color
  5403. * @returns a new Color3 object
  5404. */
  5405. static Magenta(): Color3;
  5406. /**
  5407. * Returns a Color3 value containing a yellow color
  5408. * @returns a new Color3 object
  5409. */
  5410. static Yellow(): Color3;
  5411. /**
  5412. * Returns a Color3 value containing a gray color
  5413. * @returns a new Color3 object
  5414. */
  5415. static Gray(): Color3;
  5416. /**
  5417. * Returns a Color3 value containing a teal color
  5418. * @returns a new Color3 object
  5419. */
  5420. static Teal(): Color3;
  5421. /**
  5422. * Returns a Color3 value containing a random color
  5423. * @returns a new Color3 object
  5424. */
  5425. static Random(): Color3;
  5426. }
  5427. /**
  5428. * Class used to hold a RBGA color
  5429. */
  5430. export class Color4 {
  5431. /**
  5432. * Defines the red component (between 0 and 1, default is 0)
  5433. */
  5434. r: number;
  5435. /**
  5436. * Defines the green component (between 0 and 1, default is 0)
  5437. */
  5438. g: number;
  5439. /**
  5440. * Defines the blue component (between 0 and 1, default is 0)
  5441. */
  5442. b: number;
  5443. /**
  5444. * Defines the alpha component (between 0 and 1, default is 1)
  5445. */
  5446. a: number;
  5447. /**
  5448. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5449. * @param r defines the red component (between 0 and 1, default is 0)
  5450. * @param g defines the green component (between 0 and 1, default is 0)
  5451. * @param b defines the blue component (between 0 and 1, default is 0)
  5452. * @param a defines the alpha component (between 0 and 1, default is 1)
  5453. */
  5454. constructor(
  5455. /**
  5456. * Defines the red component (between 0 and 1, default is 0)
  5457. */
  5458. r?: number,
  5459. /**
  5460. * Defines the green component (between 0 and 1, default is 0)
  5461. */
  5462. g?: number,
  5463. /**
  5464. * Defines the blue component (between 0 and 1, default is 0)
  5465. */
  5466. b?: number,
  5467. /**
  5468. * Defines the alpha component (between 0 and 1, default is 1)
  5469. */
  5470. a?: number);
  5471. /**
  5472. * Adds in place the given Color4 values to the current Color4 object
  5473. * @param right defines the second operand
  5474. * @returns the current updated Color4 object
  5475. */
  5476. addInPlace(right: DeepImmutable<Color4>): Color4;
  5477. /**
  5478. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5479. * @returns the new array
  5480. */
  5481. asArray(): number[];
  5482. /**
  5483. * Stores from the starting index in the given array the Color4 successive values
  5484. * @param array defines the array where to store the r,g,b components
  5485. * @param index defines an optional index in the target array to define where to start storing values
  5486. * @returns the current Color4 object
  5487. */
  5488. toArray(array: number[], index?: number): Color4;
  5489. /**
  5490. * Determines equality between Color4 objects
  5491. * @param otherColor defines the second operand
  5492. * @returns true if the rgba values are equal to the given ones
  5493. */
  5494. equals(otherColor: DeepImmutable<Color4>): boolean;
  5495. /**
  5496. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5497. * @param right defines the second operand
  5498. * @returns a new Color4 object
  5499. */
  5500. add(right: DeepImmutable<Color4>): Color4;
  5501. /**
  5502. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5503. * @param right defines the second operand
  5504. * @returns a new Color4 object
  5505. */
  5506. subtract(right: DeepImmutable<Color4>): Color4;
  5507. /**
  5508. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5509. * @param right defines the second operand
  5510. * @param result defines the Color4 object where to store the result
  5511. * @returns the current Color4 object
  5512. */
  5513. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5514. /**
  5515. * Creates a new Color4 with the current Color4 values multiplied by scale
  5516. * @param scale defines the scaling factor to apply
  5517. * @returns a new Color4 object
  5518. */
  5519. scale(scale: number): Color4;
  5520. /**
  5521. * Multiplies the current Color4 values by scale and stores the result in "result"
  5522. * @param scale defines the scaling factor to apply
  5523. * @param result defines the Color4 object where to store the result
  5524. * @returns the current unmodified Color4
  5525. */
  5526. scaleToRef(scale: number, result: Color4): Color4;
  5527. /**
  5528. * Scale the current Color4 values by a factor and add the result to a given Color4
  5529. * @param scale defines the scale factor
  5530. * @param result defines the Color4 object where to store the result
  5531. * @returns the unmodified current Color4
  5532. */
  5533. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5534. /**
  5535. * Clamps the rgb values by the min and max values and stores the result into "result"
  5536. * @param min defines minimum clamping value (default is 0)
  5537. * @param max defines maximum clamping value (default is 1)
  5538. * @param result defines color to store the result into.
  5539. * @returns the cuurent Color4
  5540. */
  5541. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5542. /**
  5543. * Multipy an Color4 value by another and return a new Color4 object
  5544. * @param color defines the Color4 value to multiply by
  5545. * @returns a new Color4 object
  5546. */
  5547. multiply(color: Color4): Color4;
  5548. /**
  5549. * Multipy a Color4 value by another and push the result in a reference value
  5550. * @param color defines the Color4 value to multiply by
  5551. * @param result defines the Color4 to fill the result in
  5552. * @returns the result Color4
  5553. */
  5554. multiplyToRef(color: Color4, result: Color4): Color4;
  5555. /**
  5556. * Creates a string with the Color4 current values
  5557. * @returns the string representation of the Color4 object
  5558. */
  5559. toString(): string;
  5560. /**
  5561. * Returns the string "Color4"
  5562. * @returns "Color4"
  5563. */
  5564. getClassName(): string;
  5565. /**
  5566. * Compute the Color4 hash code
  5567. * @returns an unique number that can be used to hash Color4 objects
  5568. */
  5569. getHashCode(): number;
  5570. /**
  5571. * Creates a new Color4 copied from the current one
  5572. * @returns a new Color4 object
  5573. */
  5574. clone(): Color4;
  5575. /**
  5576. * Copies the given Color4 values into the current one
  5577. * @param source defines the source Color4 object
  5578. * @returns the current updated Color4 object
  5579. */
  5580. copyFrom(source: Color4): Color4;
  5581. /**
  5582. * Copies the given float values into the current one
  5583. * @param r defines the red component to read from
  5584. * @param g defines the green component to read from
  5585. * @param b defines the blue component to read from
  5586. * @param a defines the alpha component to read from
  5587. * @returns the current updated Color4 object
  5588. */
  5589. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5590. /**
  5591. * Copies the given float values into the current one
  5592. * @param r defines the red component to read from
  5593. * @param g defines the green component to read from
  5594. * @param b defines the blue component to read from
  5595. * @param a defines the alpha component to read from
  5596. * @returns the current updated Color4 object
  5597. */
  5598. set(r: number, g: number, b: number, a: number): Color4;
  5599. /**
  5600. * Compute the Color4 hexadecimal code as a string
  5601. * @returns a string containing the hexadecimal representation of the Color4 object
  5602. */
  5603. toHexString(): string;
  5604. /**
  5605. * Computes a new Color4 converted from the current one to linear space
  5606. * @returns a new Color4 object
  5607. */
  5608. toLinearSpace(): Color4;
  5609. /**
  5610. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5611. * @param convertedColor defines the Color4 object where to store the linear space version
  5612. * @returns the unmodified Color4
  5613. */
  5614. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5615. /**
  5616. * Computes a new Color4 converted from the current one to gamma space
  5617. * @returns a new Color4 object
  5618. */
  5619. toGammaSpace(): Color4;
  5620. /**
  5621. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5622. * @param convertedColor defines the Color4 object where to store the gamma space version
  5623. * @returns the unmodified Color4
  5624. */
  5625. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5626. /**
  5627. * Creates a new Color4 from the string containing valid hexadecimal values
  5628. * @param hex defines a string containing valid hexadecimal values
  5629. * @returns a new Color4 object
  5630. */
  5631. static FromHexString(hex: string): Color4;
  5632. /**
  5633. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5634. * @param left defines the start value
  5635. * @param right defines the end value
  5636. * @param amount defines the gradient factor
  5637. * @returns a new Color4 object
  5638. */
  5639. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5640. /**
  5641. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5642. * @param left defines the start value
  5643. * @param right defines the end value
  5644. * @param amount defines the gradient factor
  5645. * @param result defines the Color4 object where to store data
  5646. */
  5647. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5648. /**
  5649. * Creates a new Color4 from a Color3 and an alpha value
  5650. * @param color3 defines the source Color3 to read from
  5651. * @param alpha defines the alpha component (1.0 by default)
  5652. * @returns a new Color4 object
  5653. */
  5654. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5655. /**
  5656. * Creates a new Color4 from the starting index element of the given array
  5657. * @param array defines the source array to read from
  5658. * @param offset defines the offset in the source array
  5659. * @returns a new Color4 object
  5660. */
  5661. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5662. /**
  5663. * Creates a new Color3 from integer values (< 256)
  5664. * @param r defines the red component to read from (value between 0 and 255)
  5665. * @param g defines the green component to read from (value between 0 and 255)
  5666. * @param b defines the blue component to read from (value between 0 and 255)
  5667. * @param a defines the alpha component to read from (value between 0 and 255)
  5668. * @returns a new Color3 object
  5669. */
  5670. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5671. /**
  5672. * Check the content of a given array and convert it to an array containing RGBA data
  5673. * If the original array was already containing count * 4 values then it is returned directly
  5674. * @param colors defines the array to check
  5675. * @param count defines the number of RGBA data to expect
  5676. * @returns an array containing count * 4 values (RGBA)
  5677. */
  5678. static CheckColors4(colors: number[], count: number): number[];
  5679. }
  5680. /**
  5681. * @hidden
  5682. */
  5683. export class TmpColors {
  5684. static Color3: Color3[];
  5685. static Color4: Color4[];
  5686. }
  5687. }
  5688. declare module "babylonjs/Animations/animationKey" {
  5689. /**
  5690. * Defines an interface which represents an animation key frame
  5691. */
  5692. export interface IAnimationKey {
  5693. /**
  5694. * Frame of the key frame
  5695. */
  5696. frame: number;
  5697. /**
  5698. * Value at the specifies key frame
  5699. */
  5700. value: any;
  5701. /**
  5702. * The input tangent for the cubic hermite spline
  5703. */
  5704. inTangent?: any;
  5705. /**
  5706. * The output tangent for the cubic hermite spline
  5707. */
  5708. outTangent?: any;
  5709. /**
  5710. * The animation interpolation type
  5711. */
  5712. interpolation?: AnimationKeyInterpolation;
  5713. }
  5714. /**
  5715. * Enum for the animation key frame interpolation type
  5716. */
  5717. export enum AnimationKeyInterpolation {
  5718. /**
  5719. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5720. */
  5721. STEP = 1
  5722. }
  5723. }
  5724. declare module "babylonjs/Animations/animationRange" {
  5725. /**
  5726. * Represents the range of an animation
  5727. */
  5728. export class AnimationRange {
  5729. /**The name of the animation range**/
  5730. name: string;
  5731. /**The starting frame of the animation */
  5732. from: number;
  5733. /**The ending frame of the animation*/
  5734. to: number;
  5735. /**
  5736. * Initializes the range of an animation
  5737. * @param name The name of the animation range
  5738. * @param from The starting frame of the animation
  5739. * @param to The ending frame of the animation
  5740. */
  5741. constructor(
  5742. /**The name of the animation range**/
  5743. name: string,
  5744. /**The starting frame of the animation */
  5745. from: number,
  5746. /**The ending frame of the animation*/
  5747. to: number);
  5748. /**
  5749. * Makes a copy of the animation range
  5750. * @returns A copy of the animation range
  5751. */
  5752. clone(): AnimationRange;
  5753. }
  5754. }
  5755. declare module "babylonjs/Animations/animationEvent" {
  5756. /**
  5757. * Composed of a frame, and an action function
  5758. */
  5759. export class AnimationEvent {
  5760. /** The frame for which the event is triggered **/
  5761. frame: number;
  5762. /** The event to perform when triggered **/
  5763. action: (currentFrame: number) => void;
  5764. /** Specifies if the event should be triggered only once**/
  5765. onlyOnce?: boolean | undefined;
  5766. /**
  5767. * Specifies if the animation event is done
  5768. */
  5769. isDone: boolean;
  5770. /**
  5771. * Initializes the animation event
  5772. * @param frame The frame for which the event is triggered
  5773. * @param action The event to perform when triggered
  5774. * @param onlyOnce Specifies if the event should be triggered only once
  5775. */
  5776. constructor(
  5777. /** The frame for which the event is triggered **/
  5778. frame: number,
  5779. /** The event to perform when triggered **/
  5780. action: (currentFrame: number) => void,
  5781. /** Specifies if the event should be triggered only once**/
  5782. onlyOnce?: boolean | undefined);
  5783. /** @hidden */
  5784. _clone(): AnimationEvent;
  5785. }
  5786. }
  5787. declare module "babylonjs/Behaviors/behavior" {
  5788. import { Nullable } from "babylonjs/types";
  5789. /**
  5790. * Interface used to define a behavior
  5791. */
  5792. export interface Behavior<T> {
  5793. /** gets or sets behavior's name */
  5794. name: string;
  5795. /**
  5796. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5797. */
  5798. init(): void;
  5799. /**
  5800. * Called when the behavior is attached to a target
  5801. * @param target defines the target where the behavior is attached to
  5802. */
  5803. attach(target: T): void;
  5804. /**
  5805. * Called when the behavior is detached from its target
  5806. */
  5807. detach(): void;
  5808. }
  5809. /**
  5810. * Interface implemented by classes supporting behaviors
  5811. */
  5812. export interface IBehaviorAware<T> {
  5813. /**
  5814. * Attach a behavior
  5815. * @param behavior defines the behavior to attach
  5816. * @returns the current host
  5817. */
  5818. addBehavior(behavior: Behavior<T>): T;
  5819. /**
  5820. * Remove a behavior from the current object
  5821. * @param behavior defines the behavior to detach
  5822. * @returns the current host
  5823. */
  5824. removeBehavior(behavior: Behavior<T>): T;
  5825. /**
  5826. * Gets a behavior using its name to search
  5827. * @param name defines the name to search
  5828. * @returns the behavior or null if not found
  5829. */
  5830. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  5831. }
  5832. }
  5833. declare module "babylonjs/Misc/smartArray" {
  5834. /**
  5835. * Defines an array and its length.
  5836. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  5837. */
  5838. export interface ISmartArrayLike<T> {
  5839. /**
  5840. * The data of the array.
  5841. */
  5842. data: Array<T>;
  5843. /**
  5844. * The active length of the array.
  5845. */
  5846. length: number;
  5847. }
  5848. /**
  5849. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5850. */
  5851. export class SmartArray<T> implements ISmartArrayLike<T> {
  5852. /**
  5853. * The full set of data from the array.
  5854. */
  5855. data: Array<T>;
  5856. /**
  5857. * The active length of the array.
  5858. */
  5859. length: number;
  5860. protected _id: number;
  5861. /**
  5862. * Instantiates a Smart Array.
  5863. * @param capacity defines the default capacity of the array.
  5864. */
  5865. constructor(capacity: number);
  5866. /**
  5867. * Pushes a value at the end of the active data.
  5868. * @param value defines the object to push in the array.
  5869. */
  5870. push(value: T): void;
  5871. /**
  5872. * Iterates over the active data and apply the lambda to them.
  5873. * @param func defines the action to apply on each value.
  5874. */
  5875. forEach(func: (content: T) => void): void;
  5876. /**
  5877. * Sorts the full sets of data.
  5878. * @param compareFn defines the comparison function to apply.
  5879. */
  5880. sort(compareFn: (a: T, b: T) => number): void;
  5881. /**
  5882. * Resets the active data to an empty array.
  5883. */
  5884. reset(): void;
  5885. /**
  5886. * Releases all the data from the array as well as the array.
  5887. */
  5888. dispose(): void;
  5889. /**
  5890. * Concats the active data with a given array.
  5891. * @param array defines the data to concatenate with.
  5892. */
  5893. concat(array: any): void;
  5894. /**
  5895. * Returns the position of a value in the active data.
  5896. * @param value defines the value to find the index for
  5897. * @returns the index if found in the active data otherwise -1
  5898. */
  5899. indexOf(value: T): number;
  5900. /**
  5901. * Returns whether an element is part of the active data.
  5902. * @param value defines the value to look for
  5903. * @returns true if found in the active data otherwise false
  5904. */
  5905. contains(value: T): boolean;
  5906. private static _GlobalId;
  5907. }
  5908. /**
  5909. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  5910. * The data in this array can only be present once
  5911. */
  5912. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  5913. private _duplicateId;
  5914. /**
  5915. * Pushes a value at the end of the active data.
  5916. * THIS DOES NOT PREVENT DUPPLICATE DATA
  5917. * @param value defines the object to push in the array.
  5918. */
  5919. push(value: T): void;
  5920. /**
  5921. * Pushes a value at the end of the active data.
  5922. * If the data is already present, it won t be added again
  5923. * @param value defines the object to push in the array.
  5924. * @returns true if added false if it was already present
  5925. */
  5926. pushNoDuplicate(value: T): boolean;
  5927. /**
  5928. * Resets the active data to an empty array.
  5929. */
  5930. reset(): void;
  5931. /**
  5932. * Concats the active data with a given array.
  5933. * This ensures no dupplicate will be present in the result.
  5934. * @param array defines the data to concatenate with.
  5935. */
  5936. concatWithNoDuplicate(array: any): void;
  5937. }
  5938. }
  5939. declare module "babylonjs/Cameras/cameraInputsManager" {
  5940. import { Nullable } from "babylonjs/types";
  5941. import { Camera } from "babylonjs/Cameras/camera";
  5942. /**
  5943. * @ignore
  5944. * This is a list of all the different input types that are available in the application.
  5945. * Fo instance: ArcRotateCameraGamepadInput...
  5946. */
  5947. export var CameraInputTypes: {};
  5948. /**
  5949. * This is the contract to implement in order to create a new input class.
  5950. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  5951. */
  5952. export interface ICameraInput<TCamera extends Camera> {
  5953. /**
  5954. * Defines the camera the input is attached to.
  5955. */
  5956. camera: Nullable<TCamera>;
  5957. /**
  5958. * Gets the class name of the current intput.
  5959. * @returns the class name
  5960. */
  5961. getClassName(): string;
  5962. /**
  5963. * Get the friendly name associated with the input class.
  5964. * @returns the input friendly name
  5965. */
  5966. getSimpleName(): string;
  5967. /**
  5968. * Attach the input controls to a specific dom element to get the input from.
  5969. * @param element Defines the element the controls should be listened from
  5970. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  5971. */
  5972. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  5973. /**
  5974. * Detach the current controls from the specified dom element.
  5975. * @param element Defines the element to stop listening the inputs from
  5976. */
  5977. detachControl(element: Nullable<HTMLElement>): void;
  5978. /**
  5979. * Update the current camera state depending on the inputs that have been used this frame.
  5980. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  5981. */
  5982. checkInputs?: () => void;
  5983. }
  5984. /**
  5985. * Represents a map of input types to input instance or input index to input instance.
  5986. */
  5987. export interface CameraInputsMap<TCamera extends Camera> {
  5988. /**
  5989. * Accessor to the input by input type.
  5990. */
  5991. [name: string]: ICameraInput<TCamera>;
  5992. /**
  5993. * Accessor to the input by input index.
  5994. */
  5995. [idx: number]: ICameraInput<TCamera>;
  5996. }
  5997. /**
  5998. * This represents the input manager used within a camera.
  5999. * It helps dealing with all the different kind of input attached to a camera.
  6000. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6001. */
  6002. export class CameraInputsManager<TCamera extends Camera> {
  6003. /**
  6004. * Defines the list of inputs attahed to the camera.
  6005. */
  6006. attached: CameraInputsMap<TCamera>;
  6007. /**
  6008. * Defines the dom element the camera is collecting inputs from.
  6009. * This is null if the controls have not been attached.
  6010. */
  6011. attachedElement: Nullable<HTMLElement>;
  6012. /**
  6013. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6014. */
  6015. noPreventDefault: boolean;
  6016. /**
  6017. * Defined the camera the input manager belongs to.
  6018. */
  6019. camera: TCamera;
  6020. /**
  6021. * Update the current camera state depending on the inputs that have been used this frame.
  6022. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6023. */
  6024. checkInputs: () => void;
  6025. /**
  6026. * Instantiate a new Camera Input Manager.
  6027. * @param camera Defines the camera the input manager blongs to
  6028. */
  6029. constructor(camera: TCamera);
  6030. /**
  6031. * Add an input method to a camera
  6032. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6033. * @param input camera input method
  6034. */
  6035. add(input: ICameraInput<TCamera>): void;
  6036. /**
  6037. * Remove a specific input method from a camera
  6038. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6039. * @param inputToRemove camera input method
  6040. */
  6041. remove(inputToRemove: ICameraInput<TCamera>): void;
  6042. /**
  6043. * Remove a specific input type from a camera
  6044. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6045. * @param inputType the type of the input to remove
  6046. */
  6047. removeByType(inputType: string): void;
  6048. private _addCheckInputs;
  6049. /**
  6050. * Attach the input controls to the currently attached dom element to listen the events from.
  6051. * @param input Defines the input to attach
  6052. */
  6053. attachInput(input: ICameraInput<TCamera>): void;
  6054. /**
  6055. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6056. * @param element Defines the dom element to collect the events from
  6057. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6058. */
  6059. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6060. /**
  6061. * Detach the current manager inputs controls from a specific dom element.
  6062. * @param element Defines the dom element to collect the events from
  6063. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6064. */
  6065. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6066. /**
  6067. * Rebuild the dynamic inputCheck function from the current list of
  6068. * defined inputs in the manager.
  6069. */
  6070. rebuildInputCheck(): void;
  6071. /**
  6072. * Remove all attached input methods from a camera
  6073. */
  6074. clear(): void;
  6075. /**
  6076. * Serialize the current input manager attached to a camera.
  6077. * This ensures than once parsed,
  6078. * the input associated to the camera will be identical to the current ones
  6079. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6080. */
  6081. serialize(serializedCamera: any): void;
  6082. /**
  6083. * Parses an input manager serialized JSON to restore the previous list of inputs
  6084. * and states associated to a camera.
  6085. * @param parsedCamera Defines the JSON to parse
  6086. */
  6087. parse(parsedCamera: any): void;
  6088. }
  6089. }
  6090. declare module "babylonjs/Meshes/buffer" {
  6091. import { Nullable, DataArray } from "babylonjs/types";
  6092. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6093. /**
  6094. * Class used to store data that will be store in GPU memory
  6095. */
  6096. export class Buffer {
  6097. private _engine;
  6098. private _buffer;
  6099. /** @hidden */
  6100. _data: Nullable<DataArray>;
  6101. private _updatable;
  6102. private _instanced;
  6103. /**
  6104. * Gets the byte stride.
  6105. */
  6106. readonly byteStride: number;
  6107. /**
  6108. * Constructor
  6109. * @param engine the engine
  6110. * @param data the data to use for this buffer
  6111. * @param updatable whether the data is updatable
  6112. * @param stride the stride (optional)
  6113. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6114. * @param instanced whether the buffer is instanced (optional)
  6115. * @param useBytes set to true if the stride in in bytes (optional)
  6116. */
  6117. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6118. /**
  6119. * Create a new VertexBuffer based on the current buffer
  6120. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6121. * @param offset defines offset in the buffer (0 by default)
  6122. * @param size defines the size in floats of attributes (position is 3 for instance)
  6123. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6124. * @param instanced defines if the vertex buffer contains indexed data
  6125. * @param useBytes defines if the offset and stride are in bytes
  6126. * @returns the new vertex buffer
  6127. */
  6128. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6129. /**
  6130. * Gets a boolean indicating if the Buffer is updatable?
  6131. * @returns true if the buffer is updatable
  6132. */
  6133. isUpdatable(): boolean;
  6134. /**
  6135. * Gets current buffer's data
  6136. * @returns a DataArray or null
  6137. */
  6138. getData(): Nullable<DataArray>;
  6139. /**
  6140. * Gets underlying native buffer
  6141. * @returns underlying native buffer
  6142. */
  6143. getBuffer(): Nullable<DataBuffer>;
  6144. /**
  6145. * Gets the stride in float32 units (i.e. byte stride / 4).
  6146. * May not be an integer if the byte stride is not divisible by 4.
  6147. * DEPRECATED. Use byteStride instead.
  6148. * @returns the stride in float32 units
  6149. */
  6150. getStrideSize(): number;
  6151. /**
  6152. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6153. * @param data defines the data to store
  6154. */
  6155. create(data?: Nullable<DataArray>): void;
  6156. /** @hidden */
  6157. _rebuild(): void;
  6158. /**
  6159. * Update current buffer data
  6160. * @param data defines the data to store
  6161. */
  6162. update(data: DataArray): void;
  6163. /**
  6164. * Updates the data directly.
  6165. * @param data the new data
  6166. * @param offset the new offset
  6167. * @param vertexCount the vertex count (optional)
  6168. * @param useBytes set to true if the offset is in bytes
  6169. */
  6170. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6171. /**
  6172. * Release all resources
  6173. */
  6174. dispose(): void;
  6175. }
  6176. /**
  6177. * Specialized buffer used to store vertex data
  6178. */
  6179. export class VertexBuffer {
  6180. /** @hidden */
  6181. _buffer: Buffer;
  6182. private _kind;
  6183. private _size;
  6184. private _ownsBuffer;
  6185. private _instanced;
  6186. private _instanceDivisor;
  6187. /**
  6188. * The byte type.
  6189. */
  6190. static readonly BYTE: number;
  6191. /**
  6192. * The unsigned byte type.
  6193. */
  6194. static readonly UNSIGNED_BYTE: number;
  6195. /**
  6196. * The short type.
  6197. */
  6198. static readonly SHORT: number;
  6199. /**
  6200. * The unsigned short type.
  6201. */
  6202. static readonly UNSIGNED_SHORT: number;
  6203. /**
  6204. * The integer type.
  6205. */
  6206. static readonly INT: number;
  6207. /**
  6208. * The unsigned integer type.
  6209. */
  6210. static readonly UNSIGNED_INT: number;
  6211. /**
  6212. * The float type.
  6213. */
  6214. static readonly FLOAT: number;
  6215. /**
  6216. * Gets or sets the instance divisor when in instanced mode
  6217. */
  6218. instanceDivisor: number;
  6219. /**
  6220. * Gets the byte stride.
  6221. */
  6222. readonly byteStride: number;
  6223. /**
  6224. * Gets the byte offset.
  6225. */
  6226. readonly byteOffset: number;
  6227. /**
  6228. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6229. */
  6230. readonly normalized: boolean;
  6231. /**
  6232. * Gets the data type of each component in the array.
  6233. */
  6234. readonly type: number;
  6235. /**
  6236. * Constructor
  6237. * @param engine the engine
  6238. * @param data the data to use for this vertex buffer
  6239. * @param kind the vertex buffer kind
  6240. * @param updatable whether the data is updatable
  6241. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6242. * @param stride the stride (optional)
  6243. * @param instanced whether the buffer is instanced (optional)
  6244. * @param offset the offset of the data (optional)
  6245. * @param size the number of components (optional)
  6246. * @param type the type of the component (optional)
  6247. * @param normalized whether the data contains normalized data (optional)
  6248. * @param useBytes set to true if stride and offset are in bytes (optional)
  6249. */
  6250. 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);
  6251. /** @hidden */
  6252. _rebuild(): void;
  6253. /**
  6254. * Returns the kind of the VertexBuffer (string)
  6255. * @returns a string
  6256. */
  6257. getKind(): string;
  6258. /**
  6259. * Gets a boolean indicating if the VertexBuffer is updatable?
  6260. * @returns true if the buffer is updatable
  6261. */
  6262. isUpdatable(): boolean;
  6263. /**
  6264. * Gets current buffer's data
  6265. * @returns a DataArray or null
  6266. */
  6267. getData(): Nullable<DataArray>;
  6268. /**
  6269. * Gets underlying native buffer
  6270. * @returns underlying native buffer
  6271. */
  6272. getBuffer(): Nullable<DataBuffer>;
  6273. /**
  6274. * Gets the stride in float32 units (i.e. byte stride / 4).
  6275. * May not be an integer if the byte stride is not divisible by 4.
  6276. * DEPRECATED. Use byteStride instead.
  6277. * @returns the stride in float32 units
  6278. */
  6279. getStrideSize(): number;
  6280. /**
  6281. * Returns the offset as a multiple of the type byte length.
  6282. * DEPRECATED. Use byteOffset instead.
  6283. * @returns the offset in bytes
  6284. */
  6285. getOffset(): number;
  6286. /**
  6287. * Returns the number of components per vertex attribute (integer)
  6288. * @returns the size in float
  6289. */
  6290. getSize(): number;
  6291. /**
  6292. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6293. * @returns true if this buffer is instanced
  6294. */
  6295. getIsInstanced(): boolean;
  6296. /**
  6297. * Returns the instancing divisor, zero for non-instanced (integer).
  6298. * @returns a number
  6299. */
  6300. getInstanceDivisor(): number;
  6301. /**
  6302. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6303. * @param data defines the data to store
  6304. */
  6305. create(data?: DataArray): void;
  6306. /**
  6307. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6308. * This function will create a new buffer if the current one is not updatable
  6309. * @param data defines the data to store
  6310. */
  6311. update(data: DataArray): void;
  6312. /**
  6313. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6314. * Returns the directly updated WebGLBuffer.
  6315. * @param data the new data
  6316. * @param offset the new offset
  6317. * @param useBytes set to true if the offset is in bytes
  6318. */
  6319. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6320. /**
  6321. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6322. */
  6323. dispose(): void;
  6324. /**
  6325. * Enumerates each value of this vertex buffer as numbers.
  6326. * @param count the number of values to enumerate
  6327. * @param callback the callback function called for each value
  6328. */
  6329. forEach(count: number, callback: (value: number, index: number) => void): void;
  6330. /**
  6331. * Positions
  6332. */
  6333. static readonly PositionKind: string;
  6334. /**
  6335. * Normals
  6336. */
  6337. static readonly NormalKind: string;
  6338. /**
  6339. * Tangents
  6340. */
  6341. static readonly TangentKind: string;
  6342. /**
  6343. * Texture coordinates
  6344. */
  6345. static readonly UVKind: string;
  6346. /**
  6347. * Texture coordinates 2
  6348. */
  6349. static readonly UV2Kind: string;
  6350. /**
  6351. * Texture coordinates 3
  6352. */
  6353. static readonly UV3Kind: string;
  6354. /**
  6355. * Texture coordinates 4
  6356. */
  6357. static readonly UV4Kind: string;
  6358. /**
  6359. * Texture coordinates 5
  6360. */
  6361. static readonly UV5Kind: string;
  6362. /**
  6363. * Texture coordinates 6
  6364. */
  6365. static readonly UV6Kind: string;
  6366. /**
  6367. * Colors
  6368. */
  6369. static readonly ColorKind: string;
  6370. /**
  6371. * Matrix indices (for bones)
  6372. */
  6373. static readonly MatricesIndicesKind: string;
  6374. /**
  6375. * Matrix weights (for bones)
  6376. */
  6377. static readonly MatricesWeightsKind: string;
  6378. /**
  6379. * Additional matrix indices (for bones)
  6380. */
  6381. static readonly MatricesIndicesExtraKind: string;
  6382. /**
  6383. * Additional matrix weights (for bones)
  6384. */
  6385. static readonly MatricesWeightsExtraKind: string;
  6386. /**
  6387. * Deduces the stride given a kind.
  6388. * @param kind The kind string to deduce
  6389. * @returns The deduced stride
  6390. */
  6391. static DeduceStride(kind: string): number;
  6392. /**
  6393. * Gets the byte length of the given type.
  6394. * @param type the type
  6395. * @returns the number of bytes
  6396. */
  6397. static GetTypeByteLength(type: number): number;
  6398. /**
  6399. * Enumerates each value of the given parameters as numbers.
  6400. * @param data the data to enumerate
  6401. * @param byteOffset the byte offset of the data
  6402. * @param byteStride the byte stride of the data
  6403. * @param componentCount the number of components per element
  6404. * @param componentType the type of the component
  6405. * @param count the number of values to enumerate
  6406. * @param normalized whether the data is normalized
  6407. * @param callback the callback function called for each value
  6408. */
  6409. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6410. private static _GetFloatValue;
  6411. }
  6412. }
  6413. declare module "babylonjs/Collisions/intersectionInfo" {
  6414. import { Nullable } from "babylonjs/types";
  6415. /**
  6416. * @hidden
  6417. */
  6418. export class IntersectionInfo {
  6419. bu: Nullable<number>;
  6420. bv: Nullable<number>;
  6421. distance: number;
  6422. faceId: number;
  6423. subMeshId: number;
  6424. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6425. }
  6426. }
  6427. declare module "babylonjs/Maths/math.plane" {
  6428. import { DeepImmutable } from "babylonjs/types";
  6429. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6430. /**
  6431. * Represens a plane by the equation ax + by + cz + d = 0
  6432. */
  6433. export class Plane {
  6434. private static _TmpMatrix;
  6435. /**
  6436. * Normal of the plane (a,b,c)
  6437. */
  6438. normal: Vector3;
  6439. /**
  6440. * d component of the plane
  6441. */
  6442. d: number;
  6443. /**
  6444. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6445. * @param a a component of the plane
  6446. * @param b b component of the plane
  6447. * @param c c component of the plane
  6448. * @param d d component of the plane
  6449. */
  6450. constructor(a: number, b: number, c: number, d: number);
  6451. /**
  6452. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6453. */
  6454. asArray(): number[];
  6455. /**
  6456. * @returns a new plane copied from the current Plane.
  6457. */
  6458. clone(): Plane;
  6459. /**
  6460. * @returns the string "Plane".
  6461. */
  6462. getClassName(): string;
  6463. /**
  6464. * @returns the Plane hash code.
  6465. */
  6466. getHashCode(): number;
  6467. /**
  6468. * Normalize the current Plane in place.
  6469. * @returns the updated Plane.
  6470. */
  6471. normalize(): Plane;
  6472. /**
  6473. * Applies a transformation the plane and returns the result
  6474. * @param transformation the transformation matrix to be applied to the plane
  6475. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6476. */
  6477. transform(transformation: DeepImmutable<Matrix>): Plane;
  6478. /**
  6479. * Calcualtte the dot product between the point and the plane normal
  6480. * @param point point to calculate the dot product with
  6481. * @returns the dot product (float) of the point coordinates and the plane normal.
  6482. */
  6483. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6484. /**
  6485. * Updates the current Plane from the plane defined by the three given points.
  6486. * @param point1 one of the points used to contruct the plane
  6487. * @param point2 one of the points used to contruct the plane
  6488. * @param point3 one of the points used to contruct the plane
  6489. * @returns the updated Plane.
  6490. */
  6491. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6492. /**
  6493. * Checks if the plane is facing a given direction
  6494. * @param direction the direction to check if the plane is facing
  6495. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6496. * @returns True is the vector "direction" is the same side than the plane normal.
  6497. */
  6498. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6499. /**
  6500. * Calculates the distance to a point
  6501. * @param point point to calculate distance to
  6502. * @returns the signed distance (float) from the given point to the Plane.
  6503. */
  6504. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6505. /**
  6506. * Creates a plane from an array
  6507. * @param array the array to create a plane from
  6508. * @returns a new Plane from the given array.
  6509. */
  6510. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6511. /**
  6512. * Creates a plane from three points
  6513. * @param point1 point used to create the plane
  6514. * @param point2 point used to create the plane
  6515. * @param point3 point used to create the plane
  6516. * @returns a new Plane defined by the three given points.
  6517. */
  6518. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6519. /**
  6520. * Creates a plane from an origin point and a normal
  6521. * @param origin origin of the plane to be constructed
  6522. * @param normal normal of the plane to be constructed
  6523. * @returns a new Plane the normal vector to this plane at the given origin point.
  6524. * Note : the vector "normal" is updated because normalized.
  6525. */
  6526. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6527. /**
  6528. * Calculates the distance from a plane and a point
  6529. * @param origin origin of the plane to be constructed
  6530. * @param normal normal of the plane to be constructed
  6531. * @param point point to calculate distance to
  6532. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6533. */
  6534. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6535. }
  6536. }
  6537. declare module "babylonjs/Culling/boundingSphere" {
  6538. import { DeepImmutable } from "babylonjs/types";
  6539. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6540. import { Plane } from "babylonjs/Maths/math.plane";
  6541. /**
  6542. * Class used to store bounding sphere information
  6543. */
  6544. export class BoundingSphere {
  6545. /**
  6546. * Gets the center of the bounding sphere in local space
  6547. */
  6548. readonly center: Vector3;
  6549. /**
  6550. * Radius of the bounding sphere in local space
  6551. */
  6552. radius: number;
  6553. /**
  6554. * Gets the center of the bounding sphere in world space
  6555. */
  6556. readonly centerWorld: Vector3;
  6557. /**
  6558. * Radius of the bounding sphere in world space
  6559. */
  6560. radiusWorld: number;
  6561. /**
  6562. * Gets the minimum vector in local space
  6563. */
  6564. readonly minimum: Vector3;
  6565. /**
  6566. * Gets the maximum vector in local space
  6567. */
  6568. readonly maximum: Vector3;
  6569. private _worldMatrix;
  6570. private static readonly TmpVector3;
  6571. /**
  6572. * Creates a new bounding sphere
  6573. * @param min defines the minimum vector (in local space)
  6574. * @param max defines the maximum vector (in local space)
  6575. * @param worldMatrix defines the new world matrix
  6576. */
  6577. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6578. /**
  6579. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6580. * @param min defines the new minimum vector (in local space)
  6581. * @param max defines the new maximum vector (in local space)
  6582. * @param worldMatrix defines the new world matrix
  6583. */
  6584. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6585. /**
  6586. * Scale the current bounding sphere by applying a scale factor
  6587. * @param factor defines the scale factor to apply
  6588. * @returns the current bounding box
  6589. */
  6590. scale(factor: number): BoundingSphere;
  6591. /**
  6592. * Gets the world matrix of the bounding box
  6593. * @returns a matrix
  6594. */
  6595. getWorldMatrix(): DeepImmutable<Matrix>;
  6596. /** @hidden */
  6597. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6598. /**
  6599. * Tests if the bounding sphere is intersecting the frustum planes
  6600. * @param frustumPlanes defines the frustum planes to test
  6601. * @returns true if there is an intersection
  6602. */
  6603. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6604. /**
  6605. * Tests if the bounding sphere center is in between the frustum planes.
  6606. * Used for optimistic fast inclusion.
  6607. * @param frustumPlanes defines the frustum planes to test
  6608. * @returns true if the sphere center is in between the frustum planes
  6609. */
  6610. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6611. /**
  6612. * Tests if a point is inside the bounding sphere
  6613. * @param point defines the point to test
  6614. * @returns true if the point is inside the bounding sphere
  6615. */
  6616. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6617. /**
  6618. * Checks if two sphere intersct
  6619. * @param sphere0 sphere 0
  6620. * @param sphere1 sphere 1
  6621. * @returns true if the speres intersect
  6622. */
  6623. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6624. }
  6625. }
  6626. declare module "babylonjs/Culling/boundingBox" {
  6627. import { DeepImmutable } from "babylonjs/types";
  6628. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6629. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6630. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6631. import { Plane } from "babylonjs/Maths/math.plane";
  6632. /**
  6633. * Class used to store bounding box information
  6634. */
  6635. export class BoundingBox implements ICullable {
  6636. /**
  6637. * Gets the 8 vectors representing the bounding box in local space
  6638. */
  6639. readonly vectors: Vector3[];
  6640. /**
  6641. * Gets the center of the bounding box in local space
  6642. */
  6643. readonly center: Vector3;
  6644. /**
  6645. * Gets the center of the bounding box in world space
  6646. */
  6647. readonly centerWorld: Vector3;
  6648. /**
  6649. * Gets the extend size in local space
  6650. */
  6651. readonly extendSize: Vector3;
  6652. /**
  6653. * Gets the extend size in world space
  6654. */
  6655. readonly extendSizeWorld: Vector3;
  6656. /**
  6657. * Gets the OBB (object bounding box) directions
  6658. */
  6659. readonly directions: Vector3[];
  6660. /**
  6661. * Gets the 8 vectors representing the bounding box in world space
  6662. */
  6663. readonly vectorsWorld: Vector3[];
  6664. /**
  6665. * Gets the minimum vector in world space
  6666. */
  6667. readonly minimumWorld: Vector3;
  6668. /**
  6669. * Gets the maximum vector in world space
  6670. */
  6671. readonly maximumWorld: Vector3;
  6672. /**
  6673. * Gets the minimum vector in local space
  6674. */
  6675. readonly minimum: Vector3;
  6676. /**
  6677. * Gets the maximum vector in local space
  6678. */
  6679. readonly maximum: Vector3;
  6680. private _worldMatrix;
  6681. private static readonly TmpVector3;
  6682. /**
  6683. * @hidden
  6684. */
  6685. _tag: number;
  6686. /**
  6687. * Creates a new bounding box
  6688. * @param min defines the minimum vector (in local space)
  6689. * @param max defines the maximum vector (in local space)
  6690. * @param worldMatrix defines the new world matrix
  6691. */
  6692. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6693. /**
  6694. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6695. * @param min defines the new minimum vector (in local space)
  6696. * @param max defines the new maximum vector (in local space)
  6697. * @param worldMatrix defines the new world matrix
  6698. */
  6699. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6700. /**
  6701. * Scale the current bounding box by applying a scale factor
  6702. * @param factor defines the scale factor to apply
  6703. * @returns the current bounding box
  6704. */
  6705. scale(factor: number): BoundingBox;
  6706. /**
  6707. * Gets the world matrix of the bounding box
  6708. * @returns a matrix
  6709. */
  6710. getWorldMatrix(): DeepImmutable<Matrix>;
  6711. /** @hidden */
  6712. _update(world: DeepImmutable<Matrix>): void;
  6713. /**
  6714. * Tests if the bounding box is intersecting the frustum planes
  6715. * @param frustumPlanes defines the frustum planes to test
  6716. * @returns true if there is an intersection
  6717. */
  6718. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6719. /**
  6720. * Tests if the bounding box is entirely inside the frustum planes
  6721. * @param frustumPlanes defines the frustum planes to test
  6722. * @returns true if there is an inclusion
  6723. */
  6724. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6725. /**
  6726. * Tests if a point is inside the bounding box
  6727. * @param point defines the point to test
  6728. * @returns true if the point is inside the bounding box
  6729. */
  6730. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6731. /**
  6732. * Tests if the bounding box intersects with a bounding sphere
  6733. * @param sphere defines the sphere to test
  6734. * @returns true if there is an intersection
  6735. */
  6736. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6737. /**
  6738. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6739. * @param min defines the min vector to use
  6740. * @param max defines the max vector to use
  6741. * @returns true if there is an intersection
  6742. */
  6743. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6744. /**
  6745. * Tests if two bounding boxes are intersections
  6746. * @param box0 defines the first box to test
  6747. * @param box1 defines the second box to test
  6748. * @returns true if there is an intersection
  6749. */
  6750. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6751. /**
  6752. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6753. * @param minPoint defines the minimum vector of the bounding box
  6754. * @param maxPoint defines the maximum vector of the bounding box
  6755. * @param sphereCenter defines the sphere center
  6756. * @param sphereRadius defines the sphere radius
  6757. * @returns true if there is an intersection
  6758. */
  6759. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6760. /**
  6761. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6762. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6763. * @param frustumPlanes defines the frustum planes to test
  6764. * @return true if there is an inclusion
  6765. */
  6766. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6767. /**
  6768. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6769. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6770. * @param frustumPlanes defines the frustum planes to test
  6771. * @return true if there is an intersection
  6772. */
  6773. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6774. }
  6775. }
  6776. declare module "babylonjs/Collisions/collider" {
  6777. import { Nullable, IndicesArray } from "babylonjs/types";
  6778. import { Vector3 } from "babylonjs/Maths/math.vector";
  6779. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6780. import { Plane } from "babylonjs/Maths/math.plane";
  6781. /** @hidden */
  6782. export class Collider {
  6783. /** Define if a collision was found */
  6784. collisionFound: boolean;
  6785. /**
  6786. * Define last intersection point in local space
  6787. */
  6788. intersectionPoint: Vector3;
  6789. /**
  6790. * Define last collided mesh
  6791. */
  6792. collidedMesh: Nullable<AbstractMesh>;
  6793. private _collisionPoint;
  6794. private _planeIntersectionPoint;
  6795. private _tempVector;
  6796. private _tempVector2;
  6797. private _tempVector3;
  6798. private _tempVector4;
  6799. private _edge;
  6800. private _baseToVertex;
  6801. private _destinationPoint;
  6802. private _slidePlaneNormal;
  6803. private _displacementVector;
  6804. /** @hidden */
  6805. _radius: Vector3;
  6806. /** @hidden */
  6807. _retry: number;
  6808. private _velocity;
  6809. private _basePoint;
  6810. private _epsilon;
  6811. /** @hidden */
  6812. _velocityWorldLength: number;
  6813. /** @hidden */
  6814. _basePointWorld: Vector3;
  6815. private _velocityWorld;
  6816. private _normalizedVelocity;
  6817. /** @hidden */
  6818. _initialVelocity: Vector3;
  6819. /** @hidden */
  6820. _initialPosition: Vector3;
  6821. private _nearestDistance;
  6822. private _collisionMask;
  6823. collisionMask: number;
  6824. /**
  6825. * Gets the plane normal used to compute the sliding response (in local space)
  6826. */
  6827. readonly slidePlaneNormal: Vector3;
  6828. /** @hidden */
  6829. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6830. /** @hidden */
  6831. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  6832. /** @hidden */
  6833. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  6834. /** @hidden */
  6835. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6836. /** @hidden */
  6837. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  6838. /** @hidden */
  6839. _getResponse(pos: Vector3, vel: Vector3): void;
  6840. }
  6841. }
  6842. declare module "babylonjs/Culling/boundingInfo" {
  6843. import { DeepImmutable } from "babylonjs/types";
  6844. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6845. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  6846. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6847. import { Plane } from "babylonjs/Maths/math.plane";
  6848. import { Collider } from "babylonjs/Collisions/collider";
  6849. /**
  6850. * Interface for cullable objects
  6851. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  6852. */
  6853. export interface ICullable {
  6854. /**
  6855. * Checks if the object or part of the object is in the frustum
  6856. * @param frustumPlanes Camera near/planes
  6857. * @returns true if the object is in frustum otherwise false
  6858. */
  6859. isInFrustum(frustumPlanes: Plane[]): boolean;
  6860. /**
  6861. * Checks if a cullable object (mesh...) is in the camera frustum
  6862. * Unlike isInFrustum this cheks the full bounding box
  6863. * @param frustumPlanes Camera near/planes
  6864. * @returns true if the object is in frustum otherwise false
  6865. */
  6866. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  6867. }
  6868. /**
  6869. * Info for a bounding data of a mesh
  6870. */
  6871. export class BoundingInfo implements ICullable {
  6872. /**
  6873. * Bounding box for the mesh
  6874. */
  6875. readonly boundingBox: BoundingBox;
  6876. /**
  6877. * Bounding sphere for the mesh
  6878. */
  6879. readonly boundingSphere: BoundingSphere;
  6880. private _isLocked;
  6881. private static readonly TmpVector3;
  6882. /**
  6883. * Constructs bounding info
  6884. * @param minimum min vector of the bounding box/sphere
  6885. * @param maximum max vector of the bounding box/sphere
  6886. * @param worldMatrix defines the new world matrix
  6887. */
  6888. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6889. /**
  6890. * Recreates the entire bounding info from scratch as if we call the constructor in place
  6891. * @param min defines the new minimum vector (in local space)
  6892. * @param max defines the new maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6896. /**
  6897. * min vector of the bounding box/sphere
  6898. */
  6899. readonly minimum: Vector3;
  6900. /**
  6901. * max vector of the bounding box/sphere
  6902. */
  6903. readonly maximum: Vector3;
  6904. /**
  6905. * If the info is locked and won't be updated to avoid perf overhead
  6906. */
  6907. isLocked: boolean;
  6908. /**
  6909. * Updates the bounding sphere and box
  6910. * @param world world matrix to be used to update
  6911. */
  6912. update(world: DeepImmutable<Matrix>): void;
  6913. /**
  6914. * Recreate the bounding info to be centered around a specific point given a specific extend.
  6915. * @param center New center of the bounding info
  6916. * @param extend New extend of the bounding info
  6917. * @returns the current bounding info
  6918. */
  6919. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  6920. /**
  6921. * Scale the current bounding info by applying a scale factor
  6922. * @param factor defines the scale factor to apply
  6923. * @returns the current bounding info
  6924. */
  6925. scale(factor: number): BoundingInfo;
  6926. /**
  6927. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  6928. * @param frustumPlanes defines the frustum to test
  6929. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  6930. * @returns true if the bounding info is in the frustum planes
  6931. */
  6932. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  6933. /**
  6934. * Gets the world distance between the min and max points of the bounding box
  6935. */
  6936. readonly diagonalLength: number;
  6937. /**
  6938. * Checks if a cullable object (mesh...) is in the camera frustum
  6939. * Unlike isInFrustum this cheks the full bounding box
  6940. * @param frustumPlanes Camera near/planes
  6941. * @returns true if the object is in frustum otherwise false
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /** @hidden */
  6945. _checkCollision(collider: Collider): boolean;
  6946. /**
  6947. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  6948. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6949. * @param point the point to check intersection with
  6950. * @returns if the point intersects
  6951. */
  6952. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6953. /**
  6954. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  6955. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  6956. * @param boundingInfo the bounding info to check intersection with
  6957. * @param precise if the intersection should be done using OBB
  6958. * @returns if the bounding info intersects
  6959. */
  6960. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  6961. }
  6962. }
  6963. declare module "babylonjs/Maths/math.functions" {
  6964. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  6965. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  6966. /**
  6967. * Extracts minimum and maximum values from a list of indexed positions
  6968. * @param positions defines the positions to use
  6969. * @param indices defines the indices to the positions
  6970. * @param indexStart defines the start index
  6971. * @param indexCount defines the end index
  6972. * @param bias defines bias value to add to the result
  6973. * @return minimum and maximum values
  6974. */
  6975. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  6976. minimum: Vector3;
  6977. maximum: Vector3;
  6978. };
  6979. /**
  6980. * Extracts minimum and maximum values from a list of positions
  6981. * @param positions defines the positions to use
  6982. * @param start defines the start index in the positions array
  6983. * @param count defines the number of positions to handle
  6984. * @param bias defines bias value to add to the result
  6985. * @param stride defines the stride size to use (distance between two positions in the positions array)
  6986. * @return minimum and maximum values
  6987. */
  6988. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  6989. minimum: Vector3;
  6990. maximum: Vector3;
  6991. };
  6992. }
  6993. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  6994. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6995. /** @hidden */
  6996. export class WebGLDataBuffer extends DataBuffer {
  6997. private _buffer;
  6998. constructor(resource: WebGLBuffer);
  6999. readonly underlyingResource: any;
  7000. }
  7001. }
  7002. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7003. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7004. import { Nullable } from "babylonjs/types";
  7005. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7006. /** @hidden */
  7007. export class WebGLPipelineContext implements IPipelineContext {
  7008. engine: ThinEngine;
  7009. program: Nullable<WebGLProgram>;
  7010. context?: WebGLRenderingContext;
  7011. vertexShader?: WebGLShader;
  7012. fragmentShader?: WebGLShader;
  7013. isParallelCompiled: boolean;
  7014. onCompiled?: () => void;
  7015. transformFeedback?: WebGLTransformFeedback | null;
  7016. readonly isAsync: boolean;
  7017. readonly isReady: boolean;
  7018. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7019. }
  7020. }
  7021. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7022. import { FloatArray, Nullable } from "babylonjs/types";
  7023. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7024. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7025. module "babylonjs/Engines/thinEngine" {
  7026. interface ThinEngine {
  7027. /**
  7028. * Create an uniform buffer
  7029. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7030. * @param elements defines the content of the uniform buffer
  7031. * @returns the webGL uniform buffer
  7032. */
  7033. createUniformBuffer(elements: FloatArray): DataBuffer;
  7034. /**
  7035. * Create a dynamic uniform buffer
  7036. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7037. * @param elements defines the content of the uniform buffer
  7038. * @returns the webGL uniform buffer
  7039. */
  7040. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7041. /**
  7042. * Update an existing uniform buffer
  7043. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7044. * @param uniformBuffer defines the target uniform buffer
  7045. * @param elements defines the content to update
  7046. * @param offset defines the offset in the uniform buffer where update should start
  7047. * @param count defines the size of the data to update
  7048. */
  7049. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7050. /**
  7051. * Bind an uniform buffer to the current webGL context
  7052. * @param buffer defines the buffer to bind
  7053. */
  7054. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7055. /**
  7056. * Bind a buffer to the current webGL context at a given location
  7057. * @param buffer defines the buffer to bind
  7058. * @param location defines the index where to bind the buffer
  7059. */
  7060. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7061. /**
  7062. * Bind a specific block at a given index in a specific shader program
  7063. * @param pipelineContext defines the pipeline context to use
  7064. * @param blockName defines the block name
  7065. * @param index defines the index where to bind the block
  7066. */
  7067. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7068. }
  7069. }
  7070. }
  7071. declare module "babylonjs/Materials/uniformBuffer" {
  7072. import { Nullable, FloatArray } from "babylonjs/types";
  7073. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7074. import { Engine } from "babylonjs/Engines/engine";
  7075. import { Effect } from "babylonjs/Materials/effect";
  7076. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7077. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7078. import { Color3 } from "babylonjs/Maths/math.color";
  7079. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7080. /**
  7081. * Uniform buffer objects.
  7082. *
  7083. * Handles blocks of uniform on the GPU.
  7084. *
  7085. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7086. *
  7087. * For more information, please refer to :
  7088. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7089. */
  7090. export class UniformBuffer {
  7091. private _engine;
  7092. private _buffer;
  7093. private _data;
  7094. private _bufferData;
  7095. private _dynamic?;
  7096. private _uniformLocations;
  7097. private _uniformSizes;
  7098. private _uniformLocationPointer;
  7099. private _needSync;
  7100. private _noUBO;
  7101. private _currentEffect;
  7102. private static _MAX_UNIFORM_SIZE;
  7103. private static _tempBuffer;
  7104. /**
  7105. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7106. * This is dynamic to allow compat with webgl 1 and 2.
  7107. * You will need to pass the name of the uniform as well as the value.
  7108. */
  7109. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7110. /**
  7111. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7112. * This is dynamic to allow compat with webgl 1 and 2.
  7113. * You will need to pass the name of the uniform as well as the value.
  7114. */
  7115. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7116. /**
  7117. * Lambda to Update a single float in a uniform buffer.
  7118. * This is dynamic to allow compat with webgl 1 and 2.
  7119. * You will need to pass the name of the uniform as well as the value.
  7120. */
  7121. updateFloat: (name: string, x: number) => void;
  7122. /**
  7123. * Lambda to Update a vec2 of float in a uniform buffer.
  7124. * This is dynamic to allow compat with webgl 1 and 2.
  7125. * You will need to pass the name of the uniform as well as the value.
  7126. */
  7127. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7128. /**
  7129. * Lambda to Update a vec3 of float in a uniform buffer.
  7130. * This is dynamic to allow compat with webgl 1 and 2.
  7131. * You will need to pass the name of the uniform as well as the value.
  7132. */
  7133. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7134. /**
  7135. * Lambda to Update a vec4 of float in a uniform buffer.
  7136. * This is dynamic to allow compat with webgl 1 and 2.
  7137. * You will need to pass the name of the uniform as well as the value.
  7138. */
  7139. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7140. /**
  7141. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7142. * This is dynamic to allow compat with webgl 1 and 2.
  7143. * You will need to pass the name of the uniform as well as the value.
  7144. */
  7145. updateMatrix: (name: string, mat: Matrix) => void;
  7146. /**
  7147. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7148. * This is dynamic to allow compat with webgl 1 and 2.
  7149. * You will need to pass the name of the uniform as well as the value.
  7150. */
  7151. updateVector3: (name: string, vector: Vector3) => void;
  7152. /**
  7153. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7154. * This is dynamic to allow compat with webgl 1 and 2.
  7155. * You will need to pass the name of the uniform as well as the value.
  7156. */
  7157. updateVector4: (name: string, vector: Vector4) => void;
  7158. /**
  7159. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7160. * This is dynamic to allow compat with webgl 1 and 2.
  7161. * You will need to pass the name of the uniform as well as the value.
  7162. */
  7163. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7164. /**
  7165. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7166. * This is dynamic to allow compat with webgl 1 and 2.
  7167. * You will need to pass the name of the uniform as well as the value.
  7168. */
  7169. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7170. /**
  7171. * Instantiates a new Uniform buffer objects.
  7172. *
  7173. * Handles blocks of uniform on the GPU.
  7174. *
  7175. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7176. *
  7177. * For more information, please refer to :
  7178. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7179. * @param engine Define the engine the buffer is associated with
  7180. * @param data Define the data contained in the buffer
  7181. * @param dynamic Define if the buffer is updatable
  7182. */
  7183. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7184. /**
  7185. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7186. * or just falling back on setUniformXXX calls.
  7187. */
  7188. readonly useUbo: boolean;
  7189. /**
  7190. * Indicates if the WebGL underlying uniform buffer is in sync
  7191. * with the javascript cache data.
  7192. */
  7193. readonly isSync: boolean;
  7194. /**
  7195. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7196. * Also, a dynamic UniformBuffer will disable cache verification and always
  7197. * update the underlying WebGL uniform buffer to the GPU.
  7198. * @returns if Dynamic, otherwise false
  7199. */
  7200. isDynamic(): boolean;
  7201. /**
  7202. * The data cache on JS side.
  7203. * @returns the underlying data as a float array
  7204. */
  7205. getData(): Float32Array;
  7206. /**
  7207. * The underlying WebGL Uniform buffer.
  7208. * @returns the webgl buffer
  7209. */
  7210. getBuffer(): Nullable<DataBuffer>;
  7211. /**
  7212. * std140 layout specifies how to align data within an UBO structure.
  7213. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7214. * for specs.
  7215. */
  7216. private _fillAlignment;
  7217. /**
  7218. * Adds an uniform in the buffer.
  7219. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7220. * for the layout to be correct !
  7221. * @param name Name of the uniform, as used in the uniform block in the shader.
  7222. * @param size Data size, or data directly.
  7223. */
  7224. addUniform(name: string, size: number | number[]): void;
  7225. /**
  7226. * Adds a Matrix 4x4 to the uniform buffer.
  7227. * @param name Name of the uniform, as used in the uniform block in the shader.
  7228. * @param mat A 4x4 matrix.
  7229. */
  7230. addMatrix(name: string, mat: Matrix): void;
  7231. /**
  7232. * Adds a vec2 to the uniform buffer.
  7233. * @param name Name of the uniform, as used in the uniform block in the shader.
  7234. * @param x Define the x component value of the vec2
  7235. * @param y Define the y component value of the vec2
  7236. */
  7237. addFloat2(name: string, x: number, y: number): void;
  7238. /**
  7239. * Adds a vec3 to the uniform buffer.
  7240. * @param name Name of the uniform, as used in the uniform block in the shader.
  7241. * @param x Define the x component value of the vec3
  7242. * @param y Define the y component value of the vec3
  7243. * @param z Define the z component value of the vec3
  7244. */
  7245. addFloat3(name: string, x: number, y: number, z: number): void;
  7246. /**
  7247. * Adds a vec3 to the uniform buffer.
  7248. * @param name Name of the uniform, as used in the uniform block in the shader.
  7249. * @param color Define the vec3 from a Color
  7250. */
  7251. addColor3(name: string, color: Color3): void;
  7252. /**
  7253. * Adds a vec4 to the uniform buffer.
  7254. * @param name Name of the uniform, as used in the uniform block in the shader.
  7255. * @param color Define the rgb components from a Color
  7256. * @param alpha Define the a component of the vec4
  7257. */
  7258. addColor4(name: string, color: Color3, alpha: number): void;
  7259. /**
  7260. * Adds a vec3 to the uniform buffer.
  7261. * @param name Name of the uniform, as used in the uniform block in the shader.
  7262. * @param vector Define the vec3 components from a Vector
  7263. */
  7264. addVector3(name: string, vector: Vector3): void;
  7265. /**
  7266. * Adds a Matrix 3x3 to the uniform buffer.
  7267. * @param name Name of the uniform, as used in the uniform block in the shader.
  7268. */
  7269. addMatrix3x3(name: string): void;
  7270. /**
  7271. * Adds a Matrix 2x2 to the uniform buffer.
  7272. * @param name Name of the uniform, as used in the uniform block in the shader.
  7273. */
  7274. addMatrix2x2(name: string): void;
  7275. /**
  7276. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7277. */
  7278. create(): void;
  7279. /** @hidden */
  7280. _rebuild(): void;
  7281. /**
  7282. * Updates the WebGL Uniform Buffer on the GPU.
  7283. * If the `dynamic` flag is set to true, no cache comparison is done.
  7284. * Otherwise, the buffer will be updated only if the cache differs.
  7285. */
  7286. update(): void;
  7287. /**
  7288. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7289. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7290. * @param data Define the flattened data
  7291. * @param size Define the size of the data.
  7292. */
  7293. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7294. private _valueCache;
  7295. private _cacheMatrix;
  7296. private _updateMatrix3x3ForUniform;
  7297. private _updateMatrix3x3ForEffect;
  7298. private _updateMatrix2x2ForEffect;
  7299. private _updateMatrix2x2ForUniform;
  7300. private _updateFloatForEffect;
  7301. private _updateFloatForUniform;
  7302. private _updateFloat2ForEffect;
  7303. private _updateFloat2ForUniform;
  7304. private _updateFloat3ForEffect;
  7305. private _updateFloat3ForUniform;
  7306. private _updateFloat4ForEffect;
  7307. private _updateFloat4ForUniform;
  7308. private _updateMatrixForEffect;
  7309. private _updateMatrixForUniform;
  7310. private _updateVector3ForEffect;
  7311. private _updateVector3ForUniform;
  7312. private _updateVector4ForEffect;
  7313. private _updateVector4ForUniform;
  7314. private _updateColor3ForEffect;
  7315. private _updateColor3ForUniform;
  7316. private _updateColor4ForEffect;
  7317. private _updateColor4ForUniform;
  7318. /**
  7319. * Sets a sampler uniform on the effect.
  7320. * @param name Define the name of the sampler.
  7321. * @param texture Define the texture to set in the sampler
  7322. */
  7323. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7324. /**
  7325. * Directly updates the value of the uniform in the cache AND on the GPU.
  7326. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7327. * @param data Define the flattened data
  7328. */
  7329. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7330. /**
  7331. * Binds this uniform buffer to an effect.
  7332. * @param effect Define the effect to bind the buffer to
  7333. * @param name Name of the uniform block in the shader.
  7334. */
  7335. bindToEffect(effect: Effect, name: string): void;
  7336. /**
  7337. * Disposes the uniform buffer.
  7338. */
  7339. dispose(): void;
  7340. }
  7341. }
  7342. declare module "babylonjs/Misc/iInspectable" {
  7343. /**
  7344. * Enum that determines the text-wrapping mode to use.
  7345. */
  7346. export enum InspectableType {
  7347. /**
  7348. * Checkbox for booleans
  7349. */
  7350. Checkbox = 0,
  7351. /**
  7352. * Sliders for numbers
  7353. */
  7354. Slider = 1,
  7355. /**
  7356. * Vector3
  7357. */
  7358. Vector3 = 2,
  7359. /**
  7360. * Quaternions
  7361. */
  7362. Quaternion = 3,
  7363. /**
  7364. * Color3
  7365. */
  7366. Color3 = 4,
  7367. /**
  7368. * String
  7369. */
  7370. String = 5
  7371. }
  7372. /**
  7373. * Interface used to define custom inspectable properties.
  7374. * This interface is used by the inspector to display custom property grids
  7375. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7376. */
  7377. export interface IInspectable {
  7378. /**
  7379. * Gets the label to display
  7380. */
  7381. label: string;
  7382. /**
  7383. * Gets the name of the property to edit
  7384. */
  7385. propertyName: string;
  7386. /**
  7387. * Gets the type of the editor to use
  7388. */
  7389. type: InspectableType;
  7390. /**
  7391. * Gets the minimum value of the property when using in "slider" mode
  7392. */
  7393. min?: number;
  7394. /**
  7395. * Gets the maximum value of the property when using in "slider" mode
  7396. */
  7397. max?: number;
  7398. /**
  7399. * Gets the setp to use when using in "slider" mode
  7400. */
  7401. step?: number;
  7402. }
  7403. }
  7404. declare module "babylonjs/Misc/timingTools" {
  7405. /**
  7406. * Class used to provide helper for timing
  7407. */
  7408. export class TimingTools {
  7409. /**
  7410. * Polyfill for setImmediate
  7411. * @param action defines the action to execute after the current execution block
  7412. */
  7413. static SetImmediate(action: () => void): void;
  7414. }
  7415. }
  7416. declare module "babylonjs/Misc/instantiationTools" {
  7417. /**
  7418. * Class used to enable instatition of objects by class name
  7419. */
  7420. export class InstantiationTools {
  7421. /**
  7422. * Use this object to register external classes like custom textures or material
  7423. * to allow the laoders to instantiate them
  7424. */
  7425. static RegisteredExternalClasses: {
  7426. [key: string]: Object;
  7427. };
  7428. /**
  7429. * Tries to instantiate a new object from a given class name
  7430. * @param className defines the class name to instantiate
  7431. * @returns the new object or null if the system was not able to do the instantiation
  7432. */
  7433. static Instantiate(className: string): any;
  7434. }
  7435. }
  7436. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7437. /**
  7438. * Define options used to create a depth texture
  7439. */
  7440. export class DepthTextureCreationOptions {
  7441. /** Specifies whether or not a stencil should be allocated in the texture */
  7442. generateStencil?: boolean;
  7443. /** Specifies whether or not bilinear filtering is enable on the texture */
  7444. bilinearFiltering?: boolean;
  7445. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7446. comparisonFunction?: number;
  7447. /** Specifies if the created texture is a cube texture */
  7448. isCube?: boolean;
  7449. }
  7450. }
  7451. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7452. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7453. import { Nullable } from "babylonjs/types";
  7454. import { Scene } from "babylonjs/scene";
  7455. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7456. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7457. module "babylonjs/Engines/thinEngine" {
  7458. interface ThinEngine {
  7459. /**
  7460. * Creates a depth stencil cube texture.
  7461. * This is only available in WebGL 2.
  7462. * @param size The size of face edge in the cube texture.
  7463. * @param options The options defining the cube texture.
  7464. * @returns The cube texture
  7465. */
  7466. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7467. /**
  7468. * Creates a cube texture
  7469. * @param rootUrl defines the url where the files to load is located
  7470. * @param scene defines the current scene
  7471. * @param files defines the list of files to load (1 per face)
  7472. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7473. * @param onLoad defines an optional callback raised when the texture is loaded
  7474. * @param onError defines an optional callback raised if there is an issue to load the texture
  7475. * @param format defines the format of the data
  7476. * @param forcedExtension defines the extension to use to pick the right loader
  7477. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7478. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7479. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7480. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7481. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7482. * @returns the cube texture as an InternalTexture
  7483. */
  7484. 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;
  7485. /**
  7486. * Creates a cube texture
  7487. * @param rootUrl defines the url where the files to load is located
  7488. * @param scene defines the current scene
  7489. * @param files defines the list of files to load (1 per face)
  7490. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7491. * @param onLoad defines an optional callback raised when the texture is loaded
  7492. * @param onError defines an optional callback raised if there is an issue to load the texture
  7493. * @param format defines the format of the data
  7494. * @param forcedExtension defines the extension to use to pick the right loader
  7495. * @returns the cube texture as an InternalTexture
  7496. */
  7497. 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;
  7498. /**
  7499. * Creates a cube texture
  7500. * @param rootUrl defines the url where the files to load is located
  7501. * @param scene defines the current scene
  7502. * @param files defines the list of files to load (1 per face)
  7503. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7504. * @param onLoad defines an optional callback raised when the texture is loaded
  7505. * @param onError defines an optional callback raised if there is an issue to load the texture
  7506. * @param format defines the format of the data
  7507. * @param forcedExtension defines the extension to use to pick the right loader
  7508. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7509. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7510. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7511. * @returns the cube texture as an InternalTexture
  7512. */
  7513. 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;
  7514. /** @hidden */
  7515. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7516. /** @hidden */
  7517. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7518. /** @hidden */
  7519. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7520. /** @hidden */
  7521. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7522. }
  7523. }
  7524. }
  7525. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7526. import { Nullable } from "babylonjs/types";
  7527. import { Scene } from "babylonjs/scene";
  7528. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7529. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7530. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7531. /**
  7532. * Class for creating a cube texture
  7533. */
  7534. export class CubeTexture extends BaseTexture {
  7535. private _delayedOnLoad;
  7536. /**
  7537. * The url of the texture
  7538. */
  7539. url: string;
  7540. /**
  7541. * Gets or sets the center of the bounding box associated with the cube texture.
  7542. * It must define where the camera used to render the texture was set
  7543. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7544. */
  7545. boundingBoxPosition: Vector3;
  7546. private _boundingBoxSize;
  7547. /**
  7548. * Gets or sets the size of the bounding box associated with the cube texture
  7549. * When defined, the cubemap will switch to local mode
  7550. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7551. * @example https://www.babylonjs-playground.com/#RNASML
  7552. */
  7553. /**
  7554. * Returns the bounding box size
  7555. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7556. */
  7557. boundingBoxSize: Vector3;
  7558. protected _rotationY: number;
  7559. /**
  7560. * Sets texture matrix rotation angle around Y axis in radians.
  7561. */
  7562. /**
  7563. * Gets texture matrix rotation angle around Y axis radians.
  7564. */
  7565. rotationY: number;
  7566. /**
  7567. * Are mip maps generated for this texture or not.
  7568. */
  7569. readonly noMipmap: boolean;
  7570. private _noMipmap;
  7571. private _files;
  7572. protected _forcedExtension: Nullable<string>;
  7573. private _extensions;
  7574. private _textureMatrix;
  7575. private _format;
  7576. private _createPolynomials;
  7577. /** @hidden */
  7578. _prefiltered: boolean;
  7579. /**
  7580. * Creates a cube texture from an array of image urls
  7581. * @param files defines an array of image urls
  7582. * @param scene defines the hosting scene
  7583. * @param noMipmap specifies if mip maps are not used
  7584. * @returns a cube texture
  7585. */
  7586. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7587. /**
  7588. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7589. * @param url defines the url of the prefiltered texture
  7590. * @param scene defines the scene the texture is attached to
  7591. * @param forcedExtension defines the extension of the file if different from the url
  7592. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7593. * @return the prefiltered texture
  7594. */
  7595. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7596. /**
  7597. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7598. * as prefiltered data.
  7599. * @param rootUrl defines the url of the texture or the root name of the six images
  7600. * @param scene defines the scene the texture is attached to
  7601. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7602. * @param noMipmap defines if mipmaps should be created or not
  7603. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7604. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7605. * @param onError defines a callback triggered in case of error during load
  7606. * @param format defines the internal format to use for the texture once loaded
  7607. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7608. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7609. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7610. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7611. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7612. * @return the cube texture
  7613. */
  7614. 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);
  7615. /**
  7616. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7617. */
  7618. readonly isPrefiltered: boolean;
  7619. /**
  7620. * Get the current class name of the texture useful for serialization or dynamic coding.
  7621. * @returns "CubeTexture"
  7622. */
  7623. getClassName(): string;
  7624. /**
  7625. * Update the url (and optional buffer) of this texture if url was null during construction.
  7626. * @param url the url of the texture
  7627. * @param forcedExtension defines the extension to use
  7628. * @param onLoad callback called when the texture is loaded (defaults to null)
  7629. */
  7630. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7631. /**
  7632. * Delays loading of the cube texture
  7633. * @param forcedExtension defines the extension to use
  7634. */
  7635. delayLoad(forcedExtension?: string): void;
  7636. /**
  7637. * Returns the reflection texture matrix
  7638. * @returns the reflection texture matrix
  7639. */
  7640. getReflectionTextureMatrix(): Matrix;
  7641. /**
  7642. * Sets the reflection texture matrix
  7643. * @param value Reflection texture matrix
  7644. */
  7645. setReflectionTextureMatrix(value: Matrix): void;
  7646. /**
  7647. * Parses text to create a cube texture
  7648. * @param parsedTexture define the serialized text to read from
  7649. * @param scene defines the hosting scene
  7650. * @param rootUrl defines the root url of the cube texture
  7651. * @returns a cube texture
  7652. */
  7653. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7654. /**
  7655. * Makes a clone, or deep copy, of the cube texture
  7656. * @returns a new cube texture
  7657. */
  7658. clone(): CubeTexture;
  7659. }
  7660. }
  7661. declare module "babylonjs/Materials/materialDefines" {
  7662. /**
  7663. * Manages the defines for the Material
  7664. */
  7665. export class MaterialDefines {
  7666. /** @hidden */
  7667. protected _keys: string[];
  7668. private _isDirty;
  7669. /** @hidden */
  7670. _renderId: number;
  7671. /** @hidden */
  7672. _areLightsDirty: boolean;
  7673. /** @hidden */
  7674. _areLightsDisposed: boolean;
  7675. /** @hidden */
  7676. _areAttributesDirty: boolean;
  7677. /** @hidden */
  7678. _areTexturesDirty: boolean;
  7679. /** @hidden */
  7680. _areFresnelDirty: boolean;
  7681. /** @hidden */
  7682. _areMiscDirty: boolean;
  7683. /** @hidden */
  7684. _areImageProcessingDirty: boolean;
  7685. /** @hidden */
  7686. _normals: boolean;
  7687. /** @hidden */
  7688. _uvs: boolean;
  7689. /** @hidden */
  7690. _needNormals: boolean;
  7691. /** @hidden */
  7692. _needUVs: boolean;
  7693. [id: string]: any;
  7694. /**
  7695. * Specifies if the material needs to be re-calculated
  7696. */
  7697. readonly isDirty: boolean;
  7698. /**
  7699. * Marks the material to indicate that it has been re-calculated
  7700. */
  7701. markAsProcessed(): void;
  7702. /**
  7703. * Marks the material to indicate that it needs to be re-calculated
  7704. */
  7705. markAsUnprocessed(): void;
  7706. /**
  7707. * Marks the material to indicate all of its defines need to be re-calculated
  7708. */
  7709. markAllAsDirty(): void;
  7710. /**
  7711. * Marks the material to indicate that image processing needs to be re-calculated
  7712. */
  7713. markAsImageProcessingDirty(): void;
  7714. /**
  7715. * Marks the material to indicate the lights need to be re-calculated
  7716. * @param disposed Defines whether the light is dirty due to dispose or not
  7717. */
  7718. markAsLightDirty(disposed?: boolean): void;
  7719. /**
  7720. * Marks the attribute state as changed
  7721. */
  7722. markAsAttributesDirty(): void;
  7723. /**
  7724. * Marks the texture state as changed
  7725. */
  7726. markAsTexturesDirty(): void;
  7727. /**
  7728. * Marks the fresnel state as changed
  7729. */
  7730. markAsFresnelDirty(): void;
  7731. /**
  7732. * Marks the misc state as changed
  7733. */
  7734. markAsMiscDirty(): void;
  7735. /**
  7736. * Rebuilds the material defines
  7737. */
  7738. rebuild(): void;
  7739. /**
  7740. * Specifies if two material defines are equal
  7741. * @param other - A material define instance to compare to
  7742. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7743. */
  7744. isEqual(other: MaterialDefines): boolean;
  7745. /**
  7746. * Clones this instance's defines to another instance
  7747. * @param other - material defines to clone values to
  7748. */
  7749. cloneTo(other: MaterialDefines): void;
  7750. /**
  7751. * Resets the material define values
  7752. */
  7753. reset(): void;
  7754. /**
  7755. * Converts the material define values to a string
  7756. * @returns - String of material define information
  7757. */
  7758. toString(): string;
  7759. }
  7760. }
  7761. declare module "babylonjs/Materials/colorCurves" {
  7762. import { Effect } from "babylonjs/Materials/effect";
  7763. /**
  7764. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7765. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7766. * 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;
  7767. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7768. */
  7769. export class ColorCurves {
  7770. private _dirty;
  7771. private _tempColor;
  7772. private _globalCurve;
  7773. private _highlightsCurve;
  7774. private _midtonesCurve;
  7775. private _shadowsCurve;
  7776. private _positiveCurve;
  7777. private _negativeCurve;
  7778. private _globalHue;
  7779. private _globalDensity;
  7780. private _globalSaturation;
  7781. private _globalExposure;
  7782. /**
  7783. * Gets the global Hue value.
  7784. * 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).
  7785. */
  7786. /**
  7787. * Sets the global Hue value.
  7788. * 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).
  7789. */
  7790. globalHue: number;
  7791. /**
  7792. * Gets the global Density value.
  7793. * 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.
  7794. * Values less than zero provide a filter of opposite hue.
  7795. */
  7796. /**
  7797. * Sets the global Density value.
  7798. * 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.
  7799. * Values less than zero provide a filter of opposite hue.
  7800. */
  7801. globalDensity: number;
  7802. /**
  7803. * Gets the global Saturation value.
  7804. * 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.
  7805. */
  7806. /**
  7807. * Sets the global Saturation value.
  7808. * 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.
  7809. */
  7810. globalSaturation: number;
  7811. /**
  7812. * Gets the global Exposure value.
  7813. * 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.
  7814. */
  7815. /**
  7816. * Sets the global Exposure value.
  7817. * 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.
  7818. */
  7819. globalExposure: number;
  7820. private _highlightsHue;
  7821. private _highlightsDensity;
  7822. private _highlightsSaturation;
  7823. private _highlightsExposure;
  7824. /**
  7825. * Gets the highlights Hue value.
  7826. * 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).
  7827. */
  7828. /**
  7829. * Sets the highlights Hue value.
  7830. * 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).
  7831. */
  7832. highlightsHue: number;
  7833. /**
  7834. * Gets the highlights Density value.
  7835. * 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.
  7836. * Values less than zero provide a filter of opposite hue.
  7837. */
  7838. /**
  7839. * Sets the highlights Density value.
  7840. * 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.
  7841. * Values less than zero provide a filter of opposite hue.
  7842. */
  7843. highlightsDensity: number;
  7844. /**
  7845. * Gets the highlights Saturation value.
  7846. * 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.
  7847. */
  7848. /**
  7849. * Sets the highlights Saturation value.
  7850. * 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.
  7851. */
  7852. highlightsSaturation: number;
  7853. /**
  7854. * Gets the highlights Exposure value.
  7855. * 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.
  7856. */
  7857. /**
  7858. * Sets the highlights Exposure value.
  7859. * 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.
  7860. */
  7861. highlightsExposure: number;
  7862. private _midtonesHue;
  7863. private _midtonesDensity;
  7864. private _midtonesSaturation;
  7865. private _midtonesExposure;
  7866. /**
  7867. * Gets the midtones Hue value.
  7868. * 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).
  7869. */
  7870. /**
  7871. * Sets the midtones Hue value.
  7872. * 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).
  7873. */
  7874. midtonesHue: number;
  7875. /**
  7876. * Gets the midtones Density value.
  7877. * 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.
  7878. * Values less than zero provide a filter of opposite hue.
  7879. */
  7880. /**
  7881. * Sets the midtones Density value.
  7882. * 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.
  7883. * Values less than zero provide a filter of opposite hue.
  7884. */
  7885. midtonesDensity: number;
  7886. /**
  7887. * Gets the midtones Saturation value.
  7888. * 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.
  7889. */
  7890. /**
  7891. * Sets the midtones Saturation value.
  7892. * 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.
  7893. */
  7894. midtonesSaturation: number;
  7895. /**
  7896. * Gets the midtones Exposure value.
  7897. * 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.
  7898. */
  7899. /**
  7900. * Sets the midtones Exposure value.
  7901. * 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.
  7902. */
  7903. midtonesExposure: number;
  7904. private _shadowsHue;
  7905. private _shadowsDensity;
  7906. private _shadowsSaturation;
  7907. private _shadowsExposure;
  7908. /**
  7909. * Gets the shadows Hue value.
  7910. * 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).
  7911. */
  7912. /**
  7913. * Sets the shadows Hue value.
  7914. * 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).
  7915. */
  7916. shadowsHue: number;
  7917. /**
  7918. * Gets the shadows Density value.
  7919. * 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.
  7920. * Values less than zero provide a filter of opposite hue.
  7921. */
  7922. /**
  7923. * Sets the shadows Density value.
  7924. * 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.
  7925. * Values less than zero provide a filter of opposite hue.
  7926. */
  7927. shadowsDensity: number;
  7928. /**
  7929. * Gets the shadows Saturation value.
  7930. * 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.
  7931. */
  7932. /**
  7933. * Sets the shadows Saturation value.
  7934. * 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.
  7935. */
  7936. shadowsSaturation: number;
  7937. /**
  7938. * Gets the shadows Exposure value.
  7939. * 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.
  7940. */
  7941. /**
  7942. * Sets the shadows Exposure value.
  7943. * 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.
  7944. */
  7945. shadowsExposure: number;
  7946. /**
  7947. * Returns the class name
  7948. * @returns The class name
  7949. */
  7950. getClassName(): string;
  7951. /**
  7952. * Binds the color curves to the shader.
  7953. * @param colorCurves The color curve to bind
  7954. * @param effect The effect to bind to
  7955. * @param positiveUniform The positive uniform shader parameter
  7956. * @param neutralUniform The neutral uniform shader parameter
  7957. * @param negativeUniform The negative uniform shader parameter
  7958. */
  7959. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7960. /**
  7961. * Prepare the list of uniforms associated with the ColorCurves effects.
  7962. * @param uniformsList The list of uniforms used in the effect
  7963. */
  7964. static PrepareUniforms(uniformsList: string[]): void;
  7965. /**
  7966. * Returns color grading data based on a hue, density, saturation and exposure value.
  7967. * @param filterHue The hue of the color filter.
  7968. * @param filterDensity The density of the color filter.
  7969. * @param saturation The saturation.
  7970. * @param exposure The exposure.
  7971. * @param result The result data container.
  7972. */
  7973. private getColorGradingDataToRef;
  7974. /**
  7975. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7976. * @param value The input slider value in range [-100,100].
  7977. * @returns Adjusted value.
  7978. */
  7979. private static applyColorGradingSliderNonlinear;
  7980. /**
  7981. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7982. * @param hue The hue (H) input.
  7983. * @param saturation The saturation (S) input.
  7984. * @param brightness The brightness (B) input.
  7985. * @result An RGBA color represented as Vector4.
  7986. */
  7987. private static fromHSBToRef;
  7988. /**
  7989. * Returns a value clamped between min and max
  7990. * @param value The value to clamp
  7991. * @param min The minimum of value
  7992. * @param max The maximum of value
  7993. * @returns The clamped value.
  7994. */
  7995. private static clamp;
  7996. /**
  7997. * Clones the current color curve instance.
  7998. * @return The cloned curves
  7999. */
  8000. clone(): ColorCurves;
  8001. /**
  8002. * Serializes the current color curve instance to a json representation.
  8003. * @return a JSON representation
  8004. */
  8005. serialize(): any;
  8006. /**
  8007. * Parses the color curve from a json representation.
  8008. * @param source the JSON source to parse
  8009. * @return The parsed curves
  8010. */
  8011. static Parse(source: any): ColorCurves;
  8012. }
  8013. }
  8014. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8015. import { Observable } from "babylonjs/Misc/observable";
  8016. import { Nullable } from "babylonjs/types";
  8017. import { Color4 } from "babylonjs/Maths/math.color";
  8018. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8019. import { Effect } from "babylonjs/Materials/effect";
  8020. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8021. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8022. /**
  8023. * Interface to follow in your material defines to integrate easily the
  8024. * Image proccessing functions.
  8025. * @hidden
  8026. */
  8027. export interface IImageProcessingConfigurationDefines {
  8028. IMAGEPROCESSING: boolean;
  8029. VIGNETTE: boolean;
  8030. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8031. VIGNETTEBLENDMODEOPAQUE: boolean;
  8032. TONEMAPPING: boolean;
  8033. TONEMAPPING_ACES: boolean;
  8034. CONTRAST: boolean;
  8035. EXPOSURE: boolean;
  8036. COLORCURVES: boolean;
  8037. COLORGRADING: boolean;
  8038. COLORGRADING3D: boolean;
  8039. SAMPLER3DGREENDEPTH: boolean;
  8040. SAMPLER3DBGRMAP: boolean;
  8041. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8042. }
  8043. /**
  8044. * @hidden
  8045. */
  8046. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8047. IMAGEPROCESSING: boolean;
  8048. VIGNETTE: boolean;
  8049. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8050. VIGNETTEBLENDMODEOPAQUE: boolean;
  8051. TONEMAPPING: boolean;
  8052. TONEMAPPING_ACES: boolean;
  8053. CONTRAST: boolean;
  8054. COLORCURVES: boolean;
  8055. COLORGRADING: boolean;
  8056. COLORGRADING3D: boolean;
  8057. SAMPLER3DGREENDEPTH: boolean;
  8058. SAMPLER3DBGRMAP: boolean;
  8059. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8060. EXPOSURE: boolean;
  8061. constructor();
  8062. }
  8063. /**
  8064. * This groups together the common properties used for image processing either in direct forward pass
  8065. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8066. * or not.
  8067. */
  8068. export class ImageProcessingConfiguration {
  8069. /**
  8070. * Default tone mapping applied in BabylonJS.
  8071. */
  8072. static readonly TONEMAPPING_STANDARD: number;
  8073. /**
  8074. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8075. * to other engines rendering to increase portability.
  8076. */
  8077. static readonly TONEMAPPING_ACES: number;
  8078. /**
  8079. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8080. */
  8081. colorCurves: Nullable<ColorCurves>;
  8082. private _colorCurvesEnabled;
  8083. /**
  8084. * Gets wether the color curves effect is enabled.
  8085. */
  8086. /**
  8087. * Sets wether the color curves effect is enabled.
  8088. */
  8089. colorCurvesEnabled: boolean;
  8090. private _colorGradingTexture;
  8091. /**
  8092. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8093. */
  8094. /**
  8095. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8096. */
  8097. colorGradingTexture: Nullable<BaseTexture>;
  8098. private _colorGradingEnabled;
  8099. /**
  8100. * Gets wether the color grading effect is enabled.
  8101. */
  8102. /**
  8103. * Sets wether the color grading effect is enabled.
  8104. */
  8105. colorGradingEnabled: boolean;
  8106. private _colorGradingWithGreenDepth;
  8107. /**
  8108. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8109. */
  8110. /**
  8111. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8112. */
  8113. colorGradingWithGreenDepth: boolean;
  8114. private _colorGradingBGR;
  8115. /**
  8116. * Gets wether the color grading texture contains BGR values.
  8117. */
  8118. /**
  8119. * Sets wether the color grading texture contains BGR values.
  8120. */
  8121. colorGradingBGR: boolean;
  8122. /** @hidden */
  8123. _exposure: number;
  8124. /**
  8125. * Gets the Exposure used in the effect.
  8126. */
  8127. /**
  8128. * Sets the Exposure used in the effect.
  8129. */
  8130. exposure: number;
  8131. private _toneMappingEnabled;
  8132. /**
  8133. * Gets wether the tone mapping effect is enabled.
  8134. */
  8135. /**
  8136. * Sets wether the tone mapping effect is enabled.
  8137. */
  8138. toneMappingEnabled: boolean;
  8139. private _toneMappingType;
  8140. /**
  8141. * Gets the type of tone mapping effect.
  8142. */
  8143. /**
  8144. * Sets the type of tone mapping effect used in BabylonJS.
  8145. */
  8146. toneMappingType: number;
  8147. protected _contrast: number;
  8148. /**
  8149. * Gets the contrast used in the effect.
  8150. */
  8151. /**
  8152. * Sets the contrast used in the effect.
  8153. */
  8154. contrast: number;
  8155. /**
  8156. * Vignette stretch size.
  8157. */
  8158. vignetteStretch: number;
  8159. /**
  8160. * Vignette centre X Offset.
  8161. */
  8162. vignetteCentreX: number;
  8163. /**
  8164. * Vignette centre Y Offset.
  8165. */
  8166. vignetteCentreY: number;
  8167. /**
  8168. * Vignette weight or intensity of the vignette effect.
  8169. */
  8170. vignetteWeight: number;
  8171. /**
  8172. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8173. * if vignetteEnabled is set to true.
  8174. */
  8175. vignetteColor: Color4;
  8176. /**
  8177. * Camera field of view used by the Vignette effect.
  8178. */
  8179. vignetteCameraFov: number;
  8180. private _vignetteBlendMode;
  8181. /**
  8182. * Gets the vignette blend mode allowing different kind of effect.
  8183. */
  8184. /**
  8185. * Sets the vignette blend mode allowing different kind of effect.
  8186. */
  8187. vignetteBlendMode: number;
  8188. private _vignetteEnabled;
  8189. /**
  8190. * Gets wether the vignette effect is enabled.
  8191. */
  8192. /**
  8193. * Sets wether the vignette effect is enabled.
  8194. */
  8195. vignetteEnabled: boolean;
  8196. private _applyByPostProcess;
  8197. /**
  8198. * Gets wether the image processing is applied through a post process or not.
  8199. */
  8200. /**
  8201. * Sets wether the image processing is applied through a post process or not.
  8202. */
  8203. applyByPostProcess: boolean;
  8204. private _isEnabled;
  8205. /**
  8206. * Gets wether the image processing is enabled or not.
  8207. */
  8208. /**
  8209. * Sets wether the image processing is enabled or not.
  8210. */
  8211. isEnabled: boolean;
  8212. /**
  8213. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8214. */
  8215. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8216. /**
  8217. * Method called each time the image processing information changes requires to recompile the effect.
  8218. */
  8219. protected _updateParameters(): void;
  8220. /**
  8221. * Gets the current class name.
  8222. * @return "ImageProcessingConfiguration"
  8223. */
  8224. getClassName(): string;
  8225. /**
  8226. * Prepare the list of uniforms associated with the Image Processing effects.
  8227. * @param uniforms The list of uniforms used in the effect
  8228. * @param defines the list of defines currently in use
  8229. */
  8230. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8231. /**
  8232. * Prepare the list of samplers associated with the Image Processing effects.
  8233. * @param samplersList The list of uniforms used in the effect
  8234. * @param defines the list of defines currently in use
  8235. */
  8236. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8237. /**
  8238. * Prepare the list of defines associated to the shader.
  8239. * @param defines the list of defines to complete
  8240. * @param forPostProcess Define if we are currently in post process mode or not
  8241. */
  8242. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8243. /**
  8244. * Returns true if all the image processing information are ready.
  8245. * @returns True if ready, otherwise, false
  8246. */
  8247. isReady(): boolean;
  8248. /**
  8249. * Binds the image processing to the shader.
  8250. * @param effect The effect to bind to
  8251. * @param aspectRatio Define the current aspect ratio of the effect
  8252. */
  8253. bind(effect: Effect, aspectRatio?: number): void;
  8254. /**
  8255. * Clones the current image processing instance.
  8256. * @return The cloned image processing
  8257. */
  8258. clone(): ImageProcessingConfiguration;
  8259. /**
  8260. * Serializes the current image processing instance to a json representation.
  8261. * @return a JSON representation
  8262. */
  8263. serialize(): any;
  8264. /**
  8265. * Parses the image processing from a json representation.
  8266. * @param source the JSON source to parse
  8267. * @return The parsed image processing
  8268. */
  8269. static Parse(source: any): ImageProcessingConfiguration;
  8270. private static _VIGNETTEMODE_MULTIPLY;
  8271. private static _VIGNETTEMODE_OPAQUE;
  8272. /**
  8273. * Used to apply the vignette as a mix with the pixel color.
  8274. */
  8275. static readonly VIGNETTEMODE_MULTIPLY: number;
  8276. /**
  8277. * Used to apply the vignette as a replacement of the pixel color.
  8278. */
  8279. static readonly VIGNETTEMODE_OPAQUE: number;
  8280. }
  8281. }
  8282. declare module "babylonjs/Shaders/postprocess.vertex" {
  8283. /** @hidden */
  8284. export var postprocessVertexShader: {
  8285. name: string;
  8286. shader: string;
  8287. };
  8288. }
  8289. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8290. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8291. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8292. module "babylonjs/Engines/thinEngine" {
  8293. interface ThinEngine {
  8294. /**
  8295. * Creates a new render target texture
  8296. * @param size defines the size of the texture
  8297. * @param options defines the options used to create the texture
  8298. * @returns a new render target texture stored in an InternalTexture
  8299. */
  8300. createRenderTargetTexture(size: number | {
  8301. width: number;
  8302. height: number;
  8303. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8304. }
  8305. }
  8306. }
  8307. declare module "babylonjs/Maths/math.axis" {
  8308. import { Vector3 } from "babylonjs/Maths/math.vector";
  8309. /** Defines supported spaces */
  8310. export enum Space {
  8311. /** Local (object) space */
  8312. LOCAL = 0,
  8313. /** World space */
  8314. WORLD = 1,
  8315. /** Bone space */
  8316. BONE = 2
  8317. }
  8318. /** Defines the 3 main axes */
  8319. export class Axis {
  8320. /** X axis */
  8321. static X: Vector3;
  8322. /** Y axis */
  8323. static Y: Vector3;
  8324. /** Z axis */
  8325. static Z: Vector3;
  8326. }
  8327. }
  8328. declare module "babylonjs/Cameras/targetCamera" {
  8329. import { Nullable } from "babylonjs/types";
  8330. import { Camera } from "babylonjs/Cameras/camera";
  8331. import { Scene } from "babylonjs/scene";
  8332. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8333. /**
  8334. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8335. * This is the base of the follow, arc rotate cameras and Free camera
  8336. * @see http://doc.babylonjs.com/features/cameras
  8337. */
  8338. export class TargetCamera extends Camera {
  8339. private static _RigCamTransformMatrix;
  8340. private static _TargetTransformMatrix;
  8341. private static _TargetFocalPoint;
  8342. /**
  8343. * Define the current direction the camera is moving to
  8344. */
  8345. cameraDirection: Vector3;
  8346. /**
  8347. * Define the current rotation the camera is rotating to
  8348. */
  8349. cameraRotation: Vector2;
  8350. /**
  8351. * When set, the up vector of the camera will be updated by the rotation of the camera
  8352. */
  8353. updateUpVectorFromRotation: boolean;
  8354. private _tmpQuaternion;
  8355. /**
  8356. * Define the current rotation of the camera
  8357. */
  8358. rotation: Vector3;
  8359. /**
  8360. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8361. */
  8362. rotationQuaternion: Quaternion;
  8363. /**
  8364. * Define the current speed of the camera
  8365. */
  8366. speed: number;
  8367. /**
  8368. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8369. * around all axis.
  8370. */
  8371. noRotationConstraint: boolean;
  8372. /**
  8373. * Define the current target of the camera as an object or a position.
  8374. */
  8375. lockedTarget: any;
  8376. /** @hidden */
  8377. _currentTarget: Vector3;
  8378. /** @hidden */
  8379. _initialFocalDistance: number;
  8380. /** @hidden */
  8381. _viewMatrix: Matrix;
  8382. /** @hidden */
  8383. _camMatrix: Matrix;
  8384. /** @hidden */
  8385. _cameraTransformMatrix: Matrix;
  8386. /** @hidden */
  8387. _cameraRotationMatrix: Matrix;
  8388. /** @hidden */
  8389. _referencePoint: Vector3;
  8390. /** @hidden */
  8391. _transformedReferencePoint: Vector3;
  8392. protected _globalCurrentTarget: Vector3;
  8393. protected _globalCurrentUpVector: Vector3;
  8394. /** @hidden */
  8395. _reset: () => void;
  8396. private _defaultUp;
  8397. /**
  8398. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8399. * This is the base of the follow, arc rotate cameras and Free camera
  8400. * @see http://doc.babylonjs.com/features/cameras
  8401. * @param name Defines the name of the camera in the scene
  8402. * @param position Defines the start position of the camera in the scene
  8403. * @param scene Defines the scene the camera belongs to
  8404. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8405. */
  8406. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8407. /**
  8408. * Gets the position in front of the camera at a given distance.
  8409. * @param distance The distance from the camera we want the position to be
  8410. * @returns the position
  8411. */
  8412. getFrontPosition(distance: number): Vector3;
  8413. /** @hidden */
  8414. _getLockedTargetPosition(): Nullable<Vector3>;
  8415. private _storedPosition;
  8416. private _storedRotation;
  8417. private _storedRotationQuaternion;
  8418. /**
  8419. * Store current camera state of the camera (fov, position, rotation, etc..)
  8420. * @returns the camera
  8421. */
  8422. storeState(): Camera;
  8423. /**
  8424. * Restored camera state. You must call storeState() first
  8425. * @returns whether it was successful or not
  8426. * @hidden
  8427. */
  8428. _restoreStateValues(): boolean;
  8429. /** @hidden */
  8430. _initCache(): void;
  8431. /** @hidden */
  8432. _updateCache(ignoreParentClass?: boolean): void;
  8433. /** @hidden */
  8434. _isSynchronizedViewMatrix(): boolean;
  8435. /** @hidden */
  8436. _computeLocalCameraSpeed(): number;
  8437. /**
  8438. * Defines the target the camera should look at.
  8439. * @param target Defines the new target as a Vector or a mesh
  8440. */
  8441. setTarget(target: Vector3): void;
  8442. /**
  8443. * Return the current target position of the camera. This value is expressed in local space.
  8444. * @returns the target position
  8445. */
  8446. getTarget(): Vector3;
  8447. /** @hidden */
  8448. _decideIfNeedsToMove(): boolean;
  8449. /** @hidden */
  8450. _updatePosition(): void;
  8451. /** @hidden */
  8452. _checkInputs(): void;
  8453. protected _updateCameraRotationMatrix(): void;
  8454. /**
  8455. * 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)
  8456. * @returns the current camera
  8457. */
  8458. private _rotateUpVectorWithCameraRotationMatrix;
  8459. private _cachedRotationZ;
  8460. private _cachedQuaternionRotationZ;
  8461. /** @hidden */
  8462. _getViewMatrix(): Matrix;
  8463. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8464. /**
  8465. * @hidden
  8466. */
  8467. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8468. /**
  8469. * @hidden
  8470. */
  8471. _updateRigCameras(): void;
  8472. private _getRigCamPositionAndTarget;
  8473. /**
  8474. * Gets the current object class name.
  8475. * @return the class name
  8476. */
  8477. getClassName(): string;
  8478. }
  8479. }
  8480. declare module "babylonjs/Events/keyboardEvents" {
  8481. /**
  8482. * Gather the list of keyboard event types as constants.
  8483. */
  8484. export class KeyboardEventTypes {
  8485. /**
  8486. * The keydown event is fired when a key becomes active (pressed).
  8487. */
  8488. static readonly KEYDOWN: number;
  8489. /**
  8490. * The keyup event is fired when a key has been released.
  8491. */
  8492. static readonly KEYUP: number;
  8493. }
  8494. /**
  8495. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8496. */
  8497. export class KeyboardInfo {
  8498. /**
  8499. * Defines the type of event (KeyboardEventTypes)
  8500. */
  8501. type: number;
  8502. /**
  8503. * Defines the related dom event
  8504. */
  8505. event: KeyboardEvent;
  8506. /**
  8507. * Instantiates a new keyboard info.
  8508. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8509. * @param type Defines the type of event (KeyboardEventTypes)
  8510. * @param event Defines the related dom event
  8511. */
  8512. constructor(
  8513. /**
  8514. * Defines the type of event (KeyboardEventTypes)
  8515. */
  8516. type: number,
  8517. /**
  8518. * Defines the related dom event
  8519. */
  8520. event: KeyboardEvent);
  8521. }
  8522. /**
  8523. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8524. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8525. */
  8526. export class KeyboardInfoPre extends KeyboardInfo {
  8527. /**
  8528. * Defines the type of event (KeyboardEventTypes)
  8529. */
  8530. type: number;
  8531. /**
  8532. * Defines the related dom event
  8533. */
  8534. event: KeyboardEvent;
  8535. /**
  8536. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8537. */
  8538. skipOnPointerObservable: boolean;
  8539. /**
  8540. * Instantiates a new keyboard pre info.
  8541. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8542. * @param type Defines the type of event (KeyboardEventTypes)
  8543. * @param event Defines the related dom event
  8544. */
  8545. constructor(
  8546. /**
  8547. * Defines the type of event (KeyboardEventTypes)
  8548. */
  8549. type: number,
  8550. /**
  8551. * Defines the related dom event
  8552. */
  8553. event: KeyboardEvent);
  8554. }
  8555. }
  8556. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8557. import { Nullable } from "babylonjs/types";
  8558. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8559. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8560. /**
  8561. * Manage the keyboard inputs to control the movement of a free camera.
  8562. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8563. */
  8564. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8565. /**
  8566. * Defines the camera the input is attached to.
  8567. */
  8568. camera: FreeCamera;
  8569. /**
  8570. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8571. */
  8572. keysUp: number[];
  8573. /**
  8574. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8575. */
  8576. keysDown: number[];
  8577. /**
  8578. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8579. */
  8580. keysLeft: number[];
  8581. /**
  8582. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8583. */
  8584. keysRight: number[];
  8585. private _keys;
  8586. private _onCanvasBlurObserver;
  8587. private _onKeyboardObserver;
  8588. private _engine;
  8589. private _scene;
  8590. /**
  8591. * Attach the input controls to a specific dom element to get the input from.
  8592. * @param element Defines the element the controls should be listened from
  8593. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8594. */
  8595. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8596. /**
  8597. * Detach the current controls from the specified dom element.
  8598. * @param element Defines the element to stop listening the inputs from
  8599. */
  8600. detachControl(element: Nullable<HTMLElement>): void;
  8601. /**
  8602. * Update the current camera state depending on the inputs that have been used this frame.
  8603. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8604. */
  8605. checkInputs(): void;
  8606. /**
  8607. * Gets the class name of the current intput.
  8608. * @returns the class name
  8609. */
  8610. getClassName(): string;
  8611. /** @hidden */
  8612. _onLostFocus(): void;
  8613. /**
  8614. * Get the friendly name associated with the input class.
  8615. * @returns the input friendly name
  8616. */
  8617. getSimpleName(): string;
  8618. }
  8619. }
  8620. declare module "babylonjs/Lights/shadowLight" {
  8621. import { Camera } from "babylonjs/Cameras/camera";
  8622. import { Scene } from "babylonjs/scene";
  8623. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8625. import { Light } from "babylonjs/Lights/light";
  8626. /**
  8627. * Interface describing all the common properties and methods a shadow light needs to implement.
  8628. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8629. * as well as binding the different shadow properties to the effects.
  8630. */
  8631. export interface IShadowLight extends Light {
  8632. /**
  8633. * The light id in the scene (used in scene.findLighById for instance)
  8634. */
  8635. id: string;
  8636. /**
  8637. * The position the shdow will be casted from.
  8638. */
  8639. position: Vector3;
  8640. /**
  8641. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8642. */
  8643. direction: Vector3;
  8644. /**
  8645. * The transformed position. Position of the light in world space taking parenting in account.
  8646. */
  8647. transformedPosition: Vector3;
  8648. /**
  8649. * The transformed direction. Direction of the light in world space taking parenting in account.
  8650. */
  8651. transformedDirection: Vector3;
  8652. /**
  8653. * The friendly name of the light in the scene.
  8654. */
  8655. name: string;
  8656. /**
  8657. * Defines the shadow projection clipping minimum z value.
  8658. */
  8659. shadowMinZ: number;
  8660. /**
  8661. * Defines the shadow projection clipping maximum z value.
  8662. */
  8663. shadowMaxZ: number;
  8664. /**
  8665. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8666. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8667. */
  8668. computeTransformedInformation(): boolean;
  8669. /**
  8670. * Gets the scene the light belongs to.
  8671. * @returns The scene
  8672. */
  8673. getScene(): Scene;
  8674. /**
  8675. * Callback defining a custom Projection Matrix Builder.
  8676. * This can be used to override the default projection matrix computation.
  8677. */
  8678. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8679. /**
  8680. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8681. * @param matrix The materix to updated with the projection information
  8682. * @param viewMatrix The transform matrix of the light
  8683. * @param renderList The list of mesh to render in the map
  8684. * @returns The current light
  8685. */
  8686. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8687. /**
  8688. * Gets the current depth scale used in ESM.
  8689. * @returns The scale
  8690. */
  8691. getDepthScale(): number;
  8692. /**
  8693. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8694. * @returns true if a cube texture needs to be use
  8695. */
  8696. needCube(): boolean;
  8697. /**
  8698. * Detects if the projection matrix requires to be recomputed this frame.
  8699. * @returns true if it requires to be recomputed otherwise, false.
  8700. */
  8701. needProjectionMatrixCompute(): boolean;
  8702. /**
  8703. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8704. */
  8705. forceProjectionMatrixCompute(): void;
  8706. /**
  8707. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8708. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8709. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8710. */
  8711. getShadowDirection(faceIndex?: number): Vector3;
  8712. /**
  8713. * Gets the minZ used for shadow according to both the scene and the light.
  8714. * @param activeCamera The camera we are returning the min for
  8715. * @returns the depth min z
  8716. */
  8717. getDepthMinZ(activeCamera: Camera): number;
  8718. /**
  8719. * Gets the maxZ used for shadow according to both the scene and the light.
  8720. * @param activeCamera The camera we are returning the max for
  8721. * @returns the depth max z
  8722. */
  8723. getDepthMaxZ(activeCamera: Camera): number;
  8724. }
  8725. /**
  8726. * Base implementation IShadowLight
  8727. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8728. */
  8729. export abstract class ShadowLight extends Light implements IShadowLight {
  8730. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8731. protected _position: Vector3;
  8732. protected _setPosition(value: Vector3): void;
  8733. /**
  8734. * Sets the position the shadow will be casted from. Also use as the light position for both
  8735. * point and spot lights.
  8736. */
  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. position: Vector3;
  8742. protected _direction: Vector3;
  8743. protected _setDirection(value: Vector3): void;
  8744. /**
  8745. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8746. * Also use as the light direction on spot and directional lights.
  8747. */
  8748. /**
  8749. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8750. * Also use as the light direction on spot and directional lights.
  8751. */
  8752. direction: Vector3;
  8753. private _shadowMinZ;
  8754. /**
  8755. * Gets the shadow projection clipping minimum z value.
  8756. */
  8757. /**
  8758. * Sets the shadow projection clipping minimum z value.
  8759. */
  8760. shadowMinZ: number;
  8761. private _shadowMaxZ;
  8762. /**
  8763. * Sets the shadow projection clipping maximum z value.
  8764. */
  8765. /**
  8766. * Gets the shadow projection clipping maximum z value.
  8767. */
  8768. shadowMaxZ: number;
  8769. /**
  8770. * Callback defining a custom Projection Matrix Builder.
  8771. * This can be used to override the default projection matrix computation.
  8772. */
  8773. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8774. /**
  8775. * The transformed position. Position of the light in world space taking parenting in account.
  8776. */
  8777. transformedPosition: Vector3;
  8778. /**
  8779. * The transformed direction. Direction of the light in world space taking parenting in account.
  8780. */
  8781. transformedDirection: Vector3;
  8782. private _needProjectionMatrixCompute;
  8783. /**
  8784. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8785. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8786. */
  8787. computeTransformedInformation(): boolean;
  8788. /**
  8789. * Return the depth scale used for the shadow map.
  8790. * @returns the depth scale.
  8791. */
  8792. getDepthScale(): number;
  8793. /**
  8794. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8795. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8796. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8797. */
  8798. getShadowDirection(faceIndex?: number): Vector3;
  8799. /**
  8800. * Returns the ShadowLight absolute position in the World.
  8801. * @returns the position vector in world space
  8802. */
  8803. getAbsolutePosition(): Vector3;
  8804. /**
  8805. * Sets the ShadowLight direction toward the passed target.
  8806. * @param target The point to target in local space
  8807. * @returns the updated ShadowLight direction
  8808. */
  8809. setDirectionToTarget(target: Vector3): Vector3;
  8810. /**
  8811. * Returns the light rotation in euler definition.
  8812. * @returns the x y z rotation in local space.
  8813. */
  8814. getRotation(): Vector3;
  8815. /**
  8816. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8817. * @returns true if a cube texture needs to be use
  8818. */
  8819. needCube(): boolean;
  8820. /**
  8821. * Detects if the projection matrix requires to be recomputed this frame.
  8822. * @returns true if it requires to be recomputed otherwise, false.
  8823. */
  8824. needProjectionMatrixCompute(): boolean;
  8825. /**
  8826. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8827. */
  8828. forceProjectionMatrixCompute(): void;
  8829. /** @hidden */
  8830. _initCache(): void;
  8831. /** @hidden */
  8832. _isSynchronized(): boolean;
  8833. /**
  8834. * Computes the world matrix of the node
  8835. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8836. * @returns the world matrix
  8837. */
  8838. computeWorldMatrix(force?: boolean): Matrix;
  8839. /**
  8840. * Gets the minZ used for shadow according to both the scene and the light.
  8841. * @param activeCamera The camera we are returning the min for
  8842. * @returns the depth min z
  8843. */
  8844. getDepthMinZ(activeCamera: Camera): number;
  8845. /**
  8846. * Gets the maxZ used for shadow according to both the scene and the light.
  8847. * @param activeCamera The camera we are returning the max for
  8848. * @returns the depth max z
  8849. */
  8850. getDepthMaxZ(activeCamera: Camera): number;
  8851. /**
  8852. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8853. * @param matrix The materix to updated with the projection information
  8854. * @param viewMatrix The transform matrix of the light
  8855. * @param renderList The list of mesh to render in the map
  8856. * @returns The current light
  8857. */
  8858. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8859. }
  8860. }
  8861. declare module "babylonjs/Materials/effectFallbacks" {
  8862. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  8863. import { Effect } from "babylonjs/Materials/effect";
  8864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8865. /**
  8866. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  8867. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  8868. */
  8869. export class EffectFallbacks implements IEffectFallbacks {
  8870. private _defines;
  8871. private _currentRank;
  8872. private _maxRank;
  8873. private _mesh;
  8874. /**
  8875. * Removes the fallback from the bound mesh.
  8876. */
  8877. unBindMesh(): void;
  8878. /**
  8879. * Adds a fallback on the specified property.
  8880. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8881. * @param define The name of the define in the shader
  8882. */
  8883. addFallback(rank: number, define: string): void;
  8884. /**
  8885. * Sets the mesh to use CPU skinning when needing to fallback.
  8886. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  8887. * @param mesh The mesh to use the fallbacks.
  8888. */
  8889. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8890. /**
  8891. * Checks to see if more fallbacks are still availible.
  8892. */
  8893. readonly hasMoreFallbacks: boolean;
  8894. /**
  8895. * Removes the defines that should be removed when falling back.
  8896. * @param currentDefines defines the current define statements for the shader.
  8897. * @param effect defines the current effect we try to compile
  8898. * @returns The resulting defines with defines of the current rank removed.
  8899. */
  8900. reduce(currentDefines: string, effect: Effect): string;
  8901. }
  8902. }
  8903. declare module "babylonjs/Materials/materialHelper" {
  8904. import { Nullable } from "babylonjs/types";
  8905. import { Scene } from "babylonjs/scene";
  8906. import { Engine } from "babylonjs/Engines/engine";
  8907. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8908. import { Light } from "babylonjs/Lights/light";
  8909. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  8910. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  8911. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8912. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8913. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  8914. /**
  8915. * "Static Class" containing the most commonly used helper while dealing with material for
  8916. * rendering purpose.
  8917. *
  8918. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8919. *
  8920. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8921. */
  8922. export class MaterialHelper {
  8923. /**
  8924. * Bind the current view position to an effect.
  8925. * @param effect The effect to be bound
  8926. * @param scene The scene the eyes position is used from
  8927. */
  8928. static BindEyePosition(effect: Effect, scene: Scene): void;
  8929. /**
  8930. * Helps preparing the defines values about the UVs in used in the effect.
  8931. * UVs are shared as much as we can accross channels in the shaders.
  8932. * @param texture The texture we are preparing the UVs for
  8933. * @param defines The defines to update
  8934. * @param key The channel key "diffuse", "specular"... used in the shader
  8935. */
  8936. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8937. /**
  8938. * Binds a texture matrix value to its corrsponding uniform
  8939. * @param texture The texture to bind the matrix for
  8940. * @param uniformBuffer The uniform buffer receivin the data
  8941. * @param key The channel key "diffuse", "specular"... used in the shader
  8942. */
  8943. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8944. /**
  8945. * Gets the current status of the fog (should it be enabled?)
  8946. * @param mesh defines the mesh to evaluate for fog support
  8947. * @param scene defines the hosting scene
  8948. * @returns true if fog must be enabled
  8949. */
  8950. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8951. /**
  8952. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8953. * @param mesh defines the current mesh
  8954. * @param scene defines the current scene
  8955. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8956. * @param pointsCloud defines if point cloud rendering has to be turned on
  8957. * @param fogEnabled defines if fog has to be turned on
  8958. * @param alphaTest defines if alpha testing has to be turned on
  8959. * @param defines defines the current list of defines
  8960. */
  8961. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8962. /**
  8963. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8964. * @param scene defines the current scene
  8965. * @param engine defines the current engine
  8966. * @param defines specifies the list of active defines
  8967. * @param useInstances defines if instances have to be turned on
  8968. * @param useClipPlane defines if clip plane have to be turned on
  8969. */
  8970. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8971. /**
  8972. * Prepares the defines for bones
  8973. * @param mesh The mesh containing the geometry data we will draw
  8974. * @param defines The defines to update
  8975. */
  8976. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8977. /**
  8978. * Prepares the defines for morph targets
  8979. * @param mesh The mesh containing the geometry data we will draw
  8980. * @param defines The defines to update
  8981. */
  8982. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8983. /**
  8984. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8985. * @param mesh The mesh containing the geometry data we will draw
  8986. * @param defines The defines to update
  8987. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8988. * @param useBones Precise whether bones should be used or not (override mesh info)
  8989. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8990. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8991. * @returns false if defines are considered not dirty and have not been checked
  8992. */
  8993. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8994. /**
  8995. * Prepares the defines related to multiview
  8996. * @param scene The scene we are intending to draw
  8997. * @param defines The defines to update
  8998. */
  8999. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9000. /**
  9001. * Prepares the defines related to the light information passed in parameter
  9002. * @param scene The scene we are intending to draw
  9003. * @param mesh The mesh the effect is compiling for
  9004. * @param light The light the effect is compiling for
  9005. * @param lightIndex The index of the light
  9006. * @param defines The defines to update
  9007. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9008. * @param state Defines the current state regarding what is needed (normals, etc...)
  9009. */
  9010. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9011. needNormals: boolean;
  9012. needRebuild: boolean;
  9013. shadowEnabled: boolean;
  9014. specularEnabled: boolean;
  9015. lightmapMode: boolean;
  9016. }): void;
  9017. /**
  9018. * Prepares the defines related to the light information passed in parameter
  9019. * @param scene The scene we are intending to draw
  9020. * @param mesh The mesh the effect is compiling for
  9021. * @param defines The defines to update
  9022. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9023. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9024. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9025. * @returns true if normals will be required for the rest of the effect
  9026. */
  9027. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9028. /**
  9029. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9030. * @param lightIndex defines the light index
  9031. * @param uniformsList The uniform list
  9032. * @param samplersList The sampler list
  9033. * @param projectedLightTexture defines if projected texture must be used
  9034. * @param uniformBuffersList defines an optional list of uniform buffers
  9035. */
  9036. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9037. /**
  9038. * Prepares the uniforms and samplers list to be used in the effect
  9039. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9040. * @param samplersList The sampler list
  9041. * @param defines The defines helping in the list generation
  9042. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9043. */
  9044. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9045. /**
  9046. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9047. * @param defines The defines to update while falling back
  9048. * @param fallbacks The authorized effect fallbacks
  9049. * @param maxSimultaneousLights The maximum number of lights allowed
  9050. * @param rank the current rank of the Effect
  9051. * @returns The newly affected rank
  9052. */
  9053. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9054. private static _TmpMorphInfluencers;
  9055. /**
  9056. * Prepares the list of attributes required for morph targets according to the effect defines.
  9057. * @param attribs The current list of supported attribs
  9058. * @param mesh The mesh to prepare the morph targets attributes for
  9059. * @param influencers The number of influencers
  9060. */
  9061. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9062. /**
  9063. * Prepares the list of attributes required for morph targets according to the effect defines.
  9064. * @param attribs The current list of supported attribs
  9065. * @param mesh The mesh to prepare the morph targets attributes for
  9066. * @param defines The current Defines of the effect
  9067. */
  9068. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9069. /**
  9070. * Prepares the list of attributes required for bones according to the effect defines.
  9071. * @param attribs The current list of supported attribs
  9072. * @param mesh The mesh to prepare the bones attributes for
  9073. * @param defines The current Defines of the effect
  9074. * @param fallbacks The current efffect fallback strategy
  9075. */
  9076. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9077. /**
  9078. * Check and prepare the list of attributes required for instances according to the effect defines.
  9079. * @param attribs The current list of supported attribs
  9080. * @param defines The current MaterialDefines of the effect
  9081. */
  9082. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9083. /**
  9084. * Add the list of attributes required for instances to the attribs array.
  9085. * @param attribs The current list of supported attribs
  9086. */
  9087. static PushAttributesForInstances(attribs: string[]): void;
  9088. /**
  9089. * Binds the light shadow information to the effect for the given mesh.
  9090. * @param light The light containing the generator
  9091. * @param scene The scene the lights belongs to
  9092. * @param mesh The mesh we are binding the information to render
  9093. * @param lightIndex The light index in the effect used to render the mesh
  9094. * @param effect The effect we are binding the data to
  9095. */
  9096. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9097. /**
  9098. * Binds the light information to the effect.
  9099. * @param light The light containing the generator
  9100. * @param effect The effect we are binding the data to
  9101. * @param lightIndex The light index in the effect used to render
  9102. */
  9103. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9104. /**
  9105. * Binds the lights information from the scene to the effect for the given mesh.
  9106. * @param light Light to bind
  9107. * @param lightIndex Light index
  9108. * @param scene The scene where the light belongs to
  9109. * @param mesh The mesh we are binding the information to render
  9110. * @param effect The effect we are binding the data to
  9111. * @param useSpecular Defines if specular is supported
  9112. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9113. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9114. */
  9115. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9116. /**
  9117. * Binds the lights information from the scene to the effect for the given mesh.
  9118. * @param scene The scene the lights belongs to
  9119. * @param mesh The mesh we are binding the information to render
  9120. * @param effect The effect we are binding the data to
  9121. * @param defines The generated defines for the effect
  9122. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9123. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9124. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9125. */
  9126. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9127. private static _tempFogColor;
  9128. /**
  9129. * Binds the fog information from the scene to the effect for the given mesh.
  9130. * @param scene The scene the lights belongs to
  9131. * @param mesh The mesh we are binding the information to render
  9132. * @param effect The effect we are binding the data to
  9133. * @param linearSpace Defines if the fog effect is applied in linear space
  9134. */
  9135. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9136. /**
  9137. * Binds the bones information from the mesh to the effect.
  9138. * @param mesh The mesh we are binding the information to render
  9139. * @param effect The effect we are binding the data to
  9140. */
  9141. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9142. /**
  9143. * Binds the morph targets information from the mesh to the effect.
  9144. * @param abstractMesh The mesh we are binding the information to render
  9145. * @param effect The effect we are binding the data to
  9146. */
  9147. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9148. /**
  9149. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9150. * @param defines The generated defines used in the effect
  9151. * @param effect The effect we are binding the data to
  9152. * @param scene The scene we are willing to render with logarithmic scale for
  9153. */
  9154. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9155. /**
  9156. * Binds the clip plane information from the scene to the effect.
  9157. * @param scene The scene the clip plane information are extracted from
  9158. * @param effect The effect we are binding the data to
  9159. */
  9160. static BindClipPlane(effect: Effect, scene: Scene): void;
  9161. }
  9162. }
  9163. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9164. /** @hidden */
  9165. export var packingFunctions: {
  9166. name: string;
  9167. shader: string;
  9168. };
  9169. }
  9170. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9171. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9172. /** @hidden */
  9173. export var shadowMapPixelShader: {
  9174. name: string;
  9175. shader: string;
  9176. };
  9177. }
  9178. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9179. /** @hidden */
  9180. export var bonesDeclaration: {
  9181. name: string;
  9182. shader: string;
  9183. };
  9184. }
  9185. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9186. /** @hidden */
  9187. export var morphTargetsVertexGlobalDeclaration: {
  9188. name: string;
  9189. shader: string;
  9190. };
  9191. }
  9192. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9193. /** @hidden */
  9194. export var morphTargetsVertexDeclaration: {
  9195. name: string;
  9196. shader: string;
  9197. };
  9198. }
  9199. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9200. /** @hidden */
  9201. export var instancesDeclaration: {
  9202. name: string;
  9203. shader: string;
  9204. };
  9205. }
  9206. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9207. /** @hidden */
  9208. export var helperFunctions: {
  9209. name: string;
  9210. shader: string;
  9211. };
  9212. }
  9213. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9214. /** @hidden */
  9215. export var morphTargetsVertex: {
  9216. name: string;
  9217. shader: string;
  9218. };
  9219. }
  9220. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9221. /** @hidden */
  9222. export var instancesVertex: {
  9223. name: string;
  9224. shader: string;
  9225. };
  9226. }
  9227. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9228. /** @hidden */
  9229. export var bonesVertex: {
  9230. name: string;
  9231. shader: string;
  9232. };
  9233. }
  9234. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9235. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9236. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9237. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9238. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9239. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9240. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9241. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9242. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9243. /** @hidden */
  9244. export var shadowMapVertexShader: {
  9245. name: string;
  9246. shader: string;
  9247. };
  9248. }
  9249. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9250. /** @hidden */
  9251. export var depthBoxBlurPixelShader: {
  9252. name: string;
  9253. shader: string;
  9254. };
  9255. }
  9256. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9257. import { Nullable } from "babylonjs/types";
  9258. import { Scene } from "babylonjs/scene";
  9259. import { Matrix } from "babylonjs/Maths/math.vector";
  9260. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9262. import { Mesh } from "babylonjs/Meshes/mesh";
  9263. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9264. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9265. import { Effect } from "babylonjs/Materials/effect";
  9266. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9267. import "babylonjs/Shaders/shadowMap.fragment";
  9268. import "babylonjs/Shaders/shadowMap.vertex";
  9269. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9270. import { Observable } from "babylonjs/Misc/observable";
  9271. /**
  9272. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9273. */
  9274. export interface ICustomShaderOptions {
  9275. /**
  9276. * Gets or sets the custom shader name to use
  9277. */
  9278. shaderName: string;
  9279. /**
  9280. * The list of attribute names used in the shader
  9281. */
  9282. attributes?: string[];
  9283. /**
  9284. * The list of unifrom names used in the shader
  9285. */
  9286. uniforms?: string[];
  9287. /**
  9288. * The list of sampler names used in the shader
  9289. */
  9290. samplers?: string[];
  9291. /**
  9292. * The list of defines used in the shader
  9293. */
  9294. defines?: string[];
  9295. }
  9296. /**
  9297. * Interface to implement to create a shadow generator compatible with BJS.
  9298. */
  9299. export interface IShadowGenerator {
  9300. /**
  9301. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9302. * @returns The render target texture if present otherwise, null
  9303. */
  9304. getShadowMap(): Nullable<RenderTargetTexture>;
  9305. /**
  9306. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9307. * @returns The render target texture if the shadow map is present otherwise, null
  9308. */
  9309. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9310. /**
  9311. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9312. * @param subMesh The submesh we want to render in the shadow map
  9313. * @param useInstances Defines wether will draw in the map using instances
  9314. * @returns true if ready otherwise, false
  9315. */
  9316. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9317. /**
  9318. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9319. * @param defines Defines of the material we want to update
  9320. * @param lightIndex Index of the light in the enabled light list of the material
  9321. */
  9322. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9323. /**
  9324. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9325. * defined in the generator but impacting the effect).
  9326. * It implies the unifroms available on the materials are the standard BJS ones.
  9327. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9328. * @param effect The effect we are binfing the information for
  9329. */
  9330. bindShadowLight(lightIndex: string, effect: Effect): void;
  9331. /**
  9332. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9333. * (eq to shadow prjection matrix * light transform matrix)
  9334. * @returns The transform matrix used to create the shadow map
  9335. */
  9336. getTransformMatrix(): Matrix;
  9337. /**
  9338. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9339. * Cube and 2D textures for instance.
  9340. */
  9341. recreateShadowMap(): void;
  9342. /**
  9343. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9344. * @param onCompiled Callback triggered at the and of the effects compilation
  9345. * @param options Sets of optional options forcing the compilation with different modes
  9346. */
  9347. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9348. useInstances: boolean;
  9349. }>): void;
  9350. /**
  9351. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9352. * @param options Sets of optional options forcing the compilation with different modes
  9353. * @returns A promise that resolves when the compilation completes
  9354. */
  9355. forceCompilationAsync(options?: Partial<{
  9356. useInstances: boolean;
  9357. }>): Promise<void>;
  9358. /**
  9359. * Serializes the shadow generator setup to a json object.
  9360. * @returns The serialized JSON object
  9361. */
  9362. serialize(): any;
  9363. /**
  9364. * Disposes the Shadow map and related Textures and effects.
  9365. */
  9366. dispose(): void;
  9367. }
  9368. /**
  9369. * Default implementation IShadowGenerator.
  9370. * This is the main object responsible of generating shadows in the framework.
  9371. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9372. */
  9373. export class ShadowGenerator implements IShadowGenerator {
  9374. /**
  9375. * Shadow generator mode None: no filtering applied.
  9376. */
  9377. static readonly FILTER_NONE: number;
  9378. /**
  9379. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9380. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9381. */
  9382. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9383. /**
  9384. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9385. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9386. */
  9387. static readonly FILTER_POISSONSAMPLING: number;
  9388. /**
  9389. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9390. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9391. */
  9392. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9393. /**
  9394. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9395. * edge artifacts on steep falloff.
  9396. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9397. */
  9398. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9399. /**
  9400. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9401. * edge artifacts on steep falloff.
  9402. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9403. */
  9404. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9405. /**
  9406. * Shadow generator mode PCF: Percentage Closer Filtering
  9407. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9408. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9409. */
  9410. static readonly FILTER_PCF: number;
  9411. /**
  9412. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9413. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9414. * Contact Hardening
  9415. */
  9416. static readonly FILTER_PCSS: number;
  9417. /**
  9418. * Reserved for PCF and PCSS
  9419. * Highest Quality.
  9420. *
  9421. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9422. *
  9423. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9424. */
  9425. static readonly QUALITY_HIGH: number;
  9426. /**
  9427. * Reserved for PCF and PCSS
  9428. * Good tradeoff for quality/perf cross devices
  9429. *
  9430. * Execute PCF on a 3*3 kernel.
  9431. *
  9432. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9433. */
  9434. static readonly QUALITY_MEDIUM: number;
  9435. /**
  9436. * Reserved for PCF and PCSS
  9437. * The lowest quality but the fastest.
  9438. *
  9439. * Execute PCF on a 1*1 kernel.
  9440. *
  9441. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9442. */
  9443. static readonly QUALITY_LOW: number;
  9444. /** Gets or sets the custom shader name to use */
  9445. customShaderOptions: ICustomShaderOptions;
  9446. /**
  9447. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9448. */
  9449. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9450. /**
  9451. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9452. */
  9453. onAfterShadowMapRenderObservable: Observable<Effect>;
  9454. /**
  9455. * Observable triggered before a mesh is rendered in the shadow map.
  9456. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9457. */
  9458. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9459. /**
  9460. * Observable triggered after a mesh is rendered in the shadow map.
  9461. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9462. */
  9463. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9464. private _bias;
  9465. /**
  9466. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9467. */
  9468. /**
  9469. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9470. */
  9471. bias: number;
  9472. private _normalBias;
  9473. /**
  9474. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9475. */
  9476. /**
  9477. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9478. */
  9479. normalBias: number;
  9480. private _blurBoxOffset;
  9481. /**
  9482. * Gets the blur box offset: offset applied during the blur pass.
  9483. * Only useful if useKernelBlur = false
  9484. */
  9485. /**
  9486. * Sets the blur box offset: offset applied during the blur pass.
  9487. * Only useful if useKernelBlur = false
  9488. */
  9489. blurBoxOffset: number;
  9490. private _blurScale;
  9491. /**
  9492. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9493. * 2 means half of the size.
  9494. */
  9495. /**
  9496. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9497. * 2 means half of the size.
  9498. */
  9499. blurScale: number;
  9500. private _blurKernel;
  9501. /**
  9502. * Gets the blur kernel: kernel size of the blur pass.
  9503. * Only useful if useKernelBlur = true
  9504. */
  9505. /**
  9506. * Sets the blur kernel: kernel size of the blur pass.
  9507. * Only useful if useKernelBlur = true
  9508. */
  9509. blurKernel: number;
  9510. private _useKernelBlur;
  9511. /**
  9512. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9513. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9514. */
  9515. /**
  9516. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9517. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9518. */
  9519. useKernelBlur: boolean;
  9520. private _depthScale;
  9521. /**
  9522. * Gets the depth scale used in ESM mode.
  9523. */
  9524. /**
  9525. * Sets the depth scale used in ESM mode.
  9526. * This can override the scale stored on the light.
  9527. */
  9528. depthScale: number;
  9529. private _filter;
  9530. /**
  9531. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9532. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9533. */
  9534. /**
  9535. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9536. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9537. */
  9538. filter: number;
  9539. /**
  9540. * Gets if the current filter is set to Poisson Sampling.
  9541. */
  9542. /**
  9543. * Sets the current filter to Poisson Sampling.
  9544. */
  9545. usePoissonSampling: boolean;
  9546. /**
  9547. * Gets if the current filter is set to ESM.
  9548. */
  9549. /**
  9550. * Sets the current filter is to ESM.
  9551. */
  9552. useExponentialShadowMap: boolean;
  9553. /**
  9554. * Gets if the current filter is set to filtered ESM.
  9555. */
  9556. /**
  9557. * Gets if the current filter is set to filtered ESM.
  9558. */
  9559. useBlurExponentialShadowMap: boolean;
  9560. /**
  9561. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9562. * exponential to prevent steep falloff artifacts).
  9563. */
  9564. /**
  9565. * Sets the current filter to "close ESM" (using the inverse of the
  9566. * exponential to prevent steep falloff artifacts).
  9567. */
  9568. useCloseExponentialShadowMap: boolean;
  9569. /**
  9570. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9571. * exponential to prevent steep falloff artifacts).
  9572. */
  9573. /**
  9574. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9575. * exponential to prevent steep falloff artifacts).
  9576. */
  9577. useBlurCloseExponentialShadowMap: boolean;
  9578. /**
  9579. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9580. */
  9581. /**
  9582. * Sets the current filter to "PCF" (percentage closer filtering).
  9583. */
  9584. usePercentageCloserFiltering: boolean;
  9585. private _filteringQuality;
  9586. /**
  9587. * Gets the PCF or PCSS Quality.
  9588. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9589. */
  9590. /**
  9591. * Sets the PCF or PCSS Quality.
  9592. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9593. */
  9594. filteringQuality: number;
  9595. /**
  9596. * Gets if the current filter is set to "PCSS" (contact hardening).
  9597. */
  9598. /**
  9599. * Sets the current filter to "PCSS" (contact hardening).
  9600. */
  9601. useContactHardeningShadow: boolean;
  9602. private _contactHardeningLightSizeUVRatio;
  9603. /**
  9604. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9605. * Using a ratio helps keeping shape stability independently of the map size.
  9606. *
  9607. * It does not account for the light projection as it was having too much
  9608. * instability during the light setup or during light position changes.
  9609. *
  9610. * Only valid if useContactHardeningShadow is true.
  9611. */
  9612. /**
  9613. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9614. * Using a ratio helps keeping shape stability independently of the map size.
  9615. *
  9616. * It does not account for the light projection as it was having too much
  9617. * instability during the light setup or during light position changes.
  9618. *
  9619. * Only valid if useContactHardeningShadow is true.
  9620. */
  9621. contactHardeningLightSizeUVRatio: number;
  9622. private _darkness;
  9623. /** Gets or sets the actual darkness of a shadow */
  9624. darkness: number;
  9625. /**
  9626. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9627. * 0 means strongest and 1 would means no shadow.
  9628. * @returns the darkness.
  9629. */
  9630. getDarkness(): number;
  9631. /**
  9632. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9633. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9634. * @returns the shadow generator allowing fluent coding.
  9635. */
  9636. setDarkness(darkness: number): ShadowGenerator;
  9637. private _transparencyShadow;
  9638. /** Gets or sets the ability to have transparent shadow */
  9639. transparencyShadow: boolean;
  9640. /**
  9641. * Sets the ability to have transparent shadow (boolean).
  9642. * @param transparent True if transparent else False
  9643. * @returns the shadow generator allowing fluent coding
  9644. */
  9645. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9646. private _shadowMap;
  9647. private _shadowMap2;
  9648. /**
  9649. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9650. * @returns The render target texture if present otherwise, null
  9651. */
  9652. getShadowMap(): Nullable<RenderTargetTexture>;
  9653. /**
  9654. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9655. * @returns The render target texture if the shadow map is present otherwise, null
  9656. */
  9657. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9658. /**
  9659. * Gets the class name of that object
  9660. * @returns "ShadowGenerator"
  9661. */
  9662. getClassName(): string;
  9663. /**
  9664. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9665. * @param mesh Mesh to add
  9666. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9667. * @returns the Shadow Generator itself
  9668. */
  9669. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9670. /**
  9671. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9672. * @param mesh Mesh to remove
  9673. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9674. * @returns the Shadow Generator itself
  9675. */
  9676. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9677. /**
  9678. * Controls the extent to which the shadows fade out at the edge of the frustum
  9679. * Used only by directionals and spots
  9680. */
  9681. frustumEdgeFalloff: number;
  9682. private _light;
  9683. /**
  9684. * Returns the associated light object.
  9685. * @returns the light generating the shadow
  9686. */
  9687. getLight(): IShadowLight;
  9688. /**
  9689. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9690. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9691. * It might on the other hand introduce peter panning.
  9692. */
  9693. forceBackFacesOnly: boolean;
  9694. private _scene;
  9695. private _lightDirection;
  9696. private _effect;
  9697. private _viewMatrix;
  9698. private _projectionMatrix;
  9699. private _transformMatrix;
  9700. private _cachedPosition;
  9701. private _cachedDirection;
  9702. private _cachedDefines;
  9703. private _currentRenderID;
  9704. private _boxBlurPostprocess;
  9705. private _kernelBlurXPostprocess;
  9706. private _kernelBlurYPostprocess;
  9707. private _blurPostProcesses;
  9708. private _mapSize;
  9709. private _currentFaceIndex;
  9710. private _currentFaceIndexCache;
  9711. private _textureType;
  9712. private _defaultTextureMatrix;
  9713. private _storedUniqueId;
  9714. /** @hidden */
  9715. static _SceneComponentInitialization: (scene: Scene) => void;
  9716. /**
  9717. * Creates a ShadowGenerator object.
  9718. * A ShadowGenerator is the required tool to use the shadows.
  9719. * Each light casting shadows needs to use its own ShadowGenerator.
  9720. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9721. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9722. * @param light The light object generating the shadows.
  9723. * @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.
  9724. */
  9725. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9726. private _initializeGenerator;
  9727. private _initializeShadowMap;
  9728. private _initializeBlurRTTAndPostProcesses;
  9729. private _renderForShadowMap;
  9730. private _renderSubMeshForShadowMap;
  9731. private _applyFilterValues;
  9732. /**
  9733. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9734. * @param onCompiled Callback triggered at the and of the effects compilation
  9735. * @param options Sets of optional options forcing the compilation with different modes
  9736. */
  9737. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9738. useInstances: boolean;
  9739. }>): void;
  9740. /**
  9741. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9742. * @param options Sets of optional options forcing the compilation with different modes
  9743. * @returns A promise that resolves when the compilation completes
  9744. */
  9745. forceCompilationAsync(options?: Partial<{
  9746. useInstances: boolean;
  9747. }>): Promise<void>;
  9748. /**
  9749. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9750. * @param subMesh The submesh we want to render in the shadow map
  9751. * @param useInstances Defines wether will draw in the map using instances
  9752. * @returns true if ready otherwise, false
  9753. */
  9754. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9755. /**
  9756. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9757. * @param defines Defines of the material we want to update
  9758. * @param lightIndex Index of the light in the enabled light list of the material
  9759. */
  9760. prepareDefines(defines: any, lightIndex: number): void;
  9761. /**
  9762. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9763. * defined in the generator but impacting the effect).
  9764. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9765. * @param effect The effect we are binfing the information for
  9766. */
  9767. bindShadowLight(lightIndex: string, effect: Effect): void;
  9768. /**
  9769. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9770. * (eq to shadow prjection matrix * light transform matrix)
  9771. * @returns The transform matrix used to create the shadow map
  9772. */
  9773. getTransformMatrix(): Matrix;
  9774. /**
  9775. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9776. * Cube and 2D textures for instance.
  9777. */
  9778. recreateShadowMap(): void;
  9779. private _disposeBlurPostProcesses;
  9780. private _disposeRTTandPostProcesses;
  9781. /**
  9782. * Disposes the ShadowGenerator.
  9783. * Returns nothing.
  9784. */
  9785. dispose(): void;
  9786. /**
  9787. * Serializes the shadow generator setup to a json object.
  9788. * @returns The serialized JSON object
  9789. */
  9790. serialize(): any;
  9791. /**
  9792. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9793. * @param parsedShadowGenerator The JSON object to parse
  9794. * @param scene The scene to create the shadow map for
  9795. * @returns The parsed shadow generator
  9796. */
  9797. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9798. }
  9799. }
  9800. declare module "babylonjs/Lights/light" {
  9801. import { Nullable } from "babylonjs/types";
  9802. import { Scene } from "babylonjs/scene";
  9803. import { Vector3 } from "babylonjs/Maths/math.vector";
  9804. import { Color3 } from "babylonjs/Maths/math.color";
  9805. import { Node } from "babylonjs/node";
  9806. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9807. import { Effect } from "babylonjs/Materials/effect";
  9808. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9809. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9810. /**
  9811. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9812. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9813. * 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.
  9814. */
  9815. export abstract class Light extends Node {
  9816. /**
  9817. * Falloff Default: light is falling off following the material specification:
  9818. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9819. */
  9820. static readonly FALLOFF_DEFAULT: number;
  9821. /**
  9822. * Falloff Physical: light is falling off following the inverse squared distance law.
  9823. */
  9824. static readonly FALLOFF_PHYSICAL: number;
  9825. /**
  9826. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9827. * to enhance interoperability with other engines.
  9828. */
  9829. static readonly FALLOFF_GLTF: number;
  9830. /**
  9831. * Falloff Standard: light is falling off like in the standard material
  9832. * to enhance interoperability with other materials.
  9833. */
  9834. static readonly FALLOFF_STANDARD: number;
  9835. /**
  9836. * If every light affecting the material is in this lightmapMode,
  9837. * material.lightmapTexture adds or multiplies
  9838. * (depends on material.useLightmapAsShadowmap)
  9839. * after every other light calculations.
  9840. */
  9841. static readonly LIGHTMAP_DEFAULT: number;
  9842. /**
  9843. * material.lightmapTexture as only diffuse lighting from this light
  9844. * adds only specular lighting from this light
  9845. * adds dynamic shadows
  9846. */
  9847. static readonly LIGHTMAP_SPECULAR: number;
  9848. /**
  9849. * material.lightmapTexture as only lighting
  9850. * no light calculation from this light
  9851. * only adds dynamic shadows from this light
  9852. */
  9853. static readonly LIGHTMAP_SHADOWSONLY: number;
  9854. /**
  9855. * Each light type uses the default quantity according to its type:
  9856. * point/spot lights use luminous intensity
  9857. * directional lights use illuminance
  9858. */
  9859. static readonly INTENSITYMODE_AUTOMATIC: number;
  9860. /**
  9861. * lumen (lm)
  9862. */
  9863. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9864. /**
  9865. * candela (lm/sr)
  9866. */
  9867. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9868. /**
  9869. * lux (lm/m^2)
  9870. */
  9871. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9872. /**
  9873. * nit (cd/m^2)
  9874. */
  9875. static readonly INTENSITYMODE_LUMINANCE: number;
  9876. /**
  9877. * Light type const id of the point light.
  9878. */
  9879. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9880. /**
  9881. * Light type const id of the directional light.
  9882. */
  9883. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9884. /**
  9885. * Light type const id of the spot light.
  9886. */
  9887. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9888. /**
  9889. * Light type const id of the hemispheric light.
  9890. */
  9891. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9892. /**
  9893. * Diffuse gives the basic color to an object.
  9894. */
  9895. diffuse: Color3;
  9896. /**
  9897. * Specular produces a highlight color on an object.
  9898. * Note: This is note affecting PBR materials.
  9899. */
  9900. specular: Color3;
  9901. /**
  9902. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9903. * falling off base on range or angle.
  9904. * This can be set to any values in Light.FALLOFF_x.
  9905. *
  9906. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9907. * other types of materials.
  9908. */
  9909. falloffType: number;
  9910. /**
  9911. * Strength of the light.
  9912. * Note: By default it is define in the framework own unit.
  9913. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9914. */
  9915. intensity: number;
  9916. private _range;
  9917. protected _inverseSquaredRange: number;
  9918. /**
  9919. * Defines how far from the source the light is impacting in scene units.
  9920. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9921. */
  9922. /**
  9923. * Defines how far from the source the light is impacting in scene units.
  9924. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9925. */
  9926. range: number;
  9927. /**
  9928. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9929. * of light.
  9930. */
  9931. private _photometricScale;
  9932. private _intensityMode;
  9933. /**
  9934. * Gets the photometric scale used to interpret the intensity.
  9935. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9936. */
  9937. /**
  9938. * Sets the photometric scale used to interpret the intensity.
  9939. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9940. */
  9941. intensityMode: number;
  9942. private _radius;
  9943. /**
  9944. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9945. */
  9946. /**
  9947. * sets the light radius used by PBR Materials to simulate soft area lights.
  9948. */
  9949. radius: number;
  9950. private _renderPriority;
  9951. /**
  9952. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9953. * exceeding the number allowed of the materials.
  9954. */
  9955. renderPriority: number;
  9956. private _shadowEnabled;
  9957. /**
  9958. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9959. * the current shadow generator.
  9960. */
  9961. /**
  9962. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9963. * the current shadow generator.
  9964. */
  9965. shadowEnabled: boolean;
  9966. private _includedOnlyMeshes;
  9967. /**
  9968. * Gets the only meshes impacted by this light.
  9969. */
  9970. /**
  9971. * Sets the only meshes impacted by this light.
  9972. */
  9973. includedOnlyMeshes: AbstractMesh[];
  9974. private _excludedMeshes;
  9975. /**
  9976. * Gets the meshes not impacted by this light.
  9977. */
  9978. /**
  9979. * Sets the meshes not impacted by this light.
  9980. */
  9981. excludedMeshes: AbstractMesh[];
  9982. private _excludeWithLayerMask;
  9983. /**
  9984. * Gets the layer id use to find what meshes are not impacted by the light.
  9985. * Inactive if 0
  9986. */
  9987. /**
  9988. * Sets the layer id use to find what meshes are not impacted by the light.
  9989. * Inactive if 0
  9990. */
  9991. excludeWithLayerMask: number;
  9992. private _includeOnlyWithLayerMask;
  9993. /**
  9994. * Gets the layer id use to find what meshes are impacted by the light.
  9995. * Inactive if 0
  9996. */
  9997. /**
  9998. * Sets the layer id use to find what meshes are impacted by the light.
  9999. * Inactive if 0
  10000. */
  10001. includeOnlyWithLayerMask: number;
  10002. private _lightmapMode;
  10003. /**
  10004. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10005. */
  10006. /**
  10007. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10008. */
  10009. lightmapMode: number;
  10010. /**
  10011. * Shadow generator associted to the light.
  10012. * @hidden Internal use only.
  10013. */
  10014. _shadowGenerator: Nullable<IShadowGenerator>;
  10015. /**
  10016. * @hidden Internal use only.
  10017. */
  10018. _excludedMeshesIds: string[];
  10019. /**
  10020. * @hidden Internal use only.
  10021. */
  10022. _includedOnlyMeshesIds: string[];
  10023. /**
  10024. * The current light unifom buffer.
  10025. * @hidden Internal use only.
  10026. */
  10027. _uniformBuffer: UniformBuffer;
  10028. /**
  10029. * Creates a Light object in the scene.
  10030. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10031. * @param name The firendly name of the light
  10032. * @param scene The scene the light belongs too
  10033. */
  10034. constructor(name: string, scene: Scene);
  10035. protected abstract _buildUniformLayout(): void;
  10036. /**
  10037. * Sets the passed Effect "effect" with the Light information.
  10038. * @param effect The effect to update
  10039. * @param lightIndex The index of the light in the effect to update
  10040. * @returns The light
  10041. */
  10042. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10043. /**
  10044. * Sets the passed Effect "effect" with the Light information.
  10045. * @param effect The effect to update
  10046. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10047. * @returns The light
  10048. */
  10049. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10050. /**
  10051. * Returns the string "Light".
  10052. * @returns the class name
  10053. */
  10054. getClassName(): string;
  10055. /** @hidden */
  10056. readonly _isLight: boolean;
  10057. /**
  10058. * Converts the light information to a readable string for debug purpose.
  10059. * @param fullDetails Supports for multiple levels of logging within scene loading
  10060. * @returns the human readable light info
  10061. */
  10062. toString(fullDetails?: boolean): string;
  10063. /** @hidden */
  10064. protected _syncParentEnabledState(): void;
  10065. /**
  10066. * Set the enabled state of this node.
  10067. * @param value - the new enabled state
  10068. */
  10069. setEnabled(value: boolean): void;
  10070. /**
  10071. * Returns the Light associated shadow generator if any.
  10072. * @return the associated shadow generator.
  10073. */
  10074. getShadowGenerator(): Nullable<IShadowGenerator>;
  10075. /**
  10076. * Returns a Vector3, the absolute light position in the World.
  10077. * @returns the world space position of the light
  10078. */
  10079. getAbsolutePosition(): Vector3;
  10080. /**
  10081. * Specifies if the light will affect the passed mesh.
  10082. * @param mesh The mesh to test against the light
  10083. * @return true the mesh is affected otherwise, false.
  10084. */
  10085. canAffectMesh(mesh: AbstractMesh): boolean;
  10086. /**
  10087. * Sort function to order lights for rendering.
  10088. * @param a First Light object to compare to second.
  10089. * @param b Second Light object to compare first.
  10090. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10091. */
  10092. static CompareLightsPriority(a: Light, b: Light): number;
  10093. /**
  10094. * Releases resources associated with this node.
  10095. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10096. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10097. */
  10098. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10099. /**
  10100. * Returns the light type ID (integer).
  10101. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10102. */
  10103. getTypeID(): number;
  10104. /**
  10105. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10106. * @returns the scaled intensity in intensity mode unit
  10107. */
  10108. getScaledIntensity(): number;
  10109. /**
  10110. * Returns a new Light object, named "name", from the current one.
  10111. * @param name The name of the cloned light
  10112. * @returns the new created light
  10113. */
  10114. clone(name: string): Nullable<Light>;
  10115. /**
  10116. * Serializes the current light into a Serialization object.
  10117. * @returns the serialized object.
  10118. */
  10119. serialize(): any;
  10120. /**
  10121. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10122. * This new light is named "name" and added to the passed scene.
  10123. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10124. * @param name The friendly name of the light
  10125. * @param scene The scene the new light will belong to
  10126. * @returns the constructor function
  10127. */
  10128. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10129. /**
  10130. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10131. * @param parsedLight The JSON representation of the light
  10132. * @param scene The scene to create the parsed light in
  10133. * @returns the created light after parsing
  10134. */
  10135. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10136. private _hookArrayForExcluded;
  10137. private _hookArrayForIncludedOnly;
  10138. private _resyncMeshes;
  10139. /**
  10140. * Forces the meshes to update their light related information in their rendering used effects
  10141. * @hidden Internal Use Only
  10142. */
  10143. _markMeshesAsLightDirty(): void;
  10144. /**
  10145. * Recomputes the cached photometric scale if needed.
  10146. */
  10147. private _computePhotometricScale;
  10148. /**
  10149. * Returns the Photometric Scale according to the light type and intensity mode.
  10150. */
  10151. private _getPhotometricScale;
  10152. /**
  10153. * Reorder the light in the scene according to their defined priority.
  10154. * @hidden Internal Use Only
  10155. */
  10156. _reorderLightsInScene(): void;
  10157. /**
  10158. * Prepares the list of defines specific to the light type.
  10159. * @param defines the list of defines
  10160. * @param lightIndex defines the index of the light for the effect
  10161. */
  10162. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10163. }
  10164. }
  10165. declare module "babylonjs/Actions/action" {
  10166. import { Observable } from "babylonjs/Misc/observable";
  10167. import { Condition } from "babylonjs/Actions/condition";
  10168. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10169. import { ActionManager } from "babylonjs/Actions/actionManager";
  10170. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10171. /**
  10172. * Interface used to define Action
  10173. */
  10174. export interface IAction {
  10175. /**
  10176. * Trigger for the action
  10177. */
  10178. trigger: number;
  10179. /** Options of the trigger */
  10180. triggerOptions: any;
  10181. /**
  10182. * Gets the trigger parameters
  10183. * @returns the trigger parameters
  10184. */
  10185. getTriggerParameter(): any;
  10186. /**
  10187. * Internal only - executes current action event
  10188. * @hidden
  10189. */
  10190. _executeCurrent(evt?: ActionEvent): void;
  10191. /**
  10192. * Serialize placeholder for child classes
  10193. * @param parent of child
  10194. * @returns the serialized object
  10195. */
  10196. serialize(parent: any): any;
  10197. /**
  10198. * Internal only
  10199. * @hidden
  10200. */
  10201. _prepare(): void;
  10202. /**
  10203. * Internal only - manager for action
  10204. * @hidden
  10205. */
  10206. _actionManager: AbstractActionManager;
  10207. /**
  10208. * Adds action to chain of actions, may be a DoNothingAction
  10209. * @param action defines the next action to execute
  10210. * @returns The action passed in
  10211. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10212. */
  10213. then(action: IAction): IAction;
  10214. }
  10215. /**
  10216. * The action to be carried out following a trigger
  10217. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10218. */
  10219. export class Action implements IAction {
  10220. /** the trigger, with or without parameters, for the action */
  10221. triggerOptions: any;
  10222. /**
  10223. * Trigger for the action
  10224. */
  10225. trigger: number;
  10226. /**
  10227. * Internal only - manager for action
  10228. * @hidden
  10229. */
  10230. _actionManager: ActionManager;
  10231. private _nextActiveAction;
  10232. private _child;
  10233. private _condition?;
  10234. private _triggerParameter;
  10235. /**
  10236. * An event triggered prior to action being executed.
  10237. */
  10238. onBeforeExecuteObservable: Observable<Action>;
  10239. /**
  10240. * Creates a new Action
  10241. * @param triggerOptions the trigger, with or without parameters, for the action
  10242. * @param condition an optional determinant of action
  10243. */
  10244. constructor(
  10245. /** the trigger, with or without parameters, for the action */
  10246. triggerOptions: any, condition?: Condition);
  10247. /**
  10248. * Internal only
  10249. * @hidden
  10250. */
  10251. _prepare(): void;
  10252. /**
  10253. * Gets the trigger parameters
  10254. * @returns the trigger parameters
  10255. */
  10256. getTriggerParameter(): any;
  10257. /**
  10258. * Internal only - executes current action event
  10259. * @hidden
  10260. */
  10261. _executeCurrent(evt?: ActionEvent): void;
  10262. /**
  10263. * Execute placeholder for child classes
  10264. * @param evt optional action event
  10265. */
  10266. execute(evt?: ActionEvent): void;
  10267. /**
  10268. * Skips to next active action
  10269. */
  10270. skipToNextActiveAction(): void;
  10271. /**
  10272. * Adds action to chain of actions, may be a DoNothingAction
  10273. * @param action defines the next action to execute
  10274. * @returns The action passed in
  10275. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10276. */
  10277. then(action: Action): Action;
  10278. /**
  10279. * Internal only
  10280. * @hidden
  10281. */
  10282. _getProperty(propertyPath: string): string;
  10283. /**
  10284. * Internal only
  10285. * @hidden
  10286. */
  10287. _getEffectiveTarget(target: any, propertyPath: string): any;
  10288. /**
  10289. * Serialize placeholder for child classes
  10290. * @param parent of child
  10291. * @returns the serialized object
  10292. */
  10293. serialize(parent: any): any;
  10294. /**
  10295. * Internal only called by serialize
  10296. * @hidden
  10297. */
  10298. protected _serialize(serializedAction: any, parent?: any): any;
  10299. /**
  10300. * Internal only
  10301. * @hidden
  10302. */
  10303. static _SerializeValueAsString: (value: any) => string;
  10304. /**
  10305. * Internal only
  10306. * @hidden
  10307. */
  10308. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10309. name: string;
  10310. targetType: string;
  10311. value: string;
  10312. };
  10313. }
  10314. }
  10315. declare module "babylonjs/Actions/condition" {
  10316. import { ActionManager } from "babylonjs/Actions/actionManager";
  10317. /**
  10318. * A Condition applied to an Action
  10319. */
  10320. export class Condition {
  10321. /**
  10322. * Internal only - manager for action
  10323. * @hidden
  10324. */
  10325. _actionManager: ActionManager;
  10326. /**
  10327. * Internal only
  10328. * @hidden
  10329. */
  10330. _evaluationId: number;
  10331. /**
  10332. * Internal only
  10333. * @hidden
  10334. */
  10335. _currentResult: boolean;
  10336. /**
  10337. * Creates a new Condition
  10338. * @param actionManager the manager of the action the condition is applied to
  10339. */
  10340. constructor(actionManager: ActionManager);
  10341. /**
  10342. * Check if the current condition is valid
  10343. * @returns a boolean
  10344. */
  10345. isValid(): boolean;
  10346. /**
  10347. * Internal only
  10348. * @hidden
  10349. */
  10350. _getProperty(propertyPath: string): string;
  10351. /**
  10352. * Internal only
  10353. * @hidden
  10354. */
  10355. _getEffectiveTarget(target: any, propertyPath: string): any;
  10356. /**
  10357. * Serialize placeholder for child classes
  10358. * @returns the serialized object
  10359. */
  10360. serialize(): any;
  10361. /**
  10362. * Internal only
  10363. * @hidden
  10364. */
  10365. protected _serialize(serializedCondition: any): any;
  10366. }
  10367. /**
  10368. * Defines specific conditional operators as extensions of Condition
  10369. */
  10370. export class ValueCondition extends Condition {
  10371. /** path to specify the property of the target the conditional operator uses */
  10372. propertyPath: string;
  10373. /** the value compared by the conditional operator against the current value of the property */
  10374. value: any;
  10375. /** the conditional operator, default ValueCondition.IsEqual */
  10376. operator: number;
  10377. /**
  10378. * Internal only
  10379. * @hidden
  10380. */
  10381. private static _IsEqual;
  10382. /**
  10383. * Internal only
  10384. * @hidden
  10385. */
  10386. private static _IsDifferent;
  10387. /**
  10388. * Internal only
  10389. * @hidden
  10390. */
  10391. private static _IsGreater;
  10392. /**
  10393. * Internal only
  10394. * @hidden
  10395. */
  10396. private static _IsLesser;
  10397. /**
  10398. * returns the number for IsEqual
  10399. */
  10400. static readonly IsEqual: number;
  10401. /**
  10402. * Returns the number for IsDifferent
  10403. */
  10404. static readonly IsDifferent: number;
  10405. /**
  10406. * Returns the number for IsGreater
  10407. */
  10408. static readonly IsGreater: number;
  10409. /**
  10410. * Returns the number for IsLesser
  10411. */
  10412. static readonly IsLesser: number;
  10413. /**
  10414. * Internal only The action manager for the condition
  10415. * @hidden
  10416. */
  10417. _actionManager: ActionManager;
  10418. /**
  10419. * Internal only
  10420. * @hidden
  10421. */
  10422. private _target;
  10423. /**
  10424. * Internal only
  10425. * @hidden
  10426. */
  10427. private _effectiveTarget;
  10428. /**
  10429. * Internal only
  10430. * @hidden
  10431. */
  10432. private _property;
  10433. /**
  10434. * Creates a new ValueCondition
  10435. * @param actionManager manager for the action the condition applies to
  10436. * @param target for the action
  10437. * @param propertyPath path to specify the property of the target the conditional operator uses
  10438. * @param value the value compared by the conditional operator against the current value of the property
  10439. * @param operator the conditional operator, default ValueCondition.IsEqual
  10440. */
  10441. constructor(actionManager: ActionManager, target: any,
  10442. /** path to specify the property of the target the conditional operator uses */
  10443. propertyPath: string,
  10444. /** the value compared by the conditional operator against the current value of the property */
  10445. value: any,
  10446. /** the conditional operator, default ValueCondition.IsEqual */
  10447. operator?: number);
  10448. /**
  10449. * Compares the given value with the property value for the specified conditional operator
  10450. * @returns the result of the comparison
  10451. */
  10452. isValid(): boolean;
  10453. /**
  10454. * Serialize the ValueCondition into a JSON compatible object
  10455. * @returns serialization object
  10456. */
  10457. serialize(): any;
  10458. /**
  10459. * Gets the name of the conditional operator for the ValueCondition
  10460. * @param operator the conditional operator
  10461. * @returns the name
  10462. */
  10463. static GetOperatorName(operator: number): string;
  10464. }
  10465. /**
  10466. * Defines a predicate condition as an extension of Condition
  10467. */
  10468. export class PredicateCondition extends Condition {
  10469. /** defines the predicate function used to validate the condition */
  10470. predicate: () => boolean;
  10471. /**
  10472. * Internal only - manager for action
  10473. * @hidden
  10474. */
  10475. _actionManager: ActionManager;
  10476. /**
  10477. * Creates a new PredicateCondition
  10478. * @param actionManager manager for the action the condition applies to
  10479. * @param predicate defines the predicate function used to validate the condition
  10480. */
  10481. constructor(actionManager: ActionManager,
  10482. /** defines the predicate function used to validate the condition */
  10483. predicate: () => boolean);
  10484. /**
  10485. * @returns the validity of the predicate condition
  10486. */
  10487. isValid(): boolean;
  10488. }
  10489. /**
  10490. * Defines a state condition as an extension of Condition
  10491. */
  10492. export class StateCondition extends Condition {
  10493. /** Value to compare with target state */
  10494. value: string;
  10495. /**
  10496. * Internal only - manager for action
  10497. * @hidden
  10498. */
  10499. _actionManager: ActionManager;
  10500. /**
  10501. * Internal only
  10502. * @hidden
  10503. */
  10504. private _target;
  10505. /**
  10506. * Creates a new StateCondition
  10507. * @param actionManager manager for the action the condition applies to
  10508. * @param target of the condition
  10509. * @param value to compare with target state
  10510. */
  10511. constructor(actionManager: ActionManager, target: any,
  10512. /** Value to compare with target state */
  10513. value: string);
  10514. /**
  10515. * Gets a boolean indicating if the current condition is met
  10516. * @returns the validity of the state
  10517. */
  10518. isValid(): boolean;
  10519. /**
  10520. * Serialize the StateCondition into a JSON compatible object
  10521. * @returns serialization object
  10522. */
  10523. serialize(): any;
  10524. }
  10525. }
  10526. declare module "babylonjs/Actions/directActions" {
  10527. import { Action } from "babylonjs/Actions/action";
  10528. import { Condition } from "babylonjs/Actions/condition";
  10529. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10530. /**
  10531. * This defines an action responsible to toggle a boolean once triggered.
  10532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10533. */
  10534. export class SwitchBooleanAction extends Action {
  10535. /**
  10536. * The path to the boolean property in the target object
  10537. */
  10538. propertyPath: string;
  10539. private _target;
  10540. private _effectiveTarget;
  10541. private _property;
  10542. /**
  10543. * Instantiate the action
  10544. * @param triggerOptions defines the trigger options
  10545. * @param target defines the object containing the boolean
  10546. * @param propertyPath defines the path to the boolean property in the target object
  10547. * @param condition defines the trigger related conditions
  10548. */
  10549. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10550. /** @hidden */
  10551. _prepare(): void;
  10552. /**
  10553. * Execute the action toggle the boolean value.
  10554. */
  10555. execute(): void;
  10556. /**
  10557. * Serializes the actions and its related information.
  10558. * @param parent defines the object to serialize in
  10559. * @returns the serialized object
  10560. */
  10561. serialize(parent: any): any;
  10562. }
  10563. /**
  10564. * This defines an action responsible to set a the state field of the target
  10565. * to a desired value once triggered.
  10566. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10567. */
  10568. export class SetStateAction extends Action {
  10569. /**
  10570. * The value to store in the state field.
  10571. */
  10572. value: string;
  10573. private _target;
  10574. /**
  10575. * Instantiate the action
  10576. * @param triggerOptions defines the trigger options
  10577. * @param target defines the object containing the state property
  10578. * @param value defines the value to store in the state field
  10579. * @param condition defines the trigger related conditions
  10580. */
  10581. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10582. /**
  10583. * Execute the action and store the value on the target state property.
  10584. */
  10585. execute(): void;
  10586. /**
  10587. * Serializes the actions and its related information.
  10588. * @param parent defines the object to serialize in
  10589. * @returns the serialized object
  10590. */
  10591. serialize(parent: any): any;
  10592. }
  10593. /**
  10594. * This defines an action responsible to set a property of the target
  10595. * to a desired value once triggered.
  10596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10597. */
  10598. export class SetValueAction extends Action {
  10599. /**
  10600. * The path of the property to set in the target.
  10601. */
  10602. propertyPath: string;
  10603. /**
  10604. * The value to set in the property
  10605. */
  10606. value: any;
  10607. private _target;
  10608. private _effectiveTarget;
  10609. private _property;
  10610. /**
  10611. * Instantiate the action
  10612. * @param triggerOptions defines the trigger options
  10613. * @param target defines the object containing the property
  10614. * @param propertyPath defines the path of the property to set in the target
  10615. * @param value defines the value to set in the property
  10616. * @param condition defines the trigger related conditions
  10617. */
  10618. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10619. /** @hidden */
  10620. _prepare(): void;
  10621. /**
  10622. * Execute the action and set the targetted property to the desired value.
  10623. */
  10624. execute(): void;
  10625. /**
  10626. * Serializes the actions and its related information.
  10627. * @param parent defines the object to serialize in
  10628. * @returns the serialized object
  10629. */
  10630. serialize(parent: any): any;
  10631. }
  10632. /**
  10633. * This defines an action responsible to increment the target value
  10634. * to a desired value once triggered.
  10635. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10636. */
  10637. export class IncrementValueAction extends Action {
  10638. /**
  10639. * The path of the property to increment in the target.
  10640. */
  10641. propertyPath: string;
  10642. /**
  10643. * The value we should increment the property by.
  10644. */
  10645. value: any;
  10646. private _target;
  10647. private _effectiveTarget;
  10648. private _property;
  10649. /**
  10650. * Instantiate the action
  10651. * @param triggerOptions defines the trigger options
  10652. * @param target defines the object containing the property
  10653. * @param propertyPath defines the path of the property to increment in the target
  10654. * @param value defines the value value we should increment the property by
  10655. * @param condition defines the trigger related conditions
  10656. */
  10657. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10658. /** @hidden */
  10659. _prepare(): void;
  10660. /**
  10661. * Execute the action and increment the target of the value amount.
  10662. */
  10663. execute(): void;
  10664. /**
  10665. * Serializes the actions and its related information.
  10666. * @param parent defines the object to serialize in
  10667. * @returns the serialized object
  10668. */
  10669. serialize(parent: any): any;
  10670. }
  10671. /**
  10672. * This defines an action responsible to start an animation once triggered.
  10673. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10674. */
  10675. export class PlayAnimationAction extends Action {
  10676. /**
  10677. * Where the animation should start (animation frame)
  10678. */
  10679. from: number;
  10680. /**
  10681. * Where the animation should stop (animation frame)
  10682. */
  10683. to: number;
  10684. /**
  10685. * Define if the animation should loop or stop after the first play.
  10686. */
  10687. loop?: boolean;
  10688. private _target;
  10689. /**
  10690. * Instantiate the action
  10691. * @param triggerOptions defines the trigger options
  10692. * @param target defines the target animation or animation name
  10693. * @param from defines from where the animation should start (animation frame)
  10694. * @param end defines where the animation should stop (animation frame)
  10695. * @param loop defines if the animation should loop or stop after the first play
  10696. * @param condition defines the trigger related conditions
  10697. */
  10698. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10699. /** @hidden */
  10700. _prepare(): void;
  10701. /**
  10702. * Execute the action and play the animation.
  10703. */
  10704. execute(): void;
  10705. /**
  10706. * Serializes the actions and its related information.
  10707. * @param parent defines the object to serialize in
  10708. * @returns the serialized object
  10709. */
  10710. serialize(parent: any): any;
  10711. }
  10712. /**
  10713. * This defines an action responsible to stop an animation once triggered.
  10714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10715. */
  10716. export class StopAnimationAction extends Action {
  10717. private _target;
  10718. /**
  10719. * Instantiate the action
  10720. * @param triggerOptions defines the trigger options
  10721. * @param target defines the target animation or animation name
  10722. * @param condition defines the trigger related conditions
  10723. */
  10724. constructor(triggerOptions: any, target: any, condition?: Condition);
  10725. /** @hidden */
  10726. _prepare(): void;
  10727. /**
  10728. * Execute the action and stop the animation.
  10729. */
  10730. execute(): void;
  10731. /**
  10732. * Serializes the actions and its related information.
  10733. * @param parent defines the object to serialize in
  10734. * @returns the serialized object
  10735. */
  10736. serialize(parent: any): any;
  10737. }
  10738. /**
  10739. * This defines an action responsible that does nothing once triggered.
  10740. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10741. */
  10742. export class DoNothingAction extends Action {
  10743. /**
  10744. * Instantiate the action
  10745. * @param triggerOptions defines the trigger options
  10746. * @param condition defines the trigger related conditions
  10747. */
  10748. constructor(triggerOptions?: any, condition?: Condition);
  10749. /**
  10750. * Execute the action and do nothing.
  10751. */
  10752. execute(): void;
  10753. /**
  10754. * Serializes the actions and its related information.
  10755. * @param parent defines the object to serialize in
  10756. * @returns the serialized object
  10757. */
  10758. serialize(parent: any): any;
  10759. }
  10760. /**
  10761. * This defines an action responsible to trigger several actions once triggered.
  10762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10763. */
  10764. export class CombineAction extends Action {
  10765. /**
  10766. * The list of aggregated animations to run.
  10767. */
  10768. children: Action[];
  10769. /**
  10770. * Instantiate the action
  10771. * @param triggerOptions defines the trigger options
  10772. * @param children defines the list of aggregated animations to run
  10773. * @param condition defines the trigger related conditions
  10774. */
  10775. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10776. /** @hidden */
  10777. _prepare(): void;
  10778. /**
  10779. * Execute the action and executes all the aggregated actions.
  10780. */
  10781. execute(evt: ActionEvent): void;
  10782. /**
  10783. * Serializes the actions and its related information.
  10784. * @param parent defines the object to serialize in
  10785. * @returns the serialized object
  10786. */
  10787. serialize(parent: any): any;
  10788. }
  10789. /**
  10790. * This defines an action responsible to run code (external event) once triggered.
  10791. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10792. */
  10793. export class ExecuteCodeAction extends Action {
  10794. /**
  10795. * The callback function to run.
  10796. */
  10797. func: (evt: ActionEvent) => void;
  10798. /**
  10799. * Instantiate the action
  10800. * @param triggerOptions defines the trigger options
  10801. * @param func defines the callback function to run
  10802. * @param condition defines the trigger related conditions
  10803. */
  10804. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10805. /**
  10806. * Execute the action and run the attached code.
  10807. */
  10808. execute(evt: ActionEvent): void;
  10809. }
  10810. /**
  10811. * This defines an action responsible to set the parent property of the target once triggered.
  10812. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10813. */
  10814. export class SetParentAction extends Action {
  10815. private _parent;
  10816. private _target;
  10817. /**
  10818. * Instantiate the action
  10819. * @param triggerOptions defines the trigger options
  10820. * @param target defines the target containing the parent property
  10821. * @param parent defines from where the animation should start (animation frame)
  10822. * @param condition defines the trigger related conditions
  10823. */
  10824. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10825. /** @hidden */
  10826. _prepare(): void;
  10827. /**
  10828. * Execute the action and set the parent property.
  10829. */
  10830. execute(): void;
  10831. /**
  10832. * Serializes the actions and its related information.
  10833. * @param parent defines the object to serialize in
  10834. * @returns the serialized object
  10835. */
  10836. serialize(parent: any): any;
  10837. }
  10838. }
  10839. declare module "babylonjs/Actions/actionManager" {
  10840. import { Nullable } from "babylonjs/types";
  10841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10842. import { Scene } from "babylonjs/scene";
  10843. import { IAction } from "babylonjs/Actions/action";
  10844. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10845. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10846. /**
  10847. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10848. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10849. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10850. */
  10851. export class ActionManager extends AbstractActionManager {
  10852. /**
  10853. * Nothing
  10854. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10855. */
  10856. static readonly NothingTrigger: number;
  10857. /**
  10858. * On pick
  10859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10860. */
  10861. static readonly OnPickTrigger: number;
  10862. /**
  10863. * On left pick
  10864. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10865. */
  10866. static readonly OnLeftPickTrigger: number;
  10867. /**
  10868. * On right pick
  10869. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10870. */
  10871. static readonly OnRightPickTrigger: number;
  10872. /**
  10873. * On center pick
  10874. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10875. */
  10876. static readonly OnCenterPickTrigger: number;
  10877. /**
  10878. * On pick down
  10879. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10880. */
  10881. static readonly OnPickDownTrigger: number;
  10882. /**
  10883. * On double pick
  10884. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10885. */
  10886. static readonly OnDoublePickTrigger: number;
  10887. /**
  10888. * On pick up
  10889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10890. */
  10891. static readonly OnPickUpTrigger: number;
  10892. /**
  10893. * On pick out.
  10894. * This trigger will only be raised if you also declared a OnPickDown
  10895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10896. */
  10897. static readonly OnPickOutTrigger: number;
  10898. /**
  10899. * On long press
  10900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10901. */
  10902. static readonly OnLongPressTrigger: number;
  10903. /**
  10904. * On pointer over
  10905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10906. */
  10907. static readonly OnPointerOverTrigger: number;
  10908. /**
  10909. * On pointer out
  10910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10911. */
  10912. static readonly OnPointerOutTrigger: number;
  10913. /**
  10914. * On every frame
  10915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10916. */
  10917. static readonly OnEveryFrameTrigger: number;
  10918. /**
  10919. * On intersection enter
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10921. */
  10922. static readonly OnIntersectionEnterTrigger: number;
  10923. /**
  10924. * On intersection exit
  10925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10926. */
  10927. static readonly OnIntersectionExitTrigger: number;
  10928. /**
  10929. * On key down
  10930. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10931. */
  10932. static readonly OnKeyDownTrigger: number;
  10933. /**
  10934. * On key up
  10935. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10936. */
  10937. static readonly OnKeyUpTrigger: number;
  10938. private _scene;
  10939. /**
  10940. * Creates a new action manager
  10941. * @param scene defines the hosting scene
  10942. */
  10943. constructor(scene: Scene);
  10944. /**
  10945. * Releases all associated resources
  10946. */
  10947. dispose(): void;
  10948. /**
  10949. * Gets hosting scene
  10950. * @returns the hosting scene
  10951. */
  10952. getScene(): Scene;
  10953. /**
  10954. * Does this action manager handles actions of any of the given triggers
  10955. * @param triggers defines the triggers to be tested
  10956. * @return a boolean indicating whether one (or more) of the triggers is handled
  10957. */
  10958. hasSpecificTriggers(triggers: number[]): boolean;
  10959. /**
  10960. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10961. * speed.
  10962. * @param triggerA defines the trigger to be tested
  10963. * @param triggerB defines the trigger to be tested
  10964. * @return a boolean indicating whether one (or more) of the triggers is handled
  10965. */
  10966. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10967. /**
  10968. * Does this action manager handles actions of a given trigger
  10969. * @param trigger defines the trigger to be tested
  10970. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10971. * @return whether the trigger is handled
  10972. */
  10973. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10974. /**
  10975. * Does this action manager has pointer triggers
  10976. */
  10977. readonly hasPointerTriggers: boolean;
  10978. /**
  10979. * Does this action manager has pick triggers
  10980. */
  10981. readonly hasPickTriggers: boolean;
  10982. /**
  10983. * Registers an action to this action manager
  10984. * @param action defines the action to be registered
  10985. * @return the action amended (prepared) after registration
  10986. */
  10987. registerAction(action: IAction): Nullable<IAction>;
  10988. /**
  10989. * Unregisters an action to this action manager
  10990. * @param action defines the action to be unregistered
  10991. * @return a boolean indicating whether the action has been unregistered
  10992. */
  10993. unregisterAction(action: IAction): Boolean;
  10994. /**
  10995. * Process a specific trigger
  10996. * @param trigger defines the trigger to process
  10997. * @param evt defines the event details to be processed
  10998. */
  10999. processTrigger(trigger: number, evt?: IActionEvent): void;
  11000. /** @hidden */
  11001. _getEffectiveTarget(target: any, propertyPath: string): any;
  11002. /** @hidden */
  11003. _getProperty(propertyPath: string): string;
  11004. /**
  11005. * Serialize this manager to a JSON object
  11006. * @param name defines the property name to store this manager
  11007. * @returns a JSON representation of this manager
  11008. */
  11009. serialize(name: string): any;
  11010. /**
  11011. * Creates a new ActionManager from a JSON data
  11012. * @param parsedActions defines the JSON data to read from
  11013. * @param object defines the hosting mesh
  11014. * @param scene defines the hosting scene
  11015. */
  11016. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11017. /**
  11018. * Get a trigger name by index
  11019. * @param trigger defines the trigger index
  11020. * @returns a trigger name
  11021. */
  11022. static GetTriggerName(trigger: number): string;
  11023. }
  11024. }
  11025. declare module "babylonjs/Culling/ray" {
  11026. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11027. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11028. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11029. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11030. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11031. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11032. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11033. import { Plane } from "babylonjs/Maths/math.plane";
  11034. /**
  11035. * Class representing a ray with position and direction
  11036. */
  11037. export class Ray {
  11038. /** origin point */
  11039. origin: Vector3;
  11040. /** direction */
  11041. direction: Vector3;
  11042. /** length of the ray */
  11043. length: number;
  11044. private static readonly TmpVector3;
  11045. private _tmpRay;
  11046. /**
  11047. * Creates a new ray
  11048. * @param origin origin point
  11049. * @param direction direction
  11050. * @param length length of the ray
  11051. */
  11052. constructor(
  11053. /** origin point */
  11054. origin: Vector3,
  11055. /** direction */
  11056. direction: Vector3,
  11057. /** length of the ray */
  11058. length?: number);
  11059. /**
  11060. * Checks if the ray intersects a box
  11061. * @param minimum bound of the box
  11062. * @param maximum bound of the box
  11063. * @param intersectionTreshold extra extend to be added to the box in all direction
  11064. * @returns if the box was hit
  11065. */
  11066. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11067. /**
  11068. * Checks if the ray intersects a box
  11069. * @param box the bounding box to check
  11070. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11071. * @returns if the box was hit
  11072. */
  11073. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11074. /**
  11075. * If the ray hits a sphere
  11076. * @param sphere the bounding sphere to check
  11077. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11078. * @returns true if it hits the sphere
  11079. */
  11080. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11081. /**
  11082. * If the ray hits a triange
  11083. * @param vertex0 triangle vertex
  11084. * @param vertex1 triangle vertex
  11085. * @param vertex2 triangle vertex
  11086. * @returns intersection information if hit
  11087. */
  11088. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11089. /**
  11090. * Checks if ray intersects a plane
  11091. * @param plane the plane to check
  11092. * @returns the distance away it was hit
  11093. */
  11094. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11095. /**
  11096. * Calculate the intercept of a ray on a given axis
  11097. * @param axis to check 'x' | 'y' | 'z'
  11098. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11099. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11100. */
  11101. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11102. /**
  11103. * Checks if ray intersects a mesh
  11104. * @param mesh the mesh to check
  11105. * @param fastCheck if only the bounding box should checked
  11106. * @returns picking info of the intersecton
  11107. */
  11108. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11109. /**
  11110. * Checks if ray intersects a mesh
  11111. * @param meshes the meshes to check
  11112. * @param fastCheck if only the bounding box should checked
  11113. * @param results array to store result in
  11114. * @returns Array of picking infos
  11115. */
  11116. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11117. private _comparePickingInfo;
  11118. private static smallnum;
  11119. private static rayl;
  11120. /**
  11121. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11122. * @param sega the first point of the segment to test the intersection against
  11123. * @param segb the second point of the segment to test the intersection against
  11124. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11125. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11126. */
  11127. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11128. /**
  11129. * Update the ray from viewport position
  11130. * @param x position
  11131. * @param y y position
  11132. * @param viewportWidth viewport width
  11133. * @param viewportHeight viewport height
  11134. * @param world world matrix
  11135. * @param view view matrix
  11136. * @param projection projection matrix
  11137. * @returns this ray updated
  11138. */
  11139. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11140. /**
  11141. * Creates a ray with origin and direction of 0,0,0
  11142. * @returns the new ray
  11143. */
  11144. static Zero(): Ray;
  11145. /**
  11146. * Creates a new ray from screen space and viewport
  11147. * @param x position
  11148. * @param y y position
  11149. * @param viewportWidth viewport width
  11150. * @param viewportHeight viewport height
  11151. * @param world world matrix
  11152. * @param view view matrix
  11153. * @param projection projection matrix
  11154. * @returns new ray
  11155. */
  11156. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11157. /**
  11158. * 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
  11159. * transformed to the given world matrix.
  11160. * @param origin The origin point
  11161. * @param end The end point
  11162. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11163. * @returns the new ray
  11164. */
  11165. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11166. /**
  11167. * Transforms a ray by a matrix
  11168. * @param ray ray to transform
  11169. * @param matrix matrix to apply
  11170. * @returns the resulting new ray
  11171. */
  11172. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11173. /**
  11174. * Transforms a ray by a matrix
  11175. * @param ray ray to transform
  11176. * @param matrix matrix to apply
  11177. * @param result ray to store result in
  11178. */
  11179. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11180. /**
  11181. * Unproject a ray from screen space to object space
  11182. * @param sourceX defines the screen space x coordinate to use
  11183. * @param sourceY defines the screen space y coordinate to use
  11184. * @param viewportWidth defines the current width of the viewport
  11185. * @param viewportHeight defines the current height of the viewport
  11186. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11187. * @param view defines the view matrix to use
  11188. * @param projection defines the projection matrix to use
  11189. */
  11190. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11191. }
  11192. /**
  11193. * Type used to define predicate used to select faces when a mesh intersection is detected
  11194. */
  11195. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11196. module "babylonjs/scene" {
  11197. interface Scene {
  11198. /** @hidden */
  11199. _tempPickingRay: Nullable<Ray>;
  11200. /** @hidden */
  11201. _cachedRayForTransform: Ray;
  11202. /** @hidden */
  11203. _pickWithRayInverseMatrix: Matrix;
  11204. /** @hidden */
  11205. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11206. /** @hidden */
  11207. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11208. }
  11209. }
  11210. }
  11211. declare module "babylonjs/sceneComponent" {
  11212. import { Scene } from "babylonjs/scene";
  11213. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11214. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11215. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11216. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11217. import { Nullable } from "babylonjs/types";
  11218. import { Camera } from "babylonjs/Cameras/camera";
  11219. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11220. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11221. import { AbstractScene } from "babylonjs/abstractScene";
  11222. /**
  11223. * Groups all the scene component constants in one place to ease maintenance.
  11224. * @hidden
  11225. */
  11226. export class SceneComponentConstants {
  11227. static readonly NAME_EFFECTLAYER: string;
  11228. static readonly NAME_LAYER: string;
  11229. static readonly NAME_LENSFLARESYSTEM: string;
  11230. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11231. static readonly NAME_PARTICLESYSTEM: string;
  11232. static readonly NAME_GAMEPAD: string;
  11233. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11234. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11235. static readonly NAME_DEPTHRENDERER: string;
  11236. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11237. static readonly NAME_SPRITE: string;
  11238. static readonly NAME_OUTLINERENDERER: string;
  11239. static readonly NAME_PROCEDURALTEXTURE: string;
  11240. static readonly NAME_SHADOWGENERATOR: string;
  11241. static readonly NAME_OCTREE: string;
  11242. static readonly NAME_PHYSICSENGINE: string;
  11243. static readonly NAME_AUDIO: string;
  11244. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11245. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11246. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11247. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11248. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11249. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11250. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11251. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11252. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11253. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11254. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11255. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11256. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11257. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11258. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11259. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11260. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11261. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11262. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11263. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11264. static readonly STEP_AFTERRENDER_AUDIO: number;
  11265. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11266. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11267. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11268. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11269. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11270. static readonly STEP_POINTERMOVE_SPRITE: number;
  11271. static readonly STEP_POINTERDOWN_SPRITE: number;
  11272. static readonly STEP_POINTERUP_SPRITE: number;
  11273. }
  11274. /**
  11275. * This represents a scene component.
  11276. *
  11277. * This is used to decouple the dependency the scene is having on the different workloads like
  11278. * layers, post processes...
  11279. */
  11280. export interface ISceneComponent {
  11281. /**
  11282. * The name of the component. Each component must have a unique name.
  11283. */
  11284. name: string;
  11285. /**
  11286. * The scene the component belongs to.
  11287. */
  11288. scene: Scene;
  11289. /**
  11290. * Register the component to one instance of a scene.
  11291. */
  11292. register(): void;
  11293. /**
  11294. * Rebuilds the elements related to this component in case of
  11295. * context lost for instance.
  11296. */
  11297. rebuild(): void;
  11298. /**
  11299. * Disposes the component and the associated ressources.
  11300. */
  11301. dispose(): void;
  11302. }
  11303. /**
  11304. * This represents a SERIALIZABLE scene component.
  11305. *
  11306. * This extends Scene Component to add Serialization methods on top.
  11307. */
  11308. export interface ISceneSerializableComponent extends ISceneComponent {
  11309. /**
  11310. * Adds all the elements from the container to the scene
  11311. * @param container the container holding the elements
  11312. */
  11313. addFromContainer(container: AbstractScene): void;
  11314. /**
  11315. * Removes all the elements in the container from the scene
  11316. * @param container contains the elements to remove
  11317. * @param dispose if the removed element should be disposed (default: false)
  11318. */
  11319. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11320. /**
  11321. * Serializes the component data to the specified json object
  11322. * @param serializationObject The object to serialize to
  11323. */
  11324. serialize(serializationObject: any): void;
  11325. }
  11326. /**
  11327. * Strong typing of a Mesh related stage step action
  11328. */
  11329. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11330. /**
  11331. * Strong typing of a Evaluate Sub Mesh related stage step action
  11332. */
  11333. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11334. /**
  11335. * Strong typing of a Active Mesh related stage step action
  11336. */
  11337. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11338. /**
  11339. * Strong typing of a Camera related stage step action
  11340. */
  11341. export type CameraStageAction = (camera: Camera) => void;
  11342. /**
  11343. * Strong typing of a Camera Frame buffer related stage step action
  11344. */
  11345. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11346. /**
  11347. * Strong typing of a Render Target related stage step action
  11348. */
  11349. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11350. /**
  11351. * Strong typing of a RenderingGroup related stage step action
  11352. */
  11353. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11354. /**
  11355. * Strong typing of a Mesh Render related stage step action
  11356. */
  11357. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11358. /**
  11359. * Strong typing of a simple stage step action
  11360. */
  11361. export type SimpleStageAction = () => void;
  11362. /**
  11363. * Strong typing of a render target action.
  11364. */
  11365. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11366. /**
  11367. * Strong typing of a pointer move action.
  11368. */
  11369. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11370. /**
  11371. * Strong typing of a pointer up/down action.
  11372. */
  11373. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11374. /**
  11375. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11376. * @hidden
  11377. */
  11378. export class Stage<T extends Function> extends Array<{
  11379. index: number;
  11380. component: ISceneComponent;
  11381. action: T;
  11382. }> {
  11383. /**
  11384. * Hide ctor from the rest of the world.
  11385. * @param items The items to add.
  11386. */
  11387. private constructor();
  11388. /**
  11389. * Creates a new Stage.
  11390. * @returns A new instance of a Stage
  11391. */
  11392. static Create<T extends Function>(): Stage<T>;
  11393. /**
  11394. * Registers a step in an ordered way in the targeted stage.
  11395. * @param index Defines the position to register the step in
  11396. * @param component Defines the component attached to the step
  11397. * @param action Defines the action to launch during the step
  11398. */
  11399. registerStep(index: number, component: ISceneComponent, action: T): void;
  11400. /**
  11401. * Clears all the steps from the stage.
  11402. */
  11403. clear(): void;
  11404. }
  11405. }
  11406. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11407. import { Nullable } from "babylonjs/types";
  11408. import { Observable } from "babylonjs/Misc/observable";
  11409. import { Scene } from "babylonjs/scene";
  11410. import { Sprite } from "babylonjs/Sprites/sprite";
  11411. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11412. import { Ray } from "babylonjs/Culling/ray";
  11413. import { Camera } from "babylonjs/Cameras/camera";
  11414. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11415. import { ISceneComponent } from "babylonjs/sceneComponent";
  11416. module "babylonjs/scene" {
  11417. interface Scene {
  11418. /** @hidden */
  11419. _pointerOverSprite: Nullable<Sprite>;
  11420. /** @hidden */
  11421. _pickedDownSprite: Nullable<Sprite>;
  11422. /** @hidden */
  11423. _tempSpritePickingRay: Nullable<Ray>;
  11424. /**
  11425. * All of the sprite managers added to this scene
  11426. * @see http://doc.babylonjs.com/babylon101/sprites
  11427. */
  11428. spriteManagers: Array<ISpriteManager>;
  11429. /**
  11430. * An event triggered when sprites rendering is about to start
  11431. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11432. */
  11433. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11434. /**
  11435. * An event triggered when sprites rendering is done
  11436. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11437. */
  11438. onAfterSpritesRenderingObservable: Observable<Scene>;
  11439. /** @hidden */
  11440. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11441. /** Launch a ray to try to pick a sprite in the scene
  11442. * @param x position on screen
  11443. * @param y position on screen
  11444. * @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
  11445. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11446. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11447. * @returns a PickingInfo
  11448. */
  11449. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11450. /** Use the given ray to pick a sprite in the scene
  11451. * @param ray The ray (in world space) to use to pick meshes
  11452. * @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
  11453. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11454. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11455. * @returns a PickingInfo
  11456. */
  11457. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11458. /** @hidden */
  11459. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11460. /** Launch a ray to try to pick sprites in the scene
  11461. * @param x position on screen
  11462. * @param y position on screen
  11463. * @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
  11464. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11465. * @returns a PickingInfo array
  11466. */
  11467. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11468. /** Use the given ray to pick sprites in the scene
  11469. * @param ray The ray (in world space) to use to pick meshes
  11470. * @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
  11471. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11472. * @returns a PickingInfo array
  11473. */
  11474. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11475. /**
  11476. * Force the sprite under the pointer
  11477. * @param sprite defines the sprite to use
  11478. */
  11479. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11480. /**
  11481. * Gets the sprite under the pointer
  11482. * @returns a Sprite or null if no sprite is under the pointer
  11483. */
  11484. getPointerOverSprite(): Nullable<Sprite>;
  11485. }
  11486. }
  11487. /**
  11488. * Defines the sprite scene component responsible to manage sprites
  11489. * in a given scene.
  11490. */
  11491. export class SpriteSceneComponent implements ISceneComponent {
  11492. /**
  11493. * The component name helpfull to identify the component in the list of scene components.
  11494. */
  11495. readonly name: string;
  11496. /**
  11497. * The scene the component belongs to.
  11498. */
  11499. scene: Scene;
  11500. /** @hidden */
  11501. private _spritePredicate;
  11502. /**
  11503. * Creates a new instance of the component for the given scene
  11504. * @param scene Defines the scene to register the component in
  11505. */
  11506. constructor(scene: Scene);
  11507. /**
  11508. * Registers the component in a given scene
  11509. */
  11510. register(): void;
  11511. /**
  11512. * Rebuilds the elements related to this component in case of
  11513. * context lost for instance.
  11514. */
  11515. rebuild(): void;
  11516. /**
  11517. * Disposes the component and the associated ressources.
  11518. */
  11519. dispose(): void;
  11520. private _pickSpriteButKeepRay;
  11521. private _pointerMove;
  11522. private _pointerDown;
  11523. private _pointerUp;
  11524. }
  11525. }
  11526. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11527. /** @hidden */
  11528. export var fogFragmentDeclaration: {
  11529. name: string;
  11530. shader: string;
  11531. };
  11532. }
  11533. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11534. /** @hidden */
  11535. export var fogFragment: {
  11536. name: string;
  11537. shader: string;
  11538. };
  11539. }
  11540. declare module "babylonjs/Shaders/sprites.fragment" {
  11541. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11542. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11543. /** @hidden */
  11544. export var spritesPixelShader: {
  11545. name: string;
  11546. shader: string;
  11547. };
  11548. }
  11549. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11550. /** @hidden */
  11551. export var fogVertexDeclaration: {
  11552. name: string;
  11553. shader: string;
  11554. };
  11555. }
  11556. declare module "babylonjs/Shaders/sprites.vertex" {
  11557. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11558. /** @hidden */
  11559. export var spritesVertexShader: {
  11560. name: string;
  11561. shader: string;
  11562. };
  11563. }
  11564. declare module "babylonjs/Sprites/spriteManager" {
  11565. import { IDisposable, Scene } from "babylonjs/scene";
  11566. import { Nullable } from "babylonjs/types";
  11567. import { Observable } from "babylonjs/Misc/observable";
  11568. import { Sprite } from "babylonjs/Sprites/sprite";
  11569. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11570. import { Camera } from "babylonjs/Cameras/camera";
  11571. import { Texture } from "babylonjs/Materials/Textures/texture";
  11572. import "babylonjs/Shaders/sprites.fragment";
  11573. import "babylonjs/Shaders/sprites.vertex";
  11574. import { Ray } from "babylonjs/Culling/ray";
  11575. /**
  11576. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11577. */
  11578. export interface ISpriteManager extends IDisposable {
  11579. /**
  11580. * Restricts the camera to viewing objects with the same layerMask.
  11581. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11582. */
  11583. layerMask: number;
  11584. /**
  11585. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11586. */
  11587. isPickable: boolean;
  11588. /**
  11589. * Specifies the rendering group id for this mesh (0 by default)
  11590. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11591. */
  11592. renderingGroupId: number;
  11593. /**
  11594. * Defines the list of sprites managed by the manager.
  11595. */
  11596. sprites: Array<Sprite>;
  11597. /**
  11598. * Tests the intersection of a sprite with a specific ray.
  11599. * @param ray The ray we are sending to test the collision
  11600. * @param camera The camera space we are sending rays in
  11601. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11602. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11603. * @returns picking info or null.
  11604. */
  11605. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11606. /**
  11607. * Intersects the sprites with a ray
  11608. * @param ray defines the ray to intersect with
  11609. * @param camera defines the current active camera
  11610. * @param predicate defines a predicate used to select candidate sprites
  11611. * @returns null if no hit or a PickingInfo array
  11612. */
  11613. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11614. /**
  11615. * Renders the list of sprites on screen.
  11616. */
  11617. render(): void;
  11618. }
  11619. /**
  11620. * Class used to manage multiple sprites on the same spritesheet
  11621. * @see http://doc.babylonjs.com/babylon101/sprites
  11622. */
  11623. export class SpriteManager implements ISpriteManager {
  11624. /** defines the manager's name */
  11625. name: string;
  11626. /** Gets the list of sprites */
  11627. sprites: Sprite[];
  11628. /** Gets or sets the rendering group id (0 by default) */
  11629. renderingGroupId: number;
  11630. /** Gets or sets camera layer mask */
  11631. layerMask: number;
  11632. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11633. fogEnabled: boolean;
  11634. /** Gets or sets a boolean indicating if the sprites are pickable */
  11635. isPickable: boolean;
  11636. /** Defines the default width of a cell in the spritesheet */
  11637. cellWidth: number;
  11638. /** Defines the default height of a cell in the spritesheet */
  11639. cellHeight: number;
  11640. /** Associative array from JSON sprite data file */
  11641. private _cellData;
  11642. /** Array of sprite names from JSON sprite data file */
  11643. private _spriteMap;
  11644. /** True when packed cell data from JSON file is ready*/
  11645. private _packedAndReady;
  11646. /**
  11647. * An event triggered when the manager is disposed.
  11648. */
  11649. onDisposeObservable: Observable<SpriteManager>;
  11650. private _onDisposeObserver;
  11651. /**
  11652. * Callback called when the manager is disposed
  11653. */
  11654. onDispose: () => void;
  11655. private _capacity;
  11656. private _fromPacked;
  11657. private _spriteTexture;
  11658. private _epsilon;
  11659. private _scene;
  11660. private _vertexData;
  11661. private _buffer;
  11662. private _vertexBuffers;
  11663. private _indexBuffer;
  11664. private _effectBase;
  11665. private _effectFog;
  11666. /**
  11667. * Gets or sets the spritesheet texture
  11668. */
  11669. texture: Texture;
  11670. /**
  11671. * Creates a new sprite manager
  11672. * @param name defines the manager's name
  11673. * @param imgUrl defines the sprite sheet url
  11674. * @param capacity defines the maximum allowed number of sprites
  11675. * @param cellSize defines the size of a sprite cell
  11676. * @param scene defines the hosting scene
  11677. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11678. * @param samplingMode defines the smapling mode to use with spritesheet
  11679. * @param fromPacked set to false; do not alter
  11680. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11681. */
  11682. constructor(
  11683. /** defines the manager's name */
  11684. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11685. private _makePacked;
  11686. private _appendSpriteVertex;
  11687. /**
  11688. * Intersects the sprites with a ray
  11689. * @param ray defines the ray to intersect with
  11690. * @param camera defines the current active camera
  11691. * @param predicate defines a predicate used to select candidate sprites
  11692. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11693. * @returns null if no hit or a PickingInfo
  11694. */
  11695. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11696. /**
  11697. * Intersects the sprites with a ray
  11698. * @param ray defines the ray to intersect with
  11699. * @param camera defines the current active camera
  11700. * @param predicate defines a predicate used to select candidate sprites
  11701. * @returns null if no hit or a PickingInfo array
  11702. */
  11703. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11704. /**
  11705. * Render all child sprites
  11706. */
  11707. render(): void;
  11708. /**
  11709. * Release associated resources
  11710. */
  11711. dispose(): void;
  11712. }
  11713. }
  11714. declare module "babylonjs/Sprites/sprite" {
  11715. import { Vector3 } from "babylonjs/Maths/math.vector";
  11716. import { Nullable } from "babylonjs/types";
  11717. import { ActionManager } from "babylonjs/Actions/actionManager";
  11718. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11719. import { Color4 } from "babylonjs/Maths/math.color";
  11720. /**
  11721. * Class used to represent a sprite
  11722. * @see http://doc.babylonjs.com/babylon101/sprites
  11723. */
  11724. export class Sprite {
  11725. /** defines the name */
  11726. name: string;
  11727. /** Gets or sets the current world position */
  11728. position: Vector3;
  11729. /** Gets or sets the main color */
  11730. color: Color4;
  11731. /** Gets or sets the width */
  11732. width: number;
  11733. /** Gets or sets the height */
  11734. height: number;
  11735. /** Gets or sets rotation angle */
  11736. angle: number;
  11737. /** Gets or sets the cell index in the sprite sheet */
  11738. cellIndex: number;
  11739. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11740. cellRef: string;
  11741. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11742. invertU: number;
  11743. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11744. invertV: number;
  11745. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11746. disposeWhenFinishedAnimating: boolean;
  11747. /** Gets the list of attached animations */
  11748. animations: Animation[];
  11749. /** Gets or sets a boolean indicating if the sprite can be picked */
  11750. isPickable: boolean;
  11751. /**
  11752. * Gets or sets the associated action manager
  11753. */
  11754. actionManager: Nullable<ActionManager>;
  11755. private _animationStarted;
  11756. private _loopAnimation;
  11757. private _fromIndex;
  11758. private _toIndex;
  11759. private _delay;
  11760. private _direction;
  11761. private _manager;
  11762. private _time;
  11763. private _onAnimationEnd;
  11764. /**
  11765. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11766. */
  11767. isVisible: boolean;
  11768. /**
  11769. * Gets or sets the sprite size
  11770. */
  11771. size: number;
  11772. /**
  11773. * Creates a new Sprite
  11774. * @param name defines the name
  11775. * @param manager defines the manager
  11776. */
  11777. constructor(
  11778. /** defines the name */
  11779. name: string, manager: ISpriteManager);
  11780. /**
  11781. * Starts an animation
  11782. * @param from defines the initial key
  11783. * @param to defines the end key
  11784. * @param loop defines if the animation must loop
  11785. * @param delay defines the start delay (in ms)
  11786. * @param onAnimationEnd defines a callback to call when animation ends
  11787. */
  11788. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11789. /** Stops current animation (if any) */
  11790. stopAnimation(): void;
  11791. /** @hidden */
  11792. _animate(deltaTime: number): void;
  11793. /** Release associated resources */
  11794. dispose(): void;
  11795. }
  11796. }
  11797. declare module "babylonjs/Collisions/pickingInfo" {
  11798. import { Nullable } from "babylonjs/types";
  11799. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11801. import { Sprite } from "babylonjs/Sprites/sprite";
  11802. import { Ray } from "babylonjs/Culling/ray";
  11803. /**
  11804. * Information about the result of picking within a scene
  11805. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11806. */
  11807. export class PickingInfo {
  11808. /** @hidden */
  11809. _pickingUnavailable: boolean;
  11810. /**
  11811. * If the pick collided with an object
  11812. */
  11813. hit: boolean;
  11814. /**
  11815. * Distance away where the pick collided
  11816. */
  11817. distance: number;
  11818. /**
  11819. * The location of pick collision
  11820. */
  11821. pickedPoint: Nullable<Vector3>;
  11822. /**
  11823. * The mesh corresponding the the pick collision
  11824. */
  11825. pickedMesh: Nullable<AbstractMesh>;
  11826. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11827. bu: number;
  11828. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11829. bv: number;
  11830. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11831. faceId: number;
  11832. /** Id of the the submesh that was picked */
  11833. subMeshId: number;
  11834. /** If a sprite was picked, this will be the sprite the pick collided with */
  11835. pickedSprite: Nullable<Sprite>;
  11836. /**
  11837. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11838. */
  11839. originMesh: Nullable<AbstractMesh>;
  11840. /**
  11841. * The ray that was used to perform the picking.
  11842. */
  11843. ray: Nullable<Ray>;
  11844. /**
  11845. * Gets the normal correspodning to the face the pick collided with
  11846. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11847. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11848. * @returns The normal correspodning to the face the pick collided with
  11849. */
  11850. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11851. /**
  11852. * Gets the texture coordinates of where the pick occured
  11853. * @returns the vector containing the coordnates of the texture
  11854. */
  11855. getTextureCoordinates(): Nullable<Vector2>;
  11856. }
  11857. }
  11858. declare module "babylonjs/Events/pointerEvents" {
  11859. import { Nullable } from "babylonjs/types";
  11860. import { Vector2 } from "babylonjs/Maths/math.vector";
  11861. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11862. import { Ray } from "babylonjs/Culling/ray";
  11863. /**
  11864. * Gather the list of pointer event types as constants.
  11865. */
  11866. export class PointerEventTypes {
  11867. /**
  11868. * 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.
  11869. */
  11870. static readonly POINTERDOWN: number;
  11871. /**
  11872. * The pointerup event is fired when a pointer is no longer active.
  11873. */
  11874. static readonly POINTERUP: number;
  11875. /**
  11876. * The pointermove event is fired when a pointer changes coordinates.
  11877. */
  11878. static readonly POINTERMOVE: number;
  11879. /**
  11880. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11881. */
  11882. static readonly POINTERWHEEL: number;
  11883. /**
  11884. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11885. */
  11886. static readonly POINTERPICK: number;
  11887. /**
  11888. * The pointertap event is fired when a the object has been touched and released without drag.
  11889. */
  11890. static readonly POINTERTAP: number;
  11891. /**
  11892. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11893. */
  11894. static readonly POINTERDOUBLETAP: number;
  11895. }
  11896. /**
  11897. * Base class of pointer info types.
  11898. */
  11899. export class PointerInfoBase {
  11900. /**
  11901. * Defines the type of event (PointerEventTypes)
  11902. */
  11903. type: number;
  11904. /**
  11905. * Defines the related dom event
  11906. */
  11907. event: PointerEvent | MouseWheelEvent;
  11908. /**
  11909. * Instantiates the base class of pointers info.
  11910. * @param type Defines the type of event (PointerEventTypes)
  11911. * @param event Defines the related dom event
  11912. */
  11913. constructor(
  11914. /**
  11915. * Defines the type of event (PointerEventTypes)
  11916. */
  11917. type: number,
  11918. /**
  11919. * Defines the related dom event
  11920. */
  11921. event: PointerEvent | MouseWheelEvent);
  11922. }
  11923. /**
  11924. * This class is used to store pointer related info for the onPrePointerObservable event.
  11925. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11926. */
  11927. export class PointerInfoPre extends PointerInfoBase {
  11928. /**
  11929. * Ray from a pointer if availible (eg. 6dof controller)
  11930. */
  11931. ray: Nullable<Ray>;
  11932. /**
  11933. * Defines the local position of the pointer on the canvas.
  11934. */
  11935. localPosition: Vector2;
  11936. /**
  11937. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11938. */
  11939. skipOnPointerObservable: boolean;
  11940. /**
  11941. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11942. * @param type Defines the type of event (PointerEventTypes)
  11943. * @param event Defines the related dom event
  11944. * @param localX Defines the local x coordinates of the pointer when the event occured
  11945. * @param localY Defines the local y coordinates of the pointer when the event occured
  11946. */
  11947. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11948. }
  11949. /**
  11950. * This type contains all the data related to a pointer event in Babylon.js.
  11951. * 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.
  11952. */
  11953. export class PointerInfo extends PointerInfoBase {
  11954. /**
  11955. * Defines the picking info associated to the info (if any)\
  11956. */
  11957. pickInfo: Nullable<PickingInfo>;
  11958. /**
  11959. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11960. * @param type Defines the type of event (PointerEventTypes)
  11961. * @param event Defines the related dom event
  11962. * @param pickInfo Defines the picking info associated to the info (if any)\
  11963. */
  11964. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11965. /**
  11966. * Defines the picking info associated to the info (if any)\
  11967. */
  11968. pickInfo: Nullable<PickingInfo>);
  11969. }
  11970. /**
  11971. * Data relating to a touch event on the screen.
  11972. */
  11973. export interface PointerTouch {
  11974. /**
  11975. * X coordinate of touch.
  11976. */
  11977. x: number;
  11978. /**
  11979. * Y coordinate of touch.
  11980. */
  11981. y: number;
  11982. /**
  11983. * Id of touch. Unique for each finger.
  11984. */
  11985. pointerId: number;
  11986. /**
  11987. * Event type passed from DOM.
  11988. */
  11989. type: any;
  11990. }
  11991. }
  11992. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  11993. import { Observable } from "babylonjs/Misc/observable";
  11994. import { Nullable } from "babylonjs/types";
  11995. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  11996. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  11997. /**
  11998. * Manage the mouse inputs to control the movement of a free camera.
  11999. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12000. */
  12001. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12002. /**
  12003. * Define if touch is enabled in the mouse input
  12004. */
  12005. touchEnabled: boolean;
  12006. /**
  12007. * Defines the camera the input is attached to.
  12008. */
  12009. camera: FreeCamera;
  12010. /**
  12011. * Defines the buttons associated with the input to handle camera move.
  12012. */
  12013. buttons: number[];
  12014. /**
  12015. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12016. */
  12017. angularSensibility: number;
  12018. private _pointerInput;
  12019. private _onMouseMove;
  12020. private _observer;
  12021. private previousPosition;
  12022. /**
  12023. * Observable for when a pointer move event occurs containing the move offset
  12024. */
  12025. onPointerMovedObservable: Observable<{
  12026. offsetX: number;
  12027. offsetY: number;
  12028. }>;
  12029. /**
  12030. * @hidden
  12031. * If the camera should be rotated automatically based on pointer movement
  12032. */
  12033. _allowCameraRotation: boolean;
  12034. /**
  12035. * Manage the mouse inputs to control the movement of a free camera.
  12036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12037. * @param touchEnabled Defines if touch is enabled or not
  12038. */
  12039. constructor(
  12040. /**
  12041. * Define if touch is enabled in the mouse input
  12042. */
  12043. touchEnabled?: boolean);
  12044. /**
  12045. * Attach the input controls to a specific dom element to get the input from.
  12046. * @param element Defines the element the controls should be listened from
  12047. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12048. */
  12049. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12050. /**
  12051. * Called on JS contextmenu event.
  12052. * Override this method to provide functionality.
  12053. */
  12054. protected onContextMenu(evt: PointerEvent): void;
  12055. /**
  12056. * Detach the current controls from the specified dom element.
  12057. * @param element Defines the element to stop listening the inputs from
  12058. */
  12059. detachControl(element: Nullable<HTMLElement>): void;
  12060. /**
  12061. * Gets the class name of the current intput.
  12062. * @returns the class name
  12063. */
  12064. getClassName(): string;
  12065. /**
  12066. * Get the friendly name associated with the input class.
  12067. * @returns the input friendly name
  12068. */
  12069. getSimpleName(): string;
  12070. }
  12071. }
  12072. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12073. import { Nullable } from "babylonjs/types";
  12074. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12075. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12076. /**
  12077. * Manage the touch inputs to control the movement of a free camera.
  12078. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12079. */
  12080. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12081. /**
  12082. * Defines the camera the input is attached to.
  12083. */
  12084. camera: FreeCamera;
  12085. /**
  12086. * Defines the touch sensibility for rotation.
  12087. * The higher the faster.
  12088. */
  12089. touchAngularSensibility: number;
  12090. /**
  12091. * Defines the touch sensibility for move.
  12092. * The higher the faster.
  12093. */
  12094. touchMoveSensibility: number;
  12095. private _offsetX;
  12096. private _offsetY;
  12097. private _pointerPressed;
  12098. private _pointerInput;
  12099. private _observer;
  12100. private _onLostFocus;
  12101. /**
  12102. * Attach the input controls to a specific dom element to get the input from.
  12103. * @param element Defines the element the controls should be listened from
  12104. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12105. */
  12106. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12107. /**
  12108. * Detach the current controls from the specified dom element.
  12109. * @param element Defines the element to stop listening the inputs from
  12110. */
  12111. detachControl(element: Nullable<HTMLElement>): void;
  12112. /**
  12113. * Update the current camera state depending on the inputs that have been used this frame.
  12114. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12115. */
  12116. checkInputs(): void;
  12117. /**
  12118. * Gets the class name of the current intput.
  12119. * @returns the class name
  12120. */
  12121. getClassName(): string;
  12122. /**
  12123. * Get the friendly name associated with the input class.
  12124. * @returns the input friendly name
  12125. */
  12126. getSimpleName(): string;
  12127. }
  12128. }
  12129. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12130. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12131. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12132. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12133. import { Nullable } from "babylonjs/types";
  12134. /**
  12135. * Default Inputs manager for the FreeCamera.
  12136. * It groups all the default supported inputs for ease of use.
  12137. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12138. */
  12139. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12140. /**
  12141. * @hidden
  12142. */
  12143. _mouseInput: Nullable<FreeCameraMouseInput>;
  12144. /**
  12145. * Instantiates a new FreeCameraInputsManager.
  12146. * @param camera Defines the camera the inputs belong to
  12147. */
  12148. constructor(camera: FreeCamera);
  12149. /**
  12150. * Add keyboard input support to the input manager.
  12151. * @returns the current input manager
  12152. */
  12153. addKeyboard(): FreeCameraInputsManager;
  12154. /**
  12155. * Add mouse input support to the input manager.
  12156. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12157. * @returns the current input manager
  12158. */
  12159. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12160. /**
  12161. * Removes the mouse input support from the manager
  12162. * @returns the current input manager
  12163. */
  12164. removeMouse(): FreeCameraInputsManager;
  12165. /**
  12166. * Add touch input support to the input manager.
  12167. * @returns the current input manager
  12168. */
  12169. addTouch(): FreeCameraInputsManager;
  12170. /**
  12171. * Remove all attached input methods from a camera
  12172. */
  12173. clear(): void;
  12174. }
  12175. }
  12176. declare module "babylonjs/Cameras/freeCamera" {
  12177. import { Vector3 } from "babylonjs/Maths/math.vector";
  12178. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12179. import { Scene } from "babylonjs/scene";
  12180. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12181. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12182. /**
  12183. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12184. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12185. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12186. */
  12187. export class FreeCamera extends TargetCamera {
  12188. /**
  12189. * Define the collision ellipsoid of the camera.
  12190. * This is helpful to simulate a camera body like the player body around the camera
  12191. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12192. */
  12193. ellipsoid: Vector3;
  12194. /**
  12195. * Define an offset for the position of the ellipsoid around the camera.
  12196. * This can be helpful to determine the center of the body near the gravity center of the body
  12197. * instead of its head.
  12198. */
  12199. ellipsoidOffset: Vector3;
  12200. /**
  12201. * Enable or disable collisions of the camera with the rest of the scene objects.
  12202. */
  12203. checkCollisions: boolean;
  12204. /**
  12205. * Enable or disable gravity on the camera.
  12206. */
  12207. applyGravity: boolean;
  12208. /**
  12209. * Define the input manager associated to the camera.
  12210. */
  12211. inputs: FreeCameraInputsManager;
  12212. /**
  12213. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12214. * Higher values reduce sensitivity.
  12215. */
  12216. /**
  12217. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12218. * Higher values reduce sensitivity.
  12219. */
  12220. angularSensibility: number;
  12221. /**
  12222. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12223. */
  12224. keysUp: number[];
  12225. /**
  12226. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12227. */
  12228. keysDown: number[];
  12229. /**
  12230. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12231. */
  12232. keysLeft: number[];
  12233. /**
  12234. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12235. */
  12236. keysRight: number[];
  12237. /**
  12238. * Event raised when the camera collide with a mesh in the scene.
  12239. */
  12240. onCollide: (collidedMesh: AbstractMesh) => void;
  12241. private _collider;
  12242. private _needMoveForGravity;
  12243. private _oldPosition;
  12244. private _diffPosition;
  12245. private _newPosition;
  12246. /** @hidden */
  12247. _localDirection: Vector3;
  12248. /** @hidden */
  12249. _transformedDirection: Vector3;
  12250. /**
  12251. * Instantiates a Free Camera.
  12252. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12253. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12254. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12255. * @param name Define the name of the camera in the scene
  12256. * @param position Define the start position of the camera in the scene
  12257. * @param scene Define the scene the camera belongs to
  12258. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12259. */
  12260. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12261. /**
  12262. * Attached controls to the current camera.
  12263. * @param element Defines the element the controls should be listened from
  12264. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12265. */
  12266. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12267. /**
  12268. * Detach the current controls from the camera.
  12269. * The camera will stop reacting to inputs.
  12270. * @param element Defines the element to stop listening the inputs from
  12271. */
  12272. detachControl(element: HTMLElement): void;
  12273. private _collisionMask;
  12274. /**
  12275. * Define a collision mask to limit the list of object the camera can collide with
  12276. */
  12277. collisionMask: number;
  12278. /** @hidden */
  12279. _collideWithWorld(displacement: Vector3): void;
  12280. private _onCollisionPositionChange;
  12281. /** @hidden */
  12282. _checkInputs(): void;
  12283. /** @hidden */
  12284. _decideIfNeedsToMove(): boolean;
  12285. /** @hidden */
  12286. _updatePosition(): void;
  12287. /**
  12288. * Destroy the camera and release the current resources hold by it.
  12289. */
  12290. dispose(): void;
  12291. /**
  12292. * Gets the current object class name.
  12293. * @return the class name
  12294. */
  12295. getClassName(): string;
  12296. }
  12297. }
  12298. declare module "babylonjs/Gamepads/gamepad" {
  12299. import { Observable } from "babylonjs/Misc/observable";
  12300. /**
  12301. * Represents a gamepad control stick position
  12302. */
  12303. export class StickValues {
  12304. /**
  12305. * The x component of the control stick
  12306. */
  12307. x: number;
  12308. /**
  12309. * The y component of the control stick
  12310. */
  12311. y: number;
  12312. /**
  12313. * Initializes the gamepad x and y control stick values
  12314. * @param x The x component of the gamepad control stick value
  12315. * @param y The y component of the gamepad control stick value
  12316. */
  12317. constructor(
  12318. /**
  12319. * The x component of the control stick
  12320. */
  12321. x: number,
  12322. /**
  12323. * The y component of the control stick
  12324. */
  12325. y: number);
  12326. }
  12327. /**
  12328. * An interface which manages callbacks for gamepad button changes
  12329. */
  12330. export interface GamepadButtonChanges {
  12331. /**
  12332. * Called when a gamepad has been changed
  12333. */
  12334. changed: boolean;
  12335. /**
  12336. * Called when a gamepad press event has been triggered
  12337. */
  12338. pressChanged: boolean;
  12339. /**
  12340. * Called when a touch event has been triggered
  12341. */
  12342. touchChanged: boolean;
  12343. /**
  12344. * Called when a value has changed
  12345. */
  12346. valueChanged: boolean;
  12347. }
  12348. /**
  12349. * Represents a gamepad
  12350. */
  12351. export class Gamepad {
  12352. /**
  12353. * The id of the gamepad
  12354. */
  12355. id: string;
  12356. /**
  12357. * The index of the gamepad
  12358. */
  12359. index: number;
  12360. /**
  12361. * The browser gamepad
  12362. */
  12363. browserGamepad: any;
  12364. /**
  12365. * Specifies what type of gamepad this represents
  12366. */
  12367. type: number;
  12368. private _leftStick;
  12369. private _rightStick;
  12370. /** @hidden */
  12371. _isConnected: boolean;
  12372. private _leftStickAxisX;
  12373. private _leftStickAxisY;
  12374. private _rightStickAxisX;
  12375. private _rightStickAxisY;
  12376. /**
  12377. * Triggered when the left control stick has been changed
  12378. */
  12379. private _onleftstickchanged;
  12380. /**
  12381. * Triggered when the right control stick has been changed
  12382. */
  12383. private _onrightstickchanged;
  12384. /**
  12385. * Represents a gamepad controller
  12386. */
  12387. static GAMEPAD: number;
  12388. /**
  12389. * Represents a generic controller
  12390. */
  12391. static GENERIC: number;
  12392. /**
  12393. * Represents an XBox controller
  12394. */
  12395. static XBOX: number;
  12396. /**
  12397. * Represents a pose-enabled controller
  12398. */
  12399. static POSE_ENABLED: number;
  12400. /**
  12401. * Represents an Dual Shock controller
  12402. */
  12403. static DUALSHOCK: number;
  12404. /**
  12405. * Specifies whether the left control stick should be Y-inverted
  12406. */
  12407. protected _invertLeftStickY: boolean;
  12408. /**
  12409. * Specifies if the gamepad has been connected
  12410. */
  12411. readonly isConnected: boolean;
  12412. /**
  12413. * Initializes the gamepad
  12414. * @param id The id of the gamepad
  12415. * @param index The index of the gamepad
  12416. * @param browserGamepad The browser gamepad
  12417. * @param leftStickX The x component of the left joystick
  12418. * @param leftStickY The y component of the left joystick
  12419. * @param rightStickX The x component of the right joystick
  12420. * @param rightStickY The y component of the right joystick
  12421. */
  12422. constructor(
  12423. /**
  12424. * The id of the gamepad
  12425. */
  12426. id: string,
  12427. /**
  12428. * The index of the gamepad
  12429. */
  12430. index: number,
  12431. /**
  12432. * The browser gamepad
  12433. */
  12434. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12435. /**
  12436. * Callback triggered when the left joystick has changed
  12437. * @param callback
  12438. */
  12439. onleftstickchanged(callback: (values: StickValues) => void): void;
  12440. /**
  12441. * Callback triggered when the right joystick has changed
  12442. * @param callback
  12443. */
  12444. onrightstickchanged(callback: (values: StickValues) => void): void;
  12445. /**
  12446. * Gets the left joystick
  12447. */
  12448. /**
  12449. * Sets the left joystick values
  12450. */
  12451. leftStick: StickValues;
  12452. /**
  12453. * Gets the right joystick
  12454. */
  12455. /**
  12456. * Sets the right joystick value
  12457. */
  12458. rightStick: StickValues;
  12459. /**
  12460. * Updates the gamepad joystick positions
  12461. */
  12462. update(): void;
  12463. /**
  12464. * Disposes the gamepad
  12465. */
  12466. dispose(): void;
  12467. }
  12468. /**
  12469. * Represents a generic gamepad
  12470. */
  12471. export class GenericPad extends Gamepad {
  12472. private _buttons;
  12473. private _onbuttondown;
  12474. private _onbuttonup;
  12475. /**
  12476. * Observable triggered when a button has been pressed
  12477. */
  12478. onButtonDownObservable: Observable<number>;
  12479. /**
  12480. * Observable triggered when a button has been released
  12481. */
  12482. onButtonUpObservable: Observable<number>;
  12483. /**
  12484. * Callback triggered when a button has been pressed
  12485. * @param callback Called when a button has been pressed
  12486. */
  12487. onbuttondown(callback: (buttonPressed: number) => void): void;
  12488. /**
  12489. * Callback triggered when a button has been released
  12490. * @param callback Called when a button has been released
  12491. */
  12492. onbuttonup(callback: (buttonReleased: number) => void): void;
  12493. /**
  12494. * Initializes the generic gamepad
  12495. * @param id The id of the generic gamepad
  12496. * @param index The index of the generic gamepad
  12497. * @param browserGamepad The browser gamepad
  12498. */
  12499. constructor(id: string, index: number, browserGamepad: any);
  12500. private _setButtonValue;
  12501. /**
  12502. * Updates the generic gamepad
  12503. */
  12504. update(): void;
  12505. /**
  12506. * Disposes the generic gamepad
  12507. */
  12508. dispose(): void;
  12509. }
  12510. }
  12511. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12512. import { Nullable } from "babylonjs/types";
  12513. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12514. import { Scene } from "babylonjs/scene";
  12515. module "babylonjs/Engines/engine" {
  12516. interface Engine {
  12517. /**
  12518. * Creates a raw texture
  12519. * @param data defines the data to store in the texture
  12520. * @param width defines the width of the texture
  12521. * @param height defines the height of the texture
  12522. * @param format defines the format of the data
  12523. * @param generateMipMaps defines if the engine should generate the mip levels
  12524. * @param invertY defines if data must be stored with Y axis inverted
  12525. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12526. * @param compression defines the compression used (null by default)
  12527. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12528. * @returns the raw texture inside an InternalTexture
  12529. */
  12530. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12531. /**
  12532. * Update a raw texture
  12533. * @param texture defines the texture to update
  12534. * @param data defines the data to store in the texture
  12535. * @param format defines the format of the data
  12536. * @param invertY defines if data must be stored with Y axis inverted
  12537. */
  12538. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12539. /**
  12540. * Update a raw texture
  12541. * @param texture defines the texture to update
  12542. * @param data defines the data to store in the texture
  12543. * @param format defines the format of the data
  12544. * @param invertY defines if data must be stored with Y axis inverted
  12545. * @param compression defines the compression used (null by default)
  12546. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12547. */
  12548. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12549. /**
  12550. * Creates a new raw cube texture
  12551. * @param data defines the array of data to use to create each face
  12552. * @param size defines the size of the textures
  12553. * @param format defines the format of the data
  12554. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12555. * @param generateMipMaps defines if the engine should generate the mip levels
  12556. * @param invertY defines if data must be stored with Y axis inverted
  12557. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12558. * @param compression defines the compression used (null by default)
  12559. * @returns the cube texture as an InternalTexture
  12560. */
  12561. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12562. /**
  12563. * Update a raw cube texture
  12564. * @param texture defines the texture to udpdate
  12565. * @param data defines the data to store
  12566. * @param format defines the data format
  12567. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12568. * @param invertY defines if data must be stored with Y axis inverted
  12569. */
  12570. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12571. /**
  12572. * Update a raw cube texture
  12573. * @param texture defines the texture to udpdate
  12574. * @param data defines the data to store
  12575. * @param format defines the data format
  12576. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12577. * @param invertY defines if data must be stored with Y axis inverted
  12578. * @param compression defines the compression used (null by default)
  12579. */
  12580. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12581. /**
  12582. * Update a raw cube texture
  12583. * @param texture defines the texture to udpdate
  12584. * @param data defines the data to store
  12585. * @param format defines the data format
  12586. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12587. * @param invertY defines if data must be stored with Y axis inverted
  12588. * @param compression defines the compression used (null by default)
  12589. * @param level defines which level of the texture to update
  12590. */
  12591. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12592. /**
  12593. * Creates a new raw cube texture from a specified url
  12594. * @param url defines the url where the data is located
  12595. * @param scene defines the current scene
  12596. * @param size defines the size of the textures
  12597. * @param format defines the format of the data
  12598. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12599. * @param noMipmap defines if the engine should avoid generating the mip levels
  12600. * @param callback defines a callback used to extract texture data from loaded data
  12601. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12602. * @param onLoad defines a callback called when texture is loaded
  12603. * @param onError defines a callback called if there is an error
  12604. * @returns the cube texture as an InternalTexture
  12605. */
  12606. 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;
  12607. /**
  12608. * Creates a new raw cube texture from a specified url
  12609. * @param url defines the url where the data is located
  12610. * @param scene defines the current scene
  12611. * @param size defines the size of the textures
  12612. * @param format defines the format of the data
  12613. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12614. * @param noMipmap defines if the engine should avoid generating the mip levels
  12615. * @param callback defines a callback used to extract texture data from loaded data
  12616. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12617. * @param onLoad defines a callback called when texture is loaded
  12618. * @param onError defines a callback called if there is an error
  12619. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12620. * @param invertY defines if data must be stored with Y axis inverted
  12621. * @returns the cube texture as an InternalTexture
  12622. */
  12623. 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;
  12624. /**
  12625. * Creates a new raw 3D texture
  12626. * @param data defines the data used to create the texture
  12627. * @param width defines the width of the texture
  12628. * @param height defines the height of the texture
  12629. * @param depth defines the depth of the texture
  12630. * @param format defines the format of the texture
  12631. * @param generateMipMaps defines if the engine must generate mip levels
  12632. * @param invertY defines if data must be stored with Y axis inverted
  12633. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12634. * @param compression defines the compressed used (can be null)
  12635. * @param textureType defines the compressed used (can be null)
  12636. * @returns a new raw 3D texture (stored in an InternalTexture)
  12637. */
  12638. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12639. /**
  12640. * Update a raw 3D texture
  12641. * @param texture defines the texture to update
  12642. * @param data defines the data to store
  12643. * @param format defines the data format
  12644. * @param invertY defines if data must be stored with Y axis inverted
  12645. */
  12646. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12647. /**
  12648. * Update a raw 3D texture
  12649. * @param texture defines the texture to update
  12650. * @param data defines the data to store
  12651. * @param format defines the data format
  12652. * @param invertY defines if data must be stored with Y axis inverted
  12653. * @param compression defines the used compression (can be null)
  12654. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12655. */
  12656. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12657. }
  12658. }
  12659. }
  12660. declare module "babylonjs/Materials/Textures/rawTexture" {
  12661. import { Scene } from "babylonjs/scene";
  12662. import { Texture } from "babylonjs/Materials/Textures/texture";
  12663. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12664. /**
  12665. * Raw texture can help creating a texture directly from an array of data.
  12666. * This can be super useful if you either get the data from an uncompressed source or
  12667. * if you wish to create your texture pixel by pixel.
  12668. */
  12669. export class RawTexture extends Texture {
  12670. /**
  12671. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12672. */
  12673. format: number;
  12674. private _engine;
  12675. /**
  12676. * Instantiates a new RawTexture.
  12677. * Raw texture can help creating a texture directly from an array of data.
  12678. * This can be super useful if you either get the data from an uncompressed source or
  12679. * if you wish to create your texture pixel by pixel.
  12680. * @param data define the array of data to use to create the texture
  12681. * @param width define the width of the texture
  12682. * @param height define the height of the texture
  12683. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12684. * @param scene define the scene the texture belongs to
  12685. * @param generateMipMaps define whether mip maps should be generated or not
  12686. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12687. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12688. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12689. */
  12690. constructor(data: ArrayBufferView, width: number, height: number,
  12691. /**
  12692. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12693. */
  12694. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12695. /**
  12696. * Updates the texture underlying data.
  12697. * @param data Define the new data of the texture
  12698. */
  12699. update(data: ArrayBufferView): void;
  12700. /**
  12701. * Creates a luminance texture from some data.
  12702. * @param data Define the texture data
  12703. * @param width Define the width of the texture
  12704. * @param height Define the height of the texture
  12705. * @param scene Define the scene the texture belongs to
  12706. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12707. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12708. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12709. * @returns the luminance texture
  12710. */
  12711. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12712. /**
  12713. * Creates a luminance alpha texture from some data.
  12714. * @param data Define the texture data
  12715. * @param width Define the width of the texture
  12716. * @param height Define the height of the texture
  12717. * @param scene Define the scene the texture belongs to
  12718. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12719. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12720. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12721. * @returns the luminance alpha texture
  12722. */
  12723. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12724. /**
  12725. * Creates an alpha texture from some data.
  12726. * @param data Define the texture data
  12727. * @param width Define the width of the texture
  12728. * @param height Define the height of the texture
  12729. * @param scene Define the scene the texture belongs to
  12730. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12731. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12732. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12733. * @returns the alpha texture
  12734. */
  12735. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12736. /**
  12737. * Creates a RGB texture from some data.
  12738. * @param data Define the texture data
  12739. * @param width Define the width of the texture
  12740. * @param height Define the height of the texture
  12741. * @param scene Define the scene the texture belongs to
  12742. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12743. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12744. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12745. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12746. * @returns the RGB alpha texture
  12747. */
  12748. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12749. /**
  12750. * Creates a RGBA texture from some data.
  12751. * @param data Define the texture data
  12752. * @param width Define the width of the texture
  12753. * @param height Define the height of the texture
  12754. * @param scene Define the scene the texture belongs to
  12755. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12756. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12757. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12758. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12759. * @returns the RGBA texture
  12760. */
  12761. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12762. /**
  12763. * Creates a R texture from some data.
  12764. * @param data Define the texture data
  12765. * @param width Define the width of the texture
  12766. * @param height Define the height of the texture
  12767. * @param scene Define the scene the texture belongs to
  12768. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12769. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12770. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12771. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12772. * @returns the R texture
  12773. */
  12774. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12775. }
  12776. }
  12777. declare module "babylonjs/Maths/math.size" {
  12778. /**
  12779. * Interface for the size containing width and height
  12780. */
  12781. export interface ISize {
  12782. /**
  12783. * Width
  12784. */
  12785. width: number;
  12786. /**
  12787. * Heighht
  12788. */
  12789. height: number;
  12790. }
  12791. /**
  12792. * Size containing widht and height
  12793. */
  12794. export class Size implements ISize {
  12795. /**
  12796. * Width
  12797. */
  12798. width: number;
  12799. /**
  12800. * Height
  12801. */
  12802. height: number;
  12803. /**
  12804. * Creates a Size object from the given width and height (floats).
  12805. * @param width width of the new size
  12806. * @param height height of the new size
  12807. */
  12808. constructor(width: number, height: number);
  12809. /**
  12810. * Returns a string with the Size width and height
  12811. * @returns a string with the Size width and height
  12812. */
  12813. toString(): string;
  12814. /**
  12815. * "Size"
  12816. * @returns the string "Size"
  12817. */
  12818. getClassName(): string;
  12819. /**
  12820. * Returns the Size hash code.
  12821. * @returns a hash code for a unique width and height
  12822. */
  12823. getHashCode(): number;
  12824. /**
  12825. * Updates the current size from the given one.
  12826. * @param src the given size
  12827. */
  12828. copyFrom(src: Size): void;
  12829. /**
  12830. * Updates in place the current Size from the given floats.
  12831. * @param width width of the new size
  12832. * @param height height of the new size
  12833. * @returns the updated Size.
  12834. */
  12835. copyFromFloats(width: number, height: number): Size;
  12836. /**
  12837. * Updates in place the current Size from the given floats.
  12838. * @param width width to set
  12839. * @param height height to set
  12840. * @returns the updated Size.
  12841. */
  12842. set(width: number, height: number): Size;
  12843. /**
  12844. * Multiplies the width and height by numbers
  12845. * @param w factor to multiple the width by
  12846. * @param h factor to multiple the height by
  12847. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12848. */
  12849. multiplyByFloats(w: number, h: number): Size;
  12850. /**
  12851. * Clones the size
  12852. * @returns a new Size copied from the given one.
  12853. */
  12854. clone(): Size;
  12855. /**
  12856. * True if the current Size and the given one width and height are strictly equal.
  12857. * @param other the other size to compare against
  12858. * @returns True if the current Size and the given one width and height are strictly equal.
  12859. */
  12860. equals(other: Size): boolean;
  12861. /**
  12862. * The surface of the Size : width * height (float).
  12863. */
  12864. readonly surface: number;
  12865. /**
  12866. * Create a new size of zero
  12867. * @returns a new Size set to (0.0, 0.0)
  12868. */
  12869. static Zero(): Size;
  12870. /**
  12871. * Sums the width and height of two sizes
  12872. * @param otherSize size to add to this size
  12873. * @returns a new Size set as the addition result of the current Size and the given one.
  12874. */
  12875. add(otherSize: Size): Size;
  12876. /**
  12877. * Subtracts the width and height of two
  12878. * @param otherSize size to subtract to this size
  12879. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12880. */
  12881. subtract(otherSize: Size): Size;
  12882. /**
  12883. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12884. * @param start starting size to lerp between
  12885. * @param end end size to lerp between
  12886. * @param amount amount to lerp between the start and end values
  12887. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12888. */
  12889. static Lerp(start: Size, end: Size, amount: number): Size;
  12890. }
  12891. }
  12892. declare module "babylonjs/Animations/runtimeAnimation" {
  12893. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  12894. import { Animatable } from "babylonjs/Animations/animatable";
  12895. import { Scene } from "babylonjs/scene";
  12896. /**
  12897. * Defines a runtime animation
  12898. */
  12899. export class RuntimeAnimation {
  12900. private _events;
  12901. /**
  12902. * The current frame of the runtime animation
  12903. */
  12904. private _currentFrame;
  12905. /**
  12906. * The animation used by the runtime animation
  12907. */
  12908. private _animation;
  12909. /**
  12910. * The target of the runtime animation
  12911. */
  12912. private _target;
  12913. /**
  12914. * The initiating animatable
  12915. */
  12916. private _host;
  12917. /**
  12918. * The original value of the runtime animation
  12919. */
  12920. private _originalValue;
  12921. /**
  12922. * The original blend value of the runtime animation
  12923. */
  12924. private _originalBlendValue;
  12925. /**
  12926. * The offsets cache of the runtime animation
  12927. */
  12928. private _offsetsCache;
  12929. /**
  12930. * The high limits cache of the runtime animation
  12931. */
  12932. private _highLimitsCache;
  12933. /**
  12934. * Specifies if the runtime animation has been stopped
  12935. */
  12936. private _stopped;
  12937. /**
  12938. * The blending factor of the runtime animation
  12939. */
  12940. private _blendingFactor;
  12941. /**
  12942. * The BabylonJS scene
  12943. */
  12944. private _scene;
  12945. /**
  12946. * The current value of the runtime animation
  12947. */
  12948. private _currentValue;
  12949. /** @hidden */
  12950. _animationState: _IAnimationState;
  12951. /**
  12952. * The active target of the runtime animation
  12953. */
  12954. private _activeTargets;
  12955. private _currentActiveTarget;
  12956. private _directTarget;
  12957. /**
  12958. * The target path of the runtime animation
  12959. */
  12960. private _targetPath;
  12961. /**
  12962. * The weight of the runtime animation
  12963. */
  12964. private _weight;
  12965. /**
  12966. * The ratio offset of the runtime animation
  12967. */
  12968. private _ratioOffset;
  12969. /**
  12970. * The previous delay of the runtime animation
  12971. */
  12972. private _previousDelay;
  12973. /**
  12974. * The previous ratio of the runtime animation
  12975. */
  12976. private _previousRatio;
  12977. private _enableBlending;
  12978. private _keys;
  12979. private _minFrame;
  12980. private _maxFrame;
  12981. private _minValue;
  12982. private _maxValue;
  12983. private _targetIsArray;
  12984. /**
  12985. * Gets the current frame of the runtime animation
  12986. */
  12987. readonly currentFrame: number;
  12988. /**
  12989. * Gets the weight of the runtime animation
  12990. */
  12991. readonly weight: number;
  12992. /**
  12993. * Gets the current value of the runtime animation
  12994. */
  12995. readonly currentValue: any;
  12996. /**
  12997. * Gets the target path of the runtime animation
  12998. */
  12999. readonly targetPath: string;
  13000. /**
  13001. * Gets the actual target of the runtime animation
  13002. */
  13003. readonly target: any;
  13004. /** @hidden */
  13005. _onLoop: () => void;
  13006. /**
  13007. * Create a new RuntimeAnimation object
  13008. * @param target defines the target of the animation
  13009. * @param animation defines the source animation object
  13010. * @param scene defines the hosting scene
  13011. * @param host defines the initiating Animatable
  13012. */
  13013. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13014. private _preparePath;
  13015. /**
  13016. * Gets the animation from the runtime animation
  13017. */
  13018. readonly animation: Animation;
  13019. /**
  13020. * Resets the runtime animation to the beginning
  13021. * @param restoreOriginal defines whether to restore the target property to the original value
  13022. */
  13023. reset(restoreOriginal?: boolean): void;
  13024. /**
  13025. * Specifies if the runtime animation is stopped
  13026. * @returns Boolean specifying if the runtime animation is stopped
  13027. */
  13028. isStopped(): boolean;
  13029. /**
  13030. * Disposes of the runtime animation
  13031. */
  13032. dispose(): void;
  13033. /**
  13034. * Apply the interpolated value to the target
  13035. * @param currentValue defines the value computed by the animation
  13036. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13037. */
  13038. setValue(currentValue: any, weight: number): void;
  13039. private _getOriginalValues;
  13040. private _setValue;
  13041. /**
  13042. * Gets the loop pmode of the runtime animation
  13043. * @returns Loop Mode
  13044. */
  13045. private _getCorrectLoopMode;
  13046. /**
  13047. * Move the current animation to a given frame
  13048. * @param frame defines the frame to move to
  13049. */
  13050. goToFrame(frame: number): void;
  13051. /**
  13052. * @hidden Internal use only
  13053. */
  13054. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13055. /**
  13056. * Execute the current animation
  13057. * @param delay defines the delay to add to the current frame
  13058. * @param from defines the lower bound of the animation range
  13059. * @param to defines the upper bound of the animation range
  13060. * @param loop defines if the current animation must loop
  13061. * @param speedRatio defines the current speed ratio
  13062. * @param weight defines the weight of the animation (default is -1 so no weight)
  13063. * @param onLoop optional callback called when animation loops
  13064. * @returns a boolean indicating if the animation is running
  13065. */
  13066. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13067. }
  13068. }
  13069. declare module "babylonjs/Animations/animatable" {
  13070. import { Animation } from "babylonjs/Animations/animation";
  13071. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13072. import { Nullable } from "babylonjs/types";
  13073. import { Observable } from "babylonjs/Misc/observable";
  13074. import { Scene } from "babylonjs/scene";
  13075. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13076. import { Node } from "babylonjs/node";
  13077. /**
  13078. * Class used to store an actual running animation
  13079. */
  13080. export class Animatable {
  13081. /** defines the target object */
  13082. target: any;
  13083. /** defines the starting frame number (default is 0) */
  13084. fromFrame: number;
  13085. /** defines the ending frame number (default is 100) */
  13086. toFrame: number;
  13087. /** defines if the animation must loop (default is false) */
  13088. loopAnimation: boolean;
  13089. /** defines a callback to call when animation ends if it is not looping */
  13090. onAnimationEnd?: (() => void) | null | undefined;
  13091. /** defines a callback to call when animation loops */
  13092. onAnimationLoop?: (() => void) | null | undefined;
  13093. private _localDelayOffset;
  13094. private _pausedDelay;
  13095. private _runtimeAnimations;
  13096. private _paused;
  13097. private _scene;
  13098. private _speedRatio;
  13099. private _weight;
  13100. private _syncRoot;
  13101. /**
  13102. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13103. * This will only apply for non looping animation (default is true)
  13104. */
  13105. disposeOnEnd: boolean;
  13106. /**
  13107. * Gets a boolean indicating if the animation has started
  13108. */
  13109. animationStarted: boolean;
  13110. /**
  13111. * Observer raised when the animation ends
  13112. */
  13113. onAnimationEndObservable: Observable<Animatable>;
  13114. /**
  13115. * Observer raised when the animation loops
  13116. */
  13117. onAnimationLoopObservable: Observable<Animatable>;
  13118. /**
  13119. * Gets the root Animatable used to synchronize and normalize animations
  13120. */
  13121. readonly syncRoot: Nullable<Animatable>;
  13122. /**
  13123. * Gets the current frame of the first RuntimeAnimation
  13124. * Used to synchronize Animatables
  13125. */
  13126. readonly masterFrame: number;
  13127. /**
  13128. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13129. */
  13130. weight: number;
  13131. /**
  13132. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13133. */
  13134. speedRatio: number;
  13135. /**
  13136. * Creates a new Animatable
  13137. * @param scene defines the hosting scene
  13138. * @param target defines the target object
  13139. * @param fromFrame defines the starting frame number (default is 0)
  13140. * @param toFrame defines the ending frame number (default is 100)
  13141. * @param loopAnimation defines if the animation must loop (default is false)
  13142. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13143. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13144. * @param animations defines a group of animation to add to the new Animatable
  13145. * @param onAnimationLoop defines a callback to call when animation loops
  13146. */
  13147. constructor(scene: Scene,
  13148. /** defines the target object */
  13149. target: any,
  13150. /** defines the starting frame number (default is 0) */
  13151. fromFrame?: number,
  13152. /** defines the ending frame number (default is 100) */
  13153. toFrame?: number,
  13154. /** defines if the animation must loop (default is false) */
  13155. loopAnimation?: boolean, speedRatio?: number,
  13156. /** defines a callback to call when animation ends if it is not looping */
  13157. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13158. /** defines a callback to call when animation loops */
  13159. onAnimationLoop?: (() => void) | null | undefined);
  13160. /**
  13161. * Synchronize and normalize current Animatable with a source Animatable
  13162. * This is useful when using animation weights and when animations are not of the same length
  13163. * @param root defines the root Animatable to synchronize with
  13164. * @returns the current Animatable
  13165. */
  13166. syncWith(root: Animatable): Animatable;
  13167. /**
  13168. * Gets the list of runtime animations
  13169. * @returns an array of RuntimeAnimation
  13170. */
  13171. getAnimations(): RuntimeAnimation[];
  13172. /**
  13173. * Adds more animations to the current animatable
  13174. * @param target defines the target of the animations
  13175. * @param animations defines the new animations to add
  13176. */
  13177. appendAnimations(target: any, animations: Animation[]): void;
  13178. /**
  13179. * Gets the source animation for a specific property
  13180. * @param property defines the propertyu to look for
  13181. * @returns null or the source animation for the given property
  13182. */
  13183. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13184. /**
  13185. * Gets the runtime animation for a specific property
  13186. * @param property defines the propertyu to look for
  13187. * @returns null or the runtime animation for the given property
  13188. */
  13189. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13190. /**
  13191. * Resets the animatable to its original state
  13192. */
  13193. reset(): void;
  13194. /**
  13195. * Allows the animatable to blend with current running animations
  13196. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13197. * @param blendingSpeed defines the blending speed to use
  13198. */
  13199. enableBlending(blendingSpeed: number): void;
  13200. /**
  13201. * Disable animation blending
  13202. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13203. */
  13204. disableBlending(): void;
  13205. /**
  13206. * Jump directly to a given frame
  13207. * @param frame defines the frame to jump to
  13208. */
  13209. goToFrame(frame: number): void;
  13210. /**
  13211. * Pause the animation
  13212. */
  13213. pause(): void;
  13214. /**
  13215. * Restart the animation
  13216. */
  13217. restart(): void;
  13218. private _raiseOnAnimationEnd;
  13219. /**
  13220. * Stop and delete the current animation
  13221. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13222. * @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)
  13223. */
  13224. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13225. /**
  13226. * Wait asynchronously for the animation to end
  13227. * @returns a promise which will be fullfilled when the animation ends
  13228. */
  13229. waitAsync(): Promise<Animatable>;
  13230. /** @hidden */
  13231. _animate(delay: number): boolean;
  13232. }
  13233. module "babylonjs/scene" {
  13234. interface Scene {
  13235. /** @hidden */
  13236. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13237. /** @hidden */
  13238. _processLateAnimationBindingsForMatrices(holder: {
  13239. totalWeight: number;
  13240. animations: RuntimeAnimation[];
  13241. originalValue: Matrix;
  13242. }): any;
  13243. /** @hidden */
  13244. _processLateAnimationBindingsForQuaternions(holder: {
  13245. totalWeight: number;
  13246. animations: RuntimeAnimation[];
  13247. originalValue: Quaternion;
  13248. }, refQuaternion: Quaternion): Quaternion;
  13249. /** @hidden */
  13250. _processLateAnimationBindings(): void;
  13251. /**
  13252. * Will start the animation sequence of a given target
  13253. * @param target defines the target
  13254. * @param from defines from which frame should animation start
  13255. * @param to defines until which frame should animation run.
  13256. * @param weight defines the weight to apply to the animation (1.0 by default)
  13257. * @param loop defines if the animation loops
  13258. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13259. * @param onAnimationEnd defines the function to be executed when the animation ends
  13260. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13261. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13262. * @param onAnimationLoop defines the callback to call when an animation loops
  13263. * @returns the animatable object created for this animation
  13264. */
  13265. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13266. /**
  13267. * Will start the animation sequence of a given target
  13268. * @param target defines the target
  13269. * @param from defines from which frame should animation start
  13270. * @param to defines until which frame should animation run.
  13271. * @param loop defines if the animation loops
  13272. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13273. * @param onAnimationEnd defines the function to be executed when the animation ends
  13274. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13275. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13276. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13277. * @param onAnimationLoop defines the callback to call when an animation loops
  13278. * @returns the animatable object created for this animation
  13279. */
  13280. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13281. /**
  13282. * Will start the animation sequence of a given target and its hierarchy
  13283. * @param target defines the target
  13284. * @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.
  13285. * @param from defines from which frame should animation start
  13286. * @param to defines until which frame should animation run.
  13287. * @param loop defines if the animation loops
  13288. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13289. * @param onAnimationEnd defines the function to be executed when the animation ends
  13290. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13291. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13292. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13293. * @param onAnimationLoop defines the callback to call when an animation loops
  13294. * @returns the list of created animatables
  13295. */
  13296. 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[];
  13297. /**
  13298. * Begin a new animation on a given node
  13299. * @param target defines the target where the animation will take place
  13300. * @param animations defines the list of animations to start
  13301. * @param from defines the initial value
  13302. * @param to defines the final value
  13303. * @param loop defines if you want animation to loop (off by default)
  13304. * @param speedRatio defines the speed ratio to apply to all animations
  13305. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13306. * @param onAnimationLoop defines the callback to call when an animation loops
  13307. * @returns the list of created animatables
  13308. */
  13309. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13310. /**
  13311. * Begin a new animation on a given node and its hierarchy
  13312. * @param target defines the root node where the animation will take place
  13313. * @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.
  13314. * @param animations defines the list of animations to start
  13315. * @param from defines the initial value
  13316. * @param to defines the final value
  13317. * @param loop defines if you want animation to loop (off by default)
  13318. * @param speedRatio defines the speed ratio to apply to all animations
  13319. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13320. * @param onAnimationLoop defines the callback to call when an animation loops
  13321. * @returns the list of animatables created for all nodes
  13322. */
  13323. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13324. /**
  13325. * Gets the animatable associated with a specific target
  13326. * @param target defines the target of the animatable
  13327. * @returns the required animatable if found
  13328. */
  13329. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13330. /**
  13331. * Gets all animatables associated with a given target
  13332. * @param target defines the target to look animatables for
  13333. * @returns an array of Animatables
  13334. */
  13335. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13336. /**
  13337. * Stops and removes all animations that have been applied to the scene
  13338. */
  13339. stopAllAnimations(): void;
  13340. /**
  13341. * Gets the current delta time used by animation engine
  13342. */
  13343. deltaTime: number;
  13344. }
  13345. }
  13346. module "babylonjs/Bones/bone" {
  13347. interface Bone {
  13348. /**
  13349. * Copy an animation range from another bone
  13350. * @param source defines the source bone
  13351. * @param rangeName defines the range name to copy
  13352. * @param frameOffset defines the frame offset
  13353. * @param rescaleAsRequired defines if rescaling must be applied if required
  13354. * @param skelDimensionsRatio defines the scaling ratio
  13355. * @returns true if operation was successful
  13356. */
  13357. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13358. }
  13359. }
  13360. }
  13361. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13362. /**
  13363. * Class used to override all child animations of a given target
  13364. */
  13365. export class AnimationPropertiesOverride {
  13366. /**
  13367. * Gets or sets a value indicating if animation blending must be used
  13368. */
  13369. enableBlending: boolean;
  13370. /**
  13371. * Gets or sets the blending speed to use when enableBlending is true
  13372. */
  13373. blendingSpeed: number;
  13374. /**
  13375. * Gets or sets the default loop mode to use
  13376. */
  13377. loopMode: number;
  13378. }
  13379. }
  13380. declare module "babylonjs/Bones/skeleton" {
  13381. import { Bone } from "babylonjs/Bones/bone";
  13382. import { Observable } from "babylonjs/Misc/observable";
  13383. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13384. import { Scene } from "babylonjs/scene";
  13385. import { Nullable } from "babylonjs/types";
  13386. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13387. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13388. import { Animatable } from "babylonjs/Animations/animatable";
  13389. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13390. import { Animation } from "babylonjs/Animations/animation";
  13391. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13392. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13393. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13394. /**
  13395. * Class used to handle skinning animations
  13396. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13397. */
  13398. export class Skeleton implements IAnimatable {
  13399. /** defines the skeleton name */
  13400. name: string;
  13401. /** defines the skeleton Id */
  13402. id: string;
  13403. /**
  13404. * Defines the list of child bones
  13405. */
  13406. bones: Bone[];
  13407. /**
  13408. * Defines an estimate of the dimension of the skeleton at rest
  13409. */
  13410. dimensionsAtRest: Vector3;
  13411. /**
  13412. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13413. */
  13414. needInitialSkinMatrix: boolean;
  13415. /**
  13416. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13417. */
  13418. overrideMesh: Nullable<AbstractMesh>;
  13419. /**
  13420. * Gets the list of animations attached to this skeleton
  13421. */
  13422. animations: Array<Animation>;
  13423. private _scene;
  13424. private _isDirty;
  13425. private _transformMatrices;
  13426. private _transformMatrixTexture;
  13427. private _meshesWithPoseMatrix;
  13428. private _animatables;
  13429. private _identity;
  13430. private _synchronizedWithMesh;
  13431. private _ranges;
  13432. private _lastAbsoluteTransformsUpdateId;
  13433. private _canUseTextureForBones;
  13434. private _uniqueId;
  13435. /** @hidden */
  13436. _numBonesWithLinkedTransformNode: number;
  13437. /** @hidden */
  13438. _hasWaitingData: Nullable<boolean>;
  13439. /**
  13440. * Specifies if the skeleton should be serialized
  13441. */
  13442. doNotSerialize: boolean;
  13443. private _useTextureToStoreBoneMatrices;
  13444. /**
  13445. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13446. * Please note that this option is not available if the hardware does not support it
  13447. */
  13448. useTextureToStoreBoneMatrices: boolean;
  13449. private _animationPropertiesOverride;
  13450. /**
  13451. * Gets or sets the animation properties override
  13452. */
  13453. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13454. /**
  13455. * List of inspectable custom properties (used by the Inspector)
  13456. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13457. */
  13458. inspectableCustomProperties: IInspectable[];
  13459. /**
  13460. * An observable triggered before computing the skeleton's matrices
  13461. */
  13462. onBeforeComputeObservable: Observable<Skeleton>;
  13463. /**
  13464. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13465. */
  13466. readonly isUsingTextureForMatrices: boolean;
  13467. /**
  13468. * Gets the unique ID of this skeleton
  13469. */
  13470. readonly uniqueId: number;
  13471. /**
  13472. * Creates a new skeleton
  13473. * @param name defines the skeleton name
  13474. * @param id defines the skeleton Id
  13475. * @param scene defines the hosting scene
  13476. */
  13477. constructor(
  13478. /** defines the skeleton name */
  13479. name: string,
  13480. /** defines the skeleton Id */
  13481. id: string, scene: Scene);
  13482. /**
  13483. * Gets the current object class name.
  13484. * @return the class name
  13485. */
  13486. getClassName(): string;
  13487. /**
  13488. * Returns an array containing the root bones
  13489. * @returns an array containing the root bones
  13490. */
  13491. getChildren(): Array<Bone>;
  13492. /**
  13493. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13494. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13495. * @returns a Float32Array containing matrices data
  13496. */
  13497. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13498. /**
  13499. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13500. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13501. * @returns a raw texture containing the data
  13502. */
  13503. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13504. /**
  13505. * Gets the current hosting scene
  13506. * @returns a scene object
  13507. */
  13508. getScene(): Scene;
  13509. /**
  13510. * Gets a string representing the current skeleton data
  13511. * @param fullDetails defines a boolean indicating if we want a verbose version
  13512. * @returns a string representing the current skeleton data
  13513. */
  13514. toString(fullDetails?: boolean): string;
  13515. /**
  13516. * Get bone's index searching by name
  13517. * @param name defines bone's name to search for
  13518. * @return the indice of the bone. Returns -1 if not found
  13519. */
  13520. getBoneIndexByName(name: string): number;
  13521. /**
  13522. * Creater a new animation range
  13523. * @param name defines the name of the range
  13524. * @param from defines the start key
  13525. * @param to defines the end key
  13526. */
  13527. createAnimationRange(name: string, from: number, to: number): void;
  13528. /**
  13529. * Delete a specific animation range
  13530. * @param name defines the name of the range
  13531. * @param deleteFrames defines if frames must be removed as well
  13532. */
  13533. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13534. /**
  13535. * Gets a specific animation range
  13536. * @param name defines the name of the range to look for
  13537. * @returns the requested animation range or null if not found
  13538. */
  13539. getAnimationRange(name: string): Nullable<AnimationRange>;
  13540. /**
  13541. * Gets the list of all animation ranges defined on this skeleton
  13542. * @returns an array
  13543. */
  13544. getAnimationRanges(): Nullable<AnimationRange>[];
  13545. /**
  13546. * Copy animation range from a source skeleton.
  13547. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13548. * @param source defines the source skeleton
  13549. * @param name defines the name of the range to copy
  13550. * @param rescaleAsRequired defines if rescaling must be applied if required
  13551. * @returns true if operation was successful
  13552. */
  13553. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13554. /**
  13555. * Forces the skeleton to go to rest pose
  13556. */
  13557. returnToRest(): void;
  13558. private _getHighestAnimationFrame;
  13559. /**
  13560. * Begin a specific animation range
  13561. * @param name defines the name of the range to start
  13562. * @param loop defines if looping must be turned on (false by default)
  13563. * @param speedRatio defines the speed ratio to apply (1 by default)
  13564. * @param onAnimationEnd defines a callback which will be called when animation will end
  13565. * @returns a new animatable
  13566. */
  13567. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13568. /** @hidden */
  13569. _markAsDirty(): void;
  13570. /** @hidden */
  13571. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13572. /** @hidden */
  13573. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13574. private _computeTransformMatrices;
  13575. /**
  13576. * Build all resources required to render a skeleton
  13577. */
  13578. prepare(): void;
  13579. /**
  13580. * Gets the list of animatables currently running for this skeleton
  13581. * @returns an array of animatables
  13582. */
  13583. getAnimatables(): IAnimatable[];
  13584. /**
  13585. * Clone the current skeleton
  13586. * @param name defines the name of the new skeleton
  13587. * @param id defines the id of the new skeleton
  13588. * @returns the new skeleton
  13589. */
  13590. clone(name: string, id: string): Skeleton;
  13591. /**
  13592. * Enable animation blending for this skeleton
  13593. * @param blendingSpeed defines the blending speed to apply
  13594. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13595. */
  13596. enableBlending(blendingSpeed?: number): void;
  13597. /**
  13598. * Releases all resources associated with the current skeleton
  13599. */
  13600. dispose(): void;
  13601. /**
  13602. * Serialize the skeleton in a JSON object
  13603. * @returns a JSON object
  13604. */
  13605. serialize(): any;
  13606. /**
  13607. * Creates a new skeleton from serialized data
  13608. * @param parsedSkeleton defines the serialized data
  13609. * @param scene defines the hosting scene
  13610. * @returns a new skeleton
  13611. */
  13612. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13613. /**
  13614. * Compute all node absolute transforms
  13615. * @param forceUpdate defines if computation must be done even if cache is up to date
  13616. */
  13617. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13618. /**
  13619. * Gets the root pose matrix
  13620. * @returns a matrix
  13621. */
  13622. getPoseMatrix(): Nullable<Matrix>;
  13623. /**
  13624. * Sorts bones per internal index
  13625. */
  13626. sortBones(): void;
  13627. private _sortBones;
  13628. }
  13629. }
  13630. declare module "babylonjs/Bones/bone" {
  13631. import { Skeleton } from "babylonjs/Bones/skeleton";
  13632. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13633. import { Nullable } from "babylonjs/types";
  13634. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13635. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13636. import { Node } from "babylonjs/node";
  13637. import { Space } from "babylonjs/Maths/math.axis";
  13638. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13639. /**
  13640. * Class used to store bone information
  13641. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13642. */
  13643. export class Bone extends Node {
  13644. /**
  13645. * defines the bone name
  13646. */
  13647. name: string;
  13648. private static _tmpVecs;
  13649. private static _tmpQuat;
  13650. private static _tmpMats;
  13651. /**
  13652. * Gets the list of child bones
  13653. */
  13654. children: Bone[];
  13655. /** Gets the animations associated with this bone */
  13656. animations: import("babylonjs/Animations/animation").Animation[];
  13657. /**
  13658. * Gets or sets bone length
  13659. */
  13660. length: number;
  13661. /**
  13662. * @hidden Internal only
  13663. * Set this value to map this bone to a different index in the transform matrices
  13664. * Set this value to -1 to exclude the bone from the transform matrices
  13665. */
  13666. _index: Nullable<number>;
  13667. private _skeleton;
  13668. private _localMatrix;
  13669. private _restPose;
  13670. private _baseMatrix;
  13671. private _absoluteTransform;
  13672. private _invertedAbsoluteTransform;
  13673. private _parent;
  13674. private _scalingDeterminant;
  13675. private _worldTransform;
  13676. private _localScaling;
  13677. private _localRotation;
  13678. private _localPosition;
  13679. private _needToDecompose;
  13680. private _needToCompose;
  13681. /** @hidden */
  13682. _linkedTransformNode: Nullable<TransformNode>;
  13683. /** @hidden */
  13684. _waitingTransformNodeId: Nullable<string>;
  13685. /** @hidden */
  13686. /** @hidden */
  13687. _matrix: Matrix;
  13688. /**
  13689. * Create a new bone
  13690. * @param name defines the bone name
  13691. * @param skeleton defines the parent skeleton
  13692. * @param parentBone defines the parent (can be null if the bone is the root)
  13693. * @param localMatrix defines the local matrix
  13694. * @param restPose defines the rest pose matrix
  13695. * @param baseMatrix defines the base matrix
  13696. * @param index defines index of the bone in the hiearchy
  13697. */
  13698. constructor(
  13699. /**
  13700. * defines the bone name
  13701. */
  13702. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13703. /**
  13704. * Gets the current object class name.
  13705. * @return the class name
  13706. */
  13707. getClassName(): string;
  13708. /**
  13709. * Gets the parent skeleton
  13710. * @returns a skeleton
  13711. */
  13712. getSkeleton(): Skeleton;
  13713. /**
  13714. * Gets parent bone
  13715. * @returns a bone or null if the bone is the root of the bone hierarchy
  13716. */
  13717. getParent(): Nullable<Bone>;
  13718. /**
  13719. * Returns an array containing the root bones
  13720. * @returns an array containing the root bones
  13721. */
  13722. getChildren(): Array<Bone>;
  13723. /**
  13724. * Sets the parent bone
  13725. * @param parent defines the parent (can be null if the bone is the root)
  13726. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13727. */
  13728. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13729. /**
  13730. * Gets the local matrix
  13731. * @returns a matrix
  13732. */
  13733. getLocalMatrix(): Matrix;
  13734. /**
  13735. * Gets the base matrix (initial matrix which remains unchanged)
  13736. * @returns a matrix
  13737. */
  13738. getBaseMatrix(): Matrix;
  13739. /**
  13740. * Gets the rest pose matrix
  13741. * @returns a matrix
  13742. */
  13743. getRestPose(): Matrix;
  13744. /**
  13745. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13746. */
  13747. getWorldMatrix(): Matrix;
  13748. /**
  13749. * Sets the local matrix to rest pose matrix
  13750. */
  13751. returnToRest(): void;
  13752. /**
  13753. * Gets the inverse of the absolute transform matrix.
  13754. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13755. * @returns a matrix
  13756. */
  13757. getInvertedAbsoluteTransform(): Matrix;
  13758. /**
  13759. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13760. * @returns a matrix
  13761. */
  13762. getAbsoluteTransform(): Matrix;
  13763. /**
  13764. * Links with the given transform node.
  13765. * The local matrix of this bone is copied from the transform node every frame.
  13766. * @param transformNode defines the transform node to link to
  13767. */
  13768. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13769. /**
  13770. * Gets the node used to drive the bone's transformation
  13771. * @returns a transform node or null
  13772. */
  13773. getTransformNode(): Nullable<TransformNode>;
  13774. /** Gets or sets current position (in local space) */
  13775. position: Vector3;
  13776. /** Gets or sets current rotation (in local space) */
  13777. rotation: Vector3;
  13778. /** Gets or sets current rotation quaternion (in local space) */
  13779. rotationQuaternion: Quaternion;
  13780. /** Gets or sets current scaling (in local space) */
  13781. scaling: Vector3;
  13782. /**
  13783. * Gets the animation properties override
  13784. */
  13785. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13786. private _decompose;
  13787. private _compose;
  13788. /**
  13789. * Update the base and local matrices
  13790. * @param matrix defines the new base or local matrix
  13791. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13792. * @param updateLocalMatrix defines if the local matrix should be updated
  13793. */
  13794. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13795. /** @hidden */
  13796. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13797. /**
  13798. * Flag the bone as dirty (Forcing it to update everything)
  13799. */
  13800. markAsDirty(): void;
  13801. /** @hidden */
  13802. _markAsDirtyAndCompose(): void;
  13803. private _markAsDirtyAndDecompose;
  13804. /**
  13805. * Translate the bone in local or world space
  13806. * @param vec The amount to translate the bone
  13807. * @param space The space that the translation is in
  13808. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13809. */
  13810. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13811. /**
  13812. * Set the postion of the bone in local or world space
  13813. * @param position The position to set the bone
  13814. * @param space The space that the position is in
  13815. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13816. */
  13817. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13818. /**
  13819. * Set the absolute position of the bone (world space)
  13820. * @param position The position to set the bone
  13821. * @param mesh The mesh that this bone is attached to
  13822. */
  13823. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13824. /**
  13825. * Scale the bone on the x, y and z axes (in local space)
  13826. * @param x The amount to scale the bone on the x axis
  13827. * @param y The amount to scale the bone on the y axis
  13828. * @param z The amount to scale the bone on the z axis
  13829. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13830. */
  13831. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13832. /**
  13833. * Set the bone scaling in local space
  13834. * @param scale defines the scaling vector
  13835. */
  13836. setScale(scale: Vector3): void;
  13837. /**
  13838. * Gets the current scaling in local space
  13839. * @returns the current scaling vector
  13840. */
  13841. getScale(): Vector3;
  13842. /**
  13843. * Gets the current scaling in local space and stores it in a target vector
  13844. * @param result defines the target vector
  13845. */
  13846. getScaleToRef(result: Vector3): void;
  13847. /**
  13848. * Set the yaw, pitch, and roll of the bone in local or world space
  13849. * @param yaw The rotation of the bone on the y axis
  13850. * @param pitch The rotation of the bone on the x axis
  13851. * @param roll The rotation of the bone on the z axis
  13852. * @param space The space that the axes of rotation are in
  13853. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13854. */
  13855. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13856. /**
  13857. * Add a rotation to the bone on an axis in local or world space
  13858. * @param axis The axis to rotate the bone on
  13859. * @param amount The amount to rotate the bone
  13860. * @param space The space that the axis is in
  13861. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13862. */
  13863. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13864. /**
  13865. * Set the rotation of the bone to a particular axis angle in local or world space
  13866. * @param axis The axis to rotate the bone on
  13867. * @param angle The angle that the bone should be rotated to
  13868. * @param space The space that the axis is in
  13869. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13870. */
  13871. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13872. /**
  13873. * Set the euler rotation of the bone in local of world space
  13874. * @param rotation The euler rotation that the bone should be set to
  13875. * @param space The space that the rotation is in
  13876. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13877. */
  13878. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13879. /**
  13880. * Set the quaternion rotation of the bone in local of world space
  13881. * @param quat The quaternion rotation that the bone should be set to
  13882. * @param space The space that the rotation is in
  13883. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13884. */
  13885. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13886. /**
  13887. * Set the rotation matrix of the bone in local of world space
  13888. * @param rotMat The rotation matrix that the bone should be set to
  13889. * @param space The space that the rotation is in
  13890. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13891. */
  13892. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13893. private _rotateWithMatrix;
  13894. private _getNegativeRotationToRef;
  13895. /**
  13896. * Get the position of the bone in local or world space
  13897. * @param space The space that the returned position is in
  13898. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13899. * @returns The position of the bone
  13900. */
  13901. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13902. /**
  13903. * Copy the position of the bone to a vector3 in local or world space
  13904. * @param space The space that the returned position is in
  13905. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13906. * @param result The vector3 to copy the position to
  13907. */
  13908. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13909. /**
  13910. * Get the absolute position of the bone (world space)
  13911. * @param mesh The mesh that this bone is attached to
  13912. * @returns The absolute position of the bone
  13913. */
  13914. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13915. /**
  13916. * Copy the absolute position of the bone (world space) to the result param
  13917. * @param mesh The mesh that this bone is attached to
  13918. * @param result The vector3 to copy the absolute position to
  13919. */
  13920. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13921. /**
  13922. * Compute the absolute transforms of this bone and its children
  13923. */
  13924. computeAbsoluteTransforms(): void;
  13925. /**
  13926. * Get the world direction from an axis that is in the local space of the bone
  13927. * @param localAxis The local direction that is used to compute the world direction
  13928. * @param mesh The mesh that this bone is attached to
  13929. * @returns The world direction
  13930. */
  13931. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13932. /**
  13933. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13934. * @param localAxis The local direction that is used to compute the world direction
  13935. * @param mesh The mesh that this bone is attached to
  13936. * @param result The vector3 that the world direction will be copied to
  13937. */
  13938. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13939. /**
  13940. * Get the euler rotation of the bone in local or world space
  13941. * @param space The space that the rotation should be in
  13942. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13943. * @returns The euler rotation
  13944. */
  13945. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13946. /**
  13947. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13948. * @param space The space that the rotation should be in
  13949. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13950. * @param result The vector3 that the rotation should be copied to
  13951. */
  13952. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13953. /**
  13954. * Get the quaternion rotation of the bone in either local or world space
  13955. * @param space The space that the rotation should be in
  13956. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13957. * @returns The quaternion rotation
  13958. */
  13959. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13960. /**
  13961. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13962. * @param space The space that the rotation should be in
  13963. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13964. * @param result The quaternion that the rotation should be copied to
  13965. */
  13966. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13967. /**
  13968. * Get the rotation matrix of the bone in local or world space
  13969. * @param space The space that the rotation should be in
  13970. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13971. * @returns The rotation matrix
  13972. */
  13973. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13974. /**
  13975. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13976. * @param space The space that the rotation should be in
  13977. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13978. * @param result The quaternion that the rotation should be copied to
  13979. */
  13980. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13981. /**
  13982. * Get the world position of a point that is in the local space of the bone
  13983. * @param position The local position
  13984. * @param mesh The mesh that this bone is attached to
  13985. * @returns The world position
  13986. */
  13987. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13988. /**
  13989. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13990. * @param position The local position
  13991. * @param mesh The mesh that this bone is attached to
  13992. * @param result The vector3 that the world position should be copied to
  13993. */
  13994. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13995. /**
  13996. * Get the local position of a point that is in world space
  13997. * @param position The world position
  13998. * @param mesh The mesh that this bone is attached to
  13999. * @returns The local position
  14000. */
  14001. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14002. /**
  14003. * Get the local position of a point that is in world space and copy it to the result param
  14004. * @param position The world position
  14005. * @param mesh The mesh that this bone is attached to
  14006. * @param result The vector3 that the local position should be copied to
  14007. */
  14008. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14009. }
  14010. }
  14011. declare module "babylonjs/Meshes/transformNode" {
  14012. import { DeepImmutable } from "babylonjs/types";
  14013. import { Observable } from "babylonjs/Misc/observable";
  14014. import { Nullable } from "babylonjs/types";
  14015. import { Camera } from "babylonjs/Cameras/camera";
  14016. import { Scene } from "babylonjs/scene";
  14017. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14018. import { Node } from "babylonjs/node";
  14019. import { Bone } from "babylonjs/Bones/bone";
  14020. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14021. import { Space } from "babylonjs/Maths/math.axis";
  14022. /**
  14023. * 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.
  14024. * @see https://doc.babylonjs.com/how_to/transformnode
  14025. */
  14026. export class TransformNode extends Node {
  14027. /**
  14028. * Object will not rotate to face the camera
  14029. */
  14030. static BILLBOARDMODE_NONE: number;
  14031. /**
  14032. * Object will rotate to face the camera but only on the x axis
  14033. */
  14034. static BILLBOARDMODE_X: number;
  14035. /**
  14036. * Object will rotate to face the camera but only on the y axis
  14037. */
  14038. static BILLBOARDMODE_Y: number;
  14039. /**
  14040. * Object will rotate to face the camera but only on the z axis
  14041. */
  14042. static BILLBOARDMODE_Z: number;
  14043. /**
  14044. * Object will rotate to face the camera
  14045. */
  14046. static BILLBOARDMODE_ALL: number;
  14047. /**
  14048. * Object will rotate to face the camera's position instead of orientation
  14049. */
  14050. static BILLBOARDMODE_USE_POSITION: number;
  14051. private _forward;
  14052. private _forwardInverted;
  14053. private _up;
  14054. private _right;
  14055. private _rightInverted;
  14056. private _position;
  14057. private _rotation;
  14058. private _rotationQuaternion;
  14059. protected _scaling: Vector3;
  14060. protected _isDirty: boolean;
  14061. private _transformToBoneReferal;
  14062. private _isAbsoluteSynced;
  14063. private _billboardMode;
  14064. /**
  14065. * Gets or sets the billboard mode. Default is 0.
  14066. *
  14067. * | Value | Type | Description |
  14068. * | --- | --- | --- |
  14069. * | 0 | BILLBOARDMODE_NONE | |
  14070. * | 1 | BILLBOARDMODE_X | |
  14071. * | 2 | BILLBOARDMODE_Y | |
  14072. * | 4 | BILLBOARDMODE_Z | |
  14073. * | 7 | BILLBOARDMODE_ALL | |
  14074. *
  14075. */
  14076. billboardMode: number;
  14077. private _preserveParentRotationForBillboard;
  14078. /**
  14079. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14080. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14081. */
  14082. preserveParentRotationForBillboard: boolean;
  14083. /**
  14084. * 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
  14085. */
  14086. scalingDeterminant: number;
  14087. private _infiniteDistance;
  14088. /**
  14089. * Gets or sets the distance of the object to max, often used by skybox
  14090. */
  14091. infiniteDistance: boolean;
  14092. /**
  14093. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14094. * By default the system will update normals to compensate
  14095. */
  14096. ignoreNonUniformScaling: boolean;
  14097. /**
  14098. * 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
  14099. */
  14100. reIntegrateRotationIntoRotationQuaternion: boolean;
  14101. /** @hidden */
  14102. _poseMatrix: Nullable<Matrix>;
  14103. /** @hidden */
  14104. _localMatrix: Matrix;
  14105. private _usePivotMatrix;
  14106. private _absolutePosition;
  14107. private _absoluteScaling;
  14108. private _absoluteRotationQuaternion;
  14109. private _pivotMatrix;
  14110. private _pivotMatrixInverse;
  14111. protected _postMultiplyPivotMatrix: boolean;
  14112. protected _isWorldMatrixFrozen: boolean;
  14113. /** @hidden */
  14114. _indexInSceneTransformNodesArray: number;
  14115. /**
  14116. * An event triggered after the world matrix is updated
  14117. */
  14118. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14119. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14120. /**
  14121. * Gets a string identifying the name of the class
  14122. * @returns "TransformNode" string
  14123. */
  14124. getClassName(): string;
  14125. /**
  14126. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14127. */
  14128. position: Vector3;
  14129. /**
  14130. * 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)).
  14131. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14132. */
  14133. rotation: Vector3;
  14134. /**
  14135. * 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)).
  14136. */
  14137. scaling: Vector3;
  14138. /**
  14139. * 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).
  14140. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14141. */
  14142. rotationQuaternion: Nullable<Quaternion>;
  14143. /**
  14144. * The forward direction of that transform in world space.
  14145. */
  14146. readonly forward: Vector3;
  14147. /**
  14148. * The up direction of that transform in world space.
  14149. */
  14150. readonly up: Vector3;
  14151. /**
  14152. * The right direction of that transform in world space.
  14153. */
  14154. readonly right: Vector3;
  14155. /**
  14156. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14157. * @param matrix the matrix to copy the pose from
  14158. * @returns this TransformNode.
  14159. */
  14160. updatePoseMatrix(matrix: Matrix): TransformNode;
  14161. /**
  14162. * Returns the mesh Pose matrix.
  14163. * @returns the pose matrix
  14164. */
  14165. getPoseMatrix(): Matrix;
  14166. /** @hidden */
  14167. _isSynchronized(): boolean;
  14168. /** @hidden */
  14169. _initCache(): void;
  14170. /**
  14171. * Flag the transform node as dirty (Forcing it to update everything)
  14172. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14173. * @returns this transform node
  14174. */
  14175. markAsDirty(property: string): TransformNode;
  14176. /**
  14177. * Returns the current mesh absolute position.
  14178. * Returns a Vector3.
  14179. */
  14180. readonly absolutePosition: Vector3;
  14181. /**
  14182. * Returns the current mesh absolute scaling.
  14183. * Returns a Vector3.
  14184. */
  14185. readonly absoluteScaling: Vector3;
  14186. /**
  14187. * Returns the current mesh absolute rotation.
  14188. * Returns a Quaternion.
  14189. */
  14190. readonly absoluteRotationQuaternion: Quaternion;
  14191. /**
  14192. * Sets a new matrix to apply before all other transformation
  14193. * @param matrix defines the transform matrix
  14194. * @returns the current TransformNode
  14195. */
  14196. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14197. /**
  14198. * Sets a new pivot matrix to the current node
  14199. * @param matrix defines the new pivot matrix to use
  14200. * @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
  14201. * @returns the current TransformNode
  14202. */
  14203. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14204. /**
  14205. * Returns the mesh pivot matrix.
  14206. * Default : Identity.
  14207. * @returns the matrix
  14208. */
  14209. getPivotMatrix(): Matrix;
  14210. /**
  14211. * Instantiate (when possible) or clone that node with its hierarchy
  14212. * @param newParent defines the new parent to use for the instance (or clone)
  14213. * @returns an instance (or a clone) of the current node with its hiearchy
  14214. */
  14215. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14216. /**
  14217. * Prevents the World matrix to be computed any longer
  14218. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14219. * @returns the TransformNode.
  14220. */
  14221. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14222. /**
  14223. * Allows back the World matrix computation.
  14224. * @returns the TransformNode.
  14225. */
  14226. unfreezeWorldMatrix(): this;
  14227. /**
  14228. * True if the World matrix has been frozen.
  14229. */
  14230. readonly isWorldMatrixFrozen: boolean;
  14231. /**
  14232. * Retuns the mesh absolute position in the World.
  14233. * @returns a Vector3.
  14234. */
  14235. getAbsolutePosition(): Vector3;
  14236. /**
  14237. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14238. * @param absolutePosition the absolute position to set
  14239. * @returns the TransformNode.
  14240. */
  14241. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14242. /**
  14243. * Sets the mesh position in its local space.
  14244. * @param vector3 the position to set in localspace
  14245. * @returns the TransformNode.
  14246. */
  14247. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14248. /**
  14249. * Returns the mesh position in the local space from the current World matrix values.
  14250. * @returns a new Vector3.
  14251. */
  14252. getPositionExpressedInLocalSpace(): Vector3;
  14253. /**
  14254. * Translates the mesh along the passed Vector3 in its local space.
  14255. * @param vector3 the distance to translate in localspace
  14256. * @returns the TransformNode.
  14257. */
  14258. locallyTranslate(vector3: Vector3): TransformNode;
  14259. private static _lookAtVectorCache;
  14260. /**
  14261. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14262. * @param targetPoint the position (must be in same space as current mesh) to look at
  14263. * @param yawCor optional yaw (y-axis) correction in radians
  14264. * @param pitchCor optional pitch (x-axis) correction in radians
  14265. * @param rollCor optional roll (z-axis) correction in radians
  14266. * @param space the choosen space of the target
  14267. * @returns the TransformNode.
  14268. */
  14269. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14270. /**
  14271. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14272. * This Vector3 is expressed in the World space.
  14273. * @param localAxis axis to rotate
  14274. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14275. */
  14276. getDirection(localAxis: Vector3): Vector3;
  14277. /**
  14278. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14279. * localAxis is expressed in the mesh local space.
  14280. * result is computed in the Wordl space from the mesh World matrix.
  14281. * @param localAxis axis to rotate
  14282. * @param result the resulting transformnode
  14283. * @returns this TransformNode.
  14284. */
  14285. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14286. /**
  14287. * Sets this transform node rotation to the given local axis.
  14288. * @param localAxis the axis in local space
  14289. * @param yawCor optional yaw (y-axis) correction in radians
  14290. * @param pitchCor optional pitch (x-axis) correction in radians
  14291. * @param rollCor optional roll (z-axis) correction in radians
  14292. * @returns this TransformNode
  14293. */
  14294. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14295. /**
  14296. * Sets a new pivot point to the current node
  14297. * @param point defines the new pivot point to use
  14298. * @param space defines if the point is in world or local space (local by default)
  14299. * @returns the current TransformNode
  14300. */
  14301. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14302. /**
  14303. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14304. * @returns the pivot point
  14305. */
  14306. getPivotPoint(): Vector3;
  14307. /**
  14308. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14309. * @param result the vector3 to store the result
  14310. * @returns this TransformNode.
  14311. */
  14312. getPivotPointToRef(result: Vector3): TransformNode;
  14313. /**
  14314. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14315. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14316. */
  14317. getAbsolutePivotPoint(): Vector3;
  14318. /**
  14319. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14320. * @param result vector3 to store the result
  14321. * @returns this TransformNode.
  14322. */
  14323. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14324. /**
  14325. * Defines the passed node as the parent of the current node.
  14326. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14327. * @see https://doc.babylonjs.com/how_to/parenting
  14328. * @param node the node ot set as the parent
  14329. * @returns this TransformNode.
  14330. */
  14331. setParent(node: Nullable<Node>): TransformNode;
  14332. private _nonUniformScaling;
  14333. /**
  14334. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14335. */
  14336. readonly nonUniformScaling: boolean;
  14337. /** @hidden */
  14338. _updateNonUniformScalingState(value: boolean): boolean;
  14339. /**
  14340. * Attach the current TransformNode to another TransformNode associated with a bone
  14341. * @param bone Bone affecting the TransformNode
  14342. * @param affectedTransformNode TransformNode associated with the bone
  14343. * @returns this object
  14344. */
  14345. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14346. /**
  14347. * Detach the transform node if its associated with a bone
  14348. * @returns this object
  14349. */
  14350. detachFromBone(): TransformNode;
  14351. private static _rotationAxisCache;
  14352. /**
  14353. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14354. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14355. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14356. * The passed axis is also normalized.
  14357. * @param axis the axis to rotate around
  14358. * @param amount the amount to rotate in radians
  14359. * @param space Space to rotate in (Default: local)
  14360. * @returns the TransformNode.
  14361. */
  14362. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14363. /**
  14364. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14365. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14366. * The passed axis is also normalized. .
  14367. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14368. * @param point the point to rotate around
  14369. * @param axis the axis to rotate around
  14370. * @param amount the amount to rotate in radians
  14371. * @returns the TransformNode
  14372. */
  14373. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14374. /**
  14375. * Translates the mesh along the axis vector for the passed distance in the given space.
  14376. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14377. * @param axis the axis to translate in
  14378. * @param distance the distance to translate
  14379. * @param space Space to rotate in (Default: local)
  14380. * @returns the TransformNode.
  14381. */
  14382. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14383. /**
  14384. * Adds a rotation step to the mesh current rotation.
  14385. * x, y, z are Euler angles expressed in radians.
  14386. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14387. * This means this rotation is made in the mesh local space only.
  14388. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14389. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14390. * ```javascript
  14391. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14392. * ```
  14393. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14394. * 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.
  14395. * @param x Rotation to add
  14396. * @param y Rotation to add
  14397. * @param z Rotation to add
  14398. * @returns the TransformNode.
  14399. */
  14400. addRotation(x: number, y: number, z: number): TransformNode;
  14401. /**
  14402. * @hidden
  14403. */
  14404. protected _getEffectiveParent(): Nullable<Node>;
  14405. /**
  14406. * Computes the world matrix of the node
  14407. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14408. * @returns the world matrix
  14409. */
  14410. computeWorldMatrix(force?: boolean): Matrix;
  14411. protected _afterComputeWorldMatrix(): void;
  14412. /**
  14413. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14414. * @param func callback function to add
  14415. *
  14416. * @returns the TransformNode.
  14417. */
  14418. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14419. /**
  14420. * Removes a registered callback function.
  14421. * @param func callback function to remove
  14422. * @returns the TransformNode.
  14423. */
  14424. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14425. /**
  14426. * Gets the position of the current mesh in camera space
  14427. * @param camera defines the camera to use
  14428. * @returns a position
  14429. */
  14430. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14431. /**
  14432. * Returns the distance from the mesh to the active camera
  14433. * @param camera defines the camera to use
  14434. * @returns the distance
  14435. */
  14436. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14437. /**
  14438. * Clone the current transform node
  14439. * @param name Name of the new clone
  14440. * @param newParent New parent for the clone
  14441. * @param doNotCloneChildren Do not clone children hierarchy
  14442. * @returns the new transform node
  14443. */
  14444. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14445. /**
  14446. * Serializes the objects information.
  14447. * @param currentSerializationObject defines the object to serialize in
  14448. * @returns the serialized object
  14449. */
  14450. serialize(currentSerializationObject?: any): any;
  14451. /**
  14452. * Returns a new TransformNode object parsed from the source provided.
  14453. * @param parsedTransformNode is the source.
  14454. * @param scene the scne the object belongs to
  14455. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14456. * @returns a new TransformNode object parsed from the source provided.
  14457. */
  14458. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14459. /**
  14460. * Get all child-transformNodes of this node
  14461. * @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
  14462. * @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
  14463. * @returns an array of TransformNode
  14464. */
  14465. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14466. /**
  14467. * Releases resources associated with this transform node.
  14468. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14469. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14470. */
  14471. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14472. /**
  14473. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14474. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14475. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14476. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14477. * @returns the current mesh
  14478. */
  14479. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14480. private _syncAbsoluteScalingAndRotation;
  14481. }
  14482. }
  14483. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14484. import { Observable } from "babylonjs/Misc/observable";
  14485. import { Nullable } from "babylonjs/types";
  14486. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14487. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14488. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14489. import { Ray } from "babylonjs/Culling/ray";
  14490. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14491. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14492. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14493. /**
  14494. * Defines the types of pose enabled controllers that are supported
  14495. */
  14496. export enum PoseEnabledControllerType {
  14497. /**
  14498. * HTC Vive
  14499. */
  14500. VIVE = 0,
  14501. /**
  14502. * Oculus Rift
  14503. */
  14504. OCULUS = 1,
  14505. /**
  14506. * Windows mixed reality
  14507. */
  14508. WINDOWS = 2,
  14509. /**
  14510. * Samsung gear VR
  14511. */
  14512. GEAR_VR = 3,
  14513. /**
  14514. * Google Daydream
  14515. */
  14516. DAYDREAM = 4,
  14517. /**
  14518. * Generic
  14519. */
  14520. GENERIC = 5
  14521. }
  14522. /**
  14523. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14524. */
  14525. export interface MutableGamepadButton {
  14526. /**
  14527. * Value of the button/trigger
  14528. */
  14529. value: number;
  14530. /**
  14531. * If the button/trigger is currently touched
  14532. */
  14533. touched: boolean;
  14534. /**
  14535. * If the button/trigger is currently pressed
  14536. */
  14537. pressed: boolean;
  14538. }
  14539. /**
  14540. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14541. * @hidden
  14542. */
  14543. export interface ExtendedGamepadButton extends GamepadButton {
  14544. /**
  14545. * If the button/trigger is currently pressed
  14546. */
  14547. readonly pressed: boolean;
  14548. /**
  14549. * If the button/trigger is currently touched
  14550. */
  14551. readonly touched: boolean;
  14552. /**
  14553. * Value of the button/trigger
  14554. */
  14555. readonly value: number;
  14556. }
  14557. /** @hidden */
  14558. export interface _GamePadFactory {
  14559. /**
  14560. * Returns wether or not the current gamepad can be created for this type of controller.
  14561. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14562. * @returns true if it can be created, otherwise false
  14563. */
  14564. canCreate(gamepadInfo: any): boolean;
  14565. /**
  14566. * Creates a new instance of the Gamepad.
  14567. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14568. * @returns the new gamepad instance
  14569. */
  14570. create(gamepadInfo: any): Gamepad;
  14571. }
  14572. /**
  14573. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14574. */
  14575. export class PoseEnabledControllerHelper {
  14576. /** @hidden */
  14577. static _ControllerFactories: _GamePadFactory[];
  14578. /** @hidden */
  14579. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14580. /**
  14581. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14582. * @param vrGamepad the gamepad to initialized
  14583. * @returns a vr controller of the type the gamepad identified as
  14584. */
  14585. static InitiateController(vrGamepad: any): Gamepad;
  14586. }
  14587. /**
  14588. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14589. */
  14590. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14591. /**
  14592. * If the controller is used in a webXR session
  14593. */
  14594. isXR: boolean;
  14595. private _deviceRoomPosition;
  14596. private _deviceRoomRotationQuaternion;
  14597. /**
  14598. * The device position in babylon space
  14599. */
  14600. devicePosition: Vector3;
  14601. /**
  14602. * The device rotation in babylon space
  14603. */
  14604. deviceRotationQuaternion: Quaternion;
  14605. /**
  14606. * The scale factor of the device in babylon space
  14607. */
  14608. deviceScaleFactor: number;
  14609. /**
  14610. * (Likely devicePosition should be used instead) The device position in its room space
  14611. */
  14612. position: Vector3;
  14613. /**
  14614. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14615. */
  14616. rotationQuaternion: Quaternion;
  14617. /**
  14618. * The type of controller (Eg. Windows mixed reality)
  14619. */
  14620. controllerType: PoseEnabledControllerType;
  14621. protected _calculatedPosition: Vector3;
  14622. private _calculatedRotation;
  14623. /**
  14624. * The raw pose from the device
  14625. */
  14626. rawPose: DevicePose;
  14627. private _trackPosition;
  14628. private _maxRotationDistFromHeadset;
  14629. private _draggedRoomRotation;
  14630. /**
  14631. * @hidden
  14632. */
  14633. _disableTrackPosition(fixedPosition: Vector3): void;
  14634. /**
  14635. * Internal, the mesh attached to the controller
  14636. * @hidden
  14637. */
  14638. _mesh: Nullable<AbstractMesh>;
  14639. private _poseControlledCamera;
  14640. private _leftHandSystemQuaternion;
  14641. /**
  14642. * Internal, matrix used to convert room space to babylon space
  14643. * @hidden
  14644. */
  14645. _deviceToWorld: Matrix;
  14646. /**
  14647. * Node to be used when casting a ray from the controller
  14648. * @hidden
  14649. */
  14650. _pointingPoseNode: Nullable<TransformNode>;
  14651. /**
  14652. * Name of the child mesh that can be used to cast a ray from the controller
  14653. */
  14654. static readonly POINTING_POSE: string;
  14655. /**
  14656. * Creates a new PoseEnabledController from a gamepad
  14657. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14658. */
  14659. constructor(browserGamepad: any);
  14660. private _workingMatrix;
  14661. /**
  14662. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14663. */
  14664. update(): void;
  14665. /**
  14666. * Updates only the pose device and mesh without doing any button event checking
  14667. */
  14668. protected _updatePoseAndMesh(): void;
  14669. /**
  14670. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14671. * @param poseData raw pose fromthe device
  14672. */
  14673. updateFromDevice(poseData: DevicePose): void;
  14674. /**
  14675. * @hidden
  14676. */
  14677. _meshAttachedObservable: Observable<AbstractMesh>;
  14678. /**
  14679. * Attaches a mesh to the controller
  14680. * @param mesh the mesh to be attached
  14681. */
  14682. attachToMesh(mesh: AbstractMesh): void;
  14683. /**
  14684. * Attaches the controllers mesh to a camera
  14685. * @param camera the camera the mesh should be attached to
  14686. */
  14687. attachToPoseControlledCamera(camera: TargetCamera): void;
  14688. /**
  14689. * Disposes of the controller
  14690. */
  14691. dispose(): void;
  14692. /**
  14693. * The mesh that is attached to the controller
  14694. */
  14695. readonly mesh: Nullable<AbstractMesh>;
  14696. /**
  14697. * Gets the ray of the controller in the direction the controller is pointing
  14698. * @param length the length the resulting ray should be
  14699. * @returns a ray in the direction the controller is pointing
  14700. */
  14701. getForwardRay(length?: number): Ray;
  14702. }
  14703. }
  14704. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14705. import { Observable } from "babylonjs/Misc/observable";
  14706. import { Scene } from "babylonjs/scene";
  14707. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14708. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14709. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14710. import { Nullable } from "babylonjs/types";
  14711. /**
  14712. * Defines the WebVRController object that represents controllers tracked in 3D space
  14713. */
  14714. export abstract class WebVRController extends PoseEnabledController {
  14715. /**
  14716. * Internal, the default controller model for the controller
  14717. */
  14718. protected _defaultModel: Nullable<AbstractMesh>;
  14719. /**
  14720. * Fired when the trigger state has changed
  14721. */
  14722. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14723. /**
  14724. * Fired when the main button state has changed
  14725. */
  14726. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14727. /**
  14728. * Fired when the secondary button state has changed
  14729. */
  14730. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14731. /**
  14732. * Fired when the pad state has changed
  14733. */
  14734. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14735. /**
  14736. * Fired when controllers stick values have changed
  14737. */
  14738. onPadValuesChangedObservable: Observable<StickValues>;
  14739. /**
  14740. * Array of button availible on the controller
  14741. */
  14742. protected _buttons: Array<MutableGamepadButton>;
  14743. private _onButtonStateChange;
  14744. /**
  14745. * Fired when a controller button's state has changed
  14746. * @param callback the callback containing the button that was modified
  14747. */
  14748. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14749. /**
  14750. * X and Y axis corresponding to the controllers joystick
  14751. */
  14752. pad: StickValues;
  14753. /**
  14754. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14755. */
  14756. hand: string;
  14757. /**
  14758. * The default controller model for the controller
  14759. */
  14760. readonly defaultModel: Nullable<AbstractMesh>;
  14761. /**
  14762. * Creates a new WebVRController from a gamepad
  14763. * @param vrGamepad the gamepad that the WebVRController should be created from
  14764. */
  14765. constructor(vrGamepad: any);
  14766. /**
  14767. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14768. */
  14769. update(): void;
  14770. /**
  14771. * Function to be called when a button is modified
  14772. */
  14773. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14774. /**
  14775. * Loads a mesh and attaches it to the controller
  14776. * @param scene the scene the mesh should be added to
  14777. * @param meshLoaded callback for when the mesh has been loaded
  14778. */
  14779. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14780. private _setButtonValue;
  14781. private _changes;
  14782. private _checkChanges;
  14783. /**
  14784. * Disposes of th webVRCOntroller
  14785. */
  14786. dispose(): void;
  14787. }
  14788. }
  14789. declare module "babylonjs/Lights/hemisphericLight" {
  14790. import { Nullable } from "babylonjs/types";
  14791. import { Scene } from "babylonjs/scene";
  14792. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14793. import { Color3 } from "babylonjs/Maths/math.color";
  14794. import { Effect } from "babylonjs/Materials/effect";
  14795. import { Light } from "babylonjs/Lights/light";
  14796. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14797. /**
  14798. * The HemisphericLight simulates the ambient environment light,
  14799. * so the passed direction is the light reflection direction, not the incoming direction.
  14800. */
  14801. export class HemisphericLight extends Light {
  14802. /**
  14803. * The groundColor is the light in the opposite direction to the one specified during creation.
  14804. * 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.
  14805. */
  14806. groundColor: Color3;
  14807. /**
  14808. * The light reflection direction, not the incoming direction.
  14809. */
  14810. direction: Vector3;
  14811. /**
  14812. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14813. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14814. * The HemisphericLight can't cast shadows.
  14815. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14816. * @param name The friendly name of the light
  14817. * @param direction The direction of the light reflection
  14818. * @param scene The scene the light belongs to
  14819. */
  14820. constructor(name: string, direction: Vector3, scene: Scene);
  14821. protected _buildUniformLayout(): void;
  14822. /**
  14823. * Returns the string "HemisphericLight".
  14824. * @return The class name
  14825. */
  14826. getClassName(): string;
  14827. /**
  14828. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14829. * Returns the updated direction.
  14830. * @param target The target the direction should point to
  14831. * @return The computed direction
  14832. */
  14833. setDirectionToTarget(target: Vector3): Vector3;
  14834. /**
  14835. * Returns the shadow generator associated to the light.
  14836. * @returns Always null for hemispheric lights because it does not support shadows.
  14837. */
  14838. getShadowGenerator(): Nullable<IShadowGenerator>;
  14839. /**
  14840. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14841. * @param effect The effect to update
  14842. * @param lightIndex The index of the light in the effect to update
  14843. * @returns The hemispheric light
  14844. */
  14845. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14846. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14847. /**
  14848. * Computes the world matrix of the node
  14849. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14850. * @param useWasUpdatedFlag defines a reserved property
  14851. * @returns the world matrix
  14852. */
  14853. computeWorldMatrix(): Matrix;
  14854. /**
  14855. * Returns the integer 3.
  14856. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14857. */
  14858. getTypeID(): number;
  14859. /**
  14860. * Prepares the list of defines specific to the light type.
  14861. * @param defines the list of defines
  14862. * @param lightIndex defines the index of the light for the effect
  14863. */
  14864. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14865. }
  14866. }
  14867. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  14868. /** @hidden */
  14869. export var vrMultiviewToSingleviewPixelShader: {
  14870. name: string;
  14871. shader: string;
  14872. };
  14873. }
  14874. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  14875. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14876. import { Scene } from "babylonjs/scene";
  14877. /**
  14878. * Renders to multiple views with a single draw call
  14879. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14880. */
  14881. export class MultiviewRenderTarget extends RenderTargetTexture {
  14882. /**
  14883. * Creates a multiview render target
  14884. * @param scene scene used with the render target
  14885. * @param size the size of the render target (used for each view)
  14886. */
  14887. constructor(scene: Scene, size?: number | {
  14888. width: number;
  14889. height: number;
  14890. } | {
  14891. ratio: number;
  14892. });
  14893. /**
  14894. * @hidden
  14895. * @param faceIndex the face index, if its a cube texture
  14896. */
  14897. _bindFrameBuffer(faceIndex?: number): void;
  14898. /**
  14899. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14900. * @returns the view count
  14901. */
  14902. getViewCount(): number;
  14903. }
  14904. }
  14905. declare module "babylonjs/Maths/math.frustum" {
  14906. import { Matrix } from "babylonjs/Maths/math.vector";
  14907. import { DeepImmutable } from "babylonjs/types";
  14908. import { Plane } from "babylonjs/Maths/math.plane";
  14909. /**
  14910. * Represents a camera frustum
  14911. */
  14912. export class Frustum {
  14913. /**
  14914. * Gets the planes representing the frustum
  14915. * @param transform matrix to be applied to the returned planes
  14916. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14917. */
  14918. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14919. /**
  14920. * Gets the near frustum plane transformed by the transform matrix
  14921. * @param transform transformation matrix to be applied to the resulting frustum plane
  14922. * @param frustumPlane the resuling frustum plane
  14923. */
  14924. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14925. /**
  14926. * Gets the far frustum plane transformed by the transform matrix
  14927. * @param transform transformation matrix to be applied to the resulting frustum plane
  14928. * @param frustumPlane the resuling frustum plane
  14929. */
  14930. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14931. /**
  14932. * Gets the left frustum plane transformed by the transform matrix
  14933. * @param transform transformation matrix to be applied to the resulting frustum plane
  14934. * @param frustumPlane the resuling frustum plane
  14935. */
  14936. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14937. /**
  14938. * Gets the right frustum plane transformed by the transform matrix
  14939. * @param transform transformation matrix to be applied to the resulting frustum plane
  14940. * @param frustumPlane the resuling frustum plane
  14941. */
  14942. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14943. /**
  14944. * Gets the top frustum plane transformed by the transform matrix
  14945. * @param transform transformation matrix to be applied to the resulting frustum plane
  14946. * @param frustumPlane the resuling frustum plane
  14947. */
  14948. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14949. /**
  14950. * Gets the bottom frustum plane transformed by the transform matrix
  14951. * @param transform transformation matrix to be applied to the resulting frustum plane
  14952. * @param frustumPlane the resuling frustum plane
  14953. */
  14954. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14955. /**
  14956. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14957. * @param transform transformation matrix to be applied to the resulting frustum planes
  14958. * @param frustumPlanes the resuling frustum planes
  14959. */
  14960. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14961. }
  14962. }
  14963. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  14964. import { Camera } from "babylonjs/Cameras/camera";
  14965. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14966. import { Nullable } from "babylonjs/types";
  14967. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14968. import { Matrix } from "babylonjs/Maths/math.vector";
  14969. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  14970. module "babylonjs/Engines/engine" {
  14971. interface Engine {
  14972. /**
  14973. * Creates a new multiview render target
  14974. * @param width defines the width of the texture
  14975. * @param height defines the height of the texture
  14976. * @returns the created multiview texture
  14977. */
  14978. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14979. /**
  14980. * Binds a multiview framebuffer to be drawn to
  14981. * @param multiviewTexture texture to bind
  14982. */
  14983. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14984. }
  14985. }
  14986. module "babylonjs/Cameras/camera" {
  14987. interface Camera {
  14988. /**
  14989. * @hidden
  14990. * 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)
  14991. */
  14992. _useMultiviewToSingleView: boolean;
  14993. /**
  14994. * @hidden
  14995. * 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)
  14996. */
  14997. _multiviewTexture: Nullable<RenderTargetTexture>;
  14998. /**
  14999. * @hidden
  15000. * ensures the multiview texture of the camera exists and has the specified width/height
  15001. * @param width height to set on the multiview texture
  15002. * @param height width to set on the multiview texture
  15003. */
  15004. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15005. }
  15006. }
  15007. module "babylonjs/scene" {
  15008. interface Scene {
  15009. /** @hidden */
  15010. _transformMatrixR: Matrix;
  15011. /** @hidden */
  15012. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15013. /** @hidden */
  15014. _createMultiviewUbo(): void;
  15015. /** @hidden */
  15016. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15017. /** @hidden */
  15018. _renderMultiviewToSingleView(camera: Camera): void;
  15019. }
  15020. }
  15021. }
  15022. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15023. import { Camera } from "babylonjs/Cameras/camera";
  15024. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15025. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15026. import "babylonjs/Engines/Extensions/engine.multiview";
  15027. /**
  15028. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15029. * This will not be used for webXR as it supports displaying texture arrays directly
  15030. */
  15031. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15032. /**
  15033. * Initializes a VRMultiviewToSingleview
  15034. * @param name name of the post process
  15035. * @param camera camera to be applied to
  15036. * @param scaleFactor scaling factor to the size of the output texture
  15037. */
  15038. constructor(name: string, camera: Camera, scaleFactor: number);
  15039. }
  15040. }
  15041. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15042. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15043. import { Nullable } from "babylonjs/types";
  15044. import { Size } from "babylonjs/Maths/math.size";
  15045. import { Observable } from "babylonjs/Misc/observable";
  15046. module "babylonjs/Engines/engine" {
  15047. interface Engine {
  15048. /** @hidden */
  15049. _vrDisplay: any;
  15050. /** @hidden */
  15051. _vrSupported: boolean;
  15052. /** @hidden */
  15053. _oldSize: Size;
  15054. /** @hidden */
  15055. _oldHardwareScaleFactor: number;
  15056. /** @hidden */
  15057. _vrExclusivePointerMode: boolean;
  15058. /** @hidden */
  15059. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15060. /** @hidden */
  15061. _onVRDisplayPointerRestricted: () => void;
  15062. /** @hidden */
  15063. _onVRDisplayPointerUnrestricted: () => void;
  15064. /** @hidden */
  15065. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15066. /** @hidden */
  15067. _onVrDisplayDisconnect: Nullable<() => void>;
  15068. /** @hidden */
  15069. _onVrDisplayPresentChange: Nullable<() => void>;
  15070. /**
  15071. * Observable signaled when VR display mode changes
  15072. */
  15073. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15074. /**
  15075. * Observable signaled when VR request present is complete
  15076. */
  15077. onVRRequestPresentComplete: Observable<boolean>;
  15078. /**
  15079. * Observable signaled when VR request present starts
  15080. */
  15081. onVRRequestPresentStart: Observable<Engine>;
  15082. /**
  15083. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15084. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15085. */
  15086. isInVRExclusivePointerMode: boolean;
  15087. /**
  15088. * Gets a boolean indicating if a webVR device was detected
  15089. * @returns true if a webVR device was detected
  15090. */
  15091. isVRDevicePresent(): boolean;
  15092. /**
  15093. * Gets the current webVR device
  15094. * @returns the current webVR device (or null)
  15095. */
  15096. getVRDevice(): any;
  15097. /**
  15098. * Initializes a webVR display and starts listening to display change events
  15099. * The onVRDisplayChangedObservable will be notified upon these changes
  15100. * @returns A promise containing a VRDisplay and if vr is supported
  15101. */
  15102. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15103. /** @hidden */
  15104. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15105. /**
  15106. * Call this function to switch to webVR mode
  15107. * Will do nothing if webVR is not supported or if there is no webVR device
  15108. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15109. */
  15110. enableVR(): void;
  15111. /** @hidden */
  15112. _onVRFullScreenTriggered(): void;
  15113. }
  15114. }
  15115. }
  15116. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15117. import { Nullable } from "babylonjs/types";
  15118. import { Observable } from "babylonjs/Misc/observable";
  15119. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15120. import { Scene } from "babylonjs/scene";
  15121. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15122. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15123. import { Node } from "babylonjs/node";
  15124. import { Ray } from "babylonjs/Culling/ray";
  15125. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15126. import "babylonjs/Engines/Extensions/engine.webVR";
  15127. /**
  15128. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15129. * IMPORTANT!! The data is right-hand data.
  15130. * @export
  15131. * @interface DevicePose
  15132. */
  15133. export interface DevicePose {
  15134. /**
  15135. * The position of the device, values in array are [x,y,z].
  15136. */
  15137. readonly position: Nullable<Float32Array>;
  15138. /**
  15139. * The linearVelocity of the device, values in array are [x,y,z].
  15140. */
  15141. readonly linearVelocity: Nullable<Float32Array>;
  15142. /**
  15143. * The linearAcceleration of the device, values in array are [x,y,z].
  15144. */
  15145. readonly linearAcceleration: Nullable<Float32Array>;
  15146. /**
  15147. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15148. */
  15149. readonly orientation: Nullable<Float32Array>;
  15150. /**
  15151. * The angularVelocity of the device, values in array are [x,y,z].
  15152. */
  15153. readonly angularVelocity: Nullable<Float32Array>;
  15154. /**
  15155. * The angularAcceleration of the device, values in array are [x,y,z].
  15156. */
  15157. readonly angularAcceleration: Nullable<Float32Array>;
  15158. }
  15159. /**
  15160. * Interface representing a pose controlled object in Babylon.
  15161. * A pose controlled object has both regular pose values as well as pose values
  15162. * from an external device such as a VR head mounted display
  15163. */
  15164. export interface PoseControlled {
  15165. /**
  15166. * The position of the object in babylon space.
  15167. */
  15168. position: Vector3;
  15169. /**
  15170. * The rotation quaternion of the object in babylon space.
  15171. */
  15172. rotationQuaternion: Quaternion;
  15173. /**
  15174. * The position of the device in babylon space.
  15175. */
  15176. devicePosition?: Vector3;
  15177. /**
  15178. * The rotation quaternion of the device in babylon space.
  15179. */
  15180. deviceRotationQuaternion: Quaternion;
  15181. /**
  15182. * The raw pose coming from the device.
  15183. */
  15184. rawPose: Nullable<DevicePose>;
  15185. /**
  15186. * The scale of the device to be used when translating from device space to babylon space.
  15187. */
  15188. deviceScaleFactor: number;
  15189. /**
  15190. * Updates the poseControlled values based on the input device pose.
  15191. * @param poseData the pose data to update the object with
  15192. */
  15193. updateFromDevice(poseData: DevicePose): void;
  15194. }
  15195. /**
  15196. * Set of options to customize the webVRCamera
  15197. */
  15198. export interface WebVROptions {
  15199. /**
  15200. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15201. */
  15202. trackPosition?: boolean;
  15203. /**
  15204. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15205. */
  15206. positionScale?: number;
  15207. /**
  15208. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15209. */
  15210. displayName?: string;
  15211. /**
  15212. * Should the native controller meshes be initialized. (default: true)
  15213. */
  15214. controllerMeshes?: boolean;
  15215. /**
  15216. * Creating a default HemiLight only on controllers. (default: true)
  15217. */
  15218. defaultLightingOnControllers?: boolean;
  15219. /**
  15220. * If you don't want to use the default VR button of the helper. (default: false)
  15221. */
  15222. useCustomVRButton?: boolean;
  15223. /**
  15224. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15225. */
  15226. customVRButton?: HTMLButtonElement;
  15227. /**
  15228. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15229. */
  15230. rayLength?: number;
  15231. /**
  15232. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15233. */
  15234. defaultHeight?: number;
  15235. /**
  15236. * If multiview should be used if availible (default: false)
  15237. */
  15238. useMultiview?: boolean;
  15239. }
  15240. /**
  15241. * This represents a WebVR camera.
  15242. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15243. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15244. */
  15245. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15246. private webVROptions;
  15247. /**
  15248. * @hidden
  15249. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15250. */
  15251. _vrDevice: any;
  15252. /**
  15253. * The rawPose of the vrDevice.
  15254. */
  15255. rawPose: Nullable<DevicePose>;
  15256. private _onVREnabled;
  15257. private _specsVersion;
  15258. private _attached;
  15259. private _frameData;
  15260. protected _descendants: Array<Node>;
  15261. private _deviceRoomPosition;
  15262. /** @hidden */
  15263. _deviceRoomRotationQuaternion: Quaternion;
  15264. private _standingMatrix;
  15265. /**
  15266. * Represents device position in babylon space.
  15267. */
  15268. devicePosition: Vector3;
  15269. /**
  15270. * Represents device rotation in babylon space.
  15271. */
  15272. deviceRotationQuaternion: Quaternion;
  15273. /**
  15274. * The scale of the device to be used when translating from device space to babylon space.
  15275. */
  15276. deviceScaleFactor: number;
  15277. private _deviceToWorld;
  15278. private _worldToDevice;
  15279. /**
  15280. * References to the webVR controllers for the vrDevice.
  15281. */
  15282. controllers: Array<WebVRController>;
  15283. /**
  15284. * Emits an event when a controller is attached.
  15285. */
  15286. onControllersAttachedObservable: Observable<WebVRController[]>;
  15287. /**
  15288. * Emits an event when a controller's mesh has been loaded;
  15289. */
  15290. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15291. /**
  15292. * Emits an event when the HMD's pose has been updated.
  15293. */
  15294. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15295. private _poseSet;
  15296. /**
  15297. * If the rig cameras be used as parent instead of this camera.
  15298. */
  15299. rigParenting: boolean;
  15300. private _lightOnControllers;
  15301. private _defaultHeight?;
  15302. /**
  15303. * Instantiates a WebVRFreeCamera.
  15304. * @param name The name of the WebVRFreeCamera
  15305. * @param position The starting anchor position for the camera
  15306. * @param scene The scene the camera belongs to
  15307. * @param webVROptions a set of customizable options for the webVRCamera
  15308. */
  15309. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15310. /**
  15311. * Gets the device distance from the ground in meters.
  15312. * @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.
  15313. */
  15314. deviceDistanceToRoomGround(): number;
  15315. /**
  15316. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15317. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15318. */
  15319. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15320. /**
  15321. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15322. * @returns A promise with a boolean set to if the standing matrix is supported.
  15323. */
  15324. useStandingMatrixAsync(): Promise<boolean>;
  15325. /**
  15326. * Disposes the camera
  15327. */
  15328. dispose(): void;
  15329. /**
  15330. * Gets a vrController by name.
  15331. * @param name The name of the controller to retreive
  15332. * @returns the controller matching the name specified or null if not found
  15333. */
  15334. getControllerByName(name: string): Nullable<WebVRController>;
  15335. private _leftController;
  15336. /**
  15337. * The controller corresponding to the users left hand.
  15338. */
  15339. readonly leftController: Nullable<WebVRController>;
  15340. private _rightController;
  15341. /**
  15342. * The controller corresponding to the users right hand.
  15343. */
  15344. readonly rightController: Nullable<WebVRController>;
  15345. /**
  15346. * Casts a ray forward from the vrCamera's gaze.
  15347. * @param length Length of the ray (default: 100)
  15348. * @returns the ray corresponding to the gaze
  15349. */
  15350. getForwardRay(length?: number): Ray;
  15351. /**
  15352. * @hidden
  15353. * Updates the camera based on device's frame data
  15354. */
  15355. _checkInputs(): void;
  15356. /**
  15357. * Updates the poseControlled values based on the input device pose.
  15358. * @param poseData Pose coming from the device
  15359. */
  15360. updateFromDevice(poseData: DevicePose): void;
  15361. private _htmlElementAttached;
  15362. private _detachIfAttached;
  15363. /**
  15364. * WebVR's attach control will start broadcasting frames to the device.
  15365. * Note that in certain browsers (chrome for example) this function must be called
  15366. * within a user-interaction callback. Example:
  15367. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15368. *
  15369. * @param element html element to attach the vrDevice to
  15370. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15371. */
  15372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15373. /**
  15374. * Detaches the camera from the html element and disables VR
  15375. *
  15376. * @param element html element to detach from
  15377. */
  15378. detachControl(element: HTMLElement): void;
  15379. /**
  15380. * @returns the name of this class
  15381. */
  15382. getClassName(): string;
  15383. /**
  15384. * Calls resetPose on the vrDisplay
  15385. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15386. */
  15387. resetToCurrentRotation(): void;
  15388. /**
  15389. * @hidden
  15390. * Updates the rig cameras (left and right eye)
  15391. */
  15392. _updateRigCameras(): void;
  15393. private _workingVector;
  15394. private _oneVector;
  15395. private _workingMatrix;
  15396. private updateCacheCalled;
  15397. private _correctPositionIfNotTrackPosition;
  15398. /**
  15399. * @hidden
  15400. * Updates the cached values of the camera
  15401. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15402. */
  15403. _updateCache(ignoreParentClass?: boolean): void;
  15404. /**
  15405. * @hidden
  15406. * Get current device position in babylon world
  15407. */
  15408. _computeDevicePosition(): void;
  15409. /**
  15410. * Updates the current device position and rotation in the babylon world
  15411. */
  15412. update(): void;
  15413. /**
  15414. * @hidden
  15415. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15416. * @returns an identity matrix
  15417. */
  15418. _getViewMatrix(): Matrix;
  15419. private _tmpMatrix;
  15420. /**
  15421. * This function is called by the two RIG cameras.
  15422. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15423. * @hidden
  15424. */
  15425. _getWebVRViewMatrix(): Matrix;
  15426. /** @hidden */
  15427. _getWebVRProjectionMatrix(): Matrix;
  15428. private _onGamepadConnectedObserver;
  15429. private _onGamepadDisconnectedObserver;
  15430. private _updateCacheWhenTrackingDisabledObserver;
  15431. /**
  15432. * Initializes the controllers and their meshes
  15433. */
  15434. initControllers(): void;
  15435. }
  15436. }
  15437. declare module "babylonjs/PostProcesses/postProcess" {
  15438. import { Nullable } from "babylonjs/types";
  15439. import { SmartArray } from "babylonjs/Misc/smartArray";
  15440. import { Observable } from "babylonjs/Misc/observable";
  15441. import { Vector2 } from "babylonjs/Maths/math.vector";
  15442. import { Camera } from "babylonjs/Cameras/camera";
  15443. import { Effect } from "babylonjs/Materials/effect";
  15444. import "babylonjs/Shaders/postprocess.vertex";
  15445. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15446. import { Engine } from "babylonjs/Engines/engine";
  15447. import { Color4 } from "babylonjs/Maths/math.color";
  15448. import "babylonjs/Engines/Extensions/engine.renderTarget";
  15449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15450. /**
  15451. * Size options for a post process
  15452. */
  15453. export type PostProcessOptions = {
  15454. width: number;
  15455. height: number;
  15456. };
  15457. /**
  15458. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15459. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15460. */
  15461. export class PostProcess {
  15462. /** Name of the PostProcess. */
  15463. name: string;
  15464. /**
  15465. * Gets or sets the unique id of the post process
  15466. */
  15467. uniqueId: number;
  15468. /**
  15469. * Width of the texture to apply the post process on
  15470. */
  15471. width: number;
  15472. /**
  15473. * Height of the texture to apply the post process on
  15474. */
  15475. height: number;
  15476. /**
  15477. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15478. * @hidden
  15479. */
  15480. _outputTexture: Nullable<InternalTexture>;
  15481. /**
  15482. * Sampling mode used by the shader
  15483. * See https://doc.babylonjs.com/classes/3.1/texture
  15484. */
  15485. renderTargetSamplingMode: number;
  15486. /**
  15487. * Clear color to use when screen clearing
  15488. */
  15489. clearColor: Color4;
  15490. /**
  15491. * If the buffer needs to be cleared before applying the post process. (default: true)
  15492. * Should be set to false if shader will overwrite all previous pixels.
  15493. */
  15494. autoClear: boolean;
  15495. /**
  15496. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15497. */
  15498. alphaMode: number;
  15499. /**
  15500. * Sets the setAlphaBlendConstants of the babylon engine
  15501. */
  15502. alphaConstants: Color4;
  15503. /**
  15504. * Animations to be used for the post processing
  15505. */
  15506. animations: import("babylonjs/Animations/animation").Animation[];
  15507. /**
  15508. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15509. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15510. */
  15511. enablePixelPerfectMode: boolean;
  15512. /**
  15513. * Force the postprocess to be applied without taking in account viewport
  15514. */
  15515. forceFullscreenViewport: boolean;
  15516. /**
  15517. * List of inspectable custom properties (used by the Inspector)
  15518. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15519. */
  15520. inspectableCustomProperties: IInspectable[];
  15521. /**
  15522. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15523. *
  15524. * | Value | Type | Description |
  15525. * | ----- | ----------------------------------- | ----------- |
  15526. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15527. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15528. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15529. *
  15530. */
  15531. scaleMode: number;
  15532. /**
  15533. * Force textures to be a power of two (default: false)
  15534. */
  15535. alwaysForcePOT: boolean;
  15536. private _samples;
  15537. /**
  15538. * Number of sample textures (default: 1)
  15539. */
  15540. samples: number;
  15541. /**
  15542. * Modify the scale of the post process to be the same as the viewport (default: false)
  15543. */
  15544. adaptScaleToCurrentViewport: boolean;
  15545. private _camera;
  15546. private _scene;
  15547. private _engine;
  15548. private _options;
  15549. private _reusable;
  15550. private _textureType;
  15551. /**
  15552. * Smart array of input and output textures for the post process.
  15553. * @hidden
  15554. */
  15555. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15556. /**
  15557. * The index in _textures that corresponds to the output texture.
  15558. * @hidden
  15559. */
  15560. _currentRenderTextureInd: number;
  15561. private _effect;
  15562. private _samplers;
  15563. private _fragmentUrl;
  15564. private _vertexUrl;
  15565. private _parameters;
  15566. private _scaleRatio;
  15567. protected _indexParameters: any;
  15568. private _shareOutputWithPostProcess;
  15569. private _texelSize;
  15570. private _forcedOutputTexture;
  15571. /**
  15572. * Returns the fragment url or shader name used in the post process.
  15573. * @returns the fragment url or name in the shader store.
  15574. */
  15575. getEffectName(): string;
  15576. /**
  15577. * An event triggered when the postprocess is activated.
  15578. */
  15579. onActivateObservable: Observable<Camera>;
  15580. private _onActivateObserver;
  15581. /**
  15582. * A function that is added to the onActivateObservable
  15583. */
  15584. onActivate: Nullable<(camera: Camera) => void>;
  15585. /**
  15586. * An event triggered when the postprocess changes its size.
  15587. */
  15588. onSizeChangedObservable: Observable<PostProcess>;
  15589. private _onSizeChangedObserver;
  15590. /**
  15591. * A function that is added to the onSizeChangedObservable
  15592. */
  15593. onSizeChanged: (postProcess: PostProcess) => void;
  15594. /**
  15595. * An event triggered when the postprocess applies its effect.
  15596. */
  15597. onApplyObservable: Observable<Effect>;
  15598. private _onApplyObserver;
  15599. /**
  15600. * A function that is added to the onApplyObservable
  15601. */
  15602. onApply: (effect: Effect) => void;
  15603. /**
  15604. * An event triggered before rendering the postprocess
  15605. */
  15606. onBeforeRenderObservable: Observable<Effect>;
  15607. private _onBeforeRenderObserver;
  15608. /**
  15609. * A function that is added to the onBeforeRenderObservable
  15610. */
  15611. onBeforeRender: (effect: Effect) => void;
  15612. /**
  15613. * An event triggered after rendering the postprocess
  15614. */
  15615. onAfterRenderObservable: Observable<Effect>;
  15616. private _onAfterRenderObserver;
  15617. /**
  15618. * A function that is added to the onAfterRenderObservable
  15619. */
  15620. onAfterRender: (efect: Effect) => void;
  15621. /**
  15622. * 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
  15623. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15624. */
  15625. inputTexture: InternalTexture;
  15626. /**
  15627. * Gets the camera which post process is applied to.
  15628. * @returns The camera the post process is applied to.
  15629. */
  15630. getCamera(): Camera;
  15631. /**
  15632. * Gets the texel size of the postprocess.
  15633. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15634. */
  15635. readonly texelSize: Vector2;
  15636. /**
  15637. * Creates a new instance PostProcess
  15638. * @param name The name of the PostProcess.
  15639. * @param fragmentUrl The url of the fragment shader to be used.
  15640. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15641. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15642. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15643. * @param camera The camera to apply the render pass to.
  15644. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15645. * @param engine The engine which the post process will be applied. (default: current engine)
  15646. * @param reusable If the post process can be reused on the same frame. (default: false)
  15647. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15648. * @param textureType Type of textures used when performing the post process. (default: 0)
  15649. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15650. * @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
  15651. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15652. */
  15653. constructor(
  15654. /** Name of the PostProcess. */
  15655. 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);
  15656. /**
  15657. * Gets a string idenfifying the name of the class
  15658. * @returns "PostProcess" string
  15659. */
  15660. getClassName(): string;
  15661. /**
  15662. * Gets the engine which this post process belongs to.
  15663. * @returns The engine the post process was enabled with.
  15664. */
  15665. getEngine(): Engine;
  15666. /**
  15667. * The effect that is created when initializing the post process.
  15668. * @returns The created effect corresponding the the postprocess.
  15669. */
  15670. getEffect(): Effect;
  15671. /**
  15672. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15673. * @param postProcess The post process to share the output with.
  15674. * @returns This post process.
  15675. */
  15676. shareOutputWith(postProcess: PostProcess): PostProcess;
  15677. /**
  15678. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15679. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15680. */
  15681. useOwnOutput(): void;
  15682. /**
  15683. * Updates the effect with the current post process compile time values and recompiles the shader.
  15684. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15685. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15686. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15687. * @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
  15688. * @param onCompiled Called when the shader has been compiled.
  15689. * @param onError Called if there is an error when compiling a shader.
  15690. */
  15691. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15692. /**
  15693. * The post process is reusable if it can be used multiple times within one frame.
  15694. * @returns If the post process is reusable
  15695. */
  15696. isReusable(): boolean;
  15697. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15698. markTextureDirty(): void;
  15699. /**
  15700. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15701. * 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.
  15702. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15703. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15704. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15705. * @returns The target texture that was bound to be written to.
  15706. */
  15707. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15708. /**
  15709. * If the post process is supported.
  15710. */
  15711. readonly isSupported: boolean;
  15712. /**
  15713. * The aspect ratio of the output texture.
  15714. */
  15715. readonly aspectRatio: number;
  15716. /**
  15717. * Get a value indicating if the post-process is ready to be used
  15718. * @returns true if the post-process is ready (shader is compiled)
  15719. */
  15720. isReady(): boolean;
  15721. /**
  15722. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15723. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15724. */
  15725. apply(): Nullable<Effect>;
  15726. private _disposeTextures;
  15727. /**
  15728. * Disposes the post process.
  15729. * @param camera The camera to dispose the post process on.
  15730. */
  15731. dispose(camera?: Camera): void;
  15732. }
  15733. }
  15734. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15735. /** @hidden */
  15736. export var kernelBlurVaryingDeclaration: {
  15737. name: string;
  15738. shader: string;
  15739. };
  15740. }
  15741. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15742. /** @hidden */
  15743. export var kernelBlurFragment: {
  15744. name: string;
  15745. shader: string;
  15746. };
  15747. }
  15748. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15749. /** @hidden */
  15750. export var kernelBlurFragment2: {
  15751. name: string;
  15752. shader: string;
  15753. };
  15754. }
  15755. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15756. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15757. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15758. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15759. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15760. /** @hidden */
  15761. export var kernelBlurPixelShader: {
  15762. name: string;
  15763. shader: string;
  15764. };
  15765. }
  15766. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15767. /** @hidden */
  15768. export var kernelBlurVertex: {
  15769. name: string;
  15770. shader: string;
  15771. };
  15772. }
  15773. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15774. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15775. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15776. /** @hidden */
  15777. export var kernelBlurVertexShader: {
  15778. name: string;
  15779. shader: string;
  15780. };
  15781. }
  15782. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15783. import { Vector2 } from "babylonjs/Maths/math.vector";
  15784. import { Nullable } from "babylonjs/types";
  15785. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15786. import { Camera } from "babylonjs/Cameras/camera";
  15787. import { Effect } from "babylonjs/Materials/effect";
  15788. import { Engine } from "babylonjs/Engines/engine";
  15789. import "babylonjs/Shaders/kernelBlur.fragment";
  15790. import "babylonjs/Shaders/kernelBlur.vertex";
  15791. /**
  15792. * The Blur Post Process which blurs an image based on a kernel and direction.
  15793. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15794. */
  15795. export class BlurPostProcess extends PostProcess {
  15796. /** The direction in which to blur the image. */
  15797. direction: Vector2;
  15798. private blockCompilation;
  15799. protected _kernel: number;
  15800. protected _idealKernel: number;
  15801. protected _packedFloat: boolean;
  15802. private _staticDefines;
  15803. /**
  15804. * Sets the length in pixels of the blur sample region
  15805. */
  15806. /**
  15807. * Gets the length in pixels of the blur sample region
  15808. */
  15809. kernel: number;
  15810. /**
  15811. * Sets wether or not the blur needs to unpack/repack floats
  15812. */
  15813. /**
  15814. * Gets wether or not the blur is unpacking/repacking floats
  15815. */
  15816. packedFloat: boolean;
  15817. /**
  15818. * Creates a new instance BlurPostProcess
  15819. * @param name The name of the effect.
  15820. * @param direction The direction in which to blur the image.
  15821. * @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.
  15822. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15823. * @param camera The camera to apply the render pass to.
  15824. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15825. * @param engine The engine which the post process will be applied. (default: current engine)
  15826. * @param reusable If the post process can be reused on the same frame. (default: false)
  15827. * @param textureType Type of textures used when performing the post process. (default: 0)
  15828. * @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)
  15829. */
  15830. constructor(name: string,
  15831. /** The direction in which to blur the image. */
  15832. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15833. /**
  15834. * Updates the effect with the current post process compile time values and recompiles the shader.
  15835. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15836. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15837. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15838. * @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
  15839. * @param onCompiled Called when the shader has been compiled.
  15840. * @param onError Called if there is an error when compiling a shader.
  15841. */
  15842. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15843. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15844. /**
  15845. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15846. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15847. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15848. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15849. * The gaps between physical kernels are compensated for in the weighting of the samples
  15850. * @param idealKernel Ideal blur kernel.
  15851. * @return Nearest best kernel.
  15852. */
  15853. protected _nearestBestKernel(idealKernel: number): number;
  15854. /**
  15855. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15856. * @param x The point on the Gaussian distribution to sample.
  15857. * @return the value of the Gaussian function at x.
  15858. */
  15859. protected _gaussianWeight(x: number): number;
  15860. /**
  15861. * Generates a string that can be used as a floating point number in GLSL.
  15862. * @param x Value to print.
  15863. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15864. * @return GLSL float string.
  15865. */
  15866. protected _glslFloat(x: number, decimalFigures?: number): string;
  15867. }
  15868. }
  15869. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  15870. import { Scene } from "babylonjs/scene";
  15871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15872. import { Plane } from "babylonjs/Maths/math.plane";
  15873. /**
  15874. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15875. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15876. * You can then easily use it as a reflectionTexture on a flat surface.
  15877. * In case the surface is not a plane, please consider relying on reflection probes.
  15878. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15879. */
  15880. export class MirrorTexture extends RenderTargetTexture {
  15881. private scene;
  15882. /**
  15883. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15884. * 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.
  15885. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15886. */
  15887. mirrorPlane: Plane;
  15888. /**
  15889. * Define the blur ratio used to blur the reflection if needed.
  15890. */
  15891. blurRatio: number;
  15892. /**
  15893. * Define the adaptive blur kernel used to blur the reflection if needed.
  15894. * This will autocompute the closest best match for the `blurKernel`
  15895. */
  15896. adaptiveBlurKernel: number;
  15897. /**
  15898. * Define the blur kernel used to blur the reflection if needed.
  15899. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15900. */
  15901. blurKernel: number;
  15902. /**
  15903. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15904. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15905. */
  15906. blurKernelX: number;
  15907. /**
  15908. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15909. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15910. */
  15911. blurKernelY: number;
  15912. private _autoComputeBlurKernel;
  15913. protected _onRatioRescale(): void;
  15914. private _updateGammaSpace;
  15915. private _imageProcessingConfigChangeObserver;
  15916. private _transformMatrix;
  15917. private _mirrorMatrix;
  15918. private _savedViewMatrix;
  15919. private _blurX;
  15920. private _blurY;
  15921. private _adaptiveBlurKernel;
  15922. private _blurKernelX;
  15923. private _blurKernelY;
  15924. private _blurRatio;
  15925. /**
  15926. * Instantiates a Mirror Texture.
  15927. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15928. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15929. * You can then easily use it as a reflectionTexture on a flat surface.
  15930. * In case the surface is not a plane, please consider relying on reflection probes.
  15931. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15932. * @param name
  15933. * @param size
  15934. * @param scene
  15935. * @param generateMipMaps
  15936. * @param type
  15937. * @param samplingMode
  15938. * @param generateDepthBuffer
  15939. */
  15940. constructor(name: string, size: number | {
  15941. width: number;
  15942. height: number;
  15943. } | {
  15944. ratio: number;
  15945. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15946. private _preparePostProcesses;
  15947. /**
  15948. * Clone the mirror texture.
  15949. * @returns the cloned texture
  15950. */
  15951. clone(): MirrorTexture;
  15952. /**
  15953. * Serialize the texture to a JSON representation you could use in Parse later on
  15954. * @returns the serialized JSON representation
  15955. */
  15956. serialize(): any;
  15957. /**
  15958. * Dispose the texture and release its associated resources.
  15959. */
  15960. dispose(): void;
  15961. }
  15962. }
  15963. declare module "babylonjs/Materials/Textures/texture" {
  15964. import { Observable } from "babylonjs/Misc/observable";
  15965. import { Nullable } from "babylonjs/types";
  15966. import { Matrix } from "babylonjs/Maths/math.vector";
  15967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15968. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15969. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  15970. import { Scene } from "babylonjs/scene";
  15971. /**
  15972. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15973. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15974. */
  15975. export class Texture extends BaseTexture {
  15976. /**
  15977. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  15978. */
  15979. static SerializeBuffers: boolean;
  15980. /** @hidden */
  15981. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  15982. /** @hidden */
  15983. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  15984. /** @hidden */
  15985. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  15986. /** nearest is mag = nearest and min = nearest and mip = linear */
  15987. static readonly NEAREST_SAMPLINGMODE: number;
  15988. /** nearest is mag = nearest and min = nearest and mip = linear */
  15989. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15990. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15991. static readonly BILINEAR_SAMPLINGMODE: number;
  15992. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15993. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15994. /** Trilinear is mag = linear and min = linear and mip = linear */
  15995. static readonly TRILINEAR_SAMPLINGMODE: number;
  15996. /** Trilinear is mag = linear and min = linear and mip = linear */
  15997. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15998. /** mag = nearest and min = nearest and mip = nearest */
  15999. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16000. /** mag = nearest and min = linear and mip = nearest */
  16001. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16002. /** mag = nearest and min = linear and mip = linear */
  16003. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16004. /** mag = nearest and min = linear and mip = none */
  16005. static readonly NEAREST_LINEAR: number;
  16006. /** mag = nearest and min = nearest and mip = none */
  16007. static readonly NEAREST_NEAREST: number;
  16008. /** mag = linear and min = nearest and mip = nearest */
  16009. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16010. /** mag = linear and min = nearest and mip = linear */
  16011. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16012. /** mag = linear and min = linear and mip = none */
  16013. static readonly LINEAR_LINEAR: number;
  16014. /** mag = linear and min = nearest and mip = none */
  16015. static readonly LINEAR_NEAREST: number;
  16016. /** Explicit coordinates mode */
  16017. static readonly EXPLICIT_MODE: number;
  16018. /** Spherical coordinates mode */
  16019. static readonly SPHERICAL_MODE: number;
  16020. /** Planar coordinates mode */
  16021. static readonly PLANAR_MODE: number;
  16022. /** Cubic coordinates mode */
  16023. static readonly CUBIC_MODE: number;
  16024. /** Projection coordinates mode */
  16025. static readonly PROJECTION_MODE: number;
  16026. /** Inverse Cubic coordinates mode */
  16027. static readonly SKYBOX_MODE: number;
  16028. /** Inverse Cubic coordinates mode */
  16029. static readonly INVCUBIC_MODE: number;
  16030. /** Equirectangular coordinates mode */
  16031. static readonly EQUIRECTANGULAR_MODE: number;
  16032. /** Equirectangular Fixed coordinates mode */
  16033. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16034. /** Equirectangular Fixed Mirrored coordinates mode */
  16035. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16036. /** Texture is not repeating outside of 0..1 UVs */
  16037. static readonly CLAMP_ADDRESSMODE: number;
  16038. /** Texture is repeating outside of 0..1 UVs */
  16039. static readonly WRAP_ADDRESSMODE: number;
  16040. /** Texture is repeating and mirrored */
  16041. static readonly MIRROR_ADDRESSMODE: number;
  16042. /**
  16043. * 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
  16044. */
  16045. static UseSerializedUrlIfAny: boolean;
  16046. /**
  16047. * Define the url of the texture.
  16048. */
  16049. url: Nullable<string>;
  16050. /**
  16051. * Define an offset on the texture to offset the u coordinates of the UVs
  16052. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16053. */
  16054. uOffset: number;
  16055. /**
  16056. * Define an offset on the texture to offset the v coordinates of the UVs
  16057. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16058. */
  16059. vOffset: number;
  16060. /**
  16061. * Define an offset on the texture to scale the u coordinates of the UVs
  16062. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16063. */
  16064. uScale: number;
  16065. /**
  16066. * Define an offset on the texture to scale the v coordinates of the UVs
  16067. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16068. */
  16069. vScale: number;
  16070. /**
  16071. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16072. * @see http://doc.babylonjs.com/how_to/more_materials
  16073. */
  16074. uAng: number;
  16075. /**
  16076. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16077. * @see http://doc.babylonjs.com/how_to/more_materials
  16078. */
  16079. vAng: number;
  16080. /**
  16081. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16082. * @see http://doc.babylonjs.com/how_to/more_materials
  16083. */
  16084. wAng: number;
  16085. /**
  16086. * Defines the center of rotation (U)
  16087. */
  16088. uRotationCenter: number;
  16089. /**
  16090. * Defines the center of rotation (V)
  16091. */
  16092. vRotationCenter: number;
  16093. /**
  16094. * Defines the center of rotation (W)
  16095. */
  16096. wRotationCenter: number;
  16097. /**
  16098. * Are mip maps generated for this texture or not.
  16099. */
  16100. readonly noMipmap: boolean;
  16101. /**
  16102. * List of inspectable custom properties (used by the Inspector)
  16103. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16104. */
  16105. inspectableCustomProperties: Nullable<IInspectable[]>;
  16106. private _noMipmap;
  16107. /** @hidden */
  16108. _invertY: boolean;
  16109. private _rowGenerationMatrix;
  16110. private _cachedTextureMatrix;
  16111. private _projectionModeMatrix;
  16112. private _t0;
  16113. private _t1;
  16114. private _t2;
  16115. private _cachedUOffset;
  16116. private _cachedVOffset;
  16117. private _cachedUScale;
  16118. private _cachedVScale;
  16119. private _cachedUAng;
  16120. private _cachedVAng;
  16121. private _cachedWAng;
  16122. private _cachedProjectionMatrixId;
  16123. private _cachedCoordinatesMode;
  16124. /** @hidden */
  16125. protected _initialSamplingMode: number;
  16126. /** @hidden */
  16127. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16128. private _deleteBuffer;
  16129. protected _format: Nullable<number>;
  16130. private _delayedOnLoad;
  16131. private _delayedOnError;
  16132. private _mimeType?;
  16133. /**
  16134. * Observable triggered once the texture has been loaded.
  16135. */
  16136. onLoadObservable: Observable<Texture>;
  16137. protected _isBlocking: boolean;
  16138. /**
  16139. * Is the texture preventing material to render while loading.
  16140. * If false, a default texture will be used instead of the loading one during the preparation step.
  16141. */
  16142. isBlocking: boolean;
  16143. /**
  16144. * Get the current sampling mode associated with the texture.
  16145. */
  16146. readonly samplingMode: number;
  16147. /**
  16148. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16149. */
  16150. readonly invertY: boolean;
  16151. /**
  16152. * Instantiates a new texture.
  16153. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16154. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16155. * @param url defines the url of the picture to load as a texture
  16156. * @param scene defines the scene or engine the texture will belong to
  16157. * @param noMipmap defines if the texture will require mip maps or not
  16158. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  16159. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16160. * @param onLoad defines a callback triggered when the texture has been loaded
  16161. * @param onError defines a callback triggered when an error occurred during the loading session
  16162. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  16163. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  16164. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16165. * @param mimeType defines an optional mime type information
  16166. */
  16167. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  16168. /**
  16169. * Update the url (and optional buffer) of this texture if url was null during construction.
  16170. * @param url the url of the texture
  16171. * @param buffer the buffer of the texture (defaults to null)
  16172. * @param onLoad callback called when the texture is loaded (defaults to null)
  16173. */
  16174. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16175. /**
  16176. * Finish the loading sequence of a texture flagged as delayed load.
  16177. * @hidden
  16178. */
  16179. delayLoad(): void;
  16180. private _prepareRowForTextureGeneration;
  16181. /**
  16182. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16183. * @returns the transform matrix of the texture.
  16184. */
  16185. getTextureMatrix(): Matrix;
  16186. /**
  16187. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16188. * @returns The reflection texture transform
  16189. */
  16190. getReflectionTextureMatrix(): Matrix;
  16191. /**
  16192. * Clones the texture.
  16193. * @returns the cloned texture
  16194. */
  16195. clone(): Texture;
  16196. /**
  16197. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16198. * @returns The JSON representation of the texture
  16199. */
  16200. serialize(): any;
  16201. /**
  16202. * Get the current class name of the texture useful for serialization or dynamic coding.
  16203. * @returns "Texture"
  16204. */
  16205. getClassName(): string;
  16206. /**
  16207. * Dispose the texture and release its associated resources.
  16208. */
  16209. dispose(): void;
  16210. /**
  16211. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16212. * @param parsedTexture Define the JSON representation of the texture
  16213. * @param scene Define the scene the parsed texture should be instantiated in
  16214. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16215. * @returns The parsed texture if successful
  16216. */
  16217. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16218. /**
  16219. * Creates a texture from its base 64 representation.
  16220. * @param data Define the base64 payload without the data: prefix
  16221. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16222. * @param scene Define the scene the texture should belong to
  16223. * @param noMipmap Forces the texture to not create mip map information if true
  16224. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16225. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16226. * @param onLoad define a callback triggered when the texture has been loaded
  16227. * @param onError define a callback triggered when an error occurred during the loading session
  16228. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16229. * @returns the created texture
  16230. */
  16231. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16232. /**
  16233. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16234. * @param data Define the base64 payload without the data: prefix
  16235. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16236. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16237. * @param scene Define the scene the texture should belong to
  16238. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16239. * @param noMipmap Forces the texture to not create mip map information if true
  16240. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16241. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16242. * @param onLoad define a callback triggered when the texture has been loaded
  16243. * @param onError define a callback triggered when an error occurred during the loading session
  16244. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16245. * @returns the created texture
  16246. */
  16247. 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;
  16248. }
  16249. }
  16250. declare module "babylonjs/PostProcesses/postProcessManager" {
  16251. import { Nullable } from "babylonjs/types";
  16252. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16253. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16254. import { Scene } from "babylonjs/scene";
  16255. /**
  16256. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16257. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16258. */
  16259. export class PostProcessManager {
  16260. private _scene;
  16261. private _indexBuffer;
  16262. private _vertexBuffers;
  16263. /**
  16264. * Creates a new instance PostProcess
  16265. * @param scene The scene that the post process is associated with.
  16266. */
  16267. constructor(scene: Scene);
  16268. private _prepareBuffers;
  16269. private _buildIndexBuffer;
  16270. /**
  16271. * Rebuilds the vertex buffers of the manager.
  16272. * @hidden
  16273. */
  16274. _rebuild(): void;
  16275. /**
  16276. * Prepares a frame to be run through a post process.
  16277. * @param sourceTexture The input texture to the post procesess. (default: null)
  16278. * @param postProcesses An array of post processes to be run. (default: null)
  16279. * @returns True if the post processes were able to be run.
  16280. * @hidden
  16281. */
  16282. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16283. /**
  16284. * Manually render a set of post processes to a texture.
  16285. * @param postProcesses An array of post processes to be run.
  16286. * @param targetTexture The target texture to render to.
  16287. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16288. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16289. * @param lodLevel defines which lod of the texture to render to
  16290. */
  16291. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16292. /**
  16293. * Finalize the result of the output of the postprocesses.
  16294. * @param doNotPresent If true the result will not be displayed to the screen.
  16295. * @param targetTexture The target texture to render to.
  16296. * @param faceIndex The index of the face to bind the target texture to.
  16297. * @param postProcesses The array of post processes to render.
  16298. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16299. * @hidden
  16300. */
  16301. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16302. /**
  16303. * Disposes of the post process manager.
  16304. */
  16305. dispose(): void;
  16306. }
  16307. }
  16308. declare module "babylonjs/Misc/gradients" {
  16309. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16310. /** Interface used by value gradients (color, factor, ...) */
  16311. export interface IValueGradient {
  16312. /**
  16313. * Gets or sets the gradient value (between 0 and 1)
  16314. */
  16315. gradient: number;
  16316. }
  16317. /** Class used to store color4 gradient */
  16318. export class ColorGradient implements IValueGradient {
  16319. /**
  16320. * Gets or sets the gradient value (between 0 and 1)
  16321. */
  16322. gradient: number;
  16323. /**
  16324. * Gets or sets first associated color
  16325. */
  16326. color1: Color4;
  16327. /**
  16328. * Gets or sets second associated color
  16329. */
  16330. color2?: Color4;
  16331. /**
  16332. * Will get a color picked randomly between color1 and color2.
  16333. * If color2 is undefined then color1 will be used
  16334. * @param result defines the target Color4 to store the result in
  16335. */
  16336. getColorToRef(result: Color4): void;
  16337. }
  16338. /** Class used to store color 3 gradient */
  16339. export class Color3Gradient implements IValueGradient {
  16340. /**
  16341. * Gets or sets the gradient value (between 0 and 1)
  16342. */
  16343. gradient: number;
  16344. /**
  16345. * Gets or sets the associated color
  16346. */
  16347. color: Color3;
  16348. }
  16349. /** Class used to store factor gradient */
  16350. export class FactorGradient implements IValueGradient {
  16351. /**
  16352. * Gets or sets the gradient value (between 0 and 1)
  16353. */
  16354. gradient: number;
  16355. /**
  16356. * Gets or sets first associated factor
  16357. */
  16358. factor1: number;
  16359. /**
  16360. * Gets or sets second associated factor
  16361. */
  16362. factor2?: number;
  16363. /**
  16364. * Will get a number picked randomly between factor1 and factor2.
  16365. * If factor2 is undefined then factor1 will be used
  16366. * @returns the picked number
  16367. */
  16368. getFactor(): number;
  16369. }
  16370. /**
  16371. * Helper used to simplify some generic gradient tasks
  16372. */
  16373. export class GradientHelper {
  16374. /**
  16375. * Gets the current gradient from an array of IValueGradient
  16376. * @param ratio defines the current ratio to get
  16377. * @param gradients defines the array of IValueGradient
  16378. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16379. */
  16380. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16381. }
  16382. }
  16383. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16384. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16385. import { Nullable } from "babylonjs/types";
  16386. module "babylonjs/Engines/thinEngine" {
  16387. interface ThinEngine {
  16388. /**
  16389. * Creates a dynamic texture
  16390. * @param width defines the width of the texture
  16391. * @param height defines the height of the texture
  16392. * @param generateMipMaps defines if the engine should generate the mip levels
  16393. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16394. * @returns the dynamic texture inside an InternalTexture
  16395. */
  16396. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16397. /**
  16398. * Update the content of a dynamic texture
  16399. * @param texture defines the texture to update
  16400. * @param canvas defines the canvas containing the source
  16401. * @param invertY defines if data must be stored with Y axis inverted
  16402. * @param premulAlpha defines if alpha is stored as premultiplied
  16403. * @param format defines the format of the data
  16404. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16405. */
  16406. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16407. }
  16408. }
  16409. }
  16410. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16411. import { Scene } from "babylonjs/scene";
  16412. import { Texture } from "babylonjs/Materials/Textures/texture";
  16413. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16414. /**
  16415. * A class extending Texture allowing drawing on a texture
  16416. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16417. */
  16418. export class DynamicTexture extends Texture {
  16419. private _generateMipMaps;
  16420. private _canvas;
  16421. private _context;
  16422. private _engine;
  16423. /**
  16424. * Creates a DynamicTexture
  16425. * @param name defines the name of the texture
  16426. * @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
  16427. * @param scene defines the scene where you want the texture
  16428. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16429. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16430. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16431. */
  16432. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16433. /**
  16434. * Get the current class name of the texture useful for serialization or dynamic coding.
  16435. * @returns "DynamicTexture"
  16436. */
  16437. getClassName(): string;
  16438. /**
  16439. * Gets the current state of canRescale
  16440. */
  16441. readonly canRescale: boolean;
  16442. private _recreate;
  16443. /**
  16444. * Scales the texture
  16445. * @param ratio the scale factor to apply to both width and height
  16446. */
  16447. scale(ratio: number): void;
  16448. /**
  16449. * Resizes the texture
  16450. * @param width the new width
  16451. * @param height the new height
  16452. */
  16453. scaleTo(width: number, height: number): void;
  16454. /**
  16455. * Gets the context of the canvas used by the texture
  16456. * @returns the canvas context of the dynamic texture
  16457. */
  16458. getContext(): CanvasRenderingContext2D;
  16459. /**
  16460. * Clears the texture
  16461. */
  16462. clear(): void;
  16463. /**
  16464. * Updates the texture
  16465. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16466. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16467. */
  16468. update(invertY?: boolean, premulAlpha?: boolean): void;
  16469. /**
  16470. * Draws text onto the texture
  16471. * @param text defines the text to be drawn
  16472. * @param x defines the placement of the text from the left
  16473. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16474. * @param font defines the font to be used with font-style, font-size, font-name
  16475. * @param color defines the color used for the text
  16476. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16477. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16478. * @param update defines whether texture is immediately update (default is true)
  16479. */
  16480. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16481. /**
  16482. * Clones the texture
  16483. * @returns the clone of the texture.
  16484. */
  16485. clone(): DynamicTexture;
  16486. /**
  16487. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16488. * @returns a serialized dynamic texture object
  16489. */
  16490. serialize(): any;
  16491. /** @hidden */
  16492. _rebuild(): void;
  16493. }
  16494. }
  16495. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16496. import { Scene } from "babylonjs/scene";
  16497. import { ISceneComponent } from "babylonjs/sceneComponent";
  16498. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16499. module "babylonjs/abstractScene" {
  16500. interface AbstractScene {
  16501. /**
  16502. * The list of procedural textures added to the scene
  16503. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16504. */
  16505. proceduralTextures: Array<ProceduralTexture>;
  16506. }
  16507. }
  16508. /**
  16509. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16510. * in a given scene.
  16511. */
  16512. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16513. /**
  16514. * The component name helpfull to identify the component in the list of scene components.
  16515. */
  16516. readonly name: string;
  16517. /**
  16518. * The scene the component belongs to.
  16519. */
  16520. scene: Scene;
  16521. /**
  16522. * Creates a new instance of the component for the given scene
  16523. * @param scene Defines the scene to register the component in
  16524. */
  16525. constructor(scene: Scene);
  16526. /**
  16527. * Registers the component in a given scene
  16528. */
  16529. register(): void;
  16530. /**
  16531. * Rebuilds the elements related to this component in case of
  16532. * context lost for instance.
  16533. */
  16534. rebuild(): void;
  16535. /**
  16536. * Disposes the component and the associated ressources.
  16537. */
  16538. dispose(): void;
  16539. private _beforeClear;
  16540. }
  16541. }
  16542. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  16543. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16544. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16545. module "babylonjs/Engines/thinEngine" {
  16546. interface ThinEngine {
  16547. /**
  16548. * Creates a new render target cube texture
  16549. * @param size defines the size of the texture
  16550. * @param options defines the options used to create the texture
  16551. * @returns a new render target cube texture stored in an InternalTexture
  16552. */
  16553. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16554. }
  16555. }
  16556. }
  16557. declare module "babylonjs/Shaders/procedural.vertex" {
  16558. /** @hidden */
  16559. export var proceduralVertexShader: {
  16560. name: string;
  16561. shader: string;
  16562. };
  16563. }
  16564. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16565. import { Observable } from "babylonjs/Misc/observable";
  16566. import { Nullable } from "babylonjs/types";
  16567. import { Scene } from "babylonjs/scene";
  16568. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16569. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16570. import { Effect } from "babylonjs/Materials/effect";
  16571. import { Texture } from "babylonjs/Materials/Textures/texture";
  16572. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16573. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  16574. import "babylonjs/Shaders/procedural.vertex";
  16575. /**
  16576. * 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.
  16577. * This is the base class of any Procedural texture and contains most of the shareable code.
  16578. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16579. */
  16580. export class ProceduralTexture extends Texture {
  16581. isCube: boolean;
  16582. /**
  16583. * Define if the texture is enabled or not (disabled texture will not render)
  16584. */
  16585. isEnabled: boolean;
  16586. /**
  16587. * Define if the texture must be cleared before rendering (default is true)
  16588. */
  16589. autoClear: boolean;
  16590. /**
  16591. * Callback called when the texture is generated
  16592. */
  16593. onGenerated: () => void;
  16594. /**
  16595. * Event raised when the texture is generated
  16596. */
  16597. onGeneratedObservable: Observable<ProceduralTexture>;
  16598. /** @hidden */
  16599. _generateMipMaps: boolean;
  16600. /** @hidden **/
  16601. _effect: Effect;
  16602. /** @hidden */
  16603. _textures: {
  16604. [key: string]: Texture;
  16605. };
  16606. private _size;
  16607. private _currentRefreshId;
  16608. private _refreshRate;
  16609. private _vertexBuffers;
  16610. private _indexBuffer;
  16611. private _uniforms;
  16612. private _samplers;
  16613. private _fragment;
  16614. private _floats;
  16615. private _ints;
  16616. private _floatsArrays;
  16617. private _colors3;
  16618. private _colors4;
  16619. private _vectors2;
  16620. private _vectors3;
  16621. private _matrices;
  16622. private _fallbackTexture;
  16623. private _fallbackTextureUsed;
  16624. private _engine;
  16625. private _cachedDefines;
  16626. private _contentUpdateId;
  16627. private _contentData;
  16628. /**
  16629. * Instantiates a new procedural texture.
  16630. * 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.
  16631. * This is the base class of any Procedural texture and contains most of the shareable code.
  16632. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16633. * @param name Define the name of the texture
  16634. * @param size Define the size of the texture to create
  16635. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16636. * @param scene Define the scene the texture belongs to
  16637. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16638. * @param generateMipMaps Define if the texture should creates mip maps or not
  16639. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16640. */
  16641. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16642. /**
  16643. * The effect that is created when initializing the post process.
  16644. * @returns The created effect corresponding the the postprocess.
  16645. */
  16646. getEffect(): Effect;
  16647. /**
  16648. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16649. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16650. */
  16651. getContent(): Nullable<ArrayBufferView>;
  16652. private _createIndexBuffer;
  16653. /** @hidden */
  16654. _rebuild(): void;
  16655. /**
  16656. * Resets the texture in order to recreate its associated resources.
  16657. * This can be called in case of context loss
  16658. */
  16659. reset(): void;
  16660. protected _getDefines(): string;
  16661. /**
  16662. * Is the texture ready to be used ? (rendered at least once)
  16663. * @returns true if ready, otherwise, false.
  16664. */
  16665. isReady(): boolean;
  16666. /**
  16667. * Resets the refresh counter of the texture and start bak from scratch.
  16668. * Could be useful to regenerate the texture if it is setup to render only once.
  16669. */
  16670. resetRefreshCounter(): void;
  16671. /**
  16672. * Set the fragment shader to use in order to render the texture.
  16673. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16674. */
  16675. setFragment(fragment: any): void;
  16676. /**
  16677. * Define the refresh rate of the texture or the rendering frequency.
  16678. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16679. */
  16680. refreshRate: number;
  16681. /** @hidden */
  16682. _shouldRender(): boolean;
  16683. /**
  16684. * Get the size the texture is rendering at.
  16685. * @returns the size (texture is always squared)
  16686. */
  16687. getRenderSize(): number;
  16688. /**
  16689. * Resize the texture to new value.
  16690. * @param size Define the new size the texture should have
  16691. * @param generateMipMaps Define whether the new texture should create mip maps
  16692. */
  16693. resize(size: number, generateMipMaps: boolean): void;
  16694. private _checkUniform;
  16695. /**
  16696. * Set a texture in the shader program used to render.
  16697. * @param name Define the name of the uniform samplers as defined in the shader
  16698. * @param texture Define the texture to bind to this sampler
  16699. * @return the texture itself allowing "fluent" like uniform updates
  16700. */
  16701. setTexture(name: string, texture: Texture): ProceduralTexture;
  16702. /**
  16703. * Set a float in the shader.
  16704. * @param name Define the name of the uniform as defined in the shader
  16705. * @param value Define the value to give to the uniform
  16706. * @return the texture itself allowing "fluent" like uniform updates
  16707. */
  16708. setFloat(name: string, value: number): ProceduralTexture;
  16709. /**
  16710. * Set a int in the shader.
  16711. * @param name Define the name of the uniform as defined in the shader
  16712. * @param value Define the value to give to the uniform
  16713. * @return the texture itself allowing "fluent" like uniform updates
  16714. */
  16715. setInt(name: string, value: number): ProceduralTexture;
  16716. /**
  16717. * Set an array of floats in the shader.
  16718. * @param name Define the name of the uniform as defined in the shader
  16719. * @param value Define the value to give to the uniform
  16720. * @return the texture itself allowing "fluent" like uniform updates
  16721. */
  16722. setFloats(name: string, value: number[]): ProceduralTexture;
  16723. /**
  16724. * Set a vec3 in the shader from a Color3.
  16725. * @param name Define the name of the uniform as defined in the shader
  16726. * @param value Define the value to give to the uniform
  16727. * @return the texture itself allowing "fluent" like uniform updates
  16728. */
  16729. setColor3(name: string, value: Color3): ProceduralTexture;
  16730. /**
  16731. * Set a vec4 in the shader from a Color4.
  16732. * @param name Define the name of the uniform as defined in the shader
  16733. * @param value Define the value to give to the uniform
  16734. * @return the texture itself allowing "fluent" like uniform updates
  16735. */
  16736. setColor4(name: string, value: Color4): ProceduralTexture;
  16737. /**
  16738. * Set a vec2 in the shader from a Vector2.
  16739. * @param name Define the name of the uniform as defined in the shader
  16740. * @param value Define the value to give to the uniform
  16741. * @return the texture itself allowing "fluent" like uniform updates
  16742. */
  16743. setVector2(name: string, value: Vector2): ProceduralTexture;
  16744. /**
  16745. * Set a vec3 in the shader from a Vector3.
  16746. * @param name Define the name of the uniform as defined in the shader
  16747. * @param value Define the value to give to the uniform
  16748. * @return the texture itself allowing "fluent" like uniform updates
  16749. */
  16750. setVector3(name: string, value: Vector3): ProceduralTexture;
  16751. /**
  16752. * Set a mat4 in the shader from a MAtrix.
  16753. * @param name Define the name of the uniform as defined in the shader
  16754. * @param value Define the value to give to the uniform
  16755. * @return the texture itself allowing "fluent" like uniform updates
  16756. */
  16757. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16758. /**
  16759. * Render the texture to its associated render target.
  16760. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16761. */
  16762. render(useCameraPostProcess?: boolean): void;
  16763. /**
  16764. * Clone the texture.
  16765. * @returns the cloned texture
  16766. */
  16767. clone(): ProceduralTexture;
  16768. /**
  16769. * Dispose the texture and release its asoociated resources.
  16770. */
  16771. dispose(): void;
  16772. }
  16773. }
  16774. declare module "babylonjs/Particles/baseParticleSystem" {
  16775. import { Nullable } from "babylonjs/types";
  16776. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16778. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16779. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16780. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16781. import { Scene } from "babylonjs/scene";
  16782. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16783. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16784. import { Texture } from "babylonjs/Materials/Textures/texture";
  16785. import { Color4 } from "babylonjs/Maths/math.color";
  16786. import { Animation } from "babylonjs/Animations/animation";
  16787. /**
  16788. * This represents the base class for particle system in Babylon.
  16789. * 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.
  16790. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16791. * @example https://doc.babylonjs.com/babylon101/particles
  16792. */
  16793. export class BaseParticleSystem {
  16794. /**
  16795. * Source color is added to the destination color without alpha affecting the result
  16796. */
  16797. static BLENDMODE_ONEONE: number;
  16798. /**
  16799. * Blend current color and particle color using particle’s alpha
  16800. */
  16801. static BLENDMODE_STANDARD: number;
  16802. /**
  16803. * Add current color and particle color multiplied by particle’s alpha
  16804. */
  16805. static BLENDMODE_ADD: number;
  16806. /**
  16807. * Multiply current color with particle color
  16808. */
  16809. static BLENDMODE_MULTIPLY: number;
  16810. /**
  16811. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16812. */
  16813. static BLENDMODE_MULTIPLYADD: number;
  16814. /**
  16815. * List of animations used by the particle system.
  16816. */
  16817. animations: Animation[];
  16818. /**
  16819. * The id of the Particle system.
  16820. */
  16821. id: string;
  16822. /**
  16823. * The friendly name of the Particle system.
  16824. */
  16825. name: string;
  16826. /**
  16827. * The rendering group used by the Particle system to chose when to render.
  16828. */
  16829. renderingGroupId: number;
  16830. /**
  16831. * The emitter represents the Mesh or position we are attaching the particle system to.
  16832. */
  16833. emitter: Nullable<AbstractMesh | Vector3>;
  16834. /**
  16835. * The maximum number of particles to emit per frame
  16836. */
  16837. emitRate: number;
  16838. /**
  16839. * If you want to launch only a few particles at once, that can be done, as well.
  16840. */
  16841. manualEmitCount: number;
  16842. /**
  16843. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16844. */
  16845. updateSpeed: number;
  16846. /**
  16847. * The amount of time the particle system is running (depends of the overall update speed).
  16848. */
  16849. targetStopDuration: number;
  16850. /**
  16851. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16852. */
  16853. disposeOnStop: boolean;
  16854. /**
  16855. * Minimum power of emitting particles.
  16856. */
  16857. minEmitPower: number;
  16858. /**
  16859. * Maximum power of emitting particles.
  16860. */
  16861. maxEmitPower: number;
  16862. /**
  16863. * Minimum life time of emitting particles.
  16864. */
  16865. minLifeTime: number;
  16866. /**
  16867. * Maximum life time of emitting particles.
  16868. */
  16869. maxLifeTime: number;
  16870. /**
  16871. * Minimum Size of emitting particles.
  16872. */
  16873. minSize: number;
  16874. /**
  16875. * Maximum Size of emitting particles.
  16876. */
  16877. maxSize: number;
  16878. /**
  16879. * Minimum scale of emitting particles on X axis.
  16880. */
  16881. minScaleX: number;
  16882. /**
  16883. * Maximum scale of emitting particles on X axis.
  16884. */
  16885. maxScaleX: number;
  16886. /**
  16887. * Minimum scale of emitting particles on Y axis.
  16888. */
  16889. minScaleY: number;
  16890. /**
  16891. * Maximum scale of emitting particles on Y axis.
  16892. */
  16893. maxScaleY: number;
  16894. /**
  16895. * Gets or sets the minimal initial rotation in radians.
  16896. */
  16897. minInitialRotation: number;
  16898. /**
  16899. * Gets or sets the maximal initial rotation in radians.
  16900. */
  16901. maxInitialRotation: number;
  16902. /**
  16903. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16904. */
  16905. minAngularSpeed: number;
  16906. /**
  16907. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16908. */
  16909. maxAngularSpeed: number;
  16910. /**
  16911. * The texture used to render each particle. (this can be a spritesheet)
  16912. */
  16913. particleTexture: Nullable<Texture>;
  16914. /**
  16915. * The layer mask we are rendering the particles through.
  16916. */
  16917. layerMask: number;
  16918. /**
  16919. * This can help using your own shader to render the particle system.
  16920. * The according effect will be created
  16921. */
  16922. customShader: any;
  16923. /**
  16924. * By default particle system starts as soon as they are created. This prevents the
  16925. * automatic start to happen and let you decide when to start emitting particles.
  16926. */
  16927. preventAutoStart: boolean;
  16928. private _noiseTexture;
  16929. /**
  16930. * Gets or sets a texture used to add random noise to particle positions
  16931. */
  16932. noiseTexture: Nullable<ProceduralTexture>;
  16933. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16934. noiseStrength: Vector3;
  16935. /**
  16936. * Callback triggered when the particle animation is ending.
  16937. */
  16938. onAnimationEnd: Nullable<() => void>;
  16939. /**
  16940. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16941. */
  16942. blendMode: number;
  16943. /**
  16944. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16945. * to override the particles.
  16946. */
  16947. forceDepthWrite: boolean;
  16948. /** 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 */
  16949. preWarmCycles: number;
  16950. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16951. preWarmStepOffset: number;
  16952. /**
  16953. * 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)
  16954. */
  16955. spriteCellChangeSpeed: number;
  16956. /**
  16957. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16958. */
  16959. startSpriteCellID: number;
  16960. /**
  16961. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16962. */
  16963. endSpriteCellID: number;
  16964. /**
  16965. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16966. */
  16967. spriteCellWidth: number;
  16968. /**
  16969. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16970. */
  16971. spriteCellHeight: number;
  16972. /**
  16973. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16974. */
  16975. spriteRandomStartCell: boolean;
  16976. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16977. translationPivot: Vector2;
  16978. /** @hidden */
  16979. protected _isAnimationSheetEnabled: boolean;
  16980. /**
  16981. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16982. */
  16983. beginAnimationOnStart: boolean;
  16984. /**
  16985. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16986. */
  16987. beginAnimationFrom: number;
  16988. /**
  16989. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16990. */
  16991. beginAnimationTo: number;
  16992. /**
  16993. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16994. */
  16995. beginAnimationLoop: boolean;
  16996. /**
  16997. * Gets or sets a world offset applied to all particles
  16998. */
  16999. worldOffset: Vector3;
  17000. /**
  17001. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17002. */
  17003. isAnimationSheetEnabled: boolean;
  17004. /**
  17005. * Get hosting scene
  17006. * @returns the scene
  17007. */
  17008. getScene(): Scene;
  17009. /**
  17010. * You can use gravity if you want to give an orientation to your particles.
  17011. */
  17012. gravity: Vector3;
  17013. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17014. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17015. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17016. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17017. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17018. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17019. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17020. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17021. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17022. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17023. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17024. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17025. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17026. /**
  17027. * Defines the delay in milliseconds before starting the system (0 by default)
  17028. */
  17029. startDelay: number;
  17030. /**
  17031. * Gets the current list of drag gradients.
  17032. * You must use addDragGradient and removeDragGradient to udpate this list
  17033. * @returns the list of drag gradients
  17034. */
  17035. getDragGradients(): Nullable<Array<FactorGradient>>;
  17036. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17037. limitVelocityDamping: number;
  17038. /**
  17039. * Gets the current list of limit velocity gradients.
  17040. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17041. * @returns the list of limit velocity gradients
  17042. */
  17043. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17044. /**
  17045. * Gets the current list of color gradients.
  17046. * You must use addColorGradient and removeColorGradient to udpate this list
  17047. * @returns the list of color gradients
  17048. */
  17049. getColorGradients(): Nullable<Array<ColorGradient>>;
  17050. /**
  17051. * Gets the current list of size gradients.
  17052. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17053. * @returns the list of size gradients
  17054. */
  17055. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17056. /**
  17057. * Gets the current list of color remap gradients.
  17058. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17059. * @returns the list of color remap gradients
  17060. */
  17061. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17062. /**
  17063. * Gets the current list of alpha remap gradients.
  17064. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17065. * @returns the list of alpha remap gradients
  17066. */
  17067. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17068. /**
  17069. * Gets the current list of life time gradients.
  17070. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17071. * @returns the list of life time gradients
  17072. */
  17073. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17074. /**
  17075. * Gets the current list of angular speed gradients.
  17076. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17077. * @returns the list of angular speed gradients
  17078. */
  17079. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17080. /**
  17081. * Gets the current list of velocity gradients.
  17082. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17083. * @returns the list of velocity gradients
  17084. */
  17085. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17086. /**
  17087. * Gets the current list of start size gradients.
  17088. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17089. * @returns the list of start size gradients
  17090. */
  17091. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17092. /**
  17093. * Gets the current list of emit rate gradients.
  17094. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17095. * @returns the list of emit rate gradients
  17096. */
  17097. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17098. /**
  17099. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17100. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17101. */
  17102. direction1: Vector3;
  17103. /**
  17104. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17105. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17106. */
  17107. direction2: Vector3;
  17108. /**
  17109. * 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.
  17110. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17111. */
  17112. minEmitBox: Vector3;
  17113. /**
  17114. * 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.
  17115. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17116. */
  17117. maxEmitBox: Vector3;
  17118. /**
  17119. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17120. */
  17121. color1: Color4;
  17122. /**
  17123. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17124. */
  17125. color2: Color4;
  17126. /**
  17127. * Color the particle will have at the end of its lifetime
  17128. */
  17129. colorDead: Color4;
  17130. /**
  17131. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17132. */
  17133. textureMask: Color4;
  17134. /**
  17135. * The particle emitter type defines the emitter used by the particle system.
  17136. * It can be for example box, sphere, or cone...
  17137. */
  17138. particleEmitterType: IParticleEmitterType;
  17139. /** @hidden */
  17140. _isSubEmitter: boolean;
  17141. /**
  17142. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17143. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17144. */
  17145. billboardMode: number;
  17146. protected _isBillboardBased: boolean;
  17147. /**
  17148. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17149. */
  17150. isBillboardBased: boolean;
  17151. /**
  17152. * The scene the particle system belongs to.
  17153. */
  17154. protected _scene: Scene;
  17155. /**
  17156. * Local cache of defines for image processing.
  17157. */
  17158. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17159. /**
  17160. * Default configuration related to image processing available in the standard Material.
  17161. */
  17162. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17163. /**
  17164. * Gets the image processing configuration used either in this material.
  17165. */
  17166. /**
  17167. * Sets the Default image processing configuration used either in the this material.
  17168. *
  17169. * If sets to null, the scene one is in use.
  17170. */
  17171. imageProcessingConfiguration: ImageProcessingConfiguration;
  17172. /**
  17173. * Attaches a new image processing configuration to the Standard Material.
  17174. * @param configuration
  17175. */
  17176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17177. /** @hidden */
  17178. protected _reset(): void;
  17179. /** @hidden */
  17180. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17181. /**
  17182. * Instantiates a particle system.
  17183. * 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.
  17184. * @param name The name of the particle system
  17185. */
  17186. constructor(name: string);
  17187. /**
  17188. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17189. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17190. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17191. * @returns the emitter
  17192. */
  17193. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17194. /**
  17195. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17196. * @param radius The radius of the hemisphere to emit from
  17197. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17198. * @returns the emitter
  17199. */
  17200. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17201. /**
  17202. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17203. * @param radius The radius of the sphere to emit from
  17204. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17205. * @returns the emitter
  17206. */
  17207. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17208. /**
  17209. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17210. * @param radius The radius of the sphere to emit from
  17211. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17212. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17213. * @returns the emitter
  17214. */
  17215. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17216. /**
  17217. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17218. * @param radius The radius of the emission cylinder
  17219. * @param height The height of the emission cylinder
  17220. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17221. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17222. * @returns the emitter
  17223. */
  17224. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17225. /**
  17226. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17227. * @param radius The radius of the cylinder to emit from
  17228. * @param height The height of the emission cylinder
  17229. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17230. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17231. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17232. * @returns the emitter
  17233. */
  17234. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17235. /**
  17236. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17237. * @param radius The radius of the cone to emit from
  17238. * @param angle The base angle of the cone
  17239. * @returns the emitter
  17240. */
  17241. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17242. /**
  17243. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17244. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17245. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17246. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17247. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17248. * @returns the emitter
  17249. */
  17250. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17251. }
  17252. }
  17253. declare module "babylonjs/Particles/subEmitter" {
  17254. import { Scene } from "babylonjs/scene";
  17255. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17256. /**
  17257. * Type of sub emitter
  17258. */
  17259. export enum SubEmitterType {
  17260. /**
  17261. * Attached to the particle over it's lifetime
  17262. */
  17263. ATTACHED = 0,
  17264. /**
  17265. * Created when the particle dies
  17266. */
  17267. END = 1
  17268. }
  17269. /**
  17270. * Sub emitter class used to emit particles from an existing particle
  17271. */
  17272. export class SubEmitter {
  17273. /**
  17274. * the particle system to be used by the sub emitter
  17275. */
  17276. particleSystem: ParticleSystem;
  17277. /**
  17278. * Type of the submitter (Default: END)
  17279. */
  17280. type: SubEmitterType;
  17281. /**
  17282. * 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)
  17283. * Note: This only is supported when using an emitter of type Mesh
  17284. */
  17285. inheritDirection: boolean;
  17286. /**
  17287. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17288. */
  17289. inheritedVelocityAmount: number;
  17290. /**
  17291. * Creates a sub emitter
  17292. * @param particleSystem the particle system to be used by the sub emitter
  17293. */
  17294. constructor(
  17295. /**
  17296. * the particle system to be used by the sub emitter
  17297. */
  17298. particleSystem: ParticleSystem);
  17299. /**
  17300. * Clones the sub emitter
  17301. * @returns the cloned sub emitter
  17302. */
  17303. clone(): SubEmitter;
  17304. /**
  17305. * Serialize current object to a JSON object
  17306. * @returns the serialized object
  17307. */
  17308. serialize(): any;
  17309. /** @hidden */
  17310. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17311. /**
  17312. * Creates a new SubEmitter from a serialized JSON version
  17313. * @param serializationObject defines the JSON object to read from
  17314. * @param scene defines the hosting scene
  17315. * @param rootUrl defines the rootUrl for data loading
  17316. * @returns a new SubEmitter
  17317. */
  17318. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17319. /** Release associated resources */
  17320. dispose(): void;
  17321. }
  17322. }
  17323. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17324. /** @hidden */
  17325. export var clipPlaneFragmentDeclaration: {
  17326. name: string;
  17327. shader: string;
  17328. };
  17329. }
  17330. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17331. /** @hidden */
  17332. export var imageProcessingDeclaration: {
  17333. name: string;
  17334. shader: string;
  17335. };
  17336. }
  17337. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17338. /** @hidden */
  17339. export var imageProcessingFunctions: {
  17340. name: string;
  17341. shader: string;
  17342. };
  17343. }
  17344. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17345. /** @hidden */
  17346. export var clipPlaneFragment: {
  17347. name: string;
  17348. shader: string;
  17349. };
  17350. }
  17351. declare module "babylonjs/Shaders/particles.fragment" {
  17352. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17353. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17354. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17355. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17356. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17357. /** @hidden */
  17358. export var particlesPixelShader: {
  17359. name: string;
  17360. shader: string;
  17361. };
  17362. }
  17363. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17364. /** @hidden */
  17365. export var clipPlaneVertexDeclaration: {
  17366. name: string;
  17367. shader: string;
  17368. };
  17369. }
  17370. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17371. /** @hidden */
  17372. export var clipPlaneVertex: {
  17373. name: string;
  17374. shader: string;
  17375. };
  17376. }
  17377. declare module "babylonjs/Shaders/particles.vertex" {
  17378. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17379. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17380. /** @hidden */
  17381. export var particlesVertexShader: {
  17382. name: string;
  17383. shader: string;
  17384. };
  17385. }
  17386. declare module "babylonjs/Particles/particleSystem" {
  17387. import { Nullable } from "babylonjs/types";
  17388. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17389. import { Observable } from "babylonjs/Misc/observable";
  17390. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17391. import { Effect } from "babylonjs/Materials/effect";
  17392. import { Scene, IDisposable } from "babylonjs/scene";
  17393. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17394. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17395. import { Particle } from "babylonjs/Particles/particle";
  17396. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17397. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17398. import "babylonjs/Shaders/particles.fragment";
  17399. import "babylonjs/Shaders/particles.vertex";
  17400. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17401. /**
  17402. * This represents a particle system in Babylon.
  17403. * 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.
  17404. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17405. * @example https://doc.babylonjs.com/babylon101/particles
  17406. */
  17407. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17408. /**
  17409. * Billboard mode will only apply to Y axis
  17410. */
  17411. static readonly BILLBOARDMODE_Y: number;
  17412. /**
  17413. * Billboard mode will apply to all axes
  17414. */
  17415. static readonly BILLBOARDMODE_ALL: number;
  17416. /**
  17417. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17418. */
  17419. static readonly BILLBOARDMODE_STRETCHED: number;
  17420. /**
  17421. * This function can be defined to provide custom update for active particles.
  17422. * This function will be called instead of regular update (age, position, color, etc.).
  17423. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17424. */
  17425. updateFunction: (particles: Particle[]) => void;
  17426. private _emitterWorldMatrix;
  17427. /**
  17428. * This function can be defined to specify initial direction for every new particle.
  17429. * It by default use the emitterType defined function
  17430. */
  17431. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17432. /**
  17433. * This function can be defined to specify initial position for every new particle.
  17434. * It by default use the emitterType defined function
  17435. */
  17436. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17437. /**
  17438. * @hidden
  17439. */
  17440. _inheritedVelocityOffset: Vector3;
  17441. /**
  17442. * An event triggered when the system is disposed
  17443. */
  17444. onDisposeObservable: Observable<ParticleSystem>;
  17445. private _onDisposeObserver;
  17446. /**
  17447. * Sets a callback that will be triggered when the system is disposed
  17448. */
  17449. onDispose: () => void;
  17450. private _particles;
  17451. private _epsilon;
  17452. private _capacity;
  17453. private _stockParticles;
  17454. private _newPartsExcess;
  17455. private _vertexData;
  17456. private _vertexBuffer;
  17457. private _vertexBuffers;
  17458. private _spriteBuffer;
  17459. private _indexBuffer;
  17460. private _effect;
  17461. private _customEffect;
  17462. private _cachedDefines;
  17463. private _scaledColorStep;
  17464. private _colorDiff;
  17465. private _scaledDirection;
  17466. private _scaledGravity;
  17467. private _currentRenderId;
  17468. private _alive;
  17469. private _useInstancing;
  17470. private _started;
  17471. private _stopped;
  17472. private _actualFrame;
  17473. private _scaledUpdateSpeed;
  17474. private _vertexBufferSize;
  17475. /** @hidden */
  17476. _currentEmitRateGradient: Nullable<FactorGradient>;
  17477. /** @hidden */
  17478. _currentEmitRate1: number;
  17479. /** @hidden */
  17480. _currentEmitRate2: number;
  17481. /** @hidden */
  17482. _currentStartSizeGradient: Nullable<FactorGradient>;
  17483. /** @hidden */
  17484. _currentStartSize1: number;
  17485. /** @hidden */
  17486. _currentStartSize2: number;
  17487. private readonly _rawTextureWidth;
  17488. private _rampGradientsTexture;
  17489. private _useRampGradients;
  17490. /** Gets or sets a boolean indicating that ramp gradients must be used
  17491. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17492. */
  17493. useRampGradients: boolean;
  17494. /**
  17495. * 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.
  17496. * 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: [])
  17497. */
  17498. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17499. private _subEmitters;
  17500. /**
  17501. * @hidden
  17502. * If the particle systems emitter should be disposed when the particle system is disposed
  17503. */
  17504. _disposeEmitterOnDispose: boolean;
  17505. /**
  17506. * The current active Sub-systems, this property is used by the root particle system only.
  17507. */
  17508. activeSubSystems: Array<ParticleSystem>;
  17509. private _rootParticleSystem;
  17510. /**
  17511. * Gets the current list of active particles
  17512. */
  17513. readonly particles: Particle[];
  17514. /**
  17515. * Returns the string "ParticleSystem"
  17516. * @returns a string containing the class name
  17517. */
  17518. getClassName(): string;
  17519. /**
  17520. * Instantiates a particle system.
  17521. * 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.
  17522. * @param name The name of the particle system
  17523. * @param capacity The max number of particles alive at the same time
  17524. * @param scene The scene the particle system belongs to
  17525. * @param customEffect a custom effect used to change the way particles are rendered by default
  17526. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17527. * @param epsilon Offset used to render the particles
  17528. */
  17529. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17530. private _addFactorGradient;
  17531. private _removeFactorGradient;
  17532. /**
  17533. * Adds a new life time gradient
  17534. * @param gradient defines the gradient to use (between 0 and 1)
  17535. * @param factor defines the life time factor to affect to the specified gradient
  17536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17537. * @returns the current particle system
  17538. */
  17539. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17540. /**
  17541. * Remove a specific life time gradient
  17542. * @param gradient defines the gradient to remove
  17543. * @returns the current particle system
  17544. */
  17545. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17546. /**
  17547. * Adds a new size gradient
  17548. * @param gradient defines the gradient to use (between 0 and 1)
  17549. * @param factor defines the size factor to affect to the specified gradient
  17550. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17551. * @returns the current particle system
  17552. */
  17553. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17554. /**
  17555. * Remove a specific size gradient
  17556. * @param gradient defines the gradient to remove
  17557. * @returns the current particle system
  17558. */
  17559. removeSizeGradient(gradient: number): IParticleSystem;
  17560. /**
  17561. * Adds a new color remap gradient
  17562. * @param gradient defines the gradient to use (between 0 and 1)
  17563. * @param min defines the color remap minimal range
  17564. * @param max defines the color remap maximal range
  17565. * @returns the current particle system
  17566. */
  17567. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17568. /**
  17569. * Remove a specific color remap gradient
  17570. * @param gradient defines the gradient to remove
  17571. * @returns the current particle system
  17572. */
  17573. removeColorRemapGradient(gradient: number): IParticleSystem;
  17574. /**
  17575. * Adds a new alpha remap gradient
  17576. * @param gradient defines the gradient to use (between 0 and 1)
  17577. * @param min defines the alpha remap minimal range
  17578. * @param max defines the alpha remap maximal range
  17579. * @returns the current particle system
  17580. */
  17581. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17582. /**
  17583. * Remove a specific alpha remap gradient
  17584. * @param gradient defines the gradient to remove
  17585. * @returns the current particle system
  17586. */
  17587. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17588. /**
  17589. * Adds a new angular speed gradient
  17590. * @param gradient defines the gradient to use (between 0 and 1)
  17591. * @param factor defines the angular speed to affect to the specified gradient
  17592. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17593. * @returns the current particle system
  17594. */
  17595. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17596. /**
  17597. * Remove a specific angular speed gradient
  17598. * @param gradient defines the gradient to remove
  17599. * @returns the current particle system
  17600. */
  17601. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17602. /**
  17603. * Adds a new velocity gradient
  17604. * @param gradient defines the gradient to use (between 0 and 1)
  17605. * @param factor defines the velocity to affect to the specified gradient
  17606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17607. * @returns the current particle system
  17608. */
  17609. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17610. /**
  17611. * Remove a specific velocity gradient
  17612. * @param gradient defines the gradient to remove
  17613. * @returns the current particle system
  17614. */
  17615. removeVelocityGradient(gradient: number): IParticleSystem;
  17616. /**
  17617. * Adds a new limit velocity gradient
  17618. * @param gradient defines the gradient to use (between 0 and 1)
  17619. * @param factor defines the limit velocity value to affect to the specified gradient
  17620. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17621. * @returns the current particle system
  17622. */
  17623. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17624. /**
  17625. * Remove a specific limit velocity gradient
  17626. * @param gradient defines the gradient to remove
  17627. * @returns the current particle system
  17628. */
  17629. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17630. /**
  17631. * Adds a new drag gradient
  17632. * @param gradient defines the gradient to use (between 0 and 1)
  17633. * @param factor defines the drag value to affect to the specified gradient
  17634. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17635. * @returns the current particle system
  17636. */
  17637. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17638. /**
  17639. * Remove a specific drag gradient
  17640. * @param gradient defines the gradient to remove
  17641. * @returns the current particle system
  17642. */
  17643. removeDragGradient(gradient: number): IParticleSystem;
  17644. /**
  17645. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17646. * @param gradient defines the gradient to use (between 0 and 1)
  17647. * @param factor defines the emit rate value to affect to the specified gradient
  17648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17649. * @returns the current particle system
  17650. */
  17651. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17652. /**
  17653. * Remove a specific emit rate gradient
  17654. * @param gradient defines the gradient to remove
  17655. * @returns the current particle system
  17656. */
  17657. removeEmitRateGradient(gradient: number): IParticleSystem;
  17658. /**
  17659. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17660. * @param gradient defines the gradient to use (between 0 and 1)
  17661. * @param factor defines the start size value to affect to the specified gradient
  17662. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17663. * @returns the current particle system
  17664. */
  17665. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17666. /**
  17667. * Remove a specific start size gradient
  17668. * @param gradient defines the gradient to remove
  17669. * @returns the current particle system
  17670. */
  17671. removeStartSizeGradient(gradient: number): IParticleSystem;
  17672. private _createRampGradientTexture;
  17673. /**
  17674. * Gets the current list of ramp gradients.
  17675. * You must use addRampGradient and removeRampGradient to udpate this list
  17676. * @returns the list of ramp gradients
  17677. */
  17678. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17679. /**
  17680. * Adds a new ramp gradient used to remap particle colors
  17681. * @param gradient defines the gradient to use (between 0 and 1)
  17682. * @param color defines the color to affect to the specified gradient
  17683. * @returns the current particle system
  17684. */
  17685. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17686. /**
  17687. * Remove a specific ramp gradient
  17688. * @param gradient defines the gradient to remove
  17689. * @returns the current particle system
  17690. */
  17691. removeRampGradient(gradient: number): ParticleSystem;
  17692. /**
  17693. * Adds a new color gradient
  17694. * @param gradient defines the gradient to use (between 0 and 1)
  17695. * @param color1 defines the color to affect to the specified gradient
  17696. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17697. * @returns this particle system
  17698. */
  17699. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17700. /**
  17701. * Remove a specific color gradient
  17702. * @param gradient defines the gradient to remove
  17703. * @returns this particle system
  17704. */
  17705. removeColorGradient(gradient: number): IParticleSystem;
  17706. private _fetchR;
  17707. protected _reset(): void;
  17708. private _resetEffect;
  17709. private _createVertexBuffers;
  17710. private _createIndexBuffer;
  17711. /**
  17712. * Gets the maximum number of particles active at the same time.
  17713. * @returns The max number of active particles.
  17714. */
  17715. getCapacity(): number;
  17716. /**
  17717. * Gets whether there are still active particles in the system.
  17718. * @returns True if it is alive, otherwise false.
  17719. */
  17720. isAlive(): boolean;
  17721. /**
  17722. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17723. * @returns True if it has been started, otherwise false.
  17724. */
  17725. isStarted(): boolean;
  17726. private _prepareSubEmitterInternalArray;
  17727. /**
  17728. * Starts the particle system and begins to emit
  17729. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17730. */
  17731. start(delay?: number): void;
  17732. /**
  17733. * Stops the particle system.
  17734. * @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.
  17735. */
  17736. stop(stopSubEmitters?: boolean): void;
  17737. /**
  17738. * Remove all active particles
  17739. */
  17740. reset(): void;
  17741. /**
  17742. * @hidden (for internal use only)
  17743. */
  17744. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17745. /**
  17746. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17747. * Its lifetime will start back at 0.
  17748. */
  17749. recycleParticle: (particle: Particle) => void;
  17750. private _stopSubEmitters;
  17751. private _createParticle;
  17752. private _removeFromRoot;
  17753. private _emitFromParticle;
  17754. private _update;
  17755. /** @hidden */
  17756. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17757. /** @hidden */
  17758. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17759. /** @hidden */
  17760. private _getEffect;
  17761. /**
  17762. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17763. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17764. */
  17765. animate(preWarmOnly?: boolean): void;
  17766. private _appendParticleVertices;
  17767. /**
  17768. * Rebuilds the particle system.
  17769. */
  17770. rebuild(): void;
  17771. /**
  17772. * Is this system ready to be used/rendered
  17773. * @return true if the system is ready
  17774. */
  17775. isReady(): boolean;
  17776. private _render;
  17777. /**
  17778. * Renders the particle system in its current state.
  17779. * @returns the current number of particles
  17780. */
  17781. render(): number;
  17782. /**
  17783. * Disposes the particle system and free the associated resources
  17784. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17785. */
  17786. dispose(disposeTexture?: boolean): void;
  17787. /**
  17788. * Clones the particle system.
  17789. * @param name The name of the cloned object
  17790. * @param newEmitter The new emitter to use
  17791. * @returns the cloned particle system
  17792. */
  17793. clone(name: string, newEmitter: any): ParticleSystem;
  17794. /**
  17795. * Serializes the particle system to a JSON object.
  17796. * @returns the JSON object
  17797. */
  17798. serialize(): any;
  17799. /** @hidden */
  17800. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17801. /** @hidden */
  17802. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17803. /**
  17804. * Parses a JSON object to create a particle system.
  17805. * @param parsedParticleSystem The JSON object to parse
  17806. * @param scene The scene to create the particle system in
  17807. * @param rootUrl The root url to use to load external dependencies like texture
  17808. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17809. * @returns the Parsed particle system
  17810. */
  17811. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17812. }
  17813. }
  17814. declare module "babylonjs/Particles/particle" {
  17815. import { Nullable } from "babylonjs/types";
  17816. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17817. import { Color4 } from "babylonjs/Maths/math.color";
  17818. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17819. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17820. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17821. /**
  17822. * A particle represents one of the element emitted by a particle system.
  17823. * This is mainly define by its coordinates, direction, velocity and age.
  17824. */
  17825. export class Particle {
  17826. /**
  17827. * The particle system the particle belongs to.
  17828. */
  17829. particleSystem: ParticleSystem;
  17830. private static _Count;
  17831. /**
  17832. * Unique ID of the particle
  17833. */
  17834. id: number;
  17835. /**
  17836. * The world position of the particle in the scene.
  17837. */
  17838. position: Vector3;
  17839. /**
  17840. * The world direction of the particle in the scene.
  17841. */
  17842. direction: Vector3;
  17843. /**
  17844. * The color of the particle.
  17845. */
  17846. color: Color4;
  17847. /**
  17848. * The color change of the particle per step.
  17849. */
  17850. colorStep: Color4;
  17851. /**
  17852. * Defines how long will the life of the particle be.
  17853. */
  17854. lifeTime: number;
  17855. /**
  17856. * The current age of the particle.
  17857. */
  17858. age: number;
  17859. /**
  17860. * The current size of the particle.
  17861. */
  17862. size: number;
  17863. /**
  17864. * The current scale of the particle.
  17865. */
  17866. scale: Vector2;
  17867. /**
  17868. * The current angle of the particle.
  17869. */
  17870. angle: number;
  17871. /**
  17872. * Defines how fast is the angle changing.
  17873. */
  17874. angularSpeed: number;
  17875. /**
  17876. * Defines the cell index used by the particle to be rendered from a sprite.
  17877. */
  17878. cellIndex: number;
  17879. /**
  17880. * The information required to support color remapping
  17881. */
  17882. remapData: Vector4;
  17883. /** @hidden */
  17884. _randomCellOffset?: number;
  17885. /** @hidden */
  17886. _initialDirection: Nullable<Vector3>;
  17887. /** @hidden */
  17888. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17889. /** @hidden */
  17890. _initialStartSpriteCellID: number;
  17891. /** @hidden */
  17892. _initialEndSpriteCellID: number;
  17893. /** @hidden */
  17894. _currentColorGradient: Nullable<ColorGradient>;
  17895. /** @hidden */
  17896. _currentColor1: Color4;
  17897. /** @hidden */
  17898. _currentColor2: Color4;
  17899. /** @hidden */
  17900. _currentSizeGradient: Nullable<FactorGradient>;
  17901. /** @hidden */
  17902. _currentSize1: number;
  17903. /** @hidden */
  17904. _currentSize2: number;
  17905. /** @hidden */
  17906. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17907. /** @hidden */
  17908. _currentAngularSpeed1: number;
  17909. /** @hidden */
  17910. _currentAngularSpeed2: number;
  17911. /** @hidden */
  17912. _currentVelocityGradient: Nullable<FactorGradient>;
  17913. /** @hidden */
  17914. _currentVelocity1: number;
  17915. /** @hidden */
  17916. _currentVelocity2: number;
  17917. /** @hidden */
  17918. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17919. /** @hidden */
  17920. _currentLimitVelocity1: number;
  17921. /** @hidden */
  17922. _currentLimitVelocity2: number;
  17923. /** @hidden */
  17924. _currentDragGradient: Nullable<FactorGradient>;
  17925. /** @hidden */
  17926. _currentDrag1: number;
  17927. /** @hidden */
  17928. _currentDrag2: number;
  17929. /** @hidden */
  17930. _randomNoiseCoordinates1: Vector3;
  17931. /** @hidden */
  17932. _randomNoiseCoordinates2: Vector3;
  17933. /**
  17934. * Creates a new instance Particle
  17935. * @param particleSystem the particle system the particle belongs to
  17936. */
  17937. constructor(
  17938. /**
  17939. * The particle system the particle belongs to.
  17940. */
  17941. particleSystem: ParticleSystem);
  17942. private updateCellInfoFromSystem;
  17943. /**
  17944. * Defines how the sprite cell index is updated for the particle
  17945. */
  17946. updateCellIndex(): void;
  17947. /** @hidden */
  17948. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17949. /** @hidden */
  17950. _inheritParticleInfoToSubEmitters(): void;
  17951. /** @hidden */
  17952. _reset(): void;
  17953. /**
  17954. * Copy the properties of particle to another one.
  17955. * @param other the particle to copy the information to.
  17956. */
  17957. copyTo(other: Particle): void;
  17958. }
  17959. }
  17960. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  17961. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17962. import { Effect } from "babylonjs/Materials/effect";
  17963. import { Particle } from "babylonjs/Particles/particle";
  17964. /**
  17965. * Particle emitter represents a volume emitting particles.
  17966. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17967. */
  17968. export interface IParticleEmitterType {
  17969. /**
  17970. * Called by the particle System when the direction is computed for the created particle.
  17971. * @param worldMatrix is the world matrix of the particle system
  17972. * @param directionToUpdate is the direction vector to update with the result
  17973. * @param particle is the particle we are computed the direction for
  17974. */
  17975. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17976. /**
  17977. * Called by the particle System when the position is computed for the created particle.
  17978. * @param worldMatrix is the world matrix of the particle system
  17979. * @param positionToUpdate is the position vector to update with the result
  17980. * @param particle is the particle we are computed the position for
  17981. */
  17982. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17983. /**
  17984. * Clones the current emitter and returns a copy of it
  17985. * @returns the new emitter
  17986. */
  17987. clone(): IParticleEmitterType;
  17988. /**
  17989. * Called by the GPUParticleSystem to setup the update shader
  17990. * @param effect defines the update shader
  17991. */
  17992. applyToShader(effect: Effect): void;
  17993. /**
  17994. * Returns a string to use to update the GPU particles update shader
  17995. * @returns the effect defines string
  17996. */
  17997. getEffectDefines(): string;
  17998. /**
  17999. * Returns a string representing the class name
  18000. * @returns a string containing the class name
  18001. */
  18002. getClassName(): string;
  18003. /**
  18004. * Serializes the particle system to a JSON object.
  18005. * @returns the JSON object
  18006. */
  18007. serialize(): any;
  18008. /**
  18009. * Parse properties from a JSON object
  18010. * @param serializationObject defines the JSON object
  18011. */
  18012. parse(serializationObject: any): void;
  18013. }
  18014. }
  18015. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18016. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18017. import { Effect } from "babylonjs/Materials/effect";
  18018. import { Particle } from "babylonjs/Particles/particle";
  18019. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18020. /**
  18021. * Particle emitter emitting particles from the inside of a box.
  18022. * It emits the particles randomly between 2 given directions.
  18023. */
  18024. export class BoxParticleEmitter implements IParticleEmitterType {
  18025. /**
  18026. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18027. */
  18028. direction1: Vector3;
  18029. /**
  18030. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18031. */
  18032. direction2: Vector3;
  18033. /**
  18034. * 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.
  18035. */
  18036. minEmitBox: Vector3;
  18037. /**
  18038. * 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.
  18039. */
  18040. maxEmitBox: Vector3;
  18041. /**
  18042. * Creates a new instance BoxParticleEmitter
  18043. */
  18044. constructor();
  18045. /**
  18046. * Called by the particle System when the direction is computed for the created particle.
  18047. * @param worldMatrix is the world matrix of the particle system
  18048. * @param directionToUpdate is the direction vector to update with the result
  18049. * @param particle is the particle we are computed the direction for
  18050. */
  18051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18052. /**
  18053. * Called by the particle System when the position is computed for the created particle.
  18054. * @param worldMatrix is the world matrix of the particle system
  18055. * @param positionToUpdate is the position vector to update with the result
  18056. * @param particle is the particle we are computed the position for
  18057. */
  18058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18059. /**
  18060. * Clones the current emitter and returns a copy of it
  18061. * @returns the new emitter
  18062. */
  18063. clone(): BoxParticleEmitter;
  18064. /**
  18065. * Called by the GPUParticleSystem to setup the update shader
  18066. * @param effect defines the update shader
  18067. */
  18068. applyToShader(effect: Effect): void;
  18069. /**
  18070. * Returns a string to use to update the GPU particles update shader
  18071. * @returns a string containng the defines string
  18072. */
  18073. getEffectDefines(): string;
  18074. /**
  18075. * Returns the string "BoxParticleEmitter"
  18076. * @returns a string containing the class name
  18077. */
  18078. getClassName(): string;
  18079. /**
  18080. * Serializes the particle system to a JSON object.
  18081. * @returns the JSON object
  18082. */
  18083. serialize(): any;
  18084. /**
  18085. * Parse properties from a JSON object
  18086. * @param serializationObject defines the JSON object
  18087. */
  18088. parse(serializationObject: any): void;
  18089. }
  18090. }
  18091. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18092. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18093. import { Effect } from "babylonjs/Materials/effect";
  18094. import { Particle } from "babylonjs/Particles/particle";
  18095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18096. /**
  18097. * Particle emitter emitting particles from the inside of a cone.
  18098. * It emits the particles alongside the cone volume from the base to the particle.
  18099. * The emission direction might be randomized.
  18100. */
  18101. export class ConeParticleEmitter implements IParticleEmitterType {
  18102. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18103. directionRandomizer: number;
  18104. private _radius;
  18105. private _angle;
  18106. private _height;
  18107. /**
  18108. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18109. */
  18110. radiusRange: number;
  18111. /**
  18112. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18113. */
  18114. heightRange: number;
  18115. /**
  18116. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18117. */
  18118. emitFromSpawnPointOnly: boolean;
  18119. /**
  18120. * Gets or sets the radius of the emission cone
  18121. */
  18122. radius: number;
  18123. /**
  18124. * Gets or sets the angle of the emission cone
  18125. */
  18126. angle: number;
  18127. private _buildHeight;
  18128. /**
  18129. * Creates a new instance ConeParticleEmitter
  18130. * @param radius the radius of the emission cone (1 by default)
  18131. * @param angle the cone base angle (PI by default)
  18132. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18133. */
  18134. constructor(radius?: number, angle?: number,
  18135. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18136. directionRandomizer?: number);
  18137. /**
  18138. * Called by the particle System when the direction is computed for the created particle.
  18139. * @param worldMatrix is the world matrix of the particle system
  18140. * @param directionToUpdate is the direction vector to update with the result
  18141. * @param particle is the particle we are computed the direction for
  18142. */
  18143. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18144. /**
  18145. * Called by the particle System when the position is computed for the created particle.
  18146. * @param worldMatrix is the world matrix of the particle system
  18147. * @param positionToUpdate is the position vector to update with the result
  18148. * @param particle is the particle we are computed the position for
  18149. */
  18150. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18151. /**
  18152. * Clones the current emitter and returns a copy of it
  18153. * @returns the new emitter
  18154. */
  18155. clone(): ConeParticleEmitter;
  18156. /**
  18157. * Called by the GPUParticleSystem to setup the update shader
  18158. * @param effect defines the update shader
  18159. */
  18160. applyToShader(effect: Effect): void;
  18161. /**
  18162. * Returns a string to use to update the GPU particles update shader
  18163. * @returns a string containng the defines string
  18164. */
  18165. getEffectDefines(): string;
  18166. /**
  18167. * Returns the string "ConeParticleEmitter"
  18168. * @returns a string containing the class name
  18169. */
  18170. getClassName(): string;
  18171. /**
  18172. * Serializes the particle system to a JSON object.
  18173. * @returns the JSON object
  18174. */
  18175. serialize(): any;
  18176. /**
  18177. * Parse properties from a JSON object
  18178. * @param serializationObject defines the JSON object
  18179. */
  18180. parse(serializationObject: any): void;
  18181. }
  18182. }
  18183. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18184. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18185. import { Effect } from "babylonjs/Materials/effect";
  18186. import { Particle } from "babylonjs/Particles/particle";
  18187. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18188. /**
  18189. * Particle emitter emitting particles from the inside of a cylinder.
  18190. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18191. */
  18192. export class CylinderParticleEmitter implements IParticleEmitterType {
  18193. /**
  18194. * The radius of the emission cylinder.
  18195. */
  18196. radius: number;
  18197. /**
  18198. * The height of the emission cylinder.
  18199. */
  18200. height: number;
  18201. /**
  18202. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18203. */
  18204. radiusRange: number;
  18205. /**
  18206. * How much to randomize the particle direction [0-1].
  18207. */
  18208. directionRandomizer: number;
  18209. /**
  18210. * Creates a new instance CylinderParticleEmitter
  18211. * @param radius the radius of the emission cylinder (1 by default)
  18212. * @param height the height of the emission cylinder (1 by default)
  18213. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18214. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18215. */
  18216. constructor(
  18217. /**
  18218. * The radius of the emission cylinder.
  18219. */
  18220. radius?: number,
  18221. /**
  18222. * The height of the emission cylinder.
  18223. */
  18224. height?: number,
  18225. /**
  18226. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18227. */
  18228. radiusRange?: number,
  18229. /**
  18230. * How much to randomize the particle direction [0-1].
  18231. */
  18232. directionRandomizer?: number);
  18233. /**
  18234. * Called by the particle System when the direction is computed for the created particle.
  18235. * @param worldMatrix is the world matrix of the particle system
  18236. * @param directionToUpdate is the direction vector to update with the result
  18237. * @param particle is the particle we are computed the direction for
  18238. */
  18239. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18240. /**
  18241. * Called by the particle System when the position is computed for the created particle.
  18242. * @param worldMatrix is the world matrix of the particle system
  18243. * @param positionToUpdate is the position vector to update with the result
  18244. * @param particle is the particle we are computed the position for
  18245. */
  18246. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18247. /**
  18248. * Clones the current emitter and returns a copy of it
  18249. * @returns the new emitter
  18250. */
  18251. clone(): CylinderParticleEmitter;
  18252. /**
  18253. * Called by the GPUParticleSystem to setup the update shader
  18254. * @param effect defines the update shader
  18255. */
  18256. applyToShader(effect: Effect): void;
  18257. /**
  18258. * Returns a string to use to update the GPU particles update shader
  18259. * @returns a string containng the defines string
  18260. */
  18261. getEffectDefines(): string;
  18262. /**
  18263. * Returns the string "CylinderParticleEmitter"
  18264. * @returns a string containing the class name
  18265. */
  18266. getClassName(): string;
  18267. /**
  18268. * Serializes the particle system to a JSON object.
  18269. * @returns the JSON object
  18270. */
  18271. serialize(): any;
  18272. /**
  18273. * Parse properties from a JSON object
  18274. * @param serializationObject defines the JSON object
  18275. */
  18276. parse(serializationObject: any): void;
  18277. }
  18278. /**
  18279. * Particle emitter emitting particles from the inside of a cylinder.
  18280. * It emits the particles randomly between two vectors.
  18281. */
  18282. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18283. /**
  18284. * The min limit of the emission direction.
  18285. */
  18286. direction1: Vector3;
  18287. /**
  18288. * The max limit of the emission direction.
  18289. */
  18290. direction2: Vector3;
  18291. /**
  18292. * Creates a new instance CylinderDirectedParticleEmitter
  18293. * @param radius the radius of the emission cylinder (1 by default)
  18294. * @param height the height of the emission cylinder (1 by default)
  18295. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18296. * @param direction1 the min limit of the emission direction (up vector by default)
  18297. * @param direction2 the max limit of the emission direction (up vector by default)
  18298. */
  18299. constructor(radius?: number, height?: number, radiusRange?: number,
  18300. /**
  18301. * The min limit of the emission direction.
  18302. */
  18303. direction1?: Vector3,
  18304. /**
  18305. * The max limit of the emission direction.
  18306. */
  18307. direction2?: Vector3);
  18308. /**
  18309. * Called by the particle System when the direction is computed for the created particle.
  18310. * @param worldMatrix is the world matrix of the particle system
  18311. * @param directionToUpdate is the direction vector to update with the result
  18312. * @param particle is the particle we are computed the direction for
  18313. */
  18314. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18315. /**
  18316. * Clones the current emitter and returns a copy of it
  18317. * @returns the new emitter
  18318. */
  18319. clone(): CylinderDirectedParticleEmitter;
  18320. /**
  18321. * Called by the GPUParticleSystem to setup the update shader
  18322. * @param effect defines the update shader
  18323. */
  18324. applyToShader(effect: Effect): void;
  18325. /**
  18326. * Returns a string to use to update the GPU particles update shader
  18327. * @returns a string containng the defines string
  18328. */
  18329. getEffectDefines(): string;
  18330. /**
  18331. * Returns the string "CylinderDirectedParticleEmitter"
  18332. * @returns a string containing the class name
  18333. */
  18334. getClassName(): string;
  18335. /**
  18336. * Serializes the particle system to a JSON object.
  18337. * @returns the JSON object
  18338. */
  18339. serialize(): any;
  18340. /**
  18341. * Parse properties from a JSON object
  18342. * @param serializationObject defines the JSON object
  18343. */
  18344. parse(serializationObject: any): void;
  18345. }
  18346. }
  18347. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18348. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18349. import { Effect } from "babylonjs/Materials/effect";
  18350. import { Particle } from "babylonjs/Particles/particle";
  18351. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18352. /**
  18353. * Particle emitter emitting particles from the inside of a hemisphere.
  18354. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18355. */
  18356. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18357. /**
  18358. * The radius of the emission hemisphere.
  18359. */
  18360. radius: number;
  18361. /**
  18362. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18363. */
  18364. radiusRange: number;
  18365. /**
  18366. * How much to randomize the particle direction [0-1].
  18367. */
  18368. directionRandomizer: number;
  18369. /**
  18370. * Creates a new instance HemisphericParticleEmitter
  18371. * @param radius the radius of the emission hemisphere (1 by default)
  18372. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18373. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18374. */
  18375. constructor(
  18376. /**
  18377. * The radius of the emission hemisphere.
  18378. */
  18379. radius?: number,
  18380. /**
  18381. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18382. */
  18383. radiusRange?: number,
  18384. /**
  18385. * How much to randomize the particle direction [0-1].
  18386. */
  18387. directionRandomizer?: number);
  18388. /**
  18389. * Called by the particle System when the direction is computed for the created particle.
  18390. * @param worldMatrix is the world matrix of the particle system
  18391. * @param directionToUpdate is the direction vector to update with the result
  18392. * @param particle is the particle we are computed the direction for
  18393. */
  18394. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18395. /**
  18396. * Called by the particle System when the position is computed for the created particle.
  18397. * @param worldMatrix is the world matrix of the particle system
  18398. * @param positionToUpdate is the position vector to update with the result
  18399. * @param particle is the particle we are computed the position for
  18400. */
  18401. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18402. /**
  18403. * Clones the current emitter and returns a copy of it
  18404. * @returns the new emitter
  18405. */
  18406. clone(): HemisphericParticleEmitter;
  18407. /**
  18408. * Called by the GPUParticleSystem to setup the update shader
  18409. * @param effect defines the update shader
  18410. */
  18411. applyToShader(effect: Effect): void;
  18412. /**
  18413. * Returns a string to use to update the GPU particles update shader
  18414. * @returns a string containng the defines string
  18415. */
  18416. getEffectDefines(): string;
  18417. /**
  18418. * Returns the string "HemisphericParticleEmitter"
  18419. * @returns a string containing the class name
  18420. */
  18421. getClassName(): string;
  18422. /**
  18423. * Serializes the particle system to a JSON object.
  18424. * @returns the JSON object
  18425. */
  18426. serialize(): any;
  18427. /**
  18428. * Parse properties from a JSON object
  18429. * @param serializationObject defines the JSON object
  18430. */
  18431. parse(serializationObject: any): void;
  18432. }
  18433. }
  18434. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18435. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18436. import { Effect } from "babylonjs/Materials/effect";
  18437. import { Particle } from "babylonjs/Particles/particle";
  18438. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18439. /**
  18440. * Particle emitter emitting particles from a point.
  18441. * It emits the particles randomly between 2 given directions.
  18442. */
  18443. export class PointParticleEmitter implements IParticleEmitterType {
  18444. /**
  18445. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18446. */
  18447. direction1: Vector3;
  18448. /**
  18449. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18450. */
  18451. direction2: Vector3;
  18452. /**
  18453. * Creates a new instance PointParticleEmitter
  18454. */
  18455. constructor();
  18456. /**
  18457. * Called by the particle System when the direction is computed for the created particle.
  18458. * @param worldMatrix is the world matrix of the particle system
  18459. * @param directionToUpdate is the direction vector to update with the result
  18460. * @param particle is the particle we are computed the direction for
  18461. */
  18462. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18463. /**
  18464. * Called by the particle System when the position is computed for the created particle.
  18465. * @param worldMatrix is the world matrix of the particle system
  18466. * @param positionToUpdate is the position vector to update with the result
  18467. * @param particle is the particle we are computed the position for
  18468. */
  18469. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18470. /**
  18471. * Clones the current emitter and returns a copy of it
  18472. * @returns the new emitter
  18473. */
  18474. clone(): PointParticleEmitter;
  18475. /**
  18476. * Called by the GPUParticleSystem to setup the update shader
  18477. * @param effect defines the update shader
  18478. */
  18479. applyToShader(effect: Effect): void;
  18480. /**
  18481. * Returns a string to use to update the GPU particles update shader
  18482. * @returns a string containng the defines string
  18483. */
  18484. getEffectDefines(): string;
  18485. /**
  18486. * Returns the string "PointParticleEmitter"
  18487. * @returns a string containing the class name
  18488. */
  18489. getClassName(): string;
  18490. /**
  18491. * Serializes the particle system to a JSON object.
  18492. * @returns the JSON object
  18493. */
  18494. serialize(): any;
  18495. /**
  18496. * Parse properties from a JSON object
  18497. * @param serializationObject defines the JSON object
  18498. */
  18499. parse(serializationObject: any): void;
  18500. }
  18501. }
  18502. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18503. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18504. import { Effect } from "babylonjs/Materials/effect";
  18505. import { Particle } from "babylonjs/Particles/particle";
  18506. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18507. /**
  18508. * Particle emitter emitting particles from the inside of a sphere.
  18509. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18510. */
  18511. export class SphereParticleEmitter implements IParticleEmitterType {
  18512. /**
  18513. * The radius of the emission sphere.
  18514. */
  18515. radius: number;
  18516. /**
  18517. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18518. */
  18519. radiusRange: number;
  18520. /**
  18521. * How much to randomize the particle direction [0-1].
  18522. */
  18523. directionRandomizer: number;
  18524. /**
  18525. * Creates a new instance SphereParticleEmitter
  18526. * @param radius the radius of the emission sphere (1 by default)
  18527. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18528. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18529. */
  18530. constructor(
  18531. /**
  18532. * The radius of the emission sphere.
  18533. */
  18534. radius?: number,
  18535. /**
  18536. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18537. */
  18538. radiusRange?: number,
  18539. /**
  18540. * How much to randomize the particle direction [0-1].
  18541. */
  18542. directionRandomizer?: number);
  18543. /**
  18544. * Called by the particle System when the direction is computed for the created particle.
  18545. * @param worldMatrix is the world matrix of the particle system
  18546. * @param directionToUpdate is the direction vector to update with the result
  18547. * @param particle is the particle we are computed the direction for
  18548. */
  18549. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18550. /**
  18551. * Called by the particle System when the position is computed for the created particle.
  18552. * @param worldMatrix is the world matrix of the particle system
  18553. * @param positionToUpdate is the position vector to update with the result
  18554. * @param particle is the particle we are computed the position for
  18555. */
  18556. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18557. /**
  18558. * Clones the current emitter and returns a copy of it
  18559. * @returns the new emitter
  18560. */
  18561. clone(): SphereParticleEmitter;
  18562. /**
  18563. * Called by the GPUParticleSystem to setup the update shader
  18564. * @param effect defines the update shader
  18565. */
  18566. applyToShader(effect: Effect): void;
  18567. /**
  18568. * Returns a string to use to update the GPU particles update shader
  18569. * @returns a string containng the defines string
  18570. */
  18571. getEffectDefines(): string;
  18572. /**
  18573. * Returns the string "SphereParticleEmitter"
  18574. * @returns a string containing the class name
  18575. */
  18576. getClassName(): string;
  18577. /**
  18578. * Serializes the particle system to a JSON object.
  18579. * @returns the JSON object
  18580. */
  18581. serialize(): any;
  18582. /**
  18583. * Parse properties from a JSON object
  18584. * @param serializationObject defines the JSON object
  18585. */
  18586. parse(serializationObject: any): void;
  18587. }
  18588. /**
  18589. * Particle emitter emitting particles from the inside of a sphere.
  18590. * It emits the particles randomly between two vectors.
  18591. */
  18592. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18593. /**
  18594. * The min limit of the emission direction.
  18595. */
  18596. direction1: Vector3;
  18597. /**
  18598. * The max limit of the emission direction.
  18599. */
  18600. direction2: Vector3;
  18601. /**
  18602. * Creates a new instance SphereDirectedParticleEmitter
  18603. * @param radius the radius of the emission sphere (1 by default)
  18604. * @param direction1 the min limit of the emission direction (up vector by default)
  18605. * @param direction2 the max limit of the emission direction (up vector by default)
  18606. */
  18607. constructor(radius?: number,
  18608. /**
  18609. * The min limit of the emission direction.
  18610. */
  18611. direction1?: Vector3,
  18612. /**
  18613. * The max limit of the emission direction.
  18614. */
  18615. direction2?: Vector3);
  18616. /**
  18617. * Called by the particle System when the direction is computed for the created particle.
  18618. * @param worldMatrix is the world matrix of the particle system
  18619. * @param directionToUpdate is the direction vector to update with the result
  18620. * @param particle is the particle we are computed the direction for
  18621. */
  18622. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18623. /**
  18624. * Clones the current emitter and returns a copy of it
  18625. * @returns the new emitter
  18626. */
  18627. clone(): SphereDirectedParticleEmitter;
  18628. /**
  18629. * Called by the GPUParticleSystem to setup the update shader
  18630. * @param effect defines the update shader
  18631. */
  18632. applyToShader(effect: Effect): void;
  18633. /**
  18634. * Returns a string to use to update the GPU particles update shader
  18635. * @returns a string containng the defines string
  18636. */
  18637. getEffectDefines(): string;
  18638. /**
  18639. * Returns the string "SphereDirectedParticleEmitter"
  18640. * @returns a string containing the class name
  18641. */
  18642. getClassName(): string;
  18643. /**
  18644. * Serializes the particle system to a JSON object.
  18645. * @returns the JSON object
  18646. */
  18647. serialize(): any;
  18648. /**
  18649. * Parse properties from a JSON object
  18650. * @param serializationObject defines the JSON object
  18651. */
  18652. parse(serializationObject: any): void;
  18653. }
  18654. }
  18655. declare module "babylonjs/Particles/EmitterTypes/index" {
  18656. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18657. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18658. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18659. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18660. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18661. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18662. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18663. }
  18664. declare module "babylonjs/Particles/IParticleSystem" {
  18665. import { Nullable } from "babylonjs/types";
  18666. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18667. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18668. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18669. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18670. import { Texture } from "babylonjs/Materials/Textures/texture";
  18671. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18672. import { Scene } from "babylonjs/scene";
  18673. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18674. import { Animation } from "babylonjs/Animations/animation";
  18675. /**
  18676. * Interface representing a particle system in Babylon.js.
  18677. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18678. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18679. */
  18680. export interface IParticleSystem {
  18681. /**
  18682. * List of animations used by the particle system.
  18683. */
  18684. animations: Animation[];
  18685. /**
  18686. * The id of the Particle system.
  18687. */
  18688. id: string;
  18689. /**
  18690. * The name of the Particle system.
  18691. */
  18692. name: string;
  18693. /**
  18694. * The emitter represents the Mesh or position we are attaching the particle system to.
  18695. */
  18696. emitter: Nullable<AbstractMesh | Vector3>;
  18697. /**
  18698. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18699. */
  18700. isBillboardBased: boolean;
  18701. /**
  18702. * The rendering group used by the Particle system to chose when to render.
  18703. */
  18704. renderingGroupId: number;
  18705. /**
  18706. * The layer mask we are rendering the particles through.
  18707. */
  18708. layerMask: number;
  18709. /**
  18710. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18711. */
  18712. updateSpeed: number;
  18713. /**
  18714. * The amount of time the particle system is running (depends of the overall update speed).
  18715. */
  18716. targetStopDuration: number;
  18717. /**
  18718. * The texture used to render each particle. (this can be a spritesheet)
  18719. */
  18720. particleTexture: Nullable<Texture>;
  18721. /**
  18722. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18723. */
  18724. blendMode: number;
  18725. /**
  18726. * Minimum life time of emitting particles.
  18727. */
  18728. minLifeTime: number;
  18729. /**
  18730. * Maximum life time of emitting particles.
  18731. */
  18732. maxLifeTime: number;
  18733. /**
  18734. * Minimum Size of emitting particles.
  18735. */
  18736. minSize: number;
  18737. /**
  18738. * Maximum Size of emitting particles.
  18739. */
  18740. maxSize: number;
  18741. /**
  18742. * Minimum scale of emitting particles on X axis.
  18743. */
  18744. minScaleX: number;
  18745. /**
  18746. * Maximum scale of emitting particles on X axis.
  18747. */
  18748. maxScaleX: number;
  18749. /**
  18750. * Minimum scale of emitting particles on Y axis.
  18751. */
  18752. minScaleY: number;
  18753. /**
  18754. * Maximum scale of emitting particles on Y axis.
  18755. */
  18756. maxScaleY: number;
  18757. /**
  18758. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18759. */
  18760. color1: Color4;
  18761. /**
  18762. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18763. */
  18764. color2: Color4;
  18765. /**
  18766. * Color the particle will have at the end of its lifetime.
  18767. */
  18768. colorDead: Color4;
  18769. /**
  18770. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18771. */
  18772. emitRate: number;
  18773. /**
  18774. * You can use gravity if you want to give an orientation to your particles.
  18775. */
  18776. gravity: Vector3;
  18777. /**
  18778. * Minimum power of emitting particles.
  18779. */
  18780. minEmitPower: number;
  18781. /**
  18782. * Maximum power of emitting particles.
  18783. */
  18784. maxEmitPower: number;
  18785. /**
  18786. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18787. */
  18788. minAngularSpeed: number;
  18789. /**
  18790. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18791. */
  18792. maxAngularSpeed: number;
  18793. /**
  18794. * Gets or sets the minimal initial rotation in radians.
  18795. */
  18796. minInitialRotation: number;
  18797. /**
  18798. * Gets or sets the maximal initial rotation in radians.
  18799. */
  18800. maxInitialRotation: number;
  18801. /**
  18802. * The particle emitter type defines the emitter used by the particle system.
  18803. * It can be for example box, sphere, or cone...
  18804. */
  18805. particleEmitterType: Nullable<IParticleEmitterType>;
  18806. /**
  18807. * Defines the delay in milliseconds before starting the system (0 by default)
  18808. */
  18809. startDelay: number;
  18810. /**
  18811. * 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
  18812. */
  18813. preWarmCycles: number;
  18814. /**
  18815. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18816. */
  18817. preWarmStepOffset: number;
  18818. /**
  18819. * 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)
  18820. */
  18821. spriteCellChangeSpeed: number;
  18822. /**
  18823. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18824. */
  18825. startSpriteCellID: number;
  18826. /**
  18827. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18828. */
  18829. endSpriteCellID: number;
  18830. /**
  18831. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18832. */
  18833. spriteCellWidth: number;
  18834. /**
  18835. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18836. */
  18837. spriteCellHeight: number;
  18838. /**
  18839. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18840. */
  18841. spriteRandomStartCell: boolean;
  18842. /**
  18843. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18844. */
  18845. isAnimationSheetEnabled: boolean;
  18846. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18847. translationPivot: Vector2;
  18848. /**
  18849. * Gets or sets a texture used to add random noise to particle positions
  18850. */
  18851. noiseTexture: Nullable<BaseTexture>;
  18852. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  18853. noiseStrength: Vector3;
  18854. /**
  18855. * Gets or sets the billboard mode to use when isBillboardBased = true.
  18856. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  18857. */
  18858. billboardMode: number;
  18859. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  18860. limitVelocityDamping: number;
  18861. /**
  18862. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  18863. */
  18864. beginAnimationOnStart: boolean;
  18865. /**
  18866. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  18867. */
  18868. beginAnimationFrom: number;
  18869. /**
  18870. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  18871. */
  18872. beginAnimationTo: number;
  18873. /**
  18874. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  18875. */
  18876. beginAnimationLoop: boolean;
  18877. /**
  18878. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  18879. */
  18880. disposeOnStop: boolean;
  18881. /**
  18882. * Gets the maximum number of particles active at the same time.
  18883. * @returns The max number of active particles.
  18884. */
  18885. getCapacity(): number;
  18886. /**
  18887. * Gets if the system has been started. (Note: this will still be true after stop is called)
  18888. * @returns True if it has been started, otherwise false.
  18889. */
  18890. isStarted(): boolean;
  18891. /**
  18892. * Animates the particle system for this frame.
  18893. */
  18894. animate(): void;
  18895. /**
  18896. * Renders the particle system in its current state.
  18897. * @returns the current number of particles
  18898. */
  18899. render(): number;
  18900. /**
  18901. * Dispose the particle system and frees its associated resources.
  18902. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  18903. */
  18904. dispose(disposeTexture?: boolean): void;
  18905. /**
  18906. * Clones the particle system.
  18907. * @param name The name of the cloned object
  18908. * @param newEmitter The new emitter to use
  18909. * @returns the cloned particle system
  18910. */
  18911. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  18912. /**
  18913. * Serializes the particle system to a JSON object.
  18914. * @returns the JSON object
  18915. */
  18916. serialize(): any;
  18917. /**
  18918. * Rebuild the particle system
  18919. */
  18920. rebuild(): void;
  18921. /**
  18922. * Starts the particle system and begins to emit
  18923. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  18924. */
  18925. start(delay?: number): void;
  18926. /**
  18927. * Stops the particle system.
  18928. */
  18929. stop(): void;
  18930. /**
  18931. * Remove all active particles
  18932. */
  18933. reset(): void;
  18934. /**
  18935. * Is this system ready to be used/rendered
  18936. * @return true if the system is ready
  18937. */
  18938. isReady(): boolean;
  18939. /**
  18940. * Adds a new color gradient
  18941. * @param gradient defines the gradient to use (between 0 and 1)
  18942. * @param color1 defines the color to affect to the specified gradient
  18943. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  18944. * @returns the current particle system
  18945. */
  18946. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  18947. /**
  18948. * Remove a specific color gradient
  18949. * @param gradient defines the gradient to remove
  18950. * @returns the current particle system
  18951. */
  18952. removeColorGradient(gradient: number): IParticleSystem;
  18953. /**
  18954. * Adds a new size gradient
  18955. * @param gradient defines the gradient to use (between 0 and 1)
  18956. * @param factor defines the size factor to affect to the specified gradient
  18957. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18958. * @returns the current particle system
  18959. */
  18960. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18961. /**
  18962. * Remove a specific size gradient
  18963. * @param gradient defines the gradient to remove
  18964. * @returns the current particle system
  18965. */
  18966. removeSizeGradient(gradient: number): IParticleSystem;
  18967. /**
  18968. * Gets the current list of color gradients.
  18969. * You must use addColorGradient and removeColorGradient to udpate this list
  18970. * @returns the list of color gradients
  18971. */
  18972. getColorGradients(): Nullable<Array<ColorGradient>>;
  18973. /**
  18974. * Gets the current list of size gradients.
  18975. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18976. * @returns the list of size gradients
  18977. */
  18978. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18979. /**
  18980. * Gets the current list of angular speed gradients.
  18981. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18982. * @returns the list of angular speed gradients
  18983. */
  18984. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18985. /**
  18986. * Adds a new angular speed gradient
  18987. * @param gradient defines the gradient to use (between 0 and 1)
  18988. * @param factor defines the angular speed to affect to the specified gradient
  18989. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18990. * @returns the current particle system
  18991. */
  18992. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18993. /**
  18994. * Remove a specific angular speed gradient
  18995. * @param gradient defines the gradient to remove
  18996. * @returns the current particle system
  18997. */
  18998. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18999. /**
  19000. * Gets the current list of velocity gradients.
  19001. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19002. * @returns the list of velocity gradients
  19003. */
  19004. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19005. /**
  19006. * Adds a new velocity gradient
  19007. * @param gradient defines the gradient to use (between 0 and 1)
  19008. * @param factor defines the velocity to affect to the specified gradient
  19009. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19010. * @returns the current particle system
  19011. */
  19012. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19013. /**
  19014. * Remove a specific velocity gradient
  19015. * @param gradient defines the gradient to remove
  19016. * @returns the current particle system
  19017. */
  19018. removeVelocityGradient(gradient: number): IParticleSystem;
  19019. /**
  19020. * Gets the current list of limit velocity gradients.
  19021. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19022. * @returns the list of limit velocity gradients
  19023. */
  19024. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19025. /**
  19026. * Adds a new limit velocity gradient
  19027. * @param gradient defines the gradient to use (between 0 and 1)
  19028. * @param factor defines the limit velocity to affect to the specified gradient
  19029. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19030. * @returns the current particle system
  19031. */
  19032. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19033. /**
  19034. * Remove a specific limit velocity gradient
  19035. * @param gradient defines the gradient to remove
  19036. * @returns the current particle system
  19037. */
  19038. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19039. /**
  19040. * Adds a new drag gradient
  19041. * @param gradient defines the gradient to use (between 0 and 1)
  19042. * @param factor defines the drag to affect to the specified gradient
  19043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19044. * @returns the current particle system
  19045. */
  19046. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19047. /**
  19048. * Remove a specific drag gradient
  19049. * @param gradient defines the gradient to remove
  19050. * @returns the current particle system
  19051. */
  19052. removeDragGradient(gradient: number): IParticleSystem;
  19053. /**
  19054. * Gets the current list of drag gradients.
  19055. * You must use addDragGradient and removeDragGradient to udpate this list
  19056. * @returns the list of drag gradients
  19057. */
  19058. getDragGradients(): Nullable<Array<FactorGradient>>;
  19059. /**
  19060. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19061. * @param gradient defines the gradient to use (between 0 and 1)
  19062. * @param factor defines the emit rate to affect to the specified gradient
  19063. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19064. * @returns the current particle system
  19065. */
  19066. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19067. /**
  19068. * Remove a specific emit rate gradient
  19069. * @param gradient defines the gradient to remove
  19070. * @returns the current particle system
  19071. */
  19072. removeEmitRateGradient(gradient: number): IParticleSystem;
  19073. /**
  19074. * Gets the current list of emit rate gradients.
  19075. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19076. * @returns the list of emit rate gradients
  19077. */
  19078. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19079. /**
  19080. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19081. * @param gradient defines the gradient to use (between 0 and 1)
  19082. * @param factor defines the start size to affect to the specified gradient
  19083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19084. * @returns the current particle system
  19085. */
  19086. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19087. /**
  19088. * Remove a specific start size gradient
  19089. * @param gradient defines the gradient to remove
  19090. * @returns the current particle system
  19091. */
  19092. removeStartSizeGradient(gradient: number): IParticleSystem;
  19093. /**
  19094. * Gets the current list of start size gradients.
  19095. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19096. * @returns the list of start size gradients
  19097. */
  19098. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19099. /**
  19100. * Adds a new life time gradient
  19101. * @param gradient defines the gradient to use (between 0 and 1)
  19102. * @param factor defines the life time factor to affect to the specified gradient
  19103. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19104. * @returns the current particle system
  19105. */
  19106. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19107. /**
  19108. * Remove a specific life time gradient
  19109. * @param gradient defines the gradient to remove
  19110. * @returns the current particle system
  19111. */
  19112. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19113. /**
  19114. * Gets the current list of life time gradients.
  19115. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19116. * @returns the list of life time gradients
  19117. */
  19118. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19119. /**
  19120. * Gets the current list of color gradients.
  19121. * You must use addColorGradient and removeColorGradient to udpate this list
  19122. * @returns the list of color gradients
  19123. */
  19124. getColorGradients(): Nullable<Array<ColorGradient>>;
  19125. /**
  19126. * Adds a new ramp gradient used to remap particle colors
  19127. * @param gradient defines the gradient to use (between 0 and 1)
  19128. * @param color defines the color to affect to the specified gradient
  19129. * @returns the current particle system
  19130. */
  19131. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19132. /**
  19133. * Gets the current list of ramp gradients.
  19134. * You must use addRampGradient and removeRampGradient to udpate this list
  19135. * @returns the list of ramp gradients
  19136. */
  19137. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19138. /** Gets or sets a boolean indicating that ramp gradients must be used
  19139. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19140. */
  19141. useRampGradients: boolean;
  19142. /**
  19143. * Adds a new color remap gradient
  19144. * @param gradient defines the gradient to use (between 0 and 1)
  19145. * @param min defines the color remap minimal range
  19146. * @param max defines the color remap maximal range
  19147. * @returns the current particle system
  19148. */
  19149. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19150. /**
  19151. * Gets the current list of color remap gradients.
  19152. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19153. * @returns the list of color remap gradients
  19154. */
  19155. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19156. /**
  19157. * Adds a new alpha remap gradient
  19158. * @param gradient defines the gradient to use (between 0 and 1)
  19159. * @param min defines the alpha remap minimal range
  19160. * @param max defines the alpha remap maximal range
  19161. * @returns the current particle system
  19162. */
  19163. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19164. /**
  19165. * Gets the current list of alpha remap gradients.
  19166. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19167. * @returns the list of alpha remap gradients
  19168. */
  19169. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19170. /**
  19171. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19172. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19173. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19174. * @returns the emitter
  19175. */
  19176. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19177. /**
  19178. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19179. * @param radius The radius of the hemisphere to emit from
  19180. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19181. * @returns the emitter
  19182. */
  19183. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19184. /**
  19185. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19186. * @param radius The radius of the sphere to emit from
  19187. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19188. * @returns the emitter
  19189. */
  19190. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19191. /**
  19192. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19193. * @param radius The radius of the sphere to emit from
  19194. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19195. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19196. * @returns the emitter
  19197. */
  19198. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19199. /**
  19200. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19201. * @param radius The radius of the emission cylinder
  19202. * @param height The height of the emission cylinder
  19203. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19204. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19205. * @returns the emitter
  19206. */
  19207. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19208. /**
  19209. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19210. * @param radius The radius of the cylinder to emit from
  19211. * @param height The height of the emission cylinder
  19212. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19213. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19214. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19215. * @returns the emitter
  19216. */
  19217. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19218. /**
  19219. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19220. * @param radius The radius of the cone to emit from
  19221. * @param angle The base angle of the cone
  19222. * @returns the emitter
  19223. */
  19224. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19225. /**
  19226. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19227. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19228. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19229. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19230. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19231. * @returns the emitter
  19232. */
  19233. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19234. /**
  19235. * Get hosting scene
  19236. * @returns the scene
  19237. */
  19238. getScene(): Scene;
  19239. }
  19240. }
  19241. declare module "babylonjs/Meshes/instancedMesh" {
  19242. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19243. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19244. import { Camera } from "babylonjs/Cameras/camera";
  19245. import { Node } from "babylonjs/node";
  19246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19247. import { Mesh } from "babylonjs/Meshes/mesh";
  19248. import { Material } from "babylonjs/Materials/material";
  19249. import { Skeleton } from "babylonjs/Bones/skeleton";
  19250. import { Light } from "babylonjs/Lights/light";
  19251. /**
  19252. * Creates an instance based on a source mesh.
  19253. */
  19254. export class InstancedMesh extends AbstractMesh {
  19255. private _sourceMesh;
  19256. private _currentLOD;
  19257. /** @hidden */
  19258. _indexInSourceMeshInstanceArray: number;
  19259. constructor(name: string, source: Mesh);
  19260. /**
  19261. * Returns the string "InstancedMesh".
  19262. */
  19263. getClassName(): string;
  19264. /** Gets the list of lights affecting that mesh */
  19265. readonly lightSources: Light[];
  19266. _resyncLightSources(): void;
  19267. _resyncLighSource(light: Light): void;
  19268. _removeLightSource(light: Light, dispose: boolean): void;
  19269. /**
  19270. * If the source mesh receives shadows
  19271. */
  19272. readonly receiveShadows: boolean;
  19273. /**
  19274. * The material of the source mesh
  19275. */
  19276. readonly material: Nullable<Material>;
  19277. /**
  19278. * Visibility of the source mesh
  19279. */
  19280. readonly visibility: number;
  19281. /**
  19282. * Skeleton of the source mesh
  19283. */
  19284. readonly skeleton: Nullable<Skeleton>;
  19285. /**
  19286. * Rendering ground id of the source mesh
  19287. */
  19288. renderingGroupId: number;
  19289. /**
  19290. * Returns the total number of vertices (integer).
  19291. */
  19292. getTotalVertices(): number;
  19293. /**
  19294. * Returns a positive integer : the total number of indices in this mesh geometry.
  19295. * @returns the numner of indices or zero if the mesh has no geometry.
  19296. */
  19297. getTotalIndices(): number;
  19298. /**
  19299. * The source mesh of the instance
  19300. */
  19301. readonly sourceMesh: Mesh;
  19302. /**
  19303. * Is this node ready to be used/rendered
  19304. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19305. * @return {boolean} is it ready
  19306. */
  19307. isReady(completeCheck?: boolean): boolean;
  19308. /**
  19309. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19310. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19311. * @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.
  19312. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19313. */
  19314. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19315. /**
  19316. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19317. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19318. * The `data` are either a numeric array either a Float32Array.
  19319. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19320. * 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).
  19321. * Note that a new underlying VertexBuffer object is created each call.
  19322. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19323. *
  19324. * Possible `kind` values :
  19325. * - VertexBuffer.PositionKind
  19326. * - VertexBuffer.UVKind
  19327. * - VertexBuffer.UV2Kind
  19328. * - VertexBuffer.UV3Kind
  19329. * - VertexBuffer.UV4Kind
  19330. * - VertexBuffer.UV5Kind
  19331. * - VertexBuffer.UV6Kind
  19332. * - VertexBuffer.ColorKind
  19333. * - VertexBuffer.MatricesIndicesKind
  19334. * - VertexBuffer.MatricesIndicesExtraKind
  19335. * - VertexBuffer.MatricesWeightsKind
  19336. * - VertexBuffer.MatricesWeightsExtraKind
  19337. *
  19338. * Returns the Mesh.
  19339. */
  19340. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19341. /**
  19342. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19343. * If the mesh has no geometry, it is simply returned as it is.
  19344. * The `data` are either a numeric array either a Float32Array.
  19345. * No new underlying VertexBuffer object is created.
  19346. * 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.
  19347. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19348. *
  19349. * Possible `kind` values :
  19350. * - VertexBuffer.PositionKind
  19351. * - VertexBuffer.UVKind
  19352. * - VertexBuffer.UV2Kind
  19353. * - VertexBuffer.UV3Kind
  19354. * - VertexBuffer.UV4Kind
  19355. * - VertexBuffer.UV5Kind
  19356. * - VertexBuffer.UV6Kind
  19357. * - VertexBuffer.ColorKind
  19358. * - VertexBuffer.MatricesIndicesKind
  19359. * - VertexBuffer.MatricesIndicesExtraKind
  19360. * - VertexBuffer.MatricesWeightsKind
  19361. * - VertexBuffer.MatricesWeightsExtraKind
  19362. *
  19363. * Returns the Mesh.
  19364. */
  19365. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19366. /**
  19367. * Sets the mesh indices.
  19368. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19369. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19370. * This method creates a new index buffer each call.
  19371. * Returns the Mesh.
  19372. */
  19373. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19374. /**
  19375. * Boolean : True if the mesh owns the requested kind of data.
  19376. */
  19377. isVerticesDataPresent(kind: string): boolean;
  19378. /**
  19379. * Returns an array of indices (IndicesArray).
  19380. */
  19381. getIndices(): Nullable<IndicesArray>;
  19382. readonly _positions: Nullable<Vector3[]>;
  19383. /**
  19384. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19385. * This means the mesh underlying bounding box and sphere are recomputed.
  19386. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19387. * @returns the current mesh
  19388. */
  19389. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19390. /** @hidden */
  19391. _preActivate(): InstancedMesh;
  19392. /** @hidden */
  19393. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19394. /** @hidden */
  19395. _postActivate(): void;
  19396. getWorldMatrix(): Matrix;
  19397. readonly isAnInstance: boolean;
  19398. /**
  19399. * Returns the current associated LOD AbstractMesh.
  19400. */
  19401. getLOD(camera: Camera): AbstractMesh;
  19402. /** @hidden */
  19403. _syncSubMeshes(): InstancedMesh;
  19404. /** @hidden */
  19405. _generatePointsArray(): boolean;
  19406. /**
  19407. * Creates a new InstancedMesh from the current mesh.
  19408. * - name (string) : the cloned mesh name
  19409. * - newParent (optional Node) : the optional Node to parent the clone to.
  19410. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19411. *
  19412. * Returns the clone.
  19413. */
  19414. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19415. /**
  19416. * Disposes the InstancedMesh.
  19417. * Returns nothing.
  19418. */
  19419. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19420. }
  19421. }
  19422. declare module "babylonjs/Materials/shaderMaterial" {
  19423. import { Scene } from "babylonjs/scene";
  19424. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19425. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19426. import { Mesh } from "babylonjs/Meshes/mesh";
  19427. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19429. import { Texture } from "babylonjs/Materials/Textures/texture";
  19430. import { Material } from "babylonjs/Materials/material";
  19431. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19432. /**
  19433. * Defines the options associated with the creation of a shader material.
  19434. */
  19435. export interface IShaderMaterialOptions {
  19436. /**
  19437. * Does the material work in alpha blend mode
  19438. */
  19439. needAlphaBlending: boolean;
  19440. /**
  19441. * Does the material work in alpha test mode
  19442. */
  19443. needAlphaTesting: boolean;
  19444. /**
  19445. * The list of attribute names used in the shader
  19446. */
  19447. attributes: string[];
  19448. /**
  19449. * The list of unifrom names used in the shader
  19450. */
  19451. uniforms: string[];
  19452. /**
  19453. * The list of UBO names used in the shader
  19454. */
  19455. uniformBuffers: string[];
  19456. /**
  19457. * The list of sampler names used in the shader
  19458. */
  19459. samplers: string[];
  19460. /**
  19461. * The list of defines used in the shader
  19462. */
  19463. defines: string[];
  19464. }
  19465. /**
  19466. * 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.
  19467. *
  19468. * This returned material effects how the mesh will look based on the code in the shaders.
  19469. *
  19470. * @see http://doc.babylonjs.com/how_to/shader_material
  19471. */
  19472. export class ShaderMaterial extends Material {
  19473. private _shaderPath;
  19474. private _options;
  19475. private _textures;
  19476. private _textureArrays;
  19477. private _floats;
  19478. private _ints;
  19479. private _floatsArrays;
  19480. private _colors3;
  19481. private _colors3Arrays;
  19482. private _colors4;
  19483. private _colors4Arrays;
  19484. private _vectors2;
  19485. private _vectors3;
  19486. private _vectors4;
  19487. private _matrices;
  19488. private _matrices3x3;
  19489. private _matrices2x2;
  19490. private _vectors2Arrays;
  19491. private _vectors3Arrays;
  19492. private _vectors4Arrays;
  19493. private _cachedWorldViewMatrix;
  19494. private _cachedWorldViewProjectionMatrix;
  19495. private _renderId;
  19496. /**
  19497. * Instantiate a new shader material.
  19498. * 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.
  19499. * This returned material effects how the mesh will look based on the code in the shaders.
  19500. * @see http://doc.babylonjs.com/how_to/shader_material
  19501. * @param name Define the name of the material in the scene
  19502. * @param scene Define the scene the material belongs to
  19503. * @param shaderPath Defines the route to the shader code in one of three ways:
  19504. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19505. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19506. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19507. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19508. * @param options Define the options used to create the shader
  19509. */
  19510. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19511. /**
  19512. * Gets the options used to compile the shader.
  19513. * They can be modified to trigger a new compilation
  19514. */
  19515. readonly options: IShaderMaterialOptions;
  19516. /**
  19517. * Gets the current class name of the material e.g. "ShaderMaterial"
  19518. * Mainly use in serialization.
  19519. * @returns the class name
  19520. */
  19521. getClassName(): string;
  19522. /**
  19523. * Specifies if the material will require alpha blending
  19524. * @returns a boolean specifying if alpha blending is needed
  19525. */
  19526. needAlphaBlending(): boolean;
  19527. /**
  19528. * Specifies if this material should be rendered in alpha test mode
  19529. * @returns a boolean specifying if an alpha test is needed.
  19530. */
  19531. needAlphaTesting(): boolean;
  19532. private _checkUniform;
  19533. /**
  19534. * Set a texture in the shader.
  19535. * @param name Define the name of the uniform samplers as defined in the shader
  19536. * @param texture Define the texture to bind to this sampler
  19537. * @return the material itself allowing "fluent" like uniform updates
  19538. */
  19539. setTexture(name: string, texture: Texture): ShaderMaterial;
  19540. /**
  19541. * Set a texture array in the shader.
  19542. * @param name Define the name of the uniform sampler array as defined in the shader
  19543. * @param textures Define the list of textures to bind to this sampler
  19544. * @return the material itself allowing "fluent" like uniform updates
  19545. */
  19546. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19547. /**
  19548. * Set a float in the shader.
  19549. * @param name Define the name of the uniform as defined in the shader
  19550. * @param value Define the value to give to the uniform
  19551. * @return the material itself allowing "fluent" like uniform updates
  19552. */
  19553. setFloat(name: string, value: number): ShaderMaterial;
  19554. /**
  19555. * Set a int in the shader.
  19556. * @param name Define the name of the uniform as defined in the shader
  19557. * @param value Define the value to give to the uniform
  19558. * @return the material itself allowing "fluent" like uniform updates
  19559. */
  19560. setInt(name: string, value: number): ShaderMaterial;
  19561. /**
  19562. * Set an array of floats in the shader.
  19563. * @param name Define the name of the uniform as defined in the shader
  19564. * @param value Define the value to give to the uniform
  19565. * @return the material itself allowing "fluent" like uniform updates
  19566. */
  19567. setFloats(name: string, value: number[]): ShaderMaterial;
  19568. /**
  19569. * Set a vec3 in the shader from a Color3.
  19570. * @param name Define the name of the uniform as defined in the shader
  19571. * @param value Define the value to give to the uniform
  19572. * @return the material itself allowing "fluent" like uniform updates
  19573. */
  19574. setColor3(name: string, value: Color3): ShaderMaterial;
  19575. /**
  19576. * Set a vec3 array in the shader from a Color3 array.
  19577. * @param name Define the name of the uniform as defined in the shader
  19578. * @param value Define the value to give to the uniform
  19579. * @return the material itself allowing "fluent" like uniform updates
  19580. */
  19581. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19582. /**
  19583. * Set a vec4 in the shader from a Color4.
  19584. * @param name Define the name of the uniform as defined in the shader
  19585. * @param value Define the value to give to the uniform
  19586. * @return the material itself allowing "fluent" like uniform updates
  19587. */
  19588. setColor4(name: string, value: Color4): ShaderMaterial;
  19589. /**
  19590. * Set a vec4 array in the shader from a Color4 array.
  19591. * @param name Define the name of the uniform as defined in the shader
  19592. * @param value Define the value to give to the uniform
  19593. * @return the material itself allowing "fluent" like uniform updates
  19594. */
  19595. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19596. /**
  19597. * Set a vec2 in the shader from a Vector2.
  19598. * @param name Define the name of the uniform as defined in the shader
  19599. * @param value Define the value to give to the uniform
  19600. * @return the material itself allowing "fluent" like uniform updates
  19601. */
  19602. setVector2(name: string, value: Vector2): ShaderMaterial;
  19603. /**
  19604. * Set a vec3 in the shader from a Vector3.
  19605. * @param name Define the name of the uniform as defined in the shader
  19606. * @param value Define the value to give to the uniform
  19607. * @return the material itself allowing "fluent" like uniform updates
  19608. */
  19609. setVector3(name: string, value: Vector3): ShaderMaterial;
  19610. /**
  19611. * Set a vec4 in the shader from a Vector4.
  19612. * @param name Define the name of the uniform as defined in the shader
  19613. * @param value Define the value to give to the uniform
  19614. * @return the material itself allowing "fluent" like uniform updates
  19615. */
  19616. setVector4(name: string, value: Vector4): ShaderMaterial;
  19617. /**
  19618. * Set a mat4 in the shader from a Matrix.
  19619. * @param name Define the name of the uniform as defined in the shader
  19620. * @param value Define the value to give to the uniform
  19621. * @return the material itself allowing "fluent" like uniform updates
  19622. */
  19623. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19624. /**
  19625. * Set a mat3 in the shader from a Float32Array.
  19626. * @param name Define the name of the uniform as defined in the shader
  19627. * @param value Define the value to give to the uniform
  19628. * @return the material itself allowing "fluent" like uniform updates
  19629. */
  19630. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19631. /**
  19632. * Set a mat2 in the shader from a Float32Array.
  19633. * @param name Define the name of the uniform as defined in the shader
  19634. * @param value Define the value to give to the uniform
  19635. * @return the material itself allowing "fluent" like uniform updates
  19636. */
  19637. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19638. /**
  19639. * Set a vec2 array in the shader from a number array.
  19640. * @param name Define the name of the uniform as defined in the shader
  19641. * @param value Define the value to give to the uniform
  19642. * @return the material itself allowing "fluent" like uniform updates
  19643. */
  19644. setArray2(name: string, value: number[]): ShaderMaterial;
  19645. /**
  19646. * Set a vec3 array in the shader from a number array.
  19647. * @param name Define the name of the uniform as defined in the shader
  19648. * @param value Define the value to give to the uniform
  19649. * @return the material itself allowing "fluent" like uniform updates
  19650. */
  19651. setArray3(name: string, value: number[]): ShaderMaterial;
  19652. /**
  19653. * Set a vec4 array in the shader from a number array.
  19654. * @param name Define the name of the uniform as defined in the shader
  19655. * @param value Define the value to give to the uniform
  19656. * @return the material itself allowing "fluent" like uniform updates
  19657. */
  19658. setArray4(name: string, value: number[]): ShaderMaterial;
  19659. private _checkCache;
  19660. /**
  19661. * Specifies that the submesh is ready to be used
  19662. * @param mesh defines the mesh to check
  19663. * @param subMesh defines which submesh to check
  19664. * @param useInstances specifies that instances should be used
  19665. * @returns a boolean indicating that the submesh is ready or not
  19666. */
  19667. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19668. /**
  19669. * Checks if the material is ready to render the requested mesh
  19670. * @param mesh Define the mesh to render
  19671. * @param useInstances Define whether or not the material is used with instances
  19672. * @returns true if ready, otherwise false
  19673. */
  19674. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19675. /**
  19676. * Binds the world matrix to the material
  19677. * @param world defines the world transformation matrix
  19678. */
  19679. bindOnlyWorldMatrix(world: Matrix): void;
  19680. /**
  19681. * Binds the material to the mesh
  19682. * @param world defines the world transformation matrix
  19683. * @param mesh defines the mesh to bind the material to
  19684. */
  19685. bind(world: Matrix, mesh?: Mesh): void;
  19686. /**
  19687. * Gets the active textures from the material
  19688. * @returns an array of textures
  19689. */
  19690. getActiveTextures(): BaseTexture[];
  19691. /**
  19692. * Specifies if the material uses a texture
  19693. * @param texture defines the texture to check against the material
  19694. * @returns a boolean specifying if the material uses the texture
  19695. */
  19696. hasTexture(texture: BaseTexture): boolean;
  19697. /**
  19698. * Makes a duplicate of the material, and gives it a new name
  19699. * @param name defines the new name for the duplicated material
  19700. * @returns the cloned material
  19701. */
  19702. clone(name: string): ShaderMaterial;
  19703. /**
  19704. * Disposes the material
  19705. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19706. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19707. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19708. */
  19709. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19710. /**
  19711. * Serializes this material in a JSON representation
  19712. * @returns the serialized material object
  19713. */
  19714. serialize(): any;
  19715. /**
  19716. * Creates a shader material from parsed shader material data
  19717. * @param source defines the JSON represnetation of the material
  19718. * @param scene defines the hosting scene
  19719. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19720. * @returns a new material
  19721. */
  19722. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19723. }
  19724. }
  19725. declare module "babylonjs/Shaders/color.fragment" {
  19726. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19727. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19728. /** @hidden */
  19729. export var colorPixelShader: {
  19730. name: string;
  19731. shader: string;
  19732. };
  19733. }
  19734. declare module "babylonjs/Shaders/color.vertex" {
  19735. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19736. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19737. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19738. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19739. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19740. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19741. /** @hidden */
  19742. export var colorVertexShader: {
  19743. name: string;
  19744. shader: string;
  19745. };
  19746. }
  19747. declare module "babylonjs/Meshes/linesMesh" {
  19748. import { Nullable } from "babylonjs/types";
  19749. import { Scene } from "babylonjs/scene";
  19750. import { Color3 } from "babylonjs/Maths/math.color";
  19751. import { Node } from "babylonjs/node";
  19752. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19753. import { Mesh } from "babylonjs/Meshes/mesh";
  19754. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19755. import { Effect } from "babylonjs/Materials/effect";
  19756. import { Material } from "babylonjs/Materials/material";
  19757. import "babylonjs/Shaders/color.fragment";
  19758. import "babylonjs/Shaders/color.vertex";
  19759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19760. /**
  19761. * Line mesh
  19762. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19763. */
  19764. export class LinesMesh extends Mesh {
  19765. /**
  19766. * If vertex color should be applied to the mesh
  19767. */
  19768. readonly useVertexColor?: boolean | undefined;
  19769. /**
  19770. * If vertex alpha should be applied to the mesh
  19771. */
  19772. readonly useVertexAlpha?: boolean | undefined;
  19773. /**
  19774. * Color of the line (Default: White)
  19775. */
  19776. color: Color3;
  19777. /**
  19778. * Alpha of the line (Default: 1)
  19779. */
  19780. alpha: number;
  19781. /**
  19782. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19783. * This margin is expressed in world space coordinates, so its value may vary.
  19784. * Default value is 0.1
  19785. */
  19786. intersectionThreshold: number;
  19787. private _colorShader;
  19788. private color4;
  19789. /**
  19790. * Creates a new LinesMesh
  19791. * @param name defines the name
  19792. * @param scene defines the hosting scene
  19793. * @param parent defines the parent mesh if any
  19794. * @param source defines the optional source LinesMesh used to clone data from
  19795. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19796. * When false, achieved by calling a clone(), also passing False.
  19797. * This will make creation of children, recursive.
  19798. * @param useVertexColor defines if this LinesMesh supports vertex color
  19799. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19800. */
  19801. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19802. /**
  19803. * If vertex color should be applied to the mesh
  19804. */
  19805. useVertexColor?: boolean | undefined,
  19806. /**
  19807. * If vertex alpha should be applied to the mesh
  19808. */
  19809. useVertexAlpha?: boolean | undefined);
  19810. private _addClipPlaneDefine;
  19811. private _removeClipPlaneDefine;
  19812. isReady(): boolean;
  19813. /**
  19814. * Returns the string "LineMesh"
  19815. */
  19816. getClassName(): string;
  19817. /**
  19818. * @hidden
  19819. */
  19820. /**
  19821. * @hidden
  19822. */
  19823. material: Material;
  19824. /**
  19825. * @hidden
  19826. */
  19827. readonly checkCollisions: boolean;
  19828. /** @hidden */
  19829. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19830. /** @hidden */
  19831. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19832. /**
  19833. * Disposes of the line mesh
  19834. * @param doNotRecurse If children should be disposed
  19835. */
  19836. dispose(doNotRecurse?: boolean): void;
  19837. /**
  19838. * Returns a new LineMesh object cloned from the current one.
  19839. */
  19840. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19841. /**
  19842. * Creates a new InstancedLinesMesh object from the mesh model.
  19843. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19844. * @param name defines the name of the new instance
  19845. * @returns a new InstancedLinesMesh
  19846. */
  19847. createInstance(name: string): InstancedLinesMesh;
  19848. }
  19849. /**
  19850. * Creates an instance based on a source LinesMesh
  19851. */
  19852. export class InstancedLinesMesh extends InstancedMesh {
  19853. /**
  19854. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19855. * This margin is expressed in world space coordinates, so its value may vary.
  19856. * Initilized with the intersectionThreshold value of the source LinesMesh
  19857. */
  19858. intersectionThreshold: number;
  19859. constructor(name: string, source: LinesMesh);
  19860. /**
  19861. * Returns the string "InstancedLinesMesh".
  19862. */
  19863. getClassName(): string;
  19864. }
  19865. }
  19866. declare module "babylonjs/Shaders/line.fragment" {
  19867. /** @hidden */
  19868. export var linePixelShader: {
  19869. name: string;
  19870. shader: string;
  19871. };
  19872. }
  19873. declare module "babylonjs/Shaders/line.vertex" {
  19874. /** @hidden */
  19875. export var lineVertexShader: {
  19876. name: string;
  19877. shader: string;
  19878. };
  19879. }
  19880. declare module "babylonjs/Rendering/edgesRenderer" {
  19881. import { Nullable } from "babylonjs/types";
  19882. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  19883. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19884. import { Vector3 } from "babylonjs/Maths/math.vector";
  19885. import { IDisposable } from "babylonjs/scene";
  19886. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  19887. import "babylonjs/Shaders/line.fragment";
  19888. import "babylonjs/Shaders/line.vertex";
  19889. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  19890. module "babylonjs/Meshes/abstractMesh" {
  19891. interface AbstractMesh {
  19892. /**
  19893. * Gets the edgesRenderer associated with the mesh
  19894. */
  19895. edgesRenderer: Nullable<EdgesRenderer>;
  19896. }
  19897. }
  19898. module "babylonjs/Meshes/linesMesh" {
  19899. interface LinesMesh {
  19900. /**
  19901. * Enables the edge rendering mode on the mesh.
  19902. * This mode makes the mesh edges visible
  19903. * @param epsilon defines the maximal distance between two angles to detect a face
  19904. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19905. * @returns the currentAbstractMesh
  19906. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19907. */
  19908. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  19909. }
  19910. }
  19911. module "babylonjs/Meshes/linesMesh" {
  19912. interface InstancedLinesMesh {
  19913. /**
  19914. * Enables the edge rendering mode on the mesh.
  19915. * This mode makes the mesh edges visible
  19916. * @param epsilon defines the maximal distance between two angles to detect a face
  19917. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  19918. * @returns the current InstancedLinesMesh
  19919. * @see https://www.babylonjs-playground.com/#19O9TU#0
  19920. */
  19921. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  19922. }
  19923. }
  19924. /**
  19925. * Defines the minimum contract an Edges renderer should follow.
  19926. */
  19927. export interface IEdgesRenderer extends IDisposable {
  19928. /**
  19929. * Gets or sets a boolean indicating if the edgesRenderer is active
  19930. */
  19931. isEnabled: boolean;
  19932. /**
  19933. * Renders the edges of the attached mesh,
  19934. */
  19935. render(): void;
  19936. /**
  19937. * Checks wether or not the edges renderer is ready to render.
  19938. * @return true if ready, otherwise false.
  19939. */
  19940. isReady(): boolean;
  19941. }
  19942. /**
  19943. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  19944. */
  19945. export class EdgesRenderer implements IEdgesRenderer {
  19946. /**
  19947. * Define the size of the edges with an orthographic camera
  19948. */
  19949. edgesWidthScalerForOrthographic: number;
  19950. /**
  19951. * Define the size of the edges with a perspective camera
  19952. */
  19953. edgesWidthScalerForPerspective: number;
  19954. protected _source: AbstractMesh;
  19955. protected _linesPositions: number[];
  19956. protected _linesNormals: number[];
  19957. protected _linesIndices: number[];
  19958. protected _epsilon: number;
  19959. protected _indicesCount: number;
  19960. protected _lineShader: ShaderMaterial;
  19961. protected _ib: DataBuffer;
  19962. protected _buffers: {
  19963. [key: string]: Nullable<VertexBuffer>;
  19964. };
  19965. protected _checkVerticesInsteadOfIndices: boolean;
  19966. private _meshRebuildObserver;
  19967. private _meshDisposeObserver;
  19968. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  19969. isEnabled: boolean;
  19970. /**
  19971. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  19972. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  19973. * @param source Mesh used to create edges
  19974. * @param epsilon sum of angles in adjacency to check for edge
  19975. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  19976. * @param generateEdgesLines - should generate Lines or only prepare resources.
  19977. */
  19978. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  19979. protected _prepareRessources(): void;
  19980. /** @hidden */
  19981. _rebuild(): void;
  19982. /**
  19983. * Releases the required resources for the edges renderer
  19984. */
  19985. dispose(): void;
  19986. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  19987. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  19988. /**
  19989. * Checks if the pair of p0 and p1 is en edge
  19990. * @param faceIndex
  19991. * @param edge
  19992. * @param faceNormals
  19993. * @param p0
  19994. * @param p1
  19995. * @private
  19996. */
  19997. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  19998. /**
  19999. * push line into the position, normal and index buffer
  20000. * @protected
  20001. */
  20002. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20003. /**
  20004. * Generates lines edges from adjacencjes
  20005. * @private
  20006. */
  20007. _generateEdgesLines(): void;
  20008. /**
  20009. * Checks wether or not the edges renderer is ready to render.
  20010. * @return true if ready, otherwise false.
  20011. */
  20012. isReady(): boolean;
  20013. /**
  20014. * Renders the edges of the attached mesh,
  20015. */
  20016. render(): void;
  20017. }
  20018. /**
  20019. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20020. */
  20021. export class LineEdgesRenderer extends EdgesRenderer {
  20022. /**
  20023. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20024. * @param source LineMesh used to generate edges
  20025. * @param epsilon not important (specified angle for edge detection)
  20026. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20027. */
  20028. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20029. /**
  20030. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20031. */
  20032. _generateEdgesLines(): void;
  20033. }
  20034. }
  20035. declare module "babylonjs/Rendering/renderingGroup" {
  20036. import { SmartArray } from "babylonjs/Misc/smartArray";
  20037. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20039. import { Nullable } from "babylonjs/types";
  20040. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20041. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20042. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20043. import { Material } from "babylonjs/Materials/material";
  20044. import { Scene } from "babylonjs/scene";
  20045. /**
  20046. * This represents the object necessary to create a rendering group.
  20047. * This is exclusively used and created by the rendering manager.
  20048. * To modify the behavior, you use the available helpers in your scene or meshes.
  20049. * @hidden
  20050. */
  20051. export class RenderingGroup {
  20052. index: number;
  20053. private static _zeroVector;
  20054. private _scene;
  20055. private _opaqueSubMeshes;
  20056. private _transparentSubMeshes;
  20057. private _alphaTestSubMeshes;
  20058. private _depthOnlySubMeshes;
  20059. private _particleSystems;
  20060. private _spriteManagers;
  20061. private _opaqueSortCompareFn;
  20062. private _alphaTestSortCompareFn;
  20063. private _transparentSortCompareFn;
  20064. private _renderOpaque;
  20065. private _renderAlphaTest;
  20066. private _renderTransparent;
  20067. /** @hidden */
  20068. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20069. onBeforeTransparentRendering: () => void;
  20070. /**
  20071. * Set the opaque sort comparison function.
  20072. * If null the sub meshes will be render in the order they were created
  20073. */
  20074. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20075. /**
  20076. * Set the alpha test sort comparison function.
  20077. * If null the sub meshes will be render in the order they were created
  20078. */
  20079. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20080. /**
  20081. * Set the transparent sort comparison function.
  20082. * If null the sub meshes will be render in the order they were created
  20083. */
  20084. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20085. /**
  20086. * Creates a new rendering group.
  20087. * @param index The rendering group index
  20088. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20089. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20090. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20091. */
  20092. 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>);
  20093. /**
  20094. * Render all the sub meshes contained in the group.
  20095. * @param customRenderFunction Used to override the default render behaviour of the group.
  20096. * @returns true if rendered some submeshes.
  20097. */
  20098. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20099. /**
  20100. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20101. * @param subMeshes The submeshes to render
  20102. */
  20103. private renderOpaqueSorted;
  20104. /**
  20105. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20106. * @param subMeshes The submeshes to render
  20107. */
  20108. private renderAlphaTestSorted;
  20109. /**
  20110. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20111. * @param subMeshes The submeshes to render
  20112. */
  20113. private renderTransparentSorted;
  20114. /**
  20115. * Renders the submeshes in a specified order.
  20116. * @param subMeshes The submeshes to sort before render
  20117. * @param sortCompareFn The comparison function use to sort
  20118. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20119. * @param transparent Specifies to activate blending if true
  20120. */
  20121. private static renderSorted;
  20122. /**
  20123. * Renders the submeshes in the order they were dispatched (no sort applied).
  20124. * @param subMeshes The submeshes to render
  20125. */
  20126. private static renderUnsorted;
  20127. /**
  20128. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20129. * are rendered back to front if in the same alpha index.
  20130. *
  20131. * @param a The first submesh
  20132. * @param b The second submesh
  20133. * @returns The result of the comparison
  20134. */
  20135. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20136. /**
  20137. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20138. * are rendered back to front.
  20139. *
  20140. * @param a The first submesh
  20141. * @param b The second submesh
  20142. * @returns The result of the comparison
  20143. */
  20144. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20145. /**
  20146. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20147. * are rendered front to back (prevent overdraw).
  20148. *
  20149. * @param a The first submesh
  20150. * @param b The second submesh
  20151. * @returns The result of the comparison
  20152. */
  20153. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20154. /**
  20155. * Resets the different lists of submeshes to prepare a new frame.
  20156. */
  20157. prepare(): void;
  20158. dispose(): void;
  20159. /**
  20160. * Inserts the submesh in its correct queue depending on its material.
  20161. * @param subMesh The submesh to dispatch
  20162. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20163. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20164. */
  20165. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20166. dispatchSprites(spriteManager: ISpriteManager): void;
  20167. dispatchParticles(particleSystem: IParticleSystem): void;
  20168. private _renderParticles;
  20169. private _renderSprites;
  20170. }
  20171. }
  20172. declare module "babylonjs/Rendering/renderingManager" {
  20173. import { Nullable } from "babylonjs/types";
  20174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20175. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20176. import { SmartArray } from "babylonjs/Misc/smartArray";
  20177. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20178. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20179. import { Material } from "babylonjs/Materials/material";
  20180. import { Scene } from "babylonjs/scene";
  20181. import { Camera } from "babylonjs/Cameras/camera";
  20182. /**
  20183. * Interface describing the different options available in the rendering manager
  20184. * regarding Auto Clear between groups.
  20185. */
  20186. export interface IRenderingManagerAutoClearSetup {
  20187. /**
  20188. * Defines whether or not autoclear is enable.
  20189. */
  20190. autoClear: boolean;
  20191. /**
  20192. * Defines whether or not to autoclear the depth buffer.
  20193. */
  20194. depth: boolean;
  20195. /**
  20196. * Defines whether or not to autoclear the stencil buffer.
  20197. */
  20198. stencil: boolean;
  20199. }
  20200. /**
  20201. * This class is used by the onRenderingGroupObservable
  20202. */
  20203. export class RenderingGroupInfo {
  20204. /**
  20205. * The Scene that being rendered
  20206. */
  20207. scene: Scene;
  20208. /**
  20209. * The camera currently used for the rendering pass
  20210. */
  20211. camera: Nullable<Camera>;
  20212. /**
  20213. * The ID of the renderingGroup being processed
  20214. */
  20215. renderingGroupId: number;
  20216. }
  20217. /**
  20218. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20219. * It is enable to manage the different groups as well as the different necessary sort functions.
  20220. * This should not be used directly aside of the few static configurations
  20221. */
  20222. export class RenderingManager {
  20223. /**
  20224. * The max id used for rendering groups (not included)
  20225. */
  20226. static MAX_RENDERINGGROUPS: number;
  20227. /**
  20228. * The min id used for rendering groups (included)
  20229. */
  20230. static MIN_RENDERINGGROUPS: number;
  20231. /**
  20232. * Used to globally prevent autoclearing scenes.
  20233. */
  20234. static AUTOCLEAR: boolean;
  20235. /**
  20236. * @hidden
  20237. */
  20238. _useSceneAutoClearSetup: boolean;
  20239. private _scene;
  20240. private _renderingGroups;
  20241. private _depthStencilBufferAlreadyCleaned;
  20242. private _autoClearDepthStencil;
  20243. private _customOpaqueSortCompareFn;
  20244. private _customAlphaTestSortCompareFn;
  20245. private _customTransparentSortCompareFn;
  20246. private _renderingGroupInfo;
  20247. /**
  20248. * Instantiates a new rendering group for a particular scene
  20249. * @param scene Defines the scene the groups belongs to
  20250. */
  20251. constructor(scene: Scene);
  20252. private _clearDepthStencilBuffer;
  20253. /**
  20254. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20255. * @hidden
  20256. */
  20257. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20258. /**
  20259. * Resets the different information of the group to prepare a new frame
  20260. * @hidden
  20261. */
  20262. reset(): void;
  20263. /**
  20264. * Dispose and release the group and its associated resources.
  20265. * @hidden
  20266. */
  20267. dispose(): void;
  20268. /**
  20269. * Clear the info related to rendering groups preventing retention points during dispose.
  20270. */
  20271. freeRenderingGroups(): void;
  20272. private _prepareRenderingGroup;
  20273. /**
  20274. * Add a sprite manager to the rendering manager in order to render it this frame.
  20275. * @param spriteManager Define the sprite manager to render
  20276. */
  20277. dispatchSprites(spriteManager: ISpriteManager): void;
  20278. /**
  20279. * Add a particle system to the rendering manager in order to render it this frame.
  20280. * @param particleSystem Define the particle system to render
  20281. */
  20282. dispatchParticles(particleSystem: IParticleSystem): void;
  20283. /**
  20284. * Add a submesh to the manager in order to render it this frame
  20285. * @param subMesh The submesh to dispatch
  20286. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20287. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20288. */
  20289. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20290. /**
  20291. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20292. * This allowed control for front to back rendering or reversly depending of the special needs.
  20293. *
  20294. * @param renderingGroupId The rendering group id corresponding to its index
  20295. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20296. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20297. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20298. */
  20299. 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;
  20300. /**
  20301. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20302. *
  20303. * @param renderingGroupId The rendering group id corresponding to its index
  20304. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20305. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20306. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20307. */
  20308. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20309. /**
  20310. * Gets the current auto clear configuration for one rendering group of the rendering
  20311. * manager.
  20312. * @param index the rendering group index to get the information for
  20313. * @returns The auto clear setup for the requested rendering group
  20314. */
  20315. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20316. }
  20317. }
  20318. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20319. import { Observable } from "babylonjs/Misc/observable";
  20320. import { SmartArray } from "babylonjs/Misc/smartArray";
  20321. import { Nullable } from "babylonjs/types";
  20322. import { Camera } from "babylonjs/Cameras/camera";
  20323. import { Scene } from "babylonjs/scene";
  20324. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20325. import { Color4 } from "babylonjs/Maths/math.color";
  20326. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20328. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20329. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20330. import { Texture } from "babylonjs/Materials/Textures/texture";
  20331. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20332. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20333. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20334. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  20335. import { Engine } from "babylonjs/Engines/engine";
  20336. /**
  20337. * This Helps creating a texture that will be created from a camera in your scene.
  20338. * It is basically a dynamic texture that could be used to create special effects for instance.
  20339. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20340. */
  20341. export class RenderTargetTexture extends Texture {
  20342. isCube: boolean;
  20343. /**
  20344. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20345. */
  20346. static readonly REFRESHRATE_RENDER_ONCE: number;
  20347. /**
  20348. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20349. */
  20350. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20351. /**
  20352. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20353. * the central point of your effect and can save a lot of performances.
  20354. */
  20355. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20356. /**
  20357. * Use this predicate to dynamically define the list of mesh you want to render.
  20358. * If set, the renderList property will be overwritten.
  20359. */
  20360. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20361. private _renderList;
  20362. /**
  20363. * Use this list to define the list of mesh you want to render.
  20364. */
  20365. renderList: Nullable<Array<AbstractMesh>>;
  20366. private _hookArray;
  20367. /**
  20368. * Define if particles should be rendered in your texture.
  20369. */
  20370. renderParticles: boolean;
  20371. /**
  20372. * Define if sprites should be rendered in your texture.
  20373. */
  20374. renderSprites: boolean;
  20375. /**
  20376. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20377. */
  20378. coordinatesMode: number;
  20379. /**
  20380. * Define the camera used to render the texture.
  20381. */
  20382. activeCamera: Nullable<Camera>;
  20383. /**
  20384. * Override the render function of the texture with your own one.
  20385. */
  20386. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20387. /**
  20388. * Define if camera post processes should be use while rendering the texture.
  20389. */
  20390. useCameraPostProcesses: boolean;
  20391. /**
  20392. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20393. */
  20394. ignoreCameraViewport: boolean;
  20395. private _postProcessManager;
  20396. private _postProcesses;
  20397. private _resizeObserver;
  20398. /**
  20399. * An event triggered when the texture is unbind.
  20400. */
  20401. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20402. /**
  20403. * An event triggered when the texture is unbind.
  20404. */
  20405. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20406. private _onAfterUnbindObserver;
  20407. /**
  20408. * Set a after unbind callback in the texture.
  20409. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20410. */
  20411. onAfterUnbind: () => void;
  20412. /**
  20413. * An event triggered before rendering the texture
  20414. */
  20415. onBeforeRenderObservable: Observable<number>;
  20416. private _onBeforeRenderObserver;
  20417. /**
  20418. * Set a before render callback in the texture.
  20419. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20420. */
  20421. onBeforeRender: (faceIndex: number) => void;
  20422. /**
  20423. * An event triggered after rendering the texture
  20424. */
  20425. onAfterRenderObservable: Observable<number>;
  20426. private _onAfterRenderObserver;
  20427. /**
  20428. * Set a after render callback in the texture.
  20429. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20430. */
  20431. onAfterRender: (faceIndex: number) => void;
  20432. /**
  20433. * An event triggered after the texture clear
  20434. */
  20435. onClearObservable: Observable<Engine>;
  20436. private _onClearObserver;
  20437. /**
  20438. * Set a clear callback in the texture.
  20439. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20440. */
  20441. onClear: (Engine: Engine) => void;
  20442. /**
  20443. * An event triggered when the texture is resized.
  20444. */
  20445. onResizeObservable: Observable<RenderTargetTexture>;
  20446. /**
  20447. * Define the clear color of the Render Target if it should be different from the scene.
  20448. */
  20449. clearColor: Color4;
  20450. protected _size: number | {
  20451. width: number;
  20452. height: number;
  20453. };
  20454. protected _initialSizeParameter: number | {
  20455. width: number;
  20456. height: number;
  20457. } | {
  20458. ratio: number;
  20459. };
  20460. protected _sizeRatio: Nullable<number>;
  20461. /** @hidden */
  20462. _generateMipMaps: boolean;
  20463. protected _renderingManager: RenderingManager;
  20464. /** @hidden */
  20465. _waitingRenderList: string[];
  20466. protected _doNotChangeAspectRatio: boolean;
  20467. protected _currentRefreshId: number;
  20468. protected _refreshRate: number;
  20469. protected _textureMatrix: Matrix;
  20470. protected _samples: number;
  20471. protected _renderTargetOptions: RenderTargetCreationOptions;
  20472. /**
  20473. * Gets render target creation options that were used.
  20474. */
  20475. readonly renderTargetOptions: RenderTargetCreationOptions;
  20476. protected _engine: Engine;
  20477. protected _onRatioRescale(): void;
  20478. /**
  20479. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20480. * It must define where the camera used to render the texture is set
  20481. */
  20482. boundingBoxPosition: Vector3;
  20483. private _boundingBoxSize;
  20484. /**
  20485. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20486. * When defined, the cubemap will switch to local mode
  20487. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20488. * @example https://www.babylonjs-playground.com/#RNASML
  20489. */
  20490. boundingBoxSize: Vector3;
  20491. /**
  20492. * In case the RTT has been created with a depth texture, get the associated
  20493. * depth texture.
  20494. * Otherwise, return null.
  20495. */
  20496. depthStencilTexture: Nullable<InternalTexture>;
  20497. /**
  20498. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20499. * or used a shadow, depth texture...
  20500. * @param name The friendly name of the texture
  20501. * @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)
  20502. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20503. * @param generateMipMaps True if mip maps need to be generated after render.
  20504. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20505. * @param type The type of the buffer in the RTT (int, half float, float...)
  20506. * @param isCube True if a cube texture needs to be created
  20507. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20508. * @param generateDepthBuffer True to generate a depth buffer
  20509. * @param generateStencilBuffer True to generate a stencil buffer
  20510. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20511. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20512. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20513. */
  20514. constructor(name: string, size: number | {
  20515. width: number;
  20516. height: number;
  20517. } | {
  20518. ratio: number;
  20519. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20520. /**
  20521. * Creates a depth stencil texture.
  20522. * This is only available in WebGL 2 or with the depth texture extension available.
  20523. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20524. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20525. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20526. */
  20527. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20528. private _processSizeParameter;
  20529. /**
  20530. * Define the number of samples to use in case of MSAA.
  20531. * It defaults to one meaning no MSAA has been enabled.
  20532. */
  20533. samples: number;
  20534. /**
  20535. * Resets the refresh counter of the texture and start bak from scratch.
  20536. * Could be useful to regenerate the texture if it is setup to render only once.
  20537. */
  20538. resetRefreshCounter(): void;
  20539. /**
  20540. * Define the refresh rate of the texture or the rendering frequency.
  20541. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20542. */
  20543. refreshRate: number;
  20544. /**
  20545. * Adds a post process to the render target rendering passes.
  20546. * @param postProcess define the post process to add
  20547. */
  20548. addPostProcess(postProcess: PostProcess): void;
  20549. /**
  20550. * Clear all the post processes attached to the render target
  20551. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20552. */
  20553. clearPostProcesses(dispose?: boolean): void;
  20554. /**
  20555. * Remove one of the post process from the list of attached post processes to the texture
  20556. * @param postProcess define the post process to remove from the list
  20557. */
  20558. removePostProcess(postProcess: PostProcess): void;
  20559. /** @hidden */
  20560. _shouldRender(): boolean;
  20561. /**
  20562. * Gets the actual render size of the texture.
  20563. * @returns the width of the render size
  20564. */
  20565. getRenderSize(): number;
  20566. /**
  20567. * Gets the actual render width of the texture.
  20568. * @returns the width of the render size
  20569. */
  20570. getRenderWidth(): number;
  20571. /**
  20572. * Gets the actual render height of the texture.
  20573. * @returns the height of the render size
  20574. */
  20575. getRenderHeight(): number;
  20576. /**
  20577. * Get if the texture can be rescaled or not.
  20578. */
  20579. readonly canRescale: boolean;
  20580. /**
  20581. * Resize the texture using a ratio.
  20582. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20583. */
  20584. scale(ratio: number): void;
  20585. /**
  20586. * Get the texture reflection matrix used to rotate/transform the reflection.
  20587. * @returns the reflection matrix
  20588. */
  20589. getReflectionTextureMatrix(): Matrix;
  20590. /**
  20591. * Resize the texture to a new desired size.
  20592. * Be carrefull as it will recreate all the data in the new texture.
  20593. * @param size Define the new size. It can be:
  20594. * - a number for squared texture,
  20595. * - an object containing { width: number, height: number }
  20596. * - or an object containing a ratio { ratio: number }
  20597. */
  20598. resize(size: number | {
  20599. width: number;
  20600. height: number;
  20601. } | {
  20602. ratio: number;
  20603. }): void;
  20604. /**
  20605. * Renders all the objects from the render list into the texture.
  20606. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20607. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20608. */
  20609. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20610. private _bestReflectionRenderTargetDimension;
  20611. /**
  20612. * @hidden
  20613. * @param faceIndex face index to bind to if this is a cubetexture
  20614. */
  20615. _bindFrameBuffer(faceIndex?: number): void;
  20616. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20617. private renderToTarget;
  20618. /**
  20619. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20620. * This allowed control for front to back rendering or reversly depending of the special needs.
  20621. *
  20622. * @param renderingGroupId The rendering group id corresponding to its index
  20623. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20624. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20625. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20626. */
  20627. 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;
  20628. /**
  20629. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20630. *
  20631. * @param renderingGroupId The rendering group id corresponding to its index
  20632. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20633. */
  20634. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20635. /**
  20636. * Clones the texture.
  20637. * @returns the cloned texture
  20638. */
  20639. clone(): RenderTargetTexture;
  20640. /**
  20641. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20642. * @returns The JSON representation of the texture
  20643. */
  20644. serialize(): any;
  20645. /**
  20646. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20647. */
  20648. disposeFramebufferObjects(): void;
  20649. /**
  20650. * Dispose the texture and release its associated resources.
  20651. */
  20652. dispose(): void;
  20653. /** @hidden */
  20654. _rebuild(): void;
  20655. /**
  20656. * Clear the info related to rendering groups preventing retention point in material dispose.
  20657. */
  20658. freeRenderingGroups(): void;
  20659. /**
  20660. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20661. * @returns the view count
  20662. */
  20663. getViewCount(): number;
  20664. }
  20665. }
  20666. declare module "babylonjs/Materials/material" {
  20667. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20668. import { SmartArray } from "babylonjs/Misc/smartArray";
  20669. import { Observable } from "babylonjs/Misc/observable";
  20670. import { Nullable } from "babylonjs/types";
  20671. import { Scene } from "babylonjs/scene";
  20672. import { Matrix } from "babylonjs/Maths/math.vector";
  20673. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20674. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20675. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20676. import { Effect } from "babylonjs/Materials/effect";
  20677. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20678. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20679. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20680. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20681. import { Mesh } from "babylonjs/Meshes/mesh";
  20682. import { Animation } from "babylonjs/Animations/animation";
  20683. /**
  20684. * Base class for the main features of a material in Babylon.js
  20685. */
  20686. export class Material implements IAnimatable {
  20687. /**
  20688. * Returns the triangle fill mode
  20689. */
  20690. static readonly TriangleFillMode: number;
  20691. /**
  20692. * Returns the wireframe mode
  20693. */
  20694. static readonly WireFrameFillMode: number;
  20695. /**
  20696. * Returns the point fill mode
  20697. */
  20698. static readonly PointFillMode: number;
  20699. /**
  20700. * Returns the point list draw mode
  20701. */
  20702. static readonly PointListDrawMode: number;
  20703. /**
  20704. * Returns the line list draw mode
  20705. */
  20706. static readonly LineListDrawMode: number;
  20707. /**
  20708. * Returns the line loop draw mode
  20709. */
  20710. static readonly LineLoopDrawMode: number;
  20711. /**
  20712. * Returns the line strip draw mode
  20713. */
  20714. static readonly LineStripDrawMode: number;
  20715. /**
  20716. * Returns the triangle strip draw mode
  20717. */
  20718. static readonly TriangleStripDrawMode: number;
  20719. /**
  20720. * Returns the triangle fan draw mode
  20721. */
  20722. static readonly TriangleFanDrawMode: number;
  20723. /**
  20724. * Stores the clock-wise side orientation
  20725. */
  20726. static readonly ClockWiseSideOrientation: number;
  20727. /**
  20728. * Stores the counter clock-wise side orientation
  20729. */
  20730. static readonly CounterClockWiseSideOrientation: number;
  20731. /**
  20732. * The dirty texture flag value
  20733. */
  20734. static readonly TextureDirtyFlag: number;
  20735. /**
  20736. * The dirty light flag value
  20737. */
  20738. static readonly LightDirtyFlag: number;
  20739. /**
  20740. * The dirty fresnel flag value
  20741. */
  20742. static readonly FresnelDirtyFlag: number;
  20743. /**
  20744. * The dirty attribute flag value
  20745. */
  20746. static readonly AttributesDirtyFlag: number;
  20747. /**
  20748. * The dirty misc flag value
  20749. */
  20750. static readonly MiscDirtyFlag: number;
  20751. /**
  20752. * The all dirty flag value
  20753. */
  20754. static readonly AllDirtyFlag: number;
  20755. /**
  20756. * The ID of the material
  20757. */
  20758. id: string;
  20759. /**
  20760. * Gets or sets the unique id of the material
  20761. */
  20762. uniqueId: number;
  20763. /**
  20764. * The name of the material
  20765. */
  20766. name: string;
  20767. /**
  20768. * Gets or sets user defined metadata
  20769. */
  20770. metadata: any;
  20771. /**
  20772. * For internal use only. Please do not use.
  20773. */
  20774. reservedDataStore: any;
  20775. /**
  20776. * Specifies if the ready state should be checked on each call
  20777. */
  20778. checkReadyOnEveryCall: boolean;
  20779. /**
  20780. * Specifies if the ready state should be checked once
  20781. */
  20782. checkReadyOnlyOnce: boolean;
  20783. /**
  20784. * The state of the material
  20785. */
  20786. state: string;
  20787. /**
  20788. * The alpha value of the material
  20789. */
  20790. protected _alpha: number;
  20791. /**
  20792. * List of inspectable custom properties (used by the Inspector)
  20793. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20794. */
  20795. inspectableCustomProperties: IInspectable[];
  20796. /**
  20797. * Sets the alpha value of the material
  20798. */
  20799. /**
  20800. * Gets the alpha value of the material
  20801. */
  20802. alpha: number;
  20803. /**
  20804. * Specifies if back face culling is enabled
  20805. */
  20806. protected _backFaceCulling: boolean;
  20807. /**
  20808. * Sets the back-face culling state
  20809. */
  20810. /**
  20811. * Gets the back-face culling state
  20812. */
  20813. backFaceCulling: boolean;
  20814. /**
  20815. * Stores the value for side orientation
  20816. */
  20817. sideOrientation: number;
  20818. /**
  20819. * Callback triggered when the material is compiled
  20820. */
  20821. onCompiled: Nullable<(effect: Effect) => void>;
  20822. /**
  20823. * Callback triggered when an error occurs
  20824. */
  20825. onError: Nullable<(effect: Effect, errors: string) => void>;
  20826. /**
  20827. * Callback triggered to get the render target textures
  20828. */
  20829. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20830. /**
  20831. * Gets a boolean indicating that current material needs to register RTT
  20832. */
  20833. readonly hasRenderTargetTextures: boolean;
  20834. /**
  20835. * Specifies if the material should be serialized
  20836. */
  20837. doNotSerialize: boolean;
  20838. /**
  20839. * @hidden
  20840. */
  20841. _storeEffectOnSubMeshes: boolean;
  20842. /**
  20843. * Stores the animations for the material
  20844. */
  20845. animations: Nullable<Array<Animation>>;
  20846. /**
  20847. * An event triggered when the material is disposed
  20848. */
  20849. onDisposeObservable: Observable<Material>;
  20850. /**
  20851. * An observer which watches for dispose events
  20852. */
  20853. private _onDisposeObserver;
  20854. private _onUnBindObservable;
  20855. /**
  20856. * Called during a dispose event
  20857. */
  20858. onDispose: () => void;
  20859. private _onBindObservable;
  20860. /**
  20861. * An event triggered when the material is bound
  20862. */
  20863. readonly onBindObservable: Observable<AbstractMesh>;
  20864. /**
  20865. * An observer which watches for bind events
  20866. */
  20867. private _onBindObserver;
  20868. /**
  20869. * Called during a bind event
  20870. */
  20871. onBind: (Mesh: AbstractMesh) => void;
  20872. /**
  20873. * An event triggered when the material is unbound
  20874. */
  20875. readonly onUnBindObservable: Observable<Material>;
  20876. /**
  20877. * Stores the value of the alpha mode
  20878. */
  20879. private _alphaMode;
  20880. /**
  20881. * Sets the value of the alpha mode.
  20882. *
  20883. * | Value | Type | Description |
  20884. * | --- | --- | --- |
  20885. * | 0 | ALPHA_DISABLE | |
  20886. * | 1 | ALPHA_ADD | |
  20887. * | 2 | ALPHA_COMBINE | |
  20888. * | 3 | ALPHA_SUBTRACT | |
  20889. * | 4 | ALPHA_MULTIPLY | |
  20890. * | 5 | ALPHA_MAXIMIZED | |
  20891. * | 6 | ALPHA_ONEONE | |
  20892. * | 7 | ALPHA_PREMULTIPLIED | |
  20893. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  20894. * | 9 | ALPHA_INTERPOLATE | |
  20895. * | 10 | ALPHA_SCREENMODE | |
  20896. *
  20897. */
  20898. /**
  20899. * Gets the value of the alpha mode
  20900. */
  20901. alphaMode: number;
  20902. /**
  20903. * Stores the state of the need depth pre-pass value
  20904. */
  20905. private _needDepthPrePass;
  20906. /**
  20907. * Sets the need depth pre-pass value
  20908. */
  20909. /**
  20910. * Gets the depth pre-pass value
  20911. */
  20912. needDepthPrePass: boolean;
  20913. /**
  20914. * Specifies if depth writing should be disabled
  20915. */
  20916. disableDepthWrite: boolean;
  20917. /**
  20918. * Specifies if depth writing should be forced
  20919. */
  20920. forceDepthWrite: boolean;
  20921. /**
  20922. * Specifies if there should be a separate pass for culling
  20923. */
  20924. separateCullingPass: boolean;
  20925. /**
  20926. * Stores the state specifing if fog should be enabled
  20927. */
  20928. private _fogEnabled;
  20929. /**
  20930. * Sets the state for enabling fog
  20931. */
  20932. /**
  20933. * Gets the value of the fog enabled state
  20934. */
  20935. fogEnabled: boolean;
  20936. /**
  20937. * Stores the size of points
  20938. */
  20939. pointSize: number;
  20940. /**
  20941. * Stores the z offset value
  20942. */
  20943. zOffset: number;
  20944. /**
  20945. * Gets a value specifying if wireframe mode is enabled
  20946. */
  20947. /**
  20948. * Sets the state of wireframe mode
  20949. */
  20950. wireframe: boolean;
  20951. /**
  20952. * Gets the value specifying if point clouds are enabled
  20953. */
  20954. /**
  20955. * Sets the state of point cloud mode
  20956. */
  20957. pointsCloud: boolean;
  20958. /**
  20959. * Gets the material fill mode
  20960. */
  20961. /**
  20962. * Sets the material fill mode
  20963. */
  20964. fillMode: number;
  20965. /**
  20966. * @hidden
  20967. * Stores the effects for the material
  20968. */
  20969. _effect: Nullable<Effect>;
  20970. /**
  20971. * @hidden
  20972. * Specifies if the material was previously ready
  20973. */
  20974. _wasPreviouslyReady: boolean;
  20975. /**
  20976. * Specifies if uniform buffers should be used
  20977. */
  20978. private _useUBO;
  20979. /**
  20980. * Stores a reference to the scene
  20981. */
  20982. private _scene;
  20983. /**
  20984. * Stores the fill mode state
  20985. */
  20986. private _fillMode;
  20987. /**
  20988. * Specifies if the depth write state should be cached
  20989. */
  20990. private _cachedDepthWriteState;
  20991. /**
  20992. * Stores the uniform buffer
  20993. */
  20994. protected _uniformBuffer: UniformBuffer;
  20995. /** @hidden */
  20996. _indexInSceneMaterialArray: number;
  20997. /** @hidden */
  20998. meshMap: Nullable<{
  20999. [id: string]: AbstractMesh | undefined;
  21000. }>;
  21001. /**
  21002. * Creates a material instance
  21003. * @param name defines the name of the material
  21004. * @param scene defines the scene to reference
  21005. * @param doNotAdd specifies if the material should be added to the scene
  21006. */
  21007. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21008. /**
  21009. * Returns a string representation of the current material
  21010. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21011. * @returns a string with material information
  21012. */
  21013. toString(fullDetails?: boolean): string;
  21014. /**
  21015. * Gets the class name of the material
  21016. * @returns a string with the class name of the material
  21017. */
  21018. getClassName(): string;
  21019. /**
  21020. * Specifies if updates for the material been locked
  21021. */
  21022. readonly isFrozen: boolean;
  21023. /**
  21024. * Locks updates for the material
  21025. */
  21026. freeze(): void;
  21027. /**
  21028. * Unlocks updates for the material
  21029. */
  21030. unfreeze(): void;
  21031. /**
  21032. * Specifies if the material is ready to be used
  21033. * @param mesh defines the mesh to check
  21034. * @param useInstances specifies if instances should be used
  21035. * @returns a boolean indicating if the material is ready to be used
  21036. */
  21037. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21038. /**
  21039. * Specifies that the submesh is ready to be used
  21040. * @param mesh defines the mesh to check
  21041. * @param subMesh defines which submesh to check
  21042. * @param useInstances specifies that instances should be used
  21043. * @returns a boolean indicating that the submesh is ready or not
  21044. */
  21045. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21046. /**
  21047. * Returns the material effect
  21048. * @returns the effect associated with the material
  21049. */
  21050. getEffect(): Nullable<Effect>;
  21051. /**
  21052. * Returns the current scene
  21053. * @returns a Scene
  21054. */
  21055. getScene(): Scene;
  21056. /**
  21057. * Specifies if the material will require alpha blending
  21058. * @returns a boolean specifying if alpha blending is needed
  21059. */
  21060. needAlphaBlending(): boolean;
  21061. /**
  21062. * Specifies if the mesh will require alpha blending
  21063. * @param mesh defines the mesh to check
  21064. * @returns a boolean specifying if alpha blending is needed for the mesh
  21065. */
  21066. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21067. /**
  21068. * Specifies if this material should be rendered in alpha test mode
  21069. * @returns a boolean specifying if an alpha test is needed.
  21070. */
  21071. needAlphaTesting(): boolean;
  21072. /**
  21073. * Gets the texture used for the alpha test
  21074. * @returns the texture to use for alpha testing
  21075. */
  21076. getAlphaTestTexture(): Nullable<BaseTexture>;
  21077. /**
  21078. * Marks the material to indicate that it needs to be re-calculated
  21079. */
  21080. markDirty(): void;
  21081. /** @hidden */
  21082. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21083. /**
  21084. * Binds the material to the mesh
  21085. * @param world defines the world transformation matrix
  21086. * @param mesh defines the mesh to bind the material to
  21087. */
  21088. bind(world: Matrix, mesh?: Mesh): void;
  21089. /**
  21090. * Binds the submesh to the material
  21091. * @param world defines the world transformation matrix
  21092. * @param mesh defines the mesh containing the submesh
  21093. * @param subMesh defines the submesh to bind the material to
  21094. */
  21095. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21096. /**
  21097. * Binds the world matrix to the material
  21098. * @param world defines the world transformation matrix
  21099. */
  21100. bindOnlyWorldMatrix(world: Matrix): void;
  21101. /**
  21102. * Binds the scene's uniform buffer to the effect.
  21103. * @param effect defines the effect to bind to the scene uniform buffer
  21104. * @param sceneUbo defines the uniform buffer storing scene data
  21105. */
  21106. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21107. /**
  21108. * Binds the view matrix to the effect
  21109. * @param effect defines the effect to bind the view matrix to
  21110. */
  21111. bindView(effect: Effect): void;
  21112. /**
  21113. * Binds the view projection matrix to the effect
  21114. * @param effect defines the effect to bind the view projection matrix to
  21115. */
  21116. bindViewProjection(effect: Effect): void;
  21117. /**
  21118. * Specifies if material alpha testing should be turned on for the mesh
  21119. * @param mesh defines the mesh to check
  21120. */
  21121. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21122. /**
  21123. * Processes to execute after binding the material to a mesh
  21124. * @param mesh defines the rendered mesh
  21125. */
  21126. protected _afterBind(mesh?: Mesh): void;
  21127. /**
  21128. * Unbinds the material from the mesh
  21129. */
  21130. unbind(): void;
  21131. /**
  21132. * Gets the active textures from the material
  21133. * @returns an array of textures
  21134. */
  21135. getActiveTextures(): BaseTexture[];
  21136. /**
  21137. * Specifies if the material uses a texture
  21138. * @param texture defines the texture to check against the material
  21139. * @returns a boolean specifying if the material uses the texture
  21140. */
  21141. hasTexture(texture: BaseTexture): boolean;
  21142. /**
  21143. * Makes a duplicate of the material, and gives it a new name
  21144. * @param name defines the new name for the duplicated material
  21145. * @returns the cloned material
  21146. */
  21147. clone(name: string): Nullable<Material>;
  21148. /**
  21149. * Gets the meshes bound to the material
  21150. * @returns an array of meshes bound to the material
  21151. */
  21152. getBindedMeshes(): AbstractMesh[];
  21153. /**
  21154. * Force shader compilation
  21155. * @param mesh defines the mesh associated with this material
  21156. * @param onCompiled defines a function to execute once the material is compiled
  21157. * @param options defines the options to configure the compilation
  21158. * @param onError defines a function to execute if the material fails compiling
  21159. */
  21160. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21161. clipPlane: boolean;
  21162. }>, onError?: (reason: string) => void): void;
  21163. /**
  21164. * Force shader compilation
  21165. * @param mesh defines the mesh that will use this material
  21166. * @param options defines additional options for compiling the shaders
  21167. * @returns a promise that resolves when the compilation completes
  21168. */
  21169. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21170. clipPlane: boolean;
  21171. }>): Promise<void>;
  21172. private static readonly _AllDirtyCallBack;
  21173. private static readonly _ImageProcessingDirtyCallBack;
  21174. private static readonly _TextureDirtyCallBack;
  21175. private static readonly _FresnelDirtyCallBack;
  21176. private static readonly _MiscDirtyCallBack;
  21177. private static readonly _LightsDirtyCallBack;
  21178. private static readonly _AttributeDirtyCallBack;
  21179. private static _FresnelAndMiscDirtyCallBack;
  21180. private static _TextureAndMiscDirtyCallBack;
  21181. private static readonly _DirtyCallbackArray;
  21182. private static readonly _RunDirtyCallBacks;
  21183. /**
  21184. * Marks a define in the material to indicate that it needs to be re-computed
  21185. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21186. */
  21187. markAsDirty(flag: number): void;
  21188. /**
  21189. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21190. * @param func defines a function which checks material defines against the submeshes
  21191. */
  21192. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21193. /**
  21194. * Indicates that we need to re-calculated for all submeshes
  21195. */
  21196. protected _markAllSubMeshesAsAllDirty(): void;
  21197. /**
  21198. * Indicates that image processing needs to be re-calculated for all submeshes
  21199. */
  21200. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21201. /**
  21202. * Indicates that textures need to be re-calculated for all submeshes
  21203. */
  21204. protected _markAllSubMeshesAsTexturesDirty(): void;
  21205. /**
  21206. * Indicates that fresnel needs to be re-calculated for all submeshes
  21207. */
  21208. protected _markAllSubMeshesAsFresnelDirty(): void;
  21209. /**
  21210. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21211. */
  21212. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21213. /**
  21214. * Indicates that lights need to be re-calculated for all submeshes
  21215. */
  21216. protected _markAllSubMeshesAsLightsDirty(): void;
  21217. /**
  21218. * Indicates that attributes need to be re-calculated for all submeshes
  21219. */
  21220. protected _markAllSubMeshesAsAttributesDirty(): void;
  21221. /**
  21222. * Indicates that misc needs to be re-calculated for all submeshes
  21223. */
  21224. protected _markAllSubMeshesAsMiscDirty(): void;
  21225. /**
  21226. * Indicates that textures and misc need to be re-calculated for all submeshes
  21227. */
  21228. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21229. /**
  21230. * Disposes the material
  21231. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21232. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21233. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21234. */
  21235. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21236. /** @hidden */
  21237. private releaseVertexArrayObject;
  21238. /**
  21239. * Serializes this material
  21240. * @returns the serialized material object
  21241. */
  21242. serialize(): any;
  21243. /**
  21244. * Creates a material from parsed material data
  21245. * @param parsedMaterial defines parsed material data
  21246. * @param scene defines the hosting scene
  21247. * @param rootUrl defines the root URL to use to load textures
  21248. * @returns a new material
  21249. */
  21250. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21251. }
  21252. }
  21253. declare module "babylonjs/Materials/multiMaterial" {
  21254. import { Nullable } from "babylonjs/types";
  21255. import { Scene } from "babylonjs/scene";
  21256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21257. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21258. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21259. import { Material } from "babylonjs/Materials/material";
  21260. /**
  21261. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21262. * separate meshes. This can be use to improve performances.
  21263. * @see http://doc.babylonjs.com/how_to/multi_materials
  21264. */
  21265. export class MultiMaterial extends Material {
  21266. private _subMaterials;
  21267. /**
  21268. * Gets or Sets the list of Materials used within the multi material.
  21269. * They need to be ordered according to the submeshes order in the associated mesh
  21270. */
  21271. subMaterials: Nullable<Material>[];
  21272. /**
  21273. * Function used to align with Node.getChildren()
  21274. * @returns the list of Materials used within the multi material
  21275. */
  21276. getChildren(): Nullable<Material>[];
  21277. /**
  21278. * Instantiates a new Multi Material
  21279. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21280. * separate meshes. This can be use to improve performances.
  21281. * @see http://doc.babylonjs.com/how_to/multi_materials
  21282. * @param name Define the name in the scene
  21283. * @param scene Define the scene the material belongs to
  21284. */
  21285. constructor(name: string, scene: Scene);
  21286. private _hookArray;
  21287. /**
  21288. * Get one of the submaterial by its index in the submaterials array
  21289. * @param index The index to look the sub material at
  21290. * @returns The Material if the index has been defined
  21291. */
  21292. getSubMaterial(index: number): Nullable<Material>;
  21293. /**
  21294. * Get the list of active textures for the whole sub materials list.
  21295. * @returns All the textures that will be used during the rendering
  21296. */
  21297. getActiveTextures(): BaseTexture[];
  21298. /**
  21299. * Gets the current class name of the material e.g. "MultiMaterial"
  21300. * Mainly use in serialization.
  21301. * @returns the class name
  21302. */
  21303. getClassName(): string;
  21304. /**
  21305. * Checks if the material is ready to render the requested sub mesh
  21306. * @param mesh Define the mesh the submesh belongs to
  21307. * @param subMesh Define the sub mesh to look readyness for
  21308. * @param useInstances Define whether or not the material is used with instances
  21309. * @returns true if ready, otherwise false
  21310. */
  21311. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21312. /**
  21313. * Clones the current material and its related sub materials
  21314. * @param name Define the name of the newly cloned material
  21315. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21316. * @returns the cloned material
  21317. */
  21318. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21319. /**
  21320. * Serializes the materials into a JSON representation.
  21321. * @returns the JSON representation
  21322. */
  21323. serialize(): any;
  21324. /**
  21325. * Dispose the material and release its associated resources
  21326. * @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)
  21327. * @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)
  21328. * @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)
  21329. */
  21330. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21331. /**
  21332. * Creates a MultiMaterial from parsed MultiMaterial data.
  21333. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21334. * @param scene defines the hosting scene
  21335. * @returns a new MultiMaterial
  21336. */
  21337. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21338. }
  21339. }
  21340. declare module "babylonjs/Meshes/subMesh" {
  21341. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21342. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21343. import { Engine } from "babylonjs/Engines/engine";
  21344. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21345. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21346. import { Effect } from "babylonjs/Materials/effect";
  21347. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21348. import { Plane } from "babylonjs/Maths/math.plane";
  21349. import { Collider } from "babylonjs/Collisions/collider";
  21350. import { Material } from "babylonjs/Materials/material";
  21351. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21353. import { Mesh } from "babylonjs/Meshes/mesh";
  21354. import { Ray } from "babylonjs/Culling/ray";
  21355. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21356. /**
  21357. * Base class for submeshes
  21358. */
  21359. export class BaseSubMesh {
  21360. /** @hidden */
  21361. _materialDefines: Nullable<MaterialDefines>;
  21362. /** @hidden */
  21363. _materialEffect: Nullable<Effect>;
  21364. /**
  21365. * Gets associated effect
  21366. */
  21367. readonly effect: Nullable<Effect>;
  21368. /**
  21369. * Sets associated effect (effect used to render this submesh)
  21370. * @param effect defines the effect to associate with
  21371. * @param defines defines the set of defines used to compile this effect
  21372. */
  21373. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21374. }
  21375. /**
  21376. * Defines a subdivision inside a mesh
  21377. */
  21378. export class SubMesh extends BaseSubMesh implements ICullable {
  21379. /** the material index to use */
  21380. materialIndex: number;
  21381. /** vertex index start */
  21382. verticesStart: number;
  21383. /** vertices count */
  21384. verticesCount: number;
  21385. /** index start */
  21386. indexStart: number;
  21387. /** indices count */
  21388. indexCount: number;
  21389. /** @hidden */
  21390. _linesIndexCount: number;
  21391. private _mesh;
  21392. private _renderingMesh;
  21393. private _boundingInfo;
  21394. private _linesIndexBuffer;
  21395. /** @hidden */
  21396. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21397. /** @hidden */
  21398. _trianglePlanes: Plane[];
  21399. /** @hidden */
  21400. _lastColliderTransformMatrix: Nullable<Matrix>;
  21401. /** @hidden */
  21402. _renderId: number;
  21403. /** @hidden */
  21404. _alphaIndex: number;
  21405. /** @hidden */
  21406. _distanceToCamera: number;
  21407. /** @hidden */
  21408. _id: number;
  21409. private _currentMaterial;
  21410. /**
  21411. * Add a new submesh to a mesh
  21412. * @param materialIndex defines the material index to use
  21413. * @param verticesStart defines vertex index start
  21414. * @param verticesCount defines vertices count
  21415. * @param indexStart defines index start
  21416. * @param indexCount defines indices count
  21417. * @param mesh defines the parent mesh
  21418. * @param renderingMesh defines an optional rendering mesh
  21419. * @param createBoundingBox defines if bounding box should be created for this submesh
  21420. * @returns the new submesh
  21421. */
  21422. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21423. /**
  21424. * Creates a new submesh
  21425. * @param materialIndex defines the material index to use
  21426. * @param verticesStart defines vertex index start
  21427. * @param verticesCount defines vertices count
  21428. * @param indexStart defines index start
  21429. * @param indexCount defines indices count
  21430. * @param mesh defines the parent mesh
  21431. * @param renderingMesh defines an optional rendering mesh
  21432. * @param createBoundingBox defines if bounding box should be created for this submesh
  21433. */
  21434. constructor(
  21435. /** the material index to use */
  21436. materialIndex: number,
  21437. /** vertex index start */
  21438. verticesStart: number,
  21439. /** vertices count */
  21440. verticesCount: number,
  21441. /** index start */
  21442. indexStart: number,
  21443. /** indices count */
  21444. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21445. /**
  21446. * Returns true if this submesh covers the entire parent mesh
  21447. * @ignorenaming
  21448. */
  21449. readonly IsGlobal: boolean;
  21450. /**
  21451. * Returns the submesh BoudingInfo object
  21452. * @returns current bounding info (or mesh's one if the submesh is global)
  21453. */
  21454. getBoundingInfo(): BoundingInfo;
  21455. /**
  21456. * Sets the submesh BoundingInfo
  21457. * @param boundingInfo defines the new bounding info to use
  21458. * @returns the SubMesh
  21459. */
  21460. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21461. /**
  21462. * Returns the mesh of the current submesh
  21463. * @return the parent mesh
  21464. */
  21465. getMesh(): AbstractMesh;
  21466. /**
  21467. * Returns the rendering mesh of the submesh
  21468. * @returns the rendering mesh (could be different from parent mesh)
  21469. */
  21470. getRenderingMesh(): Mesh;
  21471. /**
  21472. * Returns the submesh material
  21473. * @returns null or the current material
  21474. */
  21475. getMaterial(): Nullable<Material>;
  21476. /**
  21477. * Sets a new updated BoundingInfo object to the submesh
  21478. * @param data defines an optional position array to use to determine the bounding info
  21479. * @returns the SubMesh
  21480. */
  21481. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21482. /** @hidden */
  21483. _checkCollision(collider: Collider): boolean;
  21484. /**
  21485. * Updates the submesh BoundingInfo
  21486. * @param world defines the world matrix to use to update the bounding info
  21487. * @returns the submesh
  21488. */
  21489. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21490. /**
  21491. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21492. * @param frustumPlanes defines the frustum planes
  21493. * @returns true if the submesh is intersecting with the frustum
  21494. */
  21495. isInFrustum(frustumPlanes: Plane[]): boolean;
  21496. /**
  21497. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21498. * @param frustumPlanes defines the frustum planes
  21499. * @returns true if the submesh is inside the frustum
  21500. */
  21501. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21502. /**
  21503. * Renders the submesh
  21504. * @param enableAlphaMode defines if alpha needs to be used
  21505. * @returns the submesh
  21506. */
  21507. render(enableAlphaMode: boolean): SubMesh;
  21508. /**
  21509. * @hidden
  21510. */
  21511. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21512. /**
  21513. * Checks if the submesh intersects with a ray
  21514. * @param ray defines the ray to test
  21515. * @returns true is the passed ray intersects the submesh bounding box
  21516. */
  21517. canIntersects(ray: Ray): boolean;
  21518. /**
  21519. * Intersects current submesh with a ray
  21520. * @param ray defines the ray to test
  21521. * @param positions defines mesh's positions array
  21522. * @param indices defines mesh's indices array
  21523. * @param fastCheck defines if only bounding info should be used
  21524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21525. * @returns intersection info or null if no intersection
  21526. */
  21527. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21528. /** @hidden */
  21529. private _intersectLines;
  21530. /** @hidden */
  21531. private _intersectUnIndexedLines;
  21532. /** @hidden */
  21533. private _intersectTriangles;
  21534. /** @hidden */
  21535. private _intersectUnIndexedTriangles;
  21536. /** @hidden */
  21537. _rebuild(): void;
  21538. /**
  21539. * Creates a new submesh from the passed mesh
  21540. * @param newMesh defines the new hosting mesh
  21541. * @param newRenderingMesh defines an optional rendering mesh
  21542. * @returns the new submesh
  21543. */
  21544. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21545. /**
  21546. * Release associated resources
  21547. */
  21548. dispose(): void;
  21549. /**
  21550. * Gets the class name
  21551. * @returns the string "SubMesh".
  21552. */
  21553. getClassName(): string;
  21554. /**
  21555. * Creates a new submesh from indices data
  21556. * @param materialIndex the index of the main mesh material
  21557. * @param startIndex the index where to start the copy in the mesh indices array
  21558. * @param indexCount the number of indices to copy then from the startIndex
  21559. * @param mesh the main mesh to create the submesh from
  21560. * @param renderingMesh the optional rendering mesh
  21561. * @returns a new submesh
  21562. */
  21563. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21564. }
  21565. }
  21566. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21567. /**
  21568. * Class used to represent data loading progression
  21569. */
  21570. export class SceneLoaderFlags {
  21571. private static _ForceFullSceneLoadingForIncremental;
  21572. private static _ShowLoadingScreen;
  21573. private static _CleanBoneMatrixWeights;
  21574. private static _loggingLevel;
  21575. /**
  21576. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21577. */
  21578. static ForceFullSceneLoadingForIncremental: boolean;
  21579. /**
  21580. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21581. */
  21582. static ShowLoadingScreen: boolean;
  21583. /**
  21584. * Defines the current logging level (while loading the scene)
  21585. * @ignorenaming
  21586. */
  21587. static loggingLevel: number;
  21588. /**
  21589. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21590. */
  21591. static CleanBoneMatrixWeights: boolean;
  21592. }
  21593. }
  21594. declare module "babylonjs/Meshes/geometry" {
  21595. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21596. import { Scene } from "babylonjs/scene";
  21597. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21598. import { Engine } from "babylonjs/Engines/engine";
  21599. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21600. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21601. import { Effect } from "babylonjs/Materials/effect";
  21602. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21603. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21604. import { Mesh } from "babylonjs/Meshes/mesh";
  21605. /**
  21606. * Class used to store geometry data (vertex buffers + index buffer)
  21607. */
  21608. export class Geometry implements IGetSetVerticesData {
  21609. /**
  21610. * Gets or sets the ID of the geometry
  21611. */
  21612. id: string;
  21613. /**
  21614. * Gets or sets the unique ID of the geometry
  21615. */
  21616. uniqueId: number;
  21617. /**
  21618. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21619. */
  21620. delayLoadState: number;
  21621. /**
  21622. * Gets the file containing the data to load when running in delay load state
  21623. */
  21624. delayLoadingFile: Nullable<string>;
  21625. /**
  21626. * Callback called when the geometry is updated
  21627. */
  21628. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21629. private _scene;
  21630. private _engine;
  21631. private _meshes;
  21632. private _totalVertices;
  21633. /** @hidden */
  21634. _indices: IndicesArray;
  21635. /** @hidden */
  21636. _vertexBuffers: {
  21637. [key: string]: VertexBuffer;
  21638. };
  21639. private _isDisposed;
  21640. private _extend;
  21641. private _boundingBias;
  21642. /** @hidden */
  21643. _delayInfo: Array<string>;
  21644. private _indexBuffer;
  21645. private _indexBufferIsUpdatable;
  21646. /** @hidden */
  21647. _boundingInfo: Nullable<BoundingInfo>;
  21648. /** @hidden */
  21649. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21650. /** @hidden */
  21651. _softwareSkinningFrameId: number;
  21652. private _vertexArrayObjects;
  21653. private _updatable;
  21654. /** @hidden */
  21655. _positions: Nullable<Vector3[]>;
  21656. /**
  21657. * 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
  21658. */
  21659. /**
  21660. * 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
  21661. */
  21662. boundingBias: Vector2;
  21663. /**
  21664. * Static function used to attach a new empty geometry to a mesh
  21665. * @param mesh defines the mesh to attach the geometry to
  21666. * @returns the new Geometry
  21667. */
  21668. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21669. /**
  21670. * Creates a new geometry
  21671. * @param id defines the unique ID
  21672. * @param scene defines the hosting scene
  21673. * @param vertexData defines the VertexData used to get geometry data
  21674. * @param updatable defines if geometry must be updatable (false by default)
  21675. * @param mesh defines the mesh that will be associated with the geometry
  21676. */
  21677. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21678. /**
  21679. * Gets the current extend of the geometry
  21680. */
  21681. readonly extend: {
  21682. minimum: Vector3;
  21683. maximum: Vector3;
  21684. };
  21685. /**
  21686. * Gets the hosting scene
  21687. * @returns the hosting Scene
  21688. */
  21689. getScene(): Scene;
  21690. /**
  21691. * Gets the hosting engine
  21692. * @returns the hosting Engine
  21693. */
  21694. getEngine(): Engine;
  21695. /**
  21696. * Defines if the geometry is ready to use
  21697. * @returns true if the geometry is ready to be used
  21698. */
  21699. isReady(): boolean;
  21700. /**
  21701. * Gets a value indicating that the geometry should not be serialized
  21702. */
  21703. readonly doNotSerialize: boolean;
  21704. /** @hidden */
  21705. _rebuild(): void;
  21706. /**
  21707. * Affects all geometry data in one call
  21708. * @param vertexData defines the geometry data
  21709. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21710. */
  21711. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21712. /**
  21713. * Set specific vertex data
  21714. * @param kind defines the data kind (Position, normal, etc...)
  21715. * @param data defines the vertex data to use
  21716. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21717. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21718. */
  21719. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21720. /**
  21721. * Removes a specific vertex data
  21722. * @param kind defines the data kind (Position, normal, etc...)
  21723. */
  21724. removeVerticesData(kind: string): void;
  21725. /**
  21726. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21727. * @param buffer defines the vertex buffer to use
  21728. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21729. */
  21730. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21731. /**
  21732. * Update a specific vertex buffer
  21733. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21734. * It will do nothing if the buffer is not updatable
  21735. * @param kind defines the data kind (Position, normal, etc...)
  21736. * @param data defines the data to use
  21737. * @param offset defines the offset in the target buffer where to store the data
  21738. * @param useBytes set to true if the offset is in bytes
  21739. */
  21740. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21741. /**
  21742. * Update a specific vertex buffer
  21743. * This function will create a new buffer if the current one is not updatable
  21744. * @param kind defines the data kind (Position, normal, etc...)
  21745. * @param data defines the data to use
  21746. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21747. */
  21748. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21749. private _updateBoundingInfo;
  21750. /** @hidden */
  21751. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21752. /**
  21753. * Gets total number of vertices
  21754. * @returns the total number of vertices
  21755. */
  21756. getTotalVertices(): number;
  21757. /**
  21758. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21759. * @param kind defines the data kind (Position, normal, etc...)
  21760. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21761. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21762. * @returns a float array containing vertex data
  21763. */
  21764. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21765. /**
  21766. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21767. * @param kind defines the data kind (Position, normal, etc...)
  21768. * @returns true if the vertex buffer with the specified kind is updatable
  21769. */
  21770. isVertexBufferUpdatable(kind: string): boolean;
  21771. /**
  21772. * Gets a specific vertex buffer
  21773. * @param kind defines the data kind (Position, normal, etc...)
  21774. * @returns a VertexBuffer
  21775. */
  21776. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21777. /**
  21778. * Returns all vertex buffers
  21779. * @return an object holding all vertex buffers indexed by kind
  21780. */
  21781. getVertexBuffers(): Nullable<{
  21782. [key: string]: VertexBuffer;
  21783. }>;
  21784. /**
  21785. * Gets a boolean indicating if specific vertex buffer is present
  21786. * @param kind defines the data kind (Position, normal, etc...)
  21787. * @returns true if data is present
  21788. */
  21789. isVerticesDataPresent(kind: string): boolean;
  21790. /**
  21791. * Gets a list of all attached data kinds (Position, normal, etc...)
  21792. * @returns a list of string containing all kinds
  21793. */
  21794. getVerticesDataKinds(): string[];
  21795. /**
  21796. * Update index buffer
  21797. * @param indices defines the indices to store in the index buffer
  21798. * @param offset defines the offset in the target buffer where to store the data
  21799. * @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)
  21800. */
  21801. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21802. /**
  21803. * Creates a new index buffer
  21804. * @param indices defines the indices to store in the index buffer
  21805. * @param totalVertices defines the total number of vertices (could be null)
  21806. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21807. */
  21808. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21809. /**
  21810. * Return the total number of indices
  21811. * @returns the total number of indices
  21812. */
  21813. getTotalIndices(): number;
  21814. /**
  21815. * Gets the index buffer array
  21816. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21817. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21818. * @returns the index buffer array
  21819. */
  21820. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21821. /**
  21822. * Gets the index buffer
  21823. * @return the index buffer
  21824. */
  21825. getIndexBuffer(): Nullable<DataBuffer>;
  21826. /** @hidden */
  21827. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21828. /**
  21829. * Release the associated resources for a specific mesh
  21830. * @param mesh defines the source mesh
  21831. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21832. */
  21833. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21834. /**
  21835. * Apply current geometry to a given mesh
  21836. * @param mesh defines the mesh to apply geometry to
  21837. */
  21838. applyToMesh(mesh: Mesh): void;
  21839. private _updateExtend;
  21840. private _applyToMesh;
  21841. private notifyUpdate;
  21842. /**
  21843. * Load the geometry if it was flagged as delay loaded
  21844. * @param scene defines the hosting scene
  21845. * @param onLoaded defines a callback called when the geometry is loaded
  21846. */
  21847. load(scene: Scene, onLoaded?: () => void): void;
  21848. private _queueLoad;
  21849. /**
  21850. * Invert the geometry to move from a right handed system to a left handed one.
  21851. */
  21852. toLeftHanded(): void;
  21853. /** @hidden */
  21854. _resetPointsArrayCache(): void;
  21855. /** @hidden */
  21856. _generatePointsArray(): boolean;
  21857. /**
  21858. * Gets a value indicating if the geometry is disposed
  21859. * @returns true if the geometry was disposed
  21860. */
  21861. isDisposed(): boolean;
  21862. private _disposeVertexArrayObjects;
  21863. /**
  21864. * Free all associated resources
  21865. */
  21866. dispose(): void;
  21867. /**
  21868. * Clone the current geometry into a new geometry
  21869. * @param id defines the unique ID of the new geometry
  21870. * @returns a new geometry object
  21871. */
  21872. copy(id: string): Geometry;
  21873. /**
  21874. * Serialize the current geometry info (and not the vertices data) into a JSON object
  21875. * @return a JSON representation of the current geometry data (without the vertices data)
  21876. */
  21877. serialize(): any;
  21878. private toNumberArray;
  21879. /**
  21880. * Serialize all vertices data into a JSON oject
  21881. * @returns a JSON representation of the current geometry data
  21882. */
  21883. serializeVerticeData(): any;
  21884. /**
  21885. * Extracts a clone of a mesh geometry
  21886. * @param mesh defines the source mesh
  21887. * @param id defines the unique ID of the new geometry object
  21888. * @returns the new geometry object
  21889. */
  21890. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  21891. /**
  21892. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  21893. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  21894. * Be aware Math.random() could cause collisions, but:
  21895. * "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"
  21896. * @returns a string containing a new GUID
  21897. */
  21898. static RandomId(): string;
  21899. /** @hidden */
  21900. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  21901. private static _CleanMatricesWeights;
  21902. /**
  21903. * Create a new geometry from persisted data (Using .babylon file format)
  21904. * @param parsedVertexData defines the persisted data
  21905. * @param scene defines the hosting scene
  21906. * @param rootUrl defines the root url to use to load assets (like delayed data)
  21907. * @returns the new geometry object
  21908. */
  21909. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  21910. }
  21911. }
  21912. declare module "babylonjs/Meshes/mesh.vertexData" {
  21913. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21914. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  21915. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  21916. import { Geometry } from "babylonjs/Meshes/geometry";
  21917. import { Mesh } from "babylonjs/Meshes/mesh";
  21918. /**
  21919. * Define an interface for all classes that will get and set the data on vertices
  21920. */
  21921. export interface IGetSetVerticesData {
  21922. /**
  21923. * Gets a boolean indicating if specific vertex data is present
  21924. * @param kind defines the vertex data kind to use
  21925. * @returns true is data kind is present
  21926. */
  21927. isVerticesDataPresent(kind: string): boolean;
  21928. /**
  21929. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21930. * @param kind defines the data kind (Position, normal, etc...)
  21931. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21932. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21933. * @returns a float array containing vertex data
  21934. */
  21935. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21936. /**
  21937. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21938. * @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.
  21939. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21940. * @returns the indices array or an empty array if the mesh has no geometry
  21941. */
  21942. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21943. /**
  21944. * Set specific vertex data
  21945. * @param kind defines the data kind (Position, normal, etc...)
  21946. * @param data defines the vertex data to use
  21947. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21948. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21949. */
  21950. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  21951. /**
  21952. * Update a specific associated vertex buffer
  21953. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21954. * - VertexBuffer.PositionKind
  21955. * - VertexBuffer.UVKind
  21956. * - VertexBuffer.UV2Kind
  21957. * - VertexBuffer.UV3Kind
  21958. * - VertexBuffer.UV4Kind
  21959. * - VertexBuffer.UV5Kind
  21960. * - VertexBuffer.UV6Kind
  21961. * - VertexBuffer.ColorKind
  21962. * - VertexBuffer.MatricesIndicesKind
  21963. * - VertexBuffer.MatricesIndicesExtraKind
  21964. * - VertexBuffer.MatricesWeightsKind
  21965. * - VertexBuffer.MatricesWeightsExtraKind
  21966. * @param data defines the data source
  21967. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21968. * @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)
  21969. */
  21970. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  21971. /**
  21972. * Creates a new index buffer
  21973. * @param indices defines the indices to store in the index buffer
  21974. * @param totalVertices defines the total number of vertices (could be null)
  21975. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21976. */
  21977. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  21978. }
  21979. /**
  21980. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  21981. */
  21982. export class VertexData {
  21983. /**
  21984. * Mesh side orientation : usually the external or front surface
  21985. */
  21986. static readonly FRONTSIDE: number;
  21987. /**
  21988. * Mesh side orientation : usually the internal or back surface
  21989. */
  21990. static readonly BACKSIDE: number;
  21991. /**
  21992. * Mesh side orientation : both internal and external or front and back surfaces
  21993. */
  21994. static readonly DOUBLESIDE: number;
  21995. /**
  21996. * Mesh side orientation : by default, `FRONTSIDE`
  21997. */
  21998. static readonly DEFAULTSIDE: number;
  21999. /**
  22000. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22001. */
  22002. positions: Nullable<FloatArray>;
  22003. /**
  22004. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22005. */
  22006. normals: Nullable<FloatArray>;
  22007. /**
  22008. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22009. */
  22010. tangents: Nullable<FloatArray>;
  22011. /**
  22012. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22013. */
  22014. uvs: Nullable<FloatArray>;
  22015. /**
  22016. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22017. */
  22018. uvs2: Nullable<FloatArray>;
  22019. /**
  22020. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22021. */
  22022. uvs3: Nullable<FloatArray>;
  22023. /**
  22024. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22025. */
  22026. uvs4: Nullable<FloatArray>;
  22027. /**
  22028. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22029. */
  22030. uvs5: Nullable<FloatArray>;
  22031. /**
  22032. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22033. */
  22034. uvs6: Nullable<FloatArray>;
  22035. /**
  22036. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22037. */
  22038. colors: Nullable<FloatArray>;
  22039. /**
  22040. * 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).
  22041. */
  22042. matricesIndices: Nullable<FloatArray>;
  22043. /**
  22044. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22045. */
  22046. matricesWeights: Nullable<FloatArray>;
  22047. /**
  22048. * An array extending the number of possible indices
  22049. */
  22050. matricesIndicesExtra: Nullable<FloatArray>;
  22051. /**
  22052. * An array extending the number of possible weights when the number of indices is extended
  22053. */
  22054. matricesWeightsExtra: Nullable<FloatArray>;
  22055. /**
  22056. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22057. */
  22058. indices: Nullable<IndicesArray>;
  22059. /**
  22060. * Uses the passed data array to set the set the values for the specified kind of data
  22061. * @param data a linear array of floating numbers
  22062. * @param kind the type of data that is being set, eg positions, colors etc
  22063. */
  22064. set(data: FloatArray, kind: string): void;
  22065. /**
  22066. * Associates the vertexData to the passed Mesh.
  22067. * Sets it as updatable or not (default `false`)
  22068. * @param mesh the mesh the vertexData is applied to
  22069. * @param updatable when used and having the value true allows new data to update the vertexData
  22070. * @returns the VertexData
  22071. */
  22072. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22073. /**
  22074. * Associates the vertexData to the passed Geometry.
  22075. * Sets it as updatable or not (default `false`)
  22076. * @param geometry the geometry the vertexData is applied to
  22077. * @param updatable when used and having the value true allows new data to update the vertexData
  22078. * @returns VertexData
  22079. */
  22080. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22081. /**
  22082. * Updates the associated mesh
  22083. * @param mesh the mesh to be updated
  22084. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22085. * @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
  22086. * @returns VertexData
  22087. */
  22088. updateMesh(mesh: Mesh): VertexData;
  22089. /**
  22090. * Updates the associated geometry
  22091. * @param geometry the geometry to be updated
  22092. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22093. * @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
  22094. * @returns VertexData.
  22095. */
  22096. updateGeometry(geometry: Geometry): VertexData;
  22097. private _applyTo;
  22098. private _update;
  22099. /**
  22100. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22101. * @param matrix the transforming matrix
  22102. * @returns the VertexData
  22103. */
  22104. transform(matrix: Matrix): VertexData;
  22105. /**
  22106. * Merges the passed VertexData into the current one
  22107. * @param other the VertexData to be merged into the current one
  22108. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22109. * @returns the modified VertexData
  22110. */
  22111. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22112. private _mergeElement;
  22113. private _validate;
  22114. /**
  22115. * Serializes the VertexData
  22116. * @returns a serialized object
  22117. */
  22118. serialize(): any;
  22119. /**
  22120. * Extracts the vertexData from a mesh
  22121. * @param mesh the mesh from which to extract the VertexData
  22122. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22123. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22124. * @returns the object VertexData associated to the passed mesh
  22125. */
  22126. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22127. /**
  22128. * Extracts the vertexData from the geometry
  22129. * @param geometry the geometry from which to extract the VertexData
  22130. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22131. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22132. * @returns the object VertexData associated to the passed mesh
  22133. */
  22134. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22135. private static _ExtractFrom;
  22136. /**
  22137. * Creates the VertexData for a Ribbon
  22138. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22139. * * pathArray array of paths, each of which an array of successive Vector3
  22140. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22141. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22142. * * 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
  22143. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22144. * * 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)
  22145. * * 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)
  22146. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22147. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22148. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22149. * @returns the VertexData of the ribbon
  22150. */
  22151. static CreateRibbon(options: {
  22152. pathArray: Vector3[][];
  22153. closeArray?: boolean;
  22154. closePath?: boolean;
  22155. offset?: number;
  22156. sideOrientation?: number;
  22157. frontUVs?: Vector4;
  22158. backUVs?: Vector4;
  22159. invertUV?: boolean;
  22160. uvs?: Vector2[];
  22161. colors?: Color4[];
  22162. }): VertexData;
  22163. /**
  22164. * Creates the VertexData for a box
  22165. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22166. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22167. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22168. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22169. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22170. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22171. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22172. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22173. * * 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)
  22174. * * 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)
  22175. * @returns the VertexData of the box
  22176. */
  22177. static CreateBox(options: {
  22178. size?: number;
  22179. width?: number;
  22180. height?: number;
  22181. depth?: number;
  22182. faceUV?: Vector4[];
  22183. faceColors?: Color4[];
  22184. sideOrientation?: number;
  22185. frontUVs?: Vector4;
  22186. backUVs?: Vector4;
  22187. }): VertexData;
  22188. /**
  22189. * Creates the VertexData for a tiled box
  22190. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22191. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22192. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22193. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22194. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22195. * @returns the VertexData of the box
  22196. */
  22197. static CreateTiledBox(options: {
  22198. pattern?: number;
  22199. width?: number;
  22200. height?: number;
  22201. depth?: number;
  22202. tileSize?: number;
  22203. tileWidth?: number;
  22204. tileHeight?: number;
  22205. alignHorizontal?: number;
  22206. alignVertical?: number;
  22207. faceUV?: Vector4[];
  22208. faceColors?: Color4[];
  22209. sideOrientation?: number;
  22210. }): VertexData;
  22211. /**
  22212. * Creates the VertexData for a tiled plane
  22213. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22214. * * pattern a limited pattern arrangement depending on the number
  22215. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22216. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22217. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22218. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22219. * * 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)
  22220. * * 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)
  22221. * @returns the VertexData of the tiled plane
  22222. */
  22223. static CreateTiledPlane(options: {
  22224. pattern?: number;
  22225. tileSize?: number;
  22226. tileWidth?: number;
  22227. tileHeight?: number;
  22228. size?: number;
  22229. width?: number;
  22230. height?: number;
  22231. alignHorizontal?: number;
  22232. alignVertical?: number;
  22233. sideOrientation?: number;
  22234. frontUVs?: Vector4;
  22235. backUVs?: Vector4;
  22236. }): VertexData;
  22237. /**
  22238. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22239. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22240. * * segments sets the number of horizontal strips optional, default 32
  22241. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22242. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22243. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22244. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22245. * * 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
  22246. * * 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
  22247. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22248. * * 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)
  22249. * * 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)
  22250. * @returns the VertexData of the ellipsoid
  22251. */
  22252. static CreateSphere(options: {
  22253. segments?: number;
  22254. diameter?: number;
  22255. diameterX?: number;
  22256. diameterY?: number;
  22257. diameterZ?: number;
  22258. arc?: number;
  22259. slice?: number;
  22260. sideOrientation?: number;
  22261. frontUVs?: Vector4;
  22262. backUVs?: Vector4;
  22263. }): VertexData;
  22264. /**
  22265. * Creates the VertexData for a cylinder, cone or prism
  22266. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22267. * * height sets the height (y direction) of the cylinder, optional, default 2
  22268. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22269. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22270. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22271. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22272. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22273. * * 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
  22274. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22275. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22276. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22277. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22278. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22279. * * 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)
  22280. * * 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)
  22281. * @returns the VertexData of the cylinder, cone or prism
  22282. */
  22283. static CreateCylinder(options: {
  22284. height?: number;
  22285. diameterTop?: number;
  22286. diameterBottom?: number;
  22287. diameter?: number;
  22288. tessellation?: number;
  22289. subdivisions?: number;
  22290. arc?: number;
  22291. faceColors?: Color4[];
  22292. faceUV?: Vector4[];
  22293. hasRings?: boolean;
  22294. enclose?: boolean;
  22295. sideOrientation?: number;
  22296. frontUVs?: Vector4;
  22297. backUVs?: Vector4;
  22298. }): VertexData;
  22299. /**
  22300. * Creates the VertexData for a torus
  22301. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22302. * * diameter the diameter of the torus, optional default 1
  22303. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22304. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22305. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22306. * * 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)
  22307. * * 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)
  22308. * @returns the VertexData of the torus
  22309. */
  22310. static CreateTorus(options: {
  22311. diameter?: number;
  22312. thickness?: number;
  22313. tessellation?: number;
  22314. sideOrientation?: number;
  22315. frontUVs?: Vector4;
  22316. backUVs?: Vector4;
  22317. }): VertexData;
  22318. /**
  22319. * Creates the VertexData of the LineSystem
  22320. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22321. * - lines an array of lines, each line being an array of successive Vector3
  22322. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22323. * @returns the VertexData of the LineSystem
  22324. */
  22325. static CreateLineSystem(options: {
  22326. lines: Vector3[][];
  22327. colors?: Nullable<Color4[][]>;
  22328. }): VertexData;
  22329. /**
  22330. * Create the VertexData for a DashedLines
  22331. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22332. * - points an array successive Vector3
  22333. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22334. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22335. * - dashNb the intended total number of dashes, optional, default 200
  22336. * @returns the VertexData for the DashedLines
  22337. */
  22338. static CreateDashedLines(options: {
  22339. points: Vector3[];
  22340. dashSize?: number;
  22341. gapSize?: number;
  22342. dashNb?: number;
  22343. }): VertexData;
  22344. /**
  22345. * Creates the VertexData for a Ground
  22346. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22347. * - width the width (x direction) of the ground, optional, default 1
  22348. * - height the height (z direction) of the ground, optional, default 1
  22349. * - subdivisions the number of subdivisions per side, optional, default 1
  22350. * @returns the VertexData of the Ground
  22351. */
  22352. static CreateGround(options: {
  22353. width?: number;
  22354. height?: number;
  22355. subdivisions?: number;
  22356. subdivisionsX?: number;
  22357. subdivisionsY?: number;
  22358. }): VertexData;
  22359. /**
  22360. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22361. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22362. * * xmin the ground minimum X coordinate, optional, default -1
  22363. * * zmin the ground minimum Z coordinate, optional, default -1
  22364. * * xmax the ground maximum X coordinate, optional, default 1
  22365. * * zmax the ground maximum Z coordinate, optional, default 1
  22366. * * 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}
  22367. * * 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}
  22368. * @returns the VertexData of the TiledGround
  22369. */
  22370. static CreateTiledGround(options: {
  22371. xmin: number;
  22372. zmin: number;
  22373. xmax: number;
  22374. zmax: number;
  22375. subdivisions?: {
  22376. w: number;
  22377. h: number;
  22378. };
  22379. precision?: {
  22380. w: number;
  22381. h: number;
  22382. };
  22383. }): VertexData;
  22384. /**
  22385. * Creates the VertexData of the Ground designed from a heightmap
  22386. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22387. * * width the width (x direction) of the ground
  22388. * * height the height (z direction) of the ground
  22389. * * subdivisions the number of subdivisions per side
  22390. * * minHeight the minimum altitude on the ground, optional, default 0
  22391. * * maxHeight the maximum altitude on the ground, optional default 1
  22392. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22393. * * buffer the array holding the image color data
  22394. * * bufferWidth the width of image
  22395. * * bufferHeight the height of image
  22396. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22397. * @returns the VertexData of the Ground designed from a heightmap
  22398. */
  22399. static CreateGroundFromHeightMap(options: {
  22400. width: number;
  22401. height: number;
  22402. subdivisions: number;
  22403. minHeight: number;
  22404. maxHeight: number;
  22405. colorFilter: Color3;
  22406. buffer: Uint8Array;
  22407. bufferWidth: number;
  22408. bufferHeight: number;
  22409. alphaFilter: number;
  22410. }): VertexData;
  22411. /**
  22412. * Creates the VertexData for a Plane
  22413. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22414. * * size sets the width and height of the plane to the value of size, optional default 1
  22415. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22416. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22417. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22418. * * 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)
  22419. * * 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)
  22420. * @returns the VertexData of the box
  22421. */
  22422. static CreatePlane(options: {
  22423. size?: number;
  22424. width?: number;
  22425. height?: number;
  22426. sideOrientation?: number;
  22427. frontUVs?: Vector4;
  22428. backUVs?: Vector4;
  22429. }): VertexData;
  22430. /**
  22431. * Creates the VertexData of the Disc or regular Polygon
  22432. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22433. * * radius the radius of the disc, optional default 0.5
  22434. * * tessellation the number of polygon sides, optional, default 64
  22435. * * 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
  22436. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22437. * * 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)
  22438. * * 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)
  22439. * @returns the VertexData of the box
  22440. */
  22441. static CreateDisc(options: {
  22442. radius?: number;
  22443. tessellation?: number;
  22444. arc?: number;
  22445. sideOrientation?: number;
  22446. frontUVs?: Vector4;
  22447. backUVs?: Vector4;
  22448. }): VertexData;
  22449. /**
  22450. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22451. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22452. * @param polygon a mesh built from polygonTriangulation.build()
  22453. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22454. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22455. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22456. * @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)
  22457. * @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)
  22458. * @returns the VertexData of the Polygon
  22459. */
  22460. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22461. /**
  22462. * Creates the VertexData of the IcoSphere
  22463. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22464. * * radius the radius of the IcoSphere, optional default 1
  22465. * * radiusX allows stretching in the x direction, optional, default radius
  22466. * * radiusY allows stretching in the y direction, optional, default radius
  22467. * * radiusZ allows stretching in the z direction, optional, default radius
  22468. * * flat when true creates a flat shaded mesh, optional, default true
  22469. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22470. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22471. * * 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)
  22472. * * 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)
  22473. * @returns the VertexData of the IcoSphere
  22474. */
  22475. static CreateIcoSphere(options: {
  22476. radius?: number;
  22477. radiusX?: number;
  22478. radiusY?: number;
  22479. radiusZ?: number;
  22480. flat?: boolean;
  22481. subdivisions?: number;
  22482. sideOrientation?: number;
  22483. frontUVs?: Vector4;
  22484. backUVs?: Vector4;
  22485. }): VertexData;
  22486. /**
  22487. * Creates the VertexData for a Polyhedron
  22488. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22489. * * type provided types are:
  22490. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22491. * * 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)
  22492. * * size the size of the IcoSphere, optional default 1
  22493. * * sizeX allows stretching in the x direction, optional, default size
  22494. * * sizeY allows stretching in the y direction, optional, default size
  22495. * * sizeZ allows stretching in the z direction, optional, default size
  22496. * * 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
  22497. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22498. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22499. * * flat when true creates a flat shaded mesh, optional, default true
  22500. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22501. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22502. * * 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)
  22503. * * 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)
  22504. * @returns the VertexData of the Polyhedron
  22505. */
  22506. static CreatePolyhedron(options: {
  22507. type?: number;
  22508. size?: number;
  22509. sizeX?: number;
  22510. sizeY?: number;
  22511. sizeZ?: number;
  22512. custom?: any;
  22513. faceUV?: Vector4[];
  22514. faceColors?: Color4[];
  22515. flat?: boolean;
  22516. sideOrientation?: number;
  22517. frontUVs?: Vector4;
  22518. backUVs?: Vector4;
  22519. }): VertexData;
  22520. /**
  22521. * Creates the VertexData for a TorusKnot
  22522. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22523. * * radius the radius of the torus knot, optional, default 2
  22524. * * tube the thickness of the tube, optional, default 0.5
  22525. * * radialSegments the number of sides on each tube segments, optional, default 32
  22526. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22527. * * p the number of windings around the z axis, optional, default 2
  22528. * * q the number of windings around the x axis, optional, default 3
  22529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22530. * * 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)
  22531. * * 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)
  22532. * @returns the VertexData of the Torus Knot
  22533. */
  22534. static CreateTorusKnot(options: {
  22535. radius?: number;
  22536. tube?: number;
  22537. radialSegments?: number;
  22538. tubularSegments?: number;
  22539. p?: number;
  22540. q?: number;
  22541. sideOrientation?: number;
  22542. frontUVs?: Vector4;
  22543. backUVs?: Vector4;
  22544. }): VertexData;
  22545. /**
  22546. * Compute normals for given positions and indices
  22547. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22548. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22549. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22550. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22551. * * facetNormals : optional array of facet normals (vector3)
  22552. * * facetPositions : optional array of facet positions (vector3)
  22553. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22554. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22555. * * bInfo : optional bounding info, required for facetPartitioning computation
  22556. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22557. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22558. * * useRightHandedSystem: optional boolean to for right handed system computation
  22559. * * depthSort : optional boolean to enable the facet depth sort computation
  22560. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22561. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22562. */
  22563. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22564. facetNormals?: any;
  22565. facetPositions?: any;
  22566. facetPartitioning?: any;
  22567. ratio?: number;
  22568. bInfo?: any;
  22569. bbSize?: Vector3;
  22570. subDiv?: any;
  22571. useRightHandedSystem?: boolean;
  22572. depthSort?: boolean;
  22573. distanceTo?: Vector3;
  22574. depthSortedFacets?: any;
  22575. }): void;
  22576. /** @hidden */
  22577. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22578. /**
  22579. * Applies VertexData created from the imported parameters to the geometry
  22580. * @param parsedVertexData the parsed data from an imported file
  22581. * @param geometry the geometry to apply the VertexData to
  22582. */
  22583. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22584. }
  22585. }
  22586. declare module "babylonjs/Morph/morphTarget" {
  22587. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22588. import { Observable } from "babylonjs/Misc/observable";
  22589. import { Nullable, FloatArray } from "babylonjs/types";
  22590. import { Scene } from "babylonjs/scene";
  22591. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22592. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22593. /**
  22594. * Defines a target to use with MorphTargetManager
  22595. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22596. */
  22597. export class MorphTarget implements IAnimatable {
  22598. /** defines the name of the target */
  22599. name: string;
  22600. /**
  22601. * Gets or sets the list of animations
  22602. */
  22603. animations: import("babylonjs/Animations/animation").Animation[];
  22604. private _scene;
  22605. private _positions;
  22606. private _normals;
  22607. private _tangents;
  22608. private _uvs;
  22609. private _influence;
  22610. /**
  22611. * Observable raised when the influence changes
  22612. */
  22613. onInfluenceChanged: Observable<boolean>;
  22614. /** @hidden */
  22615. _onDataLayoutChanged: Observable<void>;
  22616. /**
  22617. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22618. */
  22619. influence: number;
  22620. /**
  22621. * Gets or sets the id of the morph Target
  22622. */
  22623. id: string;
  22624. private _animationPropertiesOverride;
  22625. /**
  22626. * Gets or sets the animation properties override
  22627. */
  22628. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22629. /**
  22630. * Creates a new MorphTarget
  22631. * @param name defines the name of the target
  22632. * @param influence defines the influence to use
  22633. * @param scene defines the scene the morphtarget belongs to
  22634. */
  22635. constructor(
  22636. /** defines the name of the target */
  22637. name: string, influence?: number, scene?: Nullable<Scene>);
  22638. /**
  22639. * Gets a boolean defining if the target contains position data
  22640. */
  22641. readonly hasPositions: boolean;
  22642. /**
  22643. * Gets a boolean defining if the target contains normal data
  22644. */
  22645. readonly hasNormals: boolean;
  22646. /**
  22647. * Gets a boolean defining if the target contains tangent data
  22648. */
  22649. readonly hasTangents: boolean;
  22650. /**
  22651. * Gets a boolean defining if the target contains texture coordinates data
  22652. */
  22653. readonly hasUVs: boolean;
  22654. /**
  22655. * Affects position data to this target
  22656. * @param data defines the position data to use
  22657. */
  22658. setPositions(data: Nullable<FloatArray>): void;
  22659. /**
  22660. * Gets the position data stored in this target
  22661. * @returns a FloatArray containing the position data (or null if not present)
  22662. */
  22663. getPositions(): Nullable<FloatArray>;
  22664. /**
  22665. * Affects normal data to this target
  22666. * @param data defines the normal data to use
  22667. */
  22668. setNormals(data: Nullable<FloatArray>): void;
  22669. /**
  22670. * Gets the normal data stored in this target
  22671. * @returns a FloatArray containing the normal data (or null if not present)
  22672. */
  22673. getNormals(): Nullable<FloatArray>;
  22674. /**
  22675. * Affects tangent data to this target
  22676. * @param data defines the tangent data to use
  22677. */
  22678. setTangents(data: Nullable<FloatArray>): void;
  22679. /**
  22680. * Gets the tangent data stored in this target
  22681. * @returns a FloatArray containing the tangent data (or null if not present)
  22682. */
  22683. getTangents(): Nullable<FloatArray>;
  22684. /**
  22685. * Affects texture coordinates data to this target
  22686. * @param data defines the texture coordinates data to use
  22687. */
  22688. setUVs(data: Nullable<FloatArray>): void;
  22689. /**
  22690. * Gets the texture coordinates data stored in this target
  22691. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22692. */
  22693. getUVs(): Nullable<FloatArray>;
  22694. /**
  22695. * Serializes the current target into a Serialization object
  22696. * @returns the serialized object
  22697. */
  22698. serialize(): any;
  22699. /**
  22700. * Returns the string "MorphTarget"
  22701. * @returns "MorphTarget"
  22702. */
  22703. getClassName(): string;
  22704. /**
  22705. * Creates a new target from serialized data
  22706. * @param serializationObject defines the serialized data to use
  22707. * @returns a new MorphTarget
  22708. */
  22709. static Parse(serializationObject: any): MorphTarget;
  22710. /**
  22711. * Creates a MorphTarget from mesh data
  22712. * @param mesh defines the source mesh
  22713. * @param name defines the name to use for the new target
  22714. * @param influence defines the influence to attach to the target
  22715. * @returns a new MorphTarget
  22716. */
  22717. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22718. }
  22719. }
  22720. declare module "babylonjs/Morph/morphTargetManager" {
  22721. import { Nullable } from "babylonjs/types";
  22722. import { Scene } from "babylonjs/scene";
  22723. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22724. /**
  22725. * This class is used to deform meshes using morphing between different targets
  22726. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22727. */
  22728. export class MorphTargetManager {
  22729. private _targets;
  22730. private _targetInfluenceChangedObservers;
  22731. private _targetDataLayoutChangedObservers;
  22732. private _activeTargets;
  22733. private _scene;
  22734. private _influences;
  22735. private _supportsNormals;
  22736. private _supportsTangents;
  22737. private _supportsUVs;
  22738. private _vertexCount;
  22739. private _uniqueId;
  22740. private _tempInfluences;
  22741. /**
  22742. * Gets or sets a boolean indicating if normals must be morphed
  22743. */
  22744. enableNormalMorphing: boolean;
  22745. /**
  22746. * Gets or sets a boolean indicating if tangents must be morphed
  22747. */
  22748. enableTangentMorphing: boolean;
  22749. /**
  22750. * Gets or sets a boolean indicating if UV must be morphed
  22751. */
  22752. enableUVMorphing: boolean;
  22753. /**
  22754. * Creates a new MorphTargetManager
  22755. * @param scene defines the current scene
  22756. */
  22757. constructor(scene?: Nullable<Scene>);
  22758. /**
  22759. * Gets the unique ID of this manager
  22760. */
  22761. readonly uniqueId: number;
  22762. /**
  22763. * Gets the number of vertices handled by this manager
  22764. */
  22765. readonly vertexCount: number;
  22766. /**
  22767. * Gets a boolean indicating if this manager supports morphing of normals
  22768. */
  22769. readonly supportsNormals: boolean;
  22770. /**
  22771. * Gets a boolean indicating if this manager supports morphing of tangents
  22772. */
  22773. readonly supportsTangents: boolean;
  22774. /**
  22775. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22776. */
  22777. readonly supportsUVs: boolean;
  22778. /**
  22779. * Gets the number of targets stored in this manager
  22780. */
  22781. readonly numTargets: number;
  22782. /**
  22783. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22784. */
  22785. readonly numInfluencers: number;
  22786. /**
  22787. * Gets the list of influences (one per target)
  22788. */
  22789. readonly influences: Float32Array;
  22790. /**
  22791. * Gets the active target at specified index. An active target is a target with an influence > 0
  22792. * @param index defines the index to check
  22793. * @returns the requested target
  22794. */
  22795. getActiveTarget(index: number): MorphTarget;
  22796. /**
  22797. * Gets the target at specified index
  22798. * @param index defines the index to check
  22799. * @returns the requested target
  22800. */
  22801. getTarget(index: number): MorphTarget;
  22802. /**
  22803. * Add a new target to this manager
  22804. * @param target defines the target to add
  22805. */
  22806. addTarget(target: MorphTarget): void;
  22807. /**
  22808. * Removes a target from the manager
  22809. * @param target defines the target to remove
  22810. */
  22811. removeTarget(target: MorphTarget): void;
  22812. /**
  22813. * Serializes the current manager into a Serialization object
  22814. * @returns the serialized object
  22815. */
  22816. serialize(): any;
  22817. private _syncActiveTargets;
  22818. /**
  22819. * Syncrhonize the targets with all the meshes using this morph target manager
  22820. */
  22821. synchronize(): void;
  22822. /**
  22823. * Creates a new MorphTargetManager from serialized data
  22824. * @param serializationObject defines the serialized data
  22825. * @param scene defines the hosting scene
  22826. * @returns the new MorphTargetManager
  22827. */
  22828. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22829. }
  22830. }
  22831. declare module "babylonjs/Meshes/meshLODLevel" {
  22832. import { Mesh } from "babylonjs/Meshes/mesh";
  22833. import { Nullable } from "babylonjs/types";
  22834. /**
  22835. * Class used to represent a specific level of detail of a mesh
  22836. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22837. */
  22838. export class MeshLODLevel {
  22839. /** Defines the distance where this level should start being displayed */
  22840. distance: number;
  22841. /** Defines the mesh to use to render this level */
  22842. mesh: Nullable<Mesh>;
  22843. /**
  22844. * Creates a new LOD level
  22845. * @param distance defines the distance where this level should star being displayed
  22846. * @param mesh defines the mesh to use to render this level
  22847. */
  22848. constructor(
  22849. /** Defines the distance where this level should start being displayed */
  22850. distance: number,
  22851. /** Defines the mesh to use to render this level */
  22852. mesh: Nullable<Mesh>);
  22853. }
  22854. }
  22855. declare module "babylonjs/Meshes/groundMesh" {
  22856. import { Scene } from "babylonjs/scene";
  22857. import { Vector3 } from "babylonjs/Maths/math.vector";
  22858. import { Mesh } from "babylonjs/Meshes/mesh";
  22859. /**
  22860. * Mesh representing the gorund
  22861. */
  22862. export class GroundMesh extends Mesh {
  22863. /** If octree should be generated */
  22864. generateOctree: boolean;
  22865. private _heightQuads;
  22866. /** @hidden */
  22867. _subdivisionsX: number;
  22868. /** @hidden */
  22869. _subdivisionsY: number;
  22870. /** @hidden */
  22871. _width: number;
  22872. /** @hidden */
  22873. _height: number;
  22874. /** @hidden */
  22875. _minX: number;
  22876. /** @hidden */
  22877. _maxX: number;
  22878. /** @hidden */
  22879. _minZ: number;
  22880. /** @hidden */
  22881. _maxZ: number;
  22882. constructor(name: string, scene: Scene);
  22883. /**
  22884. * "GroundMesh"
  22885. * @returns "GroundMesh"
  22886. */
  22887. getClassName(): string;
  22888. /**
  22889. * The minimum of x and y subdivisions
  22890. */
  22891. readonly subdivisions: number;
  22892. /**
  22893. * X subdivisions
  22894. */
  22895. readonly subdivisionsX: number;
  22896. /**
  22897. * Y subdivisions
  22898. */
  22899. readonly subdivisionsY: number;
  22900. /**
  22901. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  22902. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  22903. * @param chunksCount the number of subdivisions for x and y
  22904. * @param octreeBlocksSize (Default: 32)
  22905. */
  22906. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  22907. /**
  22908. * Returns a height (y) value in the Worl system :
  22909. * the ground altitude at the coordinates (x, z) expressed in the World system.
  22910. * @param x x coordinate
  22911. * @param z z coordinate
  22912. * @returns the ground y position if (x, z) are outside the ground surface.
  22913. */
  22914. getHeightAtCoordinates(x: number, z: number): number;
  22915. /**
  22916. * Returns a normalized vector (Vector3) orthogonal to the ground
  22917. * at the ground coordinates (x, z) expressed in the World system.
  22918. * @param x x coordinate
  22919. * @param z z coordinate
  22920. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  22921. */
  22922. getNormalAtCoordinates(x: number, z: number): Vector3;
  22923. /**
  22924. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  22925. * at the ground coordinates (x, z) expressed in the World system.
  22926. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  22927. * @param x x coordinate
  22928. * @param z z coordinate
  22929. * @param ref vector to store the result
  22930. * @returns the GroundMesh.
  22931. */
  22932. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  22933. /**
  22934. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  22935. * if the ground has been updated.
  22936. * This can be used in the render loop.
  22937. * @returns the GroundMesh.
  22938. */
  22939. updateCoordinateHeights(): GroundMesh;
  22940. private _getFacetAt;
  22941. private _initHeightQuads;
  22942. private _computeHeightQuads;
  22943. /**
  22944. * Serializes this ground mesh
  22945. * @param serializationObject object to write serialization to
  22946. */
  22947. serialize(serializationObject: any): void;
  22948. /**
  22949. * Parses a serialized ground mesh
  22950. * @param parsedMesh the serialized mesh
  22951. * @param scene the scene to create the ground mesh in
  22952. * @returns the created ground mesh
  22953. */
  22954. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  22955. }
  22956. }
  22957. declare module "babylonjs/Physics/physicsJoint" {
  22958. import { Vector3 } from "babylonjs/Maths/math.vector";
  22959. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  22960. /**
  22961. * Interface for Physics-Joint data
  22962. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22963. */
  22964. export interface PhysicsJointData {
  22965. /**
  22966. * The main pivot of the joint
  22967. */
  22968. mainPivot?: Vector3;
  22969. /**
  22970. * The connected pivot of the joint
  22971. */
  22972. connectedPivot?: Vector3;
  22973. /**
  22974. * The main axis of the joint
  22975. */
  22976. mainAxis?: Vector3;
  22977. /**
  22978. * The connected axis of the joint
  22979. */
  22980. connectedAxis?: Vector3;
  22981. /**
  22982. * The collision of the joint
  22983. */
  22984. collision?: boolean;
  22985. /**
  22986. * Native Oimo/Cannon/Energy data
  22987. */
  22988. nativeParams?: any;
  22989. }
  22990. /**
  22991. * This is a holder class for the physics joint created by the physics plugin
  22992. * It holds a set of functions to control the underlying joint
  22993. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22994. */
  22995. export class PhysicsJoint {
  22996. /**
  22997. * The type of the physics joint
  22998. */
  22999. type: number;
  23000. /**
  23001. * The data for the physics joint
  23002. */
  23003. jointData: PhysicsJointData;
  23004. private _physicsJoint;
  23005. protected _physicsPlugin: IPhysicsEnginePlugin;
  23006. /**
  23007. * Initializes the physics joint
  23008. * @param type The type of the physics joint
  23009. * @param jointData The data for the physics joint
  23010. */
  23011. constructor(
  23012. /**
  23013. * The type of the physics joint
  23014. */
  23015. type: number,
  23016. /**
  23017. * The data for the physics joint
  23018. */
  23019. jointData: PhysicsJointData);
  23020. /**
  23021. * Gets the physics joint
  23022. */
  23023. /**
  23024. * Sets the physics joint
  23025. */
  23026. physicsJoint: any;
  23027. /**
  23028. * Sets the physics plugin
  23029. */
  23030. physicsPlugin: IPhysicsEnginePlugin;
  23031. /**
  23032. * Execute a function that is physics-plugin specific.
  23033. * @param {Function} func the function that will be executed.
  23034. * It accepts two parameters: the physics world and the physics joint
  23035. */
  23036. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23037. /**
  23038. * Distance-Joint type
  23039. */
  23040. static DistanceJoint: number;
  23041. /**
  23042. * Hinge-Joint type
  23043. */
  23044. static HingeJoint: number;
  23045. /**
  23046. * Ball-and-Socket joint type
  23047. */
  23048. static BallAndSocketJoint: number;
  23049. /**
  23050. * Wheel-Joint type
  23051. */
  23052. static WheelJoint: number;
  23053. /**
  23054. * Slider-Joint type
  23055. */
  23056. static SliderJoint: number;
  23057. /**
  23058. * Prismatic-Joint type
  23059. */
  23060. static PrismaticJoint: number;
  23061. /**
  23062. * Universal-Joint type
  23063. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23064. */
  23065. static UniversalJoint: number;
  23066. /**
  23067. * Hinge-Joint 2 type
  23068. */
  23069. static Hinge2Joint: number;
  23070. /**
  23071. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23072. */
  23073. static PointToPointJoint: number;
  23074. /**
  23075. * Spring-Joint type
  23076. */
  23077. static SpringJoint: number;
  23078. /**
  23079. * Lock-Joint type
  23080. */
  23081. static LockJoint: number;
  23082. }
  23083. /**
  23084. * A class representing a physics distance joint
  23085. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23086. */
  23087. export class DistanceJoint extends PhysicsJoint {
  23088. /**
  23089. *
  23090. * @param jointData The data for the Distance-Joint
  23091. */
  23092. constructor(jointData: DistanceJointData);
  23093. /**
  23094. * Update the predefined distance.
  23095. * @param maxDistance The maximum preferred distance
  23096. * @param minDistance The minimum preferred distance
  23097. */
  23098. updateDistance(maxDistance: number, minDistance?: number): void;
  23099. }
  23100. /**
  23101. * Represents a Motor-Enabled Joint
  23102. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23103. */
  23104. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23105. /**
  23106. * Initializes the Motor-Enabled Joint
  23107. * @param type The type of the joint
  23108. * @param jointData The physica joint data for the joint
  23109. */
  23110. constructor(type: number, jointData: PhysicsJointData);
  23111. /**
  23112. * Set the motor values.
  23113. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23114. * @param force the force to apply
  23115. * @param maxForce max force for this motor.
  23116. */
  23117. setMotor(force?: number, maxForce?: number): void;
  23118. /**
  23119. * Set the motor's limits.
  23120. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23121. * @param upperLimit The upper limit of the motor
  23122. * @param lowerLimit The lower limit of the motor
  23123. */
  23124. setLimit(upperLimit: number, lowerLimit?: number): void;
  23125. }
  23126. /**
  23127. * This class represents a single physics Hinge-Joint
  23128. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23129. */
  23130. export class HingeJoint extends MotorEnabledJoint {
  23131. /**
  23132. * Initializes the Hinge-Joint
  23133. * @param jointData The joint data for the Hinge-Joint
  23134. */
  23135. constructor(jointData: PhysicsJointData);
  23136. /**
  23137. * Set the motor values.
  23138. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23139. * @param {number} force the force to apply
  23140. * @param {number} maxForce max force for this motor.
  23141. */
  23142. setMotor(force?: number, maxForce?: number): void;
  23143. /**
  23144. * Set the motor's limits.
  23145. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23146. * @param upperLimit The upper limit of the motor
  23147. * @param lowerLimit The lower limit of the motor
  23148. */
  23149. setLimit(upperLimit: number, lowerLimit?: number): void;
  23150. }
  23151. /**
  23152. * This class represents a dual hinge physics joint (same as wheel joint)
  23153. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23154. */
  23155. export class Hinge2Joint extends MotorEnabledJoint {
  23156. /**
  23157. * Initializes the Hinge2-Joint
  23158. * @param jointData The joint data for the Hinge2-Joint
  23159. */
  23160. constructor(jointData: PhysicsJointData);
  23161. /**
  23162. * Set the motor values.
  23163. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23164. * @param {number} targetSpeed the speed the motor is to reach
  23165. * @param {number} maxForce max force for this motor.
  23166. * @param {motorIndex} the motor's index, 0 or 1.
  23167. */
  23168. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23169. /**
  23170. * Set the motor limits.
  23171. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23172. * @param {number} upperLimit the upper limit
  23173. * @param {number} lowerLimit lower limit
  23174. * @param {motorIndex} the motor's index, 0 or 1.
  23175. */
  23176. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23177. }
  23178. /**
  23179. * Interface for a motor enabled joint
  23180. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23181. */
  23182. export interface IMotorEnabledJoint {
  23183. /**
  23184. * Physics joint
  23185. */
  23186. physicsJoint: any;
  23187. /**
  23188. * Sets the motor of the motor-enabled joint
  23189. * @param force The force of the motor
  23190. * @param maxForce The maximum force of the motor
  23191. * @param motorIndex The index of the motor
  23192. */
  23193. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23194. /**
  23195. * Sets the limit of the motor
  23196. * @param upperLimit The upper limit of the motor
  23197. * @param lowerLimit The lower limit of the motor
  23198. * @param motorIndex The index of the motor
  23199. */
  23200. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23201. }
  23202. /**
  23203. * Joint data for a Distance-Joint
  23204. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23205. */
  23206. export interface DistanceJointData extends PhysicsJointData {
  23207. /**
  23208. * Max distance the 2 joint objects can be apart
  23209. */
  23210. maxDistance: number;
  23211. }
  23212. /**
  23213. * Joint data from a spring joint
  23214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23215. */
  23216. export interface SpringJointData extends PhysicsJointData {
  23217. /**
  23218. * Length of the spring
  23219. */
  23220. length: number;
  23221. /**
  23222. * Stiffness of the spring
  23223. */
  23224. stiffness: number;
  23225. /**
  23226. * Damping of the spring
  23227. */
  23228. damping: number;
  23229. /** this callback will be called when applying the force to the impostors. */
  23230. forceApplicationCallback: () => void;
  23231. }
  23232. }
  23233. declare module "babylonjs/Physics/physicsRaycastResult" {
  23234. import { Vector3 } from "babylonjs/Maths/math.vector";
  23235. /**
  23236. * Holds the data for the raycast result
  23237. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23238. */
  23239. export class PhysicsRaycastResult {
  23240. private _hasHit;
  23241. private _hitDistance;
  23242. private _hitNormalWorld;
  23243. private _hitPointWorld;
  23244. private _rayFromWorld;
  23245. private _rayToWorld;
  23246. /**
  23247. * Gets if there was a hit
  23248. */
  23249. readonly hasHit: boolean;
  23250. /**
  23251. * Gets the distance from the hit
  23252. */
  23253. readonly hitDistance: number;
  23254. /**
  23255. * Gets the hit normal/direction in the world
  23256. */
  23257. readonly hitNormalWorld: Vector3;
  23258. /**
  23259. * Gets the hit point in the world
  23260. */
  23261. readonly hitPointWorld: Vector3;
  23262. /**
  23263. * Gets the ray "start point" of the ray in the world
  23264. */
  23265. readonly rayFromWorld: Vector3;
  23266. /**
  23267. * Gets the ray "end point" of the ray in the world
  23268. */
  23269. readonly rayToWorld: Vector3;
  23270. /**
  23271. * Sets the hit data (normal & point in world space)
  23272. * @param hitNormalWorld defines the normal in world space
  23273. * @param hitPointWorld defines the point in world space
  23274. */
  23275. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23276. /**
  23277. * Sets the distance from the start point to the hit point
  23278. * @param distance
  23279. */
  23280. setHitDistance(distance: number): void;
  23281. /**
  23282. * Calculates the distance manually
  23283. */
  23284. calculateHitDistance(): void;
  23285. /**
  23286. * Resets all the values to default
  23287. * @param from The from point on world space
  23288. * @param to The to point on world space
  23289. */
  23290. reset(from?: Vector3, to?: Vector3): void;
  23291. }
  23292. /**
  23293. * Interface for the size containing width and height
  23294. */
  23295. interface IXYZ {
  23296. /**
  23297. * X
  23298. */
  23299. x: number;
  23300. /**
  23301. * Y
  23302. */
  23303. y: number;
  23304. /**
  23305. * Z
  23306. */
  23307. z: number;
  23308. }
  23309. }
  23310. declare module "babylonjs/Physics/IPhysicsEngine" {
  23311. import { Nullable } from "babylonjs/types";
  23312. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23314. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23315. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23316. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23317. /**
  23318. * Interface used to describe a physics joint
  23319. */
  23320. export interface PhysicsImpostorJoint {
  23321. /** Defines the main impostor to which the joint is linked */
  23322. mainImpostor: PhysicsImpostor;
  23323. /** Defines the impostor that is connected to the main impostor using this joint */
  23324. connectedImpostor: PhysicsImpostor;
  23325. /** Defines the joint itself */
  23326. joint: PhysicsJoint;
  23327. }
  23328. /** @hidden */
  23329. export interface IPhysicsEnginePlugin {
  23330. world: any;
  23331. name: string;
  23332. setGravity(gravity: Vector3): void;
  23333. setTimeStep(timeStep: number): void;
  23334. getTimeStep(): number;
  23335. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23336. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23337. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23338. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23339. removePhysicsBody(impostor: PhysicsImpostor): void;
  23340. generateJoint(joint: PhysicsImpostorJoint): void;
  23341. removeJoint(joint: PhysicsImpostorJoint): void;
  23342. isSupported(): boolean;
  23343. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23344. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23345. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23346. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23347. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23348. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23349. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23350. getBodyMass(impostor: PhysicsImpostor): number;
  23351. getBodyFriction(impostor: PhysicsImpostor): number;
  23352. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23353. getBodyRestitution(impostor: PhysicsImpostor): number;
  23354. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23355. getBodyPressure?(impostor: PhysicsImpostor): number;
  23356. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23357. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23358. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23359. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23360. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23361. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23362. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23363. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23364. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23365. sleepBody(impostor: PhysicsImpostor): void;
  23366. wakeUpBody(impostor: PhysicsImpostor): void;
  23367. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23368. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23369. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23370. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23371. getRadius(impostor: PhysicsImpostor): number;
  23372. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23373. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23374. dispose(): void;
  23375. }
  23376. /**
  23377. * Interface used to define a physics engine
  23378. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23379. */
  23380. export interface IPhysicsEngine {
  23381. /**
  23382. * Gets the gravity vector used by the simulation
  23383. */
  23384. gravity: Vector3;
  23385. /**
  23386. * Sets the gravity vector used by the simulation
  23387. * @param gravity defines the gravity vector to use
  23388. */
  23389. setGravity(gravity: Vector3): void;
  23390. /**
  23391. * Set the time step of the physics engine.
  23392. * Default is 1/60.
  23393. * To slow it down, enter 1/600 for example.
  23394. * To speed it up, 1/30
  23395. * @param newTimeStep the new timestep to apply to this world.
  23396. */
  23397. setTimeStep(newTimeStep: number): void;
  23398. /**
  23399. * Get the time step of the physics engine.
  23400. * @returns the current time step
  23401. */
  23402. getTimeStep(): number;
  23403. /**
  23404. * Release all resources
  23405. */
  23406. dispose(): void;
  23407. /**
  23408. * Gets the name of the current physics plugin
  23409. * @returns the name of the plugin
  23410. */
  23411. getPhysicsPluginName(): string;
  23412. /**
  23413. * Adding a new impostor for the impostor tracking.
  23414. * This will be done by the impostor itself.
  23415. * @param impostor the impostor to add
  23416. */
  23417. addImpostor(impostor: PhysicsImpostor): void;
  23418. /**
  23419. * Remove an impostor from the engine.
  23420. * This impostor and its mesh will not longer be updated by the physics engine.
  23421. * @param impostor the impostor to remove
  23422. */
  23423. removeImpostor(impostor: PhysicsImpostor): void;
  23424. /**
  23425. * Add a joint to the physics engine
  23426. * @param mainImpostor defines the main impostor to which the joint is added.
  23427. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23428. * @param joint defines the joint that will connect both impostors.
  23429. */
  23430. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23431. /**
  23432. * Removes a joint from the simulation
  23433. * @param mainImpostor defines the impostor used with the joint
  23434. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23435. * @param joint defines the joint to remove
  23436. */
  23437. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23438. /**
  23439. * Gets the current plugin used to run the simulation
  23440. * @returns current plugin
  23441. */
  23442. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23443. /**
  23444. * Gets the list of physic impostors
  23445. * @returns an array of PhysicsImpostor
  23446. */
  23447. getImpostors(): Array<PhysicsImpostor>;
  23448. /**
  23449. * Gets the impostor for a physics enabled object
  23450. * @param object defines the object impersonated by the impostor
  23451. * @returns the PhysicsImpostor or null if not found
  23452. */
  23453. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23454. /**
  23455. * Gets the impostor for a physics body object
  23456. * @param body defines physics body used by the impostor
  23457. * @returns the PhysicsImpostor or null if not found
  23458. */
  23459. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23460. /**
  23461. * Does a raycast in the physics world
  23462. * @param from when should the ray start?
  23463. * @param to when should the ray end?
  23464. * @returns PhysicsRaycastResult
  23465. */
  23466. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23467. /**
  23468. * Called by the scene. No need to call it.
  23469. * @param delta defines the timespam between frames
  23470. */
  23471. _step(delta: number): void;
  23472. }
  23473. }
  23474. declare module "babylonjs/Physics/physicsImpostor" {
  23475. import { Nullable, IndicesArray } from "babylonjs/types";
  23476. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23477. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23478. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23479. import { Scene } from "babylonjs/scene";
  23480. import { Bone } from "babylonjs/Bones/bone";
  23481. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23482. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23483. import { Space } from "babylonjs/Maths/math.axis";
  23484. /**
  23485. * The interface for the physics imposter parameters
  23486. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23487. */
  23488. export interface PhysicsImpostorParameters {
  23489. /**
  23490. * The mass of the physics imposter
  23491. */
  23492. mass: number;
  23493. /**
  23494. * The friction of the physics imposter
  23495. */
  23496. friction?: number;
  23497. /**
  23498. * The coefficient of restitution of the physics imposter
  23499. */
  23500. restitution?: number;
  23501. /**
  23502. * The native options of the physics imposter
  23503. */
  23504. nativeOptions?: any;
  23505. /**
  23506. * Specifies if the parent should be ignored
  23507. */
  23508. ignoreParent?: boolean;
  23509. /**
  23510. * Specifies if bi-directional transformations should be disabled
  23511. */
  23512. disableBidirectionalTransformation?: boolean;
  23513. /**
  23514. * The pressure inside the physics imposter, soft object only
  23515. */
  23516. pressure?: number;
  23517. /**
  23518. * The stiffness the physics imposter, soft object only
  23519. */
  23520. stiffness?: number;
  23521. /**
  23522. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23523. */
  23524. velocityIterations?: number;
  23525. /**
  23526. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23527. */
  23528. positionIterations?: number;
  23529. /**
  23530. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23531. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23532. * Add to fix multiple points
  23533. */
  23534. fixedPoints?: number;
  23535. /**
  23536. * The collision margin around a soft object
  23537. */
  23538. margin?: number;
  23539. /**
  23540. * The collision margin around a soft object
  23541. */
  23542. damping?: number;
  23543. /**
  23544. * The path for a rope based on an extrusion
  23545. */
  23546. path?: any;
  23547. /**
  23548. * The shape of an extrusion used for a rope based on an extrusion
  23549. */
  23550. shape?: any;
  23551. }
  23552. /**
  23553. * Interface for a physics-enabled object
  23554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23555. */
  23556. export interface IPhysicsEnabledObject {
  23557. /**
  23558. * The position of the physics-enabled object
  23559. */
  23560. position: Vector3;
  23561. /**
  23562. * The rotation of the physics-enabled object
  23563. */
  23564. rotationQuaternion: Nullable<Quaternion>;
  23565. /**
  23566. * The scale of the physics-enabled object
  23567. */
  23568. scaling: Vector3;
  23569. /**
  23570. * The rotation of the physics-enabled object
  23571. */
  23572. rotation?: Vector3;
  23573. /**
  23574. * The parent of the physics-enabled object
  23575. */
  23576. parent?: any;
  23577. /**
  23578. * The bounding info of the physics-enabled object
  23579. * @returns The bounding info of the physics-enabled object
  23580. */
  23581. getBoundingInfo(): BoundingInfo;
  23582. /**
  23583. * Computes the world matrix
  23584. * @param force Specifies if the world matrix should be computed by force
  23585. * @returns A world matrix
  23586. */
  23587. computeWorldMatrix(force: boolean): Matrix;
  23588. /**
  23589. * Gets the world matrix
  23590. * @returns A world matrix
  23591. */
  23592. getWorldMatrix?(): Matrix;
  23593. /**
  23594. * Gets the child meshes
  23595. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23596. * @returns An array of abstract meshes
  23597. */
  23598. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23599. /**
  23600. * Gets the vertex data
  23601. * @param kind The type of vertex data
  23602. * @returns A nullable array of numbers, or a float32 array
  23603. */
  23604. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23605. /**
  23606. * Gets the indices from the mesh
  23607. * @returns A nullable array of index arrays
  23608. */
  23609. getIndices?(): Nullable<IndicesArray>;
  23610. /**
  23611. * Gets the scene from the mesh
  23612. * @returns the indices array or null
  23613. */
  23614. getScene?(): Scene;
  23615. /**
  23616. * Gets the absolute position from the mesh
  23617. * @returns the absolute position
  23618. */
  23619. getAbsolutePosition(): Vector3;
  23620. /**
  23621. * Gets the absolute pivot point from the mesh
  23622. * @returns the absolute pivot point
  23623. */
  23624. getAbsolutePivotPoint(): Vector3;
  23625. /**
  23626. * Rotates the mesh
  23627. * @param axis The axis of rotation
  23628. * @param amount The amount of rotation
  23629. * @param space The space of the rotation
  23630. * @returns The rotation transform node
  23631. */
  23632. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23633. /**
  23634. * Translates the mesh
  23635. * @param axis The axis of translation
  23636. * @param distance The distance of translation
  23637. * @param space The space of the translation
  23638. * @returns The transform node
  23639. */
  23640. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23641. /**
  23642. * Sets the absolute position of the mesh
  23643. * @param absolutePosition The absolute position of the mesh
  23644. * @returns The transform node
  23645. */
  23646. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23647. /**
  23648. * Gets the class name of the mesh
  23649. * @returns The class name
  23650. */
  23651. getClassName(): string;
  23652. }
  23653. /**
  23654. * Represents a physics imposter
  23655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23656. */
  23657. export class PhysicsImpostor {
  23658. /**
  23659. * The physics-enabled object used as the physics imposter
  23660. */
  23661. object: IPhysicsEnabledObject;
  23662. /**
  23663. * The type of the physics imposter
  23664. */
  23665. type: number;
  23666. private _options;
  23667. private _scene?;
  23668. /**
  23669. * The default object size of the imposter
  23670. */
  23671. static DEFAULT_OBJECT_SIZE: Vector3;
  23672. /**
  23673. * The identity quaternion of the imposter
  23674. */
  23675. static IDENTITY_QUATERNION: Quaternion;
  23676. /** @hidden */
  23677. _pluginData: any;
  23678. private _physicsEngine;
  23679. private _physicsBody;
  23680. private _bodyUpdateRequired;
  23681. private _onBeforePhysicsStepCallbacks;
  23682. private _onAfterPhysicsStepCallbacks;
  23683. /** @hidden */
  23684. _onPhysicsCollideCallbacks: Array<{
  23685. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23686. otherImpostors: Array<PhysicsImpostor>;
  23687. }>;
  23688. private _deltaPosition;
  23689. private _deltaRotation;
  23690. private _deltaRotationConjugated;
  23691. /** @hidden */
  23692. _isFromLine: boolean;
  23693. private _parent;
  23694. private _isDisposed;
  23695. private static _tmpVecs;
  23696. private static _tmpQuat;
  23697. /**
  23698. * Specifies if the physics imposter is disposed
  23699. */
  23700. readonly isDisposed: boolean;
  23701. /**
  23702. * Gets the mass of the physics imposter
  23703. */
  23704. mass: number;
  23705. /**
  23706. * Gets the coefficient of friction
  23707. */
  23708. /**
  23709. * Sets the coefficient of friction
  23710. */
  23711. friction: number;
  23712. /**
  23713. * Gets the coefficient of restitution
  23714. */
  23715. /**
  23716. * Sets the coefficient of restitution
  23717. */
  23718. restitution: number;
  23719. /**
  23720. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23721. */
  23722. /**
  23723. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23724. */
  23725. pressure: number;
  23726. /**
  23727. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23728. */
  23729. /**
  23730. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23731. */
  23732. stiffness: number;
  23733. /**
  23734. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23735. */
  23736. /**
  23737. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23738. */
  23739. velocityIterations: number;
  23740. /**
  23741. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23742. */
  23743. /**
  23744. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23745. */
  23746. positionIterations: number;
  23747. /**
  23748. * The unique id of the physics imposter
  23749. * set by the physics engine when adding this impostor to the array
  23750. */
  23751. uniqueId: number;
  23752. /**
  23753. * @hidden
  23754. */
  23755. soft: boolean;
  23756. /**
  23757. * @hidden
  23758. */
  23759. segments: number;
  23760. private _joints;
  23761. /**
  23762. * Initializes the physics imposter
  23763. * @param object The physics-enabled object used as the physics imposter
  23764. * @param type The type of the physics imposter
  23765. * @param _options The options for the physics imposter
  23766. * @param _scene The Babylon scene
  23767. */
  23768. constructor(
  23769. /**
  23770. * The physics-enabled object used as the physics imposter
  23771. */
  23772. object: IPhysicsEnabledObject,
  23773. /**
  23774. * The type of the physics imposter
  23775. */
  23776. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23777. /**
  23778. * This function will completly initialize this impostor.
  23779. * It will create a new body - but only if this mesh has no parent.
  23780. * If it has, this impostor will not be used other than to define the impostor
  23781. * of the child mesh.
  23782. * @hidden
  23783. */
  23784. _init(): void;
  23785. private _getPhysicsParent;
  23786. /**
  23787. * Should a new body be generated.
  23788. * @returns boolean specifying if body initialization is required
  23789. */
  23790. isBodyInitRequired(): boolean;
  23791. /**
  23792. * Sets the updated scaling
  23793. * @param updated Specifies if the scaling is updated
  23794. */
  23795. setScalingUpdated(): void;
  23796. /**
  23797. * Force a regeneration of this or the parent's impostor's body.
  23798. * Use under cautious - This will remove all joints already implemented.
  23799. */
  23800. forceUpdate(): void;
  23801. /**
  23802. * Gets the body that holds this impostor. Either its own, or its parent.
  23803. */
  23804. /**
  23805. * Set the physics body. Used mainly by the physics engine/plugin
  23806. */
  23807. physicsBody: any;
  23808. /**
  23809. * Get the parent of the physics imposter
  23810. * @returns Physics imposter or null
  23811. */
  23812. /**
  23813. * Sets the parent of the physics imposter
  23814. */
  23815. parent: Nullable<PhysicsImpostor>;
  23816. /**
  23817. * Resets the update flags
  23818. */
  23819. resetUpdateFlags(): void;
  23820. /**
  23821. * Gets the object extend size
  23822. * @returns the object extend size
  23823. */
  23824. getObjectExtendSize(): Vector3;
  23825. /**
  23826. * Gets the object center
  23827. * @returns The object center
  23828. */
  23829. getObjectCenter(): Vector3;
  23830. /**
  23831. * Get a specific parametes from the options parameter
  23832. * @param paramName The object parameter name
  23833. * @returns The object parameter
  23834. */
  23835. getParam(paramName: string): any;
  23836. /**
  23837. * Sets a specific parameter in the options given to the physics plugin
  23838. * @param paramName The parameter name
  23839. * @param value The value of the parameter
  23840. */
  23841. setParam(paramName: string, value: number): void;
  23842. /**
  23843. * Specifically change the body's mass option. Won't recreate the physics body object
  23844. * @param mass The mass of the physics imposter
  23845. */
  23846. setMass(mass: number): void;
  23847. /**
  23848. * Gets the linear velocity
  23849. * @returns linear velocity or null
  23850. */
  23851. getLinearVelocity(): Nullable<Vector3>;
  23852. /**
  23853. * Sets the linear velocity
  23854. * @param velocity linear velocity or null
  23855. */
  23856. setLinearVelocity(velocity: Nullable<Vector3>): void;
  23857. /**
  23858. * Gets the angular velocity
  23859. * @returns angular velocity or null
  23860. */
  23861. getAngularVelocity(): Nullable<Vector3>;
  23862. /**
  23863. * Sets the angular velocity
  23864. * @param velocity The velocity or null
  23865. */
  23866. setAngularVelocity(velocity: Nullable<Vector3>): void;
  23867. /**
  23868. * Execute a function with the physics plugin native code
  23869. * Provide a function the will have two variables - the world object and the physics body object
  23870. * @param func The function to execute with the physics plugin native code
  23871. */
  23872. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  23873. /**
  23874. * Register a function that will be executed before the physics world is stepping forward
  23875. * @param func The function to execute before the physics world is stepped forward
  23876. */
  23877. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23878. /**
  23879. * Unregister a function that will be executed before the physics world is stepping forward
  23880. * @param func The function to execute before the physics world is stepped forward
  23881. */
  23882. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23883. /**
  23884. * Register a function that will be executed after the physics step
  23885. * @param func The function to execute after physics step
  23886. */
  23887. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23888. /**
  23889. * Unregisters a function that will be executed after the physics step
  23890. * @param func The function to execute after physics step
  23891. */
  23892. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  23893. /**
  23894. * register a function that will be executed when this impostor collides against a different body
  23895. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  23896. * @param func Callback that is executed on collision
  23897. */
  23898. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  23899. /**
  23900. * Unregisters the physics imposter on contact
  23901. * @param collideAgainst The physics object to collide against
  23902. * @param func Callback to execute on collision
  23903. */
  23904. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  23905. private _tmpQuat;
  23906. private _tmpQuat2;
  23907. /**
  23908. * Get the parent rotation
  23909. * @returns The parent rotation
  23910. */
  23911. getParentsRotation(): Quaternion;
  23912. /**
  23913. * this function is executed by the physics engine.
  23914. */
  23915. beforeStep: () => void;
  23916. /**
  23917. * this function is executed by the physics engine
  23918. */
  23919. afterStep: () => void;
  23920. /**
  23921. * Legacy collision detection event support
  23922. */
  23923. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  23924. /**
  23925. * event and body object due to cannon's event-based architecture.
  23926. */
  23927. onCollide: (e: {
  23928. body: any;
  23929. }) => void;
  23930. /**
  23931. * Apply a force
  23932. * @param force The force to apply
  23933. * @param contactPoint The contact point for the force
  23934. * @returns The physics imposter
  23935. */
  23936. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23937. /**
  23938. * Apply an impulse
  23939. * @param force The impulse force
  23940. * @param contactPoint The contact point for the impulse force
  23941. * @returns The physics imposter
  23942. */
  23943. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  23944. /**
  23945. * A help function to create a joint
  23946. * @param otherImpostor A physics imposter used to create a joint
  23947. * @param jointType The type of joint
  23948. * @param jointData The data for the joint
  23949. * @returns The physics imposter
  23950. */
  23951. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  23952. /**
  23953. * Add a joint to this impostor with a different impostor
  23954. * @param otherImpostor A physics imposter used to add a joint
  23955. * @param joint The joint to add
  23956. * @returns The physics imposter
  23957. */
  23958. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  23959. /**
  23960. * Add an anchor to a cloth impostor
  23961. * @param otherImpostor rigid impostor to anchor to
  23962. * @param width ratio across width from 0 to 1
  23963. * @param height ratio up height from 0 to 1
  23964. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  23965. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  23966. * @returns impostor the soft imposter
  23967. */
  23968. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23969. /**
  23970. * Add a hook to a rope impostor
  23971. * @param otherImpostor rigid impostor to anchor to
  23972. * @param length ratio across rope from 0 to 1
  23973. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  23974. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  23975. * @returns impostor the rope imposter
  23976. */
  23977. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  23978. /**
  23979. * Will keep this body still, in a sleep mode.
  23980. * @returns the physics imposter
  23981. */
  23982. sleep(): PhysicsImpostor;
  23983. /**
  23984. * Wake the body up.
  23985. * @returns The physics imposter
  23986. */
  23987. wakeUp(): PhysicsImpostor;
  23988. /**
  23989. * Clones the physics imposter
  23990. * @param newObject The physics imposter clones to this physics-enabled object
  23991. * @returns A nullable physics imposter
  23992. */
  23993. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23994. /**
  23995. * Disposes the physics imposter
  23996. */
  23997. dispose(): void;
  23998. /**
  23999. * Sets the delta position
  24000. * @param position The delta position amount
  24001. */
  24002. setDeltaPosition(position: Vector3): void;
  24003. /**
  24004. * Sets the delta rotation
  24005. * @param rotation The delta rotation amount
  24006. */
  24007. setDeltaRotation(rotation: Quaternion): void;
  24008. /**
  24009. * Gets the box size of the physics imposter and stores the result in the input parameter
  24010. * @param result Stores the box size
  24011. * @returns The physics imposter
  24012. */
  24013. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24014. /**
  24015. * Gets the radius of the physics imposter
  24016. * @returns Radius of the physics imposter
  24017. */
  24018. getRadius(): number;
  24019. /**
  24020. * Sync a bone with this impostor
  24021. * @param bone The bone to sync to the impostor.
  24022. * @param boneMesh The mesh that the bone is influencing.
  24023. * @param jointPivot The pivot of the joint / bone in local space.
  24024. * @param distToJoint Optional distance from the impostor to the joint.
  24025. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24026. */
  24027. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24028. /**
  24029. * Sync impostor to a bone
  24030. * @param bone The bone that the impostor will be synced to.
  24031. * @param boneMesh The mesh that the bone is influencing.
  24032. * @param jointPivot The pivot of the joint / bone in local space.
  24033. * @param distToJoint Optional distance from the impostor to the joint.
  24034. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24035. * @param boneAxis Optional vector3 axis the bone is aligned with
  24036. */
  24037. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24038. /**
  24039. * No-Imposter type
  24040. */
  24041. static NoImpostor: number;
  24042. /**
  24043. * Sphere-Imposter type
  24044. */
  24045. static SphereImpostor: number;
  24046. /**
  24047. * Box-Imposter type
  24048. */
  24049. static BoxImpostor: number;
  24050. /**
  24051. * Plane-Imposter type
  24052. */
  24053. static PlaneImpostor: number;
  24054. /**
  24055. * Mesh-imposter type
  24056. */
  24057. static MeshImpostor: number;
  24058. /**
  24059. * Capsule-Impostor type (Ammo.js plugin only)
  24060. */
  24061. static CapsuleImpostor: number;
  24062. /**
  24063. * Cylinder-Imposter type
  24064. */
  24065. static CylinderImpostor: number;
  24066. /**
  24067. * Particle-Imposter type
  24068. */
  24069. static ParticleImpostor: number;
  24070. /**
  24071. * Heightmap-Imposter type
  24072. */
  24073. static HeightmapImpostor: number;
  24074. /**
  24075. * ConvexHull-Impostor type (Ammo.js plugin only)
  24076. */
  24077. static ConvexHullImpostor: number;
  24078. /**
  24079. * Rope-Imposter type
  24080. */
  24081. static RopeImpostor: number;
  24082. /**
  24083. * Cloth-Imposter type
  24084. */
  24085. static ClothImpostor: number;
  24086. /**
  24087. * Softbody-Imposter type
  24088. */
  24089. static SoftbodyImpostor: number;
  24090. }
  24091. }
  24092. declare module "babylonjs/Meshes/mesh" {
  24093. import { Observable } from "babylonjs/Misc/observable";
  24094. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24095. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24096. import { Camera } from "babylonjs/Cameras/camera";
  24097. import { Scene } from "babylonjs/scene";
  24098. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24099. import { Color4 } from "babylonjs/Maths/math.color";
  24100. import { Engine } from "babylonjs/Engines/engine";
  24101. import { Node } from "babylonjs/node";
  24102. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24103. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24104. import { Buffer } from "babylonjs/Meshes/buffer";
  24105. import { Geometry } from "babylonjs/Meshes/geometry";
  24106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24107. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24108. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24109. import { Effect } from "babylonjs/Materials/effect";
  24110. import { Material } from "babylonjs/Materials/material";
  24111. import { Skeleton } from "babylonjs/Bones/skeleton";
  24112. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24113. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24114. import { Path3D } from "babylonjs/Maths/math.path";
  24115. import { Plane } from "babylonjs/Maths/math.plane";
  24116. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24117. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24118. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24119. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24120. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24121. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24122. /**
  24123. * @hidden
  24124. **/
  24125. export class _CreationDataStorage {
  24126. closePath?: boolean;
  24127. closeArray?: boolean;
  24128. idx: number[];
  24129. dashSize: number;
  24130. gapSize: number;
  24131. path3D: Path3D;
  24132. pathArray: Vector3[][];
  24133. arc: number;
  24134. radius: number;
  24135. cap: number;
  24136. tessellation: number;
  24137. }
  24138. /**
  24139. * @hidden
  24140. **/
  24141. class _InstanceDataStorage {
  24142. visibleInstances: any;
  24143. batchCache: _InstancesBatch;
  24144. instancesBufferSize: number;
  24145. instancesBuffer: Nullable<Buffer>;
  24146. instancesData: Float32Array;
  24147. overridenInstanceCount: number;
  24148. isFrozen: boolean;
  24149. previousBatch: Nullable<_InstancesBatch>;
  24150. hardwareInstancedRendering: boolean;
  24151. sideOrientation: number;
  24152. }
  24153. /**
  24154. * @hidden
  24155. **/
  24156. export class _InstancesBatch {
  24157. mustReturn: boolean;
  24158. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24159. renderSelf: boolean[];
  24160. hardwareInstancedRendering: boolean[];
  24161. }
  24162. /**
  24163. * Class used to represent renderable models
  24164. */
  24165. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24166. /**
  24167. * Mesh side orientation : usually the external or front surface
  24168. */
  24169. static readonly FRONTSIDE: number;
  24170. /**
  24171. * Mesh side orientation : usually the internal or back surface
  24172. */
  24173. static readonly BACKSIDE: number;
  24174. /**
  24175. * Mesh side orientation : both internal and external or front and back surfaces
  24176. */
  24177. static readonly DOUBLESIDE: number;
  24178. /**
  24179. * Mesh side orientation : by default, `FRONTSIDE`
  24180. */
  24181. static readonly DEFAULTSIDE: number;
  24182. /**
  24183. * Mesh cap setting : no cap
  24184. */
  24185. static readonly NO_CAP: number;
  24186. /**
  24187. * Mesh cap setting : one cap at the beginning of the mesh
  24188. */
  24189. static readonly CAP_START: number;
  24190. /**
  24191. * Mesh cap setting : one cap at the end of the mesh
  24192. */
  24193. static readonly CAP_END: number;
  24194. /**
  24195. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24196. */
  24197. static readonly CAP_ALL: number;
  24198. /**
  24199. * Mesh pattern setting : no flip or rotate
  24200. */
  24201. static readonly NO_FLIP: number;
  24202. /**
  24203. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24204. */
  24205. static readonly FLIP_TILE: number;
  24206. /**
  24207. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24208. */
  24209. static readonly ROTATE_TILE: number;
  24210. /**
  24211. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24212. */
  24213. static readonly FLIP_ROW: number;
  24214. /**
  24215. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24216. */
  24217. static readonly ROTATE_ROW: number;
  24218. /**
  24219. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24220. */
  24221. static readonly FLIP_N_ROTATE_TILE: number;
  24222. /**
  24223. * Mesh pattern setting : rotate pattern and rotate
  24224. */
  24225. static readonly FLIP_N_ROTATE_ROW: number;
  24226. /**
  24227. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24228. */
  24229. static readonly CENTER: number;
  24230. /**
  24231. * Mesh tile positioning : part tiles on left
  24232. */
  24233. static readonly LEFT: number;
  24234. /**
  24235. * Mesh tile positioning : part tiles on right
  24236. */
  24237. static readonly RIGHT: number;
  24238. /**
  24239. * Mesh tile positioning : part tiles on top
  24240. */
  24241. static readonly TOP: number;
  24242. /**
  24243. * Mesh tile positioning : part tiles on bottom
  24244. */
  24245. static readonly BOTTOM: number;
  24246. /**
  24247. * Gets the default side orientation.
  24248. * @param orientation the orientation to value to attempt to get
  24249. * @returns the default orientation
  24250. * @hidden
  24251. */
  24252. static _GetDefaultSideOrientation(orientation?: number): number;
  24253. private _internalMeshDataInfo;
  24254. /**
  24255. * An event triggered before rendering the mesh
  24256. */
  24257. readonly onBeforeRenderObservable: Observable<Mesh>;
  24258. /**
  24259. * An event triggered before binding the mesh
  24260. */
  24261. readonly onBeforeBindObservable: Observable<Mesh>;
  24262. /**
  24263. * An event triggered after rendering the mesh
  24264. */
  24265. readonly onAfterRenderObservable: Observable<Mesh>;
  24266. /**
  24267. * An event triggered before drawing the mesh
  24268. */
  24269. readonly onBeforeDrawObservable: Observable<Mesh>;
  24270. private _onBeforeDrawObserver;
  24271. /**
  24272. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24273. */
  24274. onBeforeDraw: () => void;
  24275. readonly hasInstances: boolean;
  24276. /**
  24277. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24278. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24279. */
  24280. delayLoadState: number;
  24281. /**
  24282. * Gets the list of instances created from this mesh
  24283. * it is not supposed to be modified manually.
  24284. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24285. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24286. */
  24287. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24288. /**
  24289. * Gets the file containing delay loading data for this mesh
  24290. */
  24291. delayLoadingFile: string;
  24292. /** @hidden */
  24293. _binaryInfo: any;
  24294. /**
  24295. * User defined function used to change how LOD level selection is done
  24296. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24297. */
  24298. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24299. /**
  24300. * Gets or sets the morph target manager
  24301. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24302. */
  24303. morphTargetManager: Nullable<MorphTargetManager>;
  24304. /** @hidden */
  24305. _creationDataStorage: Nullable<_CreationDataStorage>;
  24306. /** @hidden */
  24307. _geometry: Nullable<Geometry>;
  24308. /** @hidden */
  24309. _delayInfo: Array<string>;
  24310. /** @hidden */
  24311. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24312. /** @hidden */
  24313. _instanceDataStorage: _InstanceDataStorage;
  24314. private _effectiveMaterial;
  24315. /** @hidden */
  24316. _shouldGenerateFlatShading: boolean;
  24317. /** @hidden */
  24318. _originalBuilderSideOrientation: number;
  24319. /**
  24320. * Use this property to change the original side orientation defined at construction time
  24321. */
  24322. overrideMaterialSideOrientation: Nullable<number>;
  24323. /**
  24324. * Gets the source mesh (the one used to clone this one from)
  24325. */
  24326. readonly source: Nullable<Mesh>;
  24327. /**
  24328. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24329. */
  24330. isUnIndexed: boolean;
  24331. /**
  24332. * @constructor
  24333. * @param name The value used by scene.getMeshByName() to do a lookup.
  24334. * @param scene The scene to add this mesh to.
  24335. * @param parent The parent of this mesh, if it has one
  24336. * @param source An optional Mesh from which geometry is shared, cloned.
  24337. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24338. * When false, achieved by calling a clone(), also passing False.
  24339. * This will make creation of children, recursive.
  24340. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24341. */
  24342. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24343. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24344. /**
  24345. * Gets the class name
  24346. * @returns the string "Mesh".
  24347. */
  24348. getClassName(): string;
  24349. /** @hidden */
  24350. readonly _isMesh: boolean;
  24351. /**
  24352. * Returns a description of this mesh
  24353. * @param fullDetails define if full details about this mesh must be used
  24354. * @returns a descriptive string representing this mesh
  24355. */
  24356. toString(fullDetails?: boolean): string;
  24357. /** @hidden */
  24358. _unBindEffect(): void;
  24359. /**
  24360. * Gets a boolean indicating if this mesh has LOD
  24361. */
  24362. readonly hasLODLevels: boolean;
  24363. /**
  24364. * Gets the list of MeshLODLevel associated with the current mesh
  24365. * @returns an array of MeshLODLevel
  24366. */
  24367. getLODLevels(): MeshLODLevel[];
  24368. private _sortLODLevels;
  24369. /**
  24370. * Add a mesh as LOD level triggered at the given distance.
  24371. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24372. * @param distance The distance from the center of the object to show this level
  24373. * @param mesh The mesh to be added as LOD level (can be null)
  24374. * @return This mesh (for chaining)
  24375. */
  24376. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24377. /**
  24378. * Returns the LOD level mesh at the passed distance or null if not found.
  24379. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24380. * @param distance The distance from the center of the object to show this level
  24381. * @returns a Mesh or `null`
  24382. */
  24383. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24384. /**
  24385. * Remove a mesh from the LOD array
  24386. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24387. * @param mesh defines the mesh to be removed
  24388. * @return This mesh (for chaining)
  24389. */
  24390. removeLODLevel(mesh: Mesh): Mesh;
  24391. /**
  24392. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24393. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24394. * @param camera defines the camera to use to compute distance
  24395. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24396. * @return This mesh (for chaining)
  24397. */
  24398. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24399. /**
  24400. * Gets the mesh internal Geometry object
  24401. */
  24402. readonly geometry: Nullable<Geometry>;
  24403. /**
  24404. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24405. * @returns the total number of vertices
  24406. */
  24407. getTotalVertices(): number;
  24408. /**
  24409. * Returns the content of an associated vertex buffer
  24410. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24411. * - VertexBuffer.PositionKind
  24412. * - VertexBuffer.UVKind
  24413. * - VertexBuffer.UV2Kind
  24414. * - VertexBuffer.UV3Kind
  24415. * - VertexBuffer.UV4Kind
  24416. * - VertexBuffer.UV5Kind
  24417. * - VertexBuffer.UV6Kind
  24418. * - VertexBuffer.ColorKind
  24419. * - VertexBuffer.MatricesIndicesKind
  24420. * - VertexBuffer.MatricesIndicesExtraKind
  24421. * - VertexBuffer.MatricesWeightsKind
  24422. * - VertexBuffer.MatricesWeightsExtraKind
  24423. * @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
  24424. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24425. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24426. */
  24427. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24428. /**
  24429. * Returns the mesh VertexBuffer object from the requested `kind`
  24430. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24431. * - VertexBuffer.PositionKind
  24432. * - VertexBuffer.NormalKind
  24433. * - VertexBuffer.UVKind
  24434. * - VertexBuffer.UV2Kind
  24435. * - VertexBuffer.UV3Kind
  24436. * - VertexBuffer.UV4Kind
  24437. * - VertexBuffer.UV5Kind
  24438. * - VertexBuffer.UV6Kind
  24439. * - VertexBuffer.ColorKind
  24440. * - VertexBuffer.MatricesIndicesKind
  24441. * - VertexBuffer.MatricesIndicesExtraKind
  24442. * - VertexBuffer.MatricesWeightsKind
  24443. * - VertexBuffer.MatricesWeightsExtraKind
  24444. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24445. */
  24446. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24447. /**
  24448. * Tests if a specific vertex buffer is associated with this mesh
  24449. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24450. * - VertexBuffer.PositionKind
  24451. * - VertexBuffer.NormalKind
  24452. * - VertexBuffer.UVKind
  24453. * - VertexBuffer.UV2Kind
  24454. * - VertexBuffer.UV3Kind
  24455. * - VertexBuffer.UV4Kind
  24456. * - VertexBuffer.UV5Kind
  24457. * - VertexBuffer.UV6Kind
  24458. * - VertexBuffer.ColorKind
  24459. * - VertexBuffer.MatricesIndicesKind
  24460. * - VertexBuffer.MatricesIndicesExtraKind
  24461. * - VertexBuffer.MatricesWeightsKind
  24462. * - VertexBuffer.MatricesWeightsExtraKind
  24463. * @returns a boolean
  24464. */
  24465. isVerticesDataPresent(kind: string): boolean;
  24466. /**
  24467. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24468. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24469. * - VertexBuffer.PositionKind
  24470. * - VertexBuffer.UVKind
  24471. * - VertexBuffer.UV2Kind
  24472. * - VertexBuffer.UV3Kind
  24473. * - VertexBuffer.UV4Kind
  24474. * - VertexBuffer.UV5Kind
  24475. * - VertexBuffer.UV6Kind
  24476. * - VertexBuffer.ColorKind
  24477. * - VertexBuffer.MatricesIndicesKind
  24478. * - VertexBuffer.MatricesIndicesExtraKind
  24479. * - VertexBuffer.MatricesWeightsKind
  24480. * - VertexBuffer.MatricesWeightsExtraKind
  24481. * @returns a boolean
  24482. */
  24483. isVertexBufferUpdatable(kind: string): boolean;
  24484. /**
  24485. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24486. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24487. * - VertexBuffer.PositionKind
  24488. * - VertexBuffer.NormalKind
  24489. * - VertexBuffer.UVKind
  24490. * - VertexBuffer.UV2Kind
  24491. * - VertexBuffer.UV3Kind
  24492. * - VertexBuffer.UV4Kind
  24493. * - VertexBuffer.UV5Kind
  24494. * - VertexBuffer.UV6Kind
  24495. * - VertexBuffer.ColorKind
  24496. * - VertexBuffer.MatricesIndicesKind
  24497. * - VertexBuffer.MatricesIndicesExtraKind
  24498. * - VertexBuffer.MatricesWeightsKind
  24499. * - VertexBuffer.MatricesWeightsExtraKind
  24500. * @returns an array of strings
  24501. */
  24502. getVerticesDataKinds(): string[];
  24503. /**
  24504. * Returns a positive integer : the total number of indices in this mesh geometry.
  24505. * @returns the numner of indices or zero if the mesh has no geometry.
  24506. */
  24507. getTotalIndices(): number;
  24508. /**
  24509. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24510. * @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.
  24511. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24512. * @returns the indices array or an empty array if the mesh has no geometry
  24513. */
  24514. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24515. readonly isBlocked: boolean;
  24516. /**
  24517. * Determine if the current mesh is ready to be rendered
  24518. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24519. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24520. * @returns true if all associated assets are ready (material, textures, shaders)
  24521. */
  24522. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24523. /**
  24524. * 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.
  24525. */
  24526. readonly areNormalsFrozen: boolean;
  24527. /**
  24528. * 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.
  24529. * @returns the current mesh
  24530. */
  24531. freezeNormals(): Mesh;
  24532. /**
  24533. * 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
  24534. * @returns the current mesh
  24535. */
  24536. unfreezeNormals(): Mesh;
  24537. /**
  24538. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24539. */
  24540. overridenInstanceCount: number;
  24541. /** @hidden */
  24542. _preActivate(): Mesh;
  24543. /** @hidden */
  24544. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24545. /** @hidden */
  24546. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24547. /**
  24548. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24549. * This means the mesh underlying bounding box and sphere are recomputed.
  24550. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24551. * @returns the current mesh
  24552. */
  24553. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24554. /** @hidden */
  24555. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24556. /**
  24557. * This function will subdivide the mesh into multiple submeshes
  24558. * @param count defines the expected number of submeshes
  24559. */
  24560. subdivide(count: number): void;
  24561. /**
  24562. * Copy a FloatArray into a specific associated vertex buffer
  24563. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24564. * - VertexBuffer.PositionKind
  24565. * - VertexBuffer.UVKind
  24566. * - VertexBuffer.UV2Kind
  24567. * - VertexBuffer.UV3Kind
  24568. * - VertexBuffer.UV4Kind
  24569. * - VertexBuffer.UV5Kind
  24570. * - VertexBuffer.UV6Kind
  24571. * - VertexBuffer.ColorKind
  24572. * - VertexBuffer.MatricesIndicesKind
  24573. * - VertexBuffer.MatricesIndicesExtraKind
  24574. * - VertexBuffer.MatricesWeightsKind
  24575. * - VertexBuffer.MatricesWeightsExtraKind
  24576. * @param data defines the data source
  24577. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24578. * @param stride defines the data stride size (can be null)
  24579. * @returns the current mesh
  24580. */
  24581. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24582. /**
  24583. * Flags an associated vertex buffer as updatable
  24584. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24585. * - VertexBuffer.PositionKind
  24586. * - VertexBuffer.UVKind
  24587. * - VertexBuffer.UV2Kind
  24588. * - VertexBuffer.UV3Kind
  24589. * - VertexBuffer.UV4Kind
  24590. * - VertexBuffer.UV5Kind
  24591. * - VertexBuffer.UV6Kind
  24592. * - VertexBuffer.ColorKind
  24593. * - VertexBuffer.MatricesIndicesKind
  24594. * - VertexBuffer.MatricesIndicesExtraKind
  24595. * - VertexBuffer.MatricesWeightsKind
  24596. * - VertexBuffer.MatricesWeightsExtraKind
  24597. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24598. */
  24599. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24600. /**
  24601. * Sets the mesh global Vertex Buffer
  24602. * @param buffer defines the buffer to use
  24603. * @returns the current mesh
  24604. */
  24605. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24606. /**
  24607. * Update a specific associated vertex buffer
  24608. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24609. * - VertexBuffer.PositionKind
  24610. * - VertexBuffer.UVKind
  24611. * - VertexBuffer.UV2Kind
  24612. * - VertexBuffer.UV3Kind
  24613. * - VertexBuffer.UV4Kind
  24614. * - VertexBuffer.UV5Kind
  24615. * - VertexBuffer.UV6Kind
  24616. * - VertexBuffer.ColorKind
  24617. * - VertexBuffer.MatricesIndicesKind
  24618. * - VertexBuffer.MatricesIndicesExtraKind
  24619. * - VertexBuffer.MatricesWeightsKind
  24620. * - VertexBuffer.MatricesWeightsExtraKind
  24621. * @param data defines the data source
  24622. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24623. * @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)
  24624. * @returns the current mesh
  24625. */
  24626. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24627. /**
  24628. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24629. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24630. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24631. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24632. * @returns the current mesh
  24633. */
  24634. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24635. /**
  24636. * Creates a un-shared specific occurence of the geometry for the mesh.
  24637. * @returns the current mesh
  24638. */
  24639. makeGeometryUnique(): Mesh;
  24640. /**
  24641. * Set the index buffer of this mesh
  24642. * @param indices defines the source data
  24643. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24644. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24645. * @returns the current mesh
  24646. */
  24647. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24648. /**
  24649. * Update the current index buffer
  24650. * @param indices defines the source data
  24651. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24652. * @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)
  24653. * @returns the current mesh
  24654. */
  24655. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24656. /**
  24657. * Invert the geometry to move from a right handed system to a left handed one.
  24658. * @returns the current mesh
  24659. */
  24660. toLeftHanded(): Mesh;
  24661. /** @hidden */
  24662. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24663. /** @hidden */
  24664. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24665. /**
  24666. * Registers for this mesh a javascript function called just before the rendering process
  24667. * @param func defines the function to call before rendering this mesh
  24668. * @returns the current mesh
  24669. */
  24670. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24671. /**
  24672. * Disposes a previously registered javascript function called before the rendering
  24673. * @param func defines the function to remove
  24674. * @returns the current mesh
  24675. */
  24676. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24677. /**
  24678. * Registers for this mesh a javascript function called just after the rendering is complete
  24679. * @param func defines the function to call after rendering this mesh
  24680. * @returns the current mesh
  24681. */
  24682. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24683. /**
  24684. * Disposes a previously registered javascript function called after the rendering.
  24685. * @param func defines the function to remove
  24686. * @returns the current mesh
  24687. */
  24688. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24689. /** @hidden */
  24690. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24691. /** @hidden */
  24692. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24693. /** @hidden */
  24694. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24695. /** @hidden */
  24696. _rebuild(): void;
  24697. /** @hidden */
  24698. _freeze(): void;
  24699. /** @hidden */
  24700. _unFreeze(): void;
  24701. /**
  24702. * 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
  24703. * @param subMesh defines the subMesh to render
  24704. * @param enableAlphaMode defines if alpha mode can be changed
  24705. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  24706. * @returns the current mesh
  24707. */
  24708. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  24709. private _onBeforeDraw;
  24710. /**
  24711. * Renormalize the mesh and patch it up if there are no weights
  24712. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24713. * However in the case of zero weights then we set just a single influence to 1.
  24714. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24715. */
  24716. cleanMatrixWeights(): void;
  24717. private normalizeSkinFourWeights;
  24718. private normalizeSkinWeightsAndExtra;
  24719. /**
  24720. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24721. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24722. * the user know there was an issue with importing the mesh
  24723. * @returns a validation object with skinned, valid and report string
  24724. */
  24725. validateSkinning(): {
  24726. skinned: boolean;
  24727. valid: boolean;
  24728. report: string;
  24729. };
  24730. /** @hidden */
  24731. _checkDelayState(): Mesh;
  24732. private _queueLoad;
  24733. /**
  24734. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24735. * A mesh is in the frustum if its bounding box intersects the frustum
  24736. * @param frustumPlanes defines the frustum to test
  24737. * @returns true if the mesh is in the frustum planes
  24738. */
  24739. isInFrustum(frustumPlanes: Plane[]): boolean;
  24740. /**
  24741. * Sets the mesh material by the material or multiMaterial `id` property
  24742. * @param id is a string identifying the material or the multiMaterial
  24743. * @returns the current mesh
  24744. */
  24745. setMaterialByID(id: string): Mesh;
  24746. /**
  24747. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24748. * @returns an array of IAnimatable
  24749. */
  24750. getAnimatables(): IAnimatable[];
  24751. /**
  24752. * Modifies the mesh geometry according to the passed transformation matrix.
  24753. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24754. * The mesh normals are modified using the same transformation.
  24755. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24756. * @param transform defines the transform matrix to use
  24757. * @see http://doc.babylonjs.com/resources/baking_transformations
  24758. * @returns the current mesh
  24759. */
  24760. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24761. /**
  24762. * Modifies the mesh geometry according to its own current World Matrix.
  24763. * The mesh World Matrix is then reset.
  24764. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24765. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24766. * @see http://doc.babylonjs.com/resources/baking_transformations
  24767. * @returns the current mesh
  24768. */
  24769. bakeCurrentTransformIntoVertices(): Mesh;
  24770. /** @hidden */
  24771. readonly _positions: Nullable<Vector3[]>;
  24772. /** @hidden */
  24773. _resetPointsArrayCache(): Mesh;
  24774. /** @hidden */
  24775. _generatePointsArray(): boolean;
  24776. /**
  24777. * Returns a new Mesh object generated from the current mesh properties.
  24778. * This method must not get confused with createInstance()
  24779. * @param name is a string, the name given to the new mesh
  24780. * @param newParent can be any Node object (default `null`)
  24781. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24782. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24783. * @returns a new mesh
  24784. */
  24785. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24786. /**
  24787. * Releases resources associated with this mesh.
  24788. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24789. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24790. */
  24791. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24792. /**
  24793. * Modifies the mesh geometry according to a displacement map.
  24794. * 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.
  24795. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24796. * @param url is a string, the URL from the image file is to be downloaded.
  24797. * @param minHeight is the lower limit of the displacement.
  24798. * @param maxHeight is the upper limit of the displacement.
  24799. * @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.
  24800. * @param uvOffset is an optional vector2 used to offset UV.
  24801. * @param uvScale is an optional vector2 used to scale UV.
  24802. * @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.
  24803. * @returns the Mesh.
  24804. */
  24805. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24806. /**
  24807. * Modifies the mesh geometry according to a displacementMap buffer.
  24808. * 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.
  24809. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24810. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24811. * @param heightMapWidth is the width of the buffer image.
  24812. * @param heightMapHeight is the height of the buffer image.
  24813. * @param minHeight is the lower limit of the displacement.
  24814. * @param maxHeight is the upper limit of the displacement.
  24815. * @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.
  24816. * @param uvOffset is an optional vector2 used to offset UV.
  24817. * @param uvScale is an optional vector2 used to scale UV.
  24818. * @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.
  24819. * @returns the Mesh.
  24820. */
  24821. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24822. /**
  24823. * Modify the mesh to get a flat shading rendering.
  24824. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24825. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24826. * @returns current mesh
  24827. */
  24828. convertToFlatShadedMesh(): Mesh;
  24829. /**
  24830. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24831. * In other words, more vertices, no more indices and a single bigger VBO.
  24832. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24833. * @returns current mesh
  24834. */
  24835. convertToUnIndexedMesh(): Mesh;
  24836. /**
  24837. * Inverses facet orientations.
  24838. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24839. * @param flipNormals will also inverts the normals
  24840. * @returns current mesh
  24841. */
  24842. flipFaces(flipNormals?: boolean): Mesh;
  24843. /**
  24844. * Increase the number of facets and hence vertices in a mesh
  24845. * Vertex normals are interpolated from existing vertex normals
  24846. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24847. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24848. */
  24849. increaseVertices(numberPerEdge: number): void;
  24850. /**
  24851. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24852. * This will undo any application of covertToFlatShadedMesh
  24853. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24854. */
  24855. forceSharedVertices(): void;
  24856. /** @hidden */
  24857. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  24858. /** @hidden */
  24859. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  24860. /**
  24861. * Creates a new InstancedMesh object from the mesh model.
  24862. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24863. * @param name defines the name of the new instance
  24864. * @returns a new InstancedMesh
  24865. */
  24866. createInstance(name: string): InstancedMesh;
  24867. /**
  24868. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  24869. * After this call, all the mesh instances have the same submeshes than the current mesh.
  24870. * @returns the current mesh
  24871. */
  24872. synchronizeInstances(): Mesh;
  24873. /**
  24874. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  24875. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  24876. * This should be used together with the simplification to avoid disappearing triangles.
  24877. * @param successCallback an optional success callback to be called after the optimization finished.
  24878. * @returns the current mesh
  24879. */
  24880. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  24881. /**
  24882. * Serialize current mesh
  24883. * @param serializationObject defines the object which will receive the serialization data
  24884. */
  24885. serialize(serializationObject: any): void;
  24886. /** @hidden */
  24887. _syncGeometryWithMorphTargetManager(): void;
  24888. /** @hidden */
  24889. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  24890. /**
  24891. * Returns a new Mesh object parsed from the source provided.
  24892. * @param parsedMesh is the source
  24893. * @param scene defines the hosting scene
  24894. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  24895. * @returns a new Mesh
  24896. */
  24897. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  24898. /**
  24899. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  24900. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  24901. * @param name defines the name of the mesh to create
  24902. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  24903. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  24904. * @param closePath creates a seam between the first and the last points of each path of the path array
  24905. * @param offset is taken in account only if the `pathArray` is containing a single path
  24906. * @param scene defines the hosting scene
  24907. * @param updatable defines if the mesh must be flagged as updatable
  24908. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24909. * @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)
  24910. * @returns a new Mesh
  24911. */
  24912. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  24913. /**
  24914. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  24915. * @param name defines the name of the mesh to create
  24916. * @param radius sets the radius size (float) of the polygon (default 0.5)
  24917. * @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
  24918. * @param scene defines the hosting scene
  24919. * @param updatable defines if the mesh must be flagged as updatable
  24920. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24921. * @returns a new Mesh
  24922. */
  24923. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24924. /**
  24925. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  24926. * @param name defines the name of the mesh to create
  24927. * @param size sets the size (float) of each box side (default 1)
  24928. * @param scene defines the hosting scene
  24929. * @param updatable defines if the mesh must be flagged as updatable
  24930. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24931. * @returns a new Mesh
  24932. */
  24933. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  24934. /**
  24935. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  24936. * @param name defines the name of the mesh to create
  24937. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24938. * @param diameter sets the diameter size (float) of the sphere (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 CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24945. /**
  24946. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  24947. * @param name defines the name of the mesh to create
  24948. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  24949. * @param diameter sets the diameter size (float) of the sphere (default 1)
  24950. * @param scene defines the hosting scene
  24951. * @returns a new Mesh
  24952. */
  24953. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  24954. /**
  24955. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  24956. * @param name defines the name of the mesh to create
  24957. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  24958. * @param diameterTop set the top cap diameter (floats, default 1)
  24959. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  24960. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  24961. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  24962. * @param scene defines the hosting scene
  24963. * @param updatable defines if the mesh must be flagged as updatable
  24964. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24965. * @returns a new Mesh
  24966. */
  24967. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  24968. /**
  24969. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  24970. * @param name defines the name of the mesh to create
  24971. * @param diameter sets the diameter size (float) of the torus (default 1)
  24972. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  24973. * @param tessellation sets the number of torus sides (postive integer, default 16)
  24974. * @param scene defines the hosting scene
  24975. * @param updatable defines if the mesh must be flagged as updatable
  24976. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24977. * @returns a new Mesh
  24978. */
  24979. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24980. /**
  24981. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  24982. * @param name defines the name of the mesh to create
  24983. * @param radius sets the global radius size (float) of the torus knot (default 2)
  24984. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  24985. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  24986. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  24987. * @param p the number of windings on X axis (positive integers, default 2)
  24988. * @param q the number of windings on Y axis (positive integers, default 3)
  24989. * @param scene defines the hosting scene
  24990. * @param updatable defines if the mesh must be flagged as updatable
  24991. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  24992. * @returns a new Mesh
  24993. */
  24994. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  24995. /**
  24996. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  24997. * @param name defines the name of the mesh to create
  24998. * @param points is an array successive Vector3
  24999. * @param scene defines the hosting scene
  25000. * @param updatable defines if the mesh must be flagged as updatable
  25001. * @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).
  25002. * @returns a new Mesh
  25003. */
  25004. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25005. /**
  25006. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25007. * @param name defines the name of the mesh to create
  25008. * @param points is an array successive Vector3
  25009. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25010. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25011. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25012. * @param scene defines the hosting scene
  25013. * @param updatable defines if the mesh must be flagged as updatable
  25014. * @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)
  25015. * @returns a new Mesh
  25016. */
  25017. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25018. /**
  25019. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25020. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25021. * 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.
  25022. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25023. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25024. * Remember you can only change the shape positions, not their number when updating a polygon.
  25025. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25026. * @param name defines the name of the mesh to create
  25027. * @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
  25028. * @param scene defines the hosting scene
  25029. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25030. * @param updatable defines if the mesh must be flagged as updatable
  25031. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25032. * @param earcutInjection can be used to inject your own earcut reference
  25033. * @returns a new Mesh
  25034. */
  25035. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25036. /**
  25037. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25038. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25039. * @param name defines the name of the mesh to create
  25040. * @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
  25041. * @param depth defines the height of extrusion
  25042. * @param scene defines the hosting scene
  25043. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25044. * @param updatable defines if the mesh must be flagged as updatable
  25045. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25046. * @param earcutInjection can be used to inject your own earcut reference
  25047. * @returns a new Mesh
  25048. */
  25049. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25050. /**
  25051. * Creates an extruded shape mesh.
  25052. * 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
  25053. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25054. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25055. * @param name defines the name of the mesh to create
  25056. * @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
  25057. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25058. * @param scale is the value to scale the shape
  25059. * @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
  25060. * @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
  25061. * @param scene defines the hosting scene
  25062. * @param updatable defines if the mesh must be flagged as updatable
  25063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25064. * @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)
  25065. * @returns a new Mesh
  25066. */
  25067. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25068. /**
  25069. * Creates an custom extruded shape mesh.
  25070. * The custom extrusion is a parametric shape.
  25071. * It has no predefined shape. Its final shape will depend on the input parameters.
  25072. * Please consider using the same method from the MeshBuilder class instead
  25073. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25074. * @param name defines the name of the mesh to create
  25075. * @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
  25076. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25077. * @param scaleFunction is a custom Javascript function called on each path point
  25078. * @param rotationFunction is a custom Javascript function called on each path point
  25079. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25080. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25081. * @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
  25082. * @param scene defines the hosting scene
  25083. * @param updatable defines if the mesh must be flagged as updatable
  25084. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25085. * @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)
  25086. * @returns a new Mesh
  25087. */
  25088. 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;
  25089. /**
  25090. * Creates lathe mesh.
  25091. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25092. * Please consider using the same method from the MeshBuilder class instead
  25093. * @param name defines the name of the mesh to create
  25094. * @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
  25095. * @param radius is the radius value of the lathe
  25096. * @param tessellation is the side number of the lathe.
  25097. * @param scene defines the hosting scene
  25098. * @param updatable defines if the mesh must be flagged as updatable
  25099. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25100. * @returns a new Mesh
  25101. */
  25102. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25103. /**
  25104. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25105. * @param name defines the name of the mesh to create
  25106. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25107. * @param scene defines the hosting scene
  25108. * @param updatable defines if the mesh must be flagged as updatable
  25109. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25110. * @returns a new Mesh
  25111. */
  25112. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25113. /**
  25114. * Creates a ground mesh.
  25115. * Please consider using the same method from the MeshBuilder class instead
  25116. * @param name defines the name of the mesh to create
  25117. * @param width set the width of the ground
  25118. * @param height set the height of the ground
  25119. * @param subdivisions sets the number of subdivisions per side
  25120. * @param scene defines the hosting scene
  25121. * @param updatable defines if the mesh must be flagged as updatable
  25122. * @returns a new Mesh
  25123. */
  25124. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25125. /**
  25126. * Creates a tiled ground mesh.
  25127. * Please consider using the same method from the MeshBuilder class instead
  25128. * @param name defines the name of the mesh to create
  25129. * @param xmin set the ground minimum X coordinate
  25130. * @param zmin set the ground minimum Y coordinate
  25131. * @param xmax set the ground maximum X coordinate
  25132. * @param zmax set the ground maximum Z coordinate
  25133. * @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
  25134. * @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
  25135. * @param scene defines the hosting scene
  25136. * @param updatable defines if the mesh must be flagged as updatable
  25137. * @returns a new Mesh
  25138. */
  25139. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25140. w: number;
  25141. h: number;
  25142. }, precision: {
  25143. w: number;
  25144. h: number;
  25145. }, scene: Scene, updatable?: boolean): Mesh;
  25146. /**
  25147. * Creates a ground mesh from a height map.
  25148. * Please consider using the same method from the MeshBuilder class instead
  25149. * @see http://doc.babylonjs.com/babylon101/height_map
  25150. * @param name defines the name of the mesh to create
  25151. * @param url sets the URL of the height map image resource
  25152. * @param width set the ground width size
  25153. * @param height set the ground height size
  25154. * @param subdivisions sets the number of subdivision per side
  25155. * @param minHeight is the minimum altitude on the ground
  25156. * @param maxHeight is the maximum altitude on the ground
  25157. * @param scene defines the hosting scene
  25158. * @param updatable defines if the mesh must be flagged as updatable
  25159. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25160. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25161. * @returns a new Mesh
  25162. */
  25163. 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;
  25164. /**
  25165. * Creates a tube mesh.
  25166. * The tube is a parametric shape.
  25167. * It has no predefined shape. Its final shape will depend on the input parameters.
  25168. * Please consider using the same method from the MeshBuilder class instead
  25169. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25170. * @param name defines the name of the mesh to create
  25171. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25172. * @param radius sets the tube radius size
  25173. * @param tessellation is the number of sides on the tubular surface
  25174. * @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
  25175. * @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
  25176. * @param scene defines the hosting scene
  25177. * @param updatable defines if the mesh must be flagged as updatable
  25178. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25179. * @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)
  25180. * @returns a new Mesh
  25181. */
  25182. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25183. (i: number, distance: number): number;
  25184. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25185. /**
  25186. * Creates a polyhedron mesh.
  25187. * Please consider using the same method from the MeshBuilder class instead.
  25188. * * 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
  25189. * * The parameter `size` (positive float, default 1) sets the polygon size
  25190. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25191. * * 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`
  25192. * * 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
  25193. * * 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)`)
  25194. * * 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
  25195. * * 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
  25196. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25197. * * 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
  25198. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25199. * @param name defines the name of the mesh to create
  25200. * @param options defines the options used to create the mesh
  25201. * @param scene defines the hosting scene
  25202. * @returns a new Mesh
  25203. */
  25204. static CreatePolyhedron(name: string, options: {
  25205. type?: number;
  25206. size?: number;
  25207. sizeX?: number;
  25208. sizeY?: number;
  25209. sizeZ?: number;
  25210. custom?: any;
  25211. faceUV?: Vector4[];
  25212. faceColors?: Color4[];
  25213. updatable?: boolean;
  25214. sideOrientation?: number;
  25215. }, scene: Scene): Mesh;
  25216. /**
  25217. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25218. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25219. * * 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`)
  25220. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25221. * * 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
  25222. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25223. * * 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
  25224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25225. * @param name defines the name of the mesh
  25226. * @param options defines the options used to create the mesh
  25227. * @param scene defines the hosting scene
  25228. * @returns a new Mesh
  25229. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25230. */
  25231. static CreateIcoSphere(name: string, options: {
  25232. radius?: number;
  25233. flat?: boolean;
  25234. subdivisions?: number;
  25235. sideOrientation?: number;
  25236. updatable?: boolean;
  25237. }, scene: Scene): Mesh;
  25238. /**
  25239. * Creates a decal mesh.
  25240. * Please consider using the same method from the MeshBuilder class instead.
  25241. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25242. * @param name defines the name of the mesh
  25243. * @param sourceMesh defines the mesh receiving the decal
  25244. * @param position sets the position of the decal in world coordinates
  25245. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25246. * @param size sets the decal scaling
  25247. * @param angle sets the angle to rotate the decal
  25248. * @returns a new Mesh
  25249. */
  25250. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25251. /**
  25252. * Prepare internal position array for software CPU skinning
  25253. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25254. */
  25255. setPositionsForCPUSkinning(): Float32Array;
  25256. /**
  25257. * Prepare internal normal array for software CPU skinning
  25258. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25259. */
  25260. setNormalsForCPUSkinning(): Float32Array;
  25261. /**
  25262. * Updates the vertex buffer by applying transformation from the bones
  25263. * @param skeleton defines the skeleton to apply to current mesh
  25264. * @returns the current mesh
  25265. */
  25266. applySkeleton(skeleton: Skeleton): Mesh;
  25267. /**
  25268. * 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
  25269. * @param meshes defines the list of meshes to scan
  25270. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25271. */
  25272. static MinMax(meshes: AbstractMesh[]): {
  25273. min: Vector3;
  25274. max: Vector3;
  25275. };
  25276. /**
  25277. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25278. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25279. * @returns a vector3
  25280. */
  25281. static Center(meshesOrMinMaxVector: {
  25282. min: Vector3;
  25283. max: Vector3;
  25284. } | AbstractMesh[]): Vector3;
  25285. /**
  25286. * Merge the array of meshes into a single mesh for performance reasons.
  25287. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25288. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25289. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25290. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25291. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25292. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25293. * @returns a new mesh
  25294. */
  25295. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25296. /** @hidden */
  25297. addInstance(instance: InstancedMesh): void;
  25298. /** @hidden */
  25299. removeInstance(instance: InstancedMesh): void;
  25300. }
  25301. }
  25302. declare module "babylonjs/Cameras/camera" {
  25303. import { SmartArray } from "babylonjs/Misc/smartArray";
  25304. import { Observable } from "babylonjs/Misc/observable";
  25305. import { Nullable } from "babylonjs/types";
  25306. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25307. import { Scene } from "babylonjs/scene";
  25308. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25309. import { Node } from "babylonjs/node";
  25310. import { Mesh } from "babylonjs/Meshes/mesh";
  25311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25312. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25313. import { Viewport } from "babylonjs/Maths/math.viewport";
  25314. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25315. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25316. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25317. import { Ray } from "babylonjs/Culling/ray";
  25318. /**
  25319. * This is the base class of all the camera used in the application.
  25320. * @see http://doc.babylonjs.com/features/cameras
  25321. */
  25322. export class Camera extends Node {
  25323. /** @hidden */
  25324. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25325. /**
  25326. * This is the default projection mode used by the cameras.
  25327. * It helps recreating a feeling of perspective and better appreciate depth.
  25328. * This is the best way to simulate real life cameras.
  25329. */
  25330. static readonly PERSPECTIVE_CAMERA: number;
  25331. /**
  25332. * This helps creating camera with an orthographic mode.
  25333. * 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.
  25334. */
  25335. static readonly ORTHOGRAPHIC_CAMERA: number;
  25336. /**
  25337. * This is the default FOV mode for perspective cameras.
  25338. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25339. */
  25340. static readonly FOVMODE_VERTICAL_FIXED: number;
  25341. /**
  25342. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25343. */
  25344. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25345. /**
  25346. * This specifies ther is no need for a camera rig.
  25347. * Basically only one eye is rendered corresponding to the camera.
  25348. */
  25349. static readonly RIG_MODE_NONE: number;
  25350. /**
  25351. * Simulates a camera Rig with one blue eye and one red eye.
  25352. * This can be use with 3d blue and red glasses.
  25353. */
  25354. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25355. /**
  25356. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25357. */
  25358. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25359. /**
  25360. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25361. */
  25362. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25363. /**
  25364. * Defines that both eyes of the camera will be rendered over under each other.
  25365. */
  25366. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25367. /**
  25368. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25369. */
  25370. static readonly RIG_MODE_VR: number;
  25371. /**
  25372. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25373. */
  25374. static readonly RIG_MODE_WEBVR: number;
  25375. /**
  25376. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25377. */
  25378. static readonly RIG_MODE_CUSTOM: number;
  25379. /**
  25380. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25381. */
  25382. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25383. /**
  25384. * Define the input manager associated with the camera.
  25385. */
  25386. inputs: CameraInputsManager<Camera>;
  25387. /** @hidden */
  25388. _position: Vector3;
  25389. /**
  25390. * Define the current local position of the camera in the scene
  25391. */
  25392. position: Vector3;
  25393. /**
  25394. * The vector the camera should consider as up.
  25395. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25396. */
  25397. upVector: Vector3;
  25398. /**
  25399. * Define the current limit on the left side for an orthographic camera
  25400. * In scene unit
  25401. */
  25402. orthoLeft: Nullable<number>;
  25403. /**
  25404. * Define the current limit on the right side for an orthographic camera
  25405. * In scene unit
  25406. */
  25407. orthoRight: Nullable<number>;
  25408. /**
  25409. * Define the current limit on the bottom side for an orthographic camera
  25410. * In scene unit
  25411. */
  25412. orthoBottom: Nullable<number>;
  25413. /**
  25414. * Define the current limit on the top side for an orthographic camera
  25415. * In scene unit
  25416. */
  25417. orthoTop: Nullable<number>;
  25418. /**
  25419. * Field Of View is set in Radians. (default is 0.8)
  25420. */
  25421. fov: number;
  25422. /**
  25423. * Define the minimum distance the camera can see from.
  25424. * This is important to note that the depth buffer are not infinite and the closer it starts
  25425. * the more your scene might encounter depth fighting issue.
  25426. */
  25427. minZ: number;
  25428. /**
  25429. * Define the maximum distance the camera can see to.
  25430. * This is important to note that the depth buffer are not infinite and the further it end
  25431. * the more your scene might encounter depth fighting issue.
  25432. */
  25433. maxZ: number;
  25434. /**
  25435. * Define the default inertia of the camera.
  25436. * This helps giving a smooth feeling to the camera movement.
  25437. */
  25438. inertia: number;
  25439. /**
  25440. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25441. */
  25442. mode: number;
  25443. /**
  25444. * Define wether the camera is intermediate.
  25445. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25446. */
  25447. isIntermediate: boolean;
  25448. /**
  25449. * Define the viewport of the camera.
  25450. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25451. */
  25452. viewport: Viewport;
  25453. /**
  25454. * Restricts the camera to viewing objects with the same layerMask.
  25455. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25456. */
  25457. layerMask: number;
  25458. /**
  25459. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25460. */
  25461. fovMode: number;
  25462. /**
  25463. * Rig mode of the camera.
  25464. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25465. * This is normally controlled byt the camera themselves as internal use.
  25466. */
  25467. cameraRigMode: number;
  25468. /**
  25469. * Defines the distance between both "eyes" in case of a RIG
  25470. */
  25471. interaxialDistance: number;
  25472. /**
  25473. * Defines if stereoscopic rendering is done side by side or over under.
  25474. */
  25475. isStereoscopicSideBySide: boolean;
  25476. /**
  25477. * 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
  25478. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25479. * else in the scene. (Eg. security camera)
  25480. *
  25481. * 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)
  25482. */
  25483. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25484. /**
  25485. * When set, the camera will render to this render target instead of the default canvas
  25486. *
  25487. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25488. */
  25489. outputRenderTarget: Nullable<RenderTargetTexture>;
  25490. /**
  25491. * Observable triggered when the camera view matrix has changed.
  25492. */
  25493. onViewMatrixChangedObservable: Observable<Camera>;
  25494. /**
  25495. * Observable triggered when the camera Projection matrix has changed.
  25496. */
  25497. onProjectionMatrixChangedObservable: Observable<Camera>;
  25498. /**
  25499. * Observable triggered when the inputs have been processed.
  25500. */
  25501. onAfterCheckInputsObservable: Observable<Camera>;
  25502. /**
  25503. * Observable triggered when reset has been called and applied to the camera.
  25504. */
  25505. onRestoreStateObservable: Observable<Camera>;
  25506. /** @hidden */
  25507. _cameraRigParams: any;
  25508. /** @hidden */
  25509. _rigCameras: Camera[];
  25510. /** @hidden */
  25511. _rigPostProcess: Nullable<PostProcess>;
  25512. protected _webvrViewMatrix: Matrix;
  25513. /** @hidden */
  25514. _skipRendering: boolean;
  25515. /** @hidden */
  25516. _projectionMatrix: Matrix;
  25517. /** @hidden */
  25518. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25519. /** @hidden */
  25520. _activeMeshes: SmartArray<AbstractMesh>;
  25521. protected _globalPosition: Vector3;
  25522. /** @hidden */
  25523. _computedViewMatrix: Matrix;
  25524. private _doNotComputeProjectionMatrix;
  25525. private _transformMatrix;
  25526. private _frustumPlanes;
  25527. private _refreshFrustumPlanes;
  25528. private _storedFov;
  25529. private _stateStored;
  25530. /**
  25531. * Instantiates a new camera object.
  25532. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25533. * @see http://doc.babylonjs.com/features/cameras
  25534. * @param name Defines the name of the camera in the scene
  25535. * @param position Defines the position of the camera
  25536. * @param scene Defines the scene the camera belongs too
  25537. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25538. */
  25539. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25540. /**
  25541. * Store current camera state (fov, position, etc..)
  25542. * @returns the camera
  25543. */
  25544. storeState(): Camera;
  25545. /**
  25546. * Restores the camera state values if it has been stored. You must call storeState() first
  25547. */
  25548. protected _restoreStateValues(): boolean;
  25549. /**
  25550. * Restored camera state. You must call storeState() first.
  25551. * @returns true if restored and false otherwise
  25552. */
  25553. restoreState(): boolean;
  25554. /**
  25555. * Gets the class name of the camera.
  25556. * @returns the class name
  25557. */
  25558. getClassName(): string;
  25559. /** @hidden */
  25560. readonly _isCamera: boolean;
  25561. /**
  25562. * Gets a string representation of the camera useful for debug purpose.
  25563. * @param fullDetails Defines that a more verboe level of logging is required
  25564. * @returns the string representation
  25565. */
  25566. toString(fullDetails?: boolean): string;
  25567. /**
  25568. * Gets the current world space position of the camera.
  25569. */
  25570. readonly globalPosition: Vector3;
  25571. /**
  25572. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25573. * @returns the active meshe list
  25574. */
  25575. getActiveMeshes(): SmartArray<AbstractMesh>;
  25576. /**
  25577. * Check wether a mesh is part of the current active mesh list of the camera
  25578. * @param mesh Defines the mesh to check
  25579. * @returns true if active, false otherwise
  25580. */
  25581. isActiveMesh(mesh: Mesh): boolean;
  25582. /**
  25583. * Is this camera ready to be used/rendered
  25584. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25585. * @return true if the camera is ready
  25586. */
  25587. isReady(completeCheck?: boolean): boolean;
  25588. /** @hidden */
  25589. _initCache(): void;
  25590. /** @hidden */
  25591. _updateCache(ignoreParentClass?: boolean): void;
  25592. /** @hidden */
  25593. _isSynchronized(): boolean;
  25594. /** @hidden */
  25595. _isSynchronizedViewMatrix(): boolean;
  25596. /** @hidden */
  25597. _isSynchronizedProjectionMatrix(): boolean;
  25598. /**
  25599. * Attach the input controls to a specific dom element to get the input from.
  25600. * @param element Defines the element the controls should be listened from
  25601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25602. */
  25603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25604. /**
  25605. * Detach the current controls from the specified dom element.
  25606. * @param element Defines the element to stop listening the inputs from
  25607. */
  25608. detachControl(element: HTMLElement): void;
  25609. /**
  25610. * Update the camera state according to the different inputs gathered during the frame.
  25611. */
  25612. update(): void;
  25613. /** @hidden */
  25614. _checkInputs(): void;
  25615. /** @hidden */
  25616. readonly rigCameras: Camera[];
  25617. /**
  25618. * Gets the post process used by the rig cameras
  25619. */
  25620. readonly rigPostProcess: Nullable<PostProcess>;
  25621. /**
  25622. * Internal, gets the first post proces.
  25623. * @returns the first post process to be run on this camera.
  25624. */
  25625. _getFirstPostProcess(): Nullable<PostProcess>;
  25626. private _cascadePostProcessesToRigCams;
  25627. /**
  25628. * Attach a post process to the camera.
  25629. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25630. * @param postProcess The post process to attach to the camera
  25631. * @param insertAt The position of the post process in case several of them are in use in the scene
  25632. * @returns the position the post process has been inserted at
  25633. */
  25634. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25635. /**
  25636. * Detach a post process to the camera.
  25637. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25638. * @param postProcess The post process to detach from the camera
  25639. */
  25640. detachPostProcess(postProcess: PostProcess): void;
  25641. /**
  25642. * Gets the current world matrix of the camera
  25643. */
  25644. getWorldMatrix(): Matrix;
  25645. /** @hidden */
  25646. _getViewMatrix(): Matrix;
  25647. /**
  25648. * Gets the current view matrix of the camera.
  25649. * @param force forces the camera to recompute the matrix without looking at the cached state
  25650. * @returns the view matrix
  25651. */
  25652. getViewMatrix(force?: boolean): Matrix;
  25653. /**
  25654. * Freeze the projection matrix.
  25655. * It will prevent the cache check of the camera projection compute and can speed up perf
  25656. * if no parameter of the camera are meant to change
  25657. * @param projection Defines manually a projection if necessary
  25658. */
  25659. freezeProjectionMatrix(projection?: Matrix): void;
  25660. /**
  25661. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25662. */
  25663. unfreezeProjectionMatrix(): void;
  25664. /**
  25665. * Gets the current projection matrix of the camera.
  25666. * @param force forces the camera to recompute the matrix without looking at the cached state
  25667. * @returns the projection matrix
  25668. */
  25669. getProjectionMatrix(force?: boolean): Matrix;
  25670. /**
  25671. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25672. * @returns a Matrix
  25673. */
  25674. getTransformationMatrix(): Matrix;
  25675. private _updateFrustumPlanes;
  25676. /**
  25677. * Checks if a cullable object (mesh...) is in the camera frustum
  25678. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25679. * @param target The object to check
  25680. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25681. * @returns true if the object is in frustum otherwise false
  25682. */
  25683. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25684. /**
  25685. * Checks if a cullable object (mesh...) is in the camera frustum
  25686. * Unlike isInFrustum this cheks the full bounding box
  25687. * @param target The object to check
  25688. * @returns true if the object is in frustum otherwise false
  25689. */
  25690. isCompletelyInFrustum(target: ICullable): boolean;
  25691. /**
  25692. * Gets a ray in the forward direction from the camera.
  25693. * @param length Defines the length of the ray to create
  25694. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25695. * @param origin Defines the start point of the ray which defaults to the camera position
  25696. * @returns the forward ray
  25697. */
  25698. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25699. /**
  25700. * Releases resources associated with this node.
  25701. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25702. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25703. */
  25704. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25705. /** @hidden */
  25706. _isLeftCamera: boolean;
  25707. /**
  25708. * Gets the left camera of a rig setup in case of Rigged Camera
  25709. */
  25710. readonly isLeftCamera: boolean;
  25711. /** @hidden */
  25712. _isRightCamera: boolean;
  25713. /**
  25714. * Gets the right camera of a rig setup in case of Rigged Camera
  25715. */
  25716. readonly isRightCamera: boolean;
  25717. /**
  25718. * Gets the left camera of a rig setup in case of Rigged Camera
  25719. */
  25720. readonly leftCamera: Nullable<FreeCamera>;
  25721. /**
  25722. * Gets the right camera of a rig setup in case of Rigged Camera
  25723. */
  25724. readonly rightCamera: Nullable<FreeCamera>;
  25725. /**
  25726. * Gets the left camera target of a rig setup in case of Rigged Camera
  25727. * @returns the target position
  25728. */
  25729. getLeftTarget(): Nullable<Vector3>;
  25730. /**
  25731. * Gets the right camera target of a rig setup in case of Rigged Camera
  25732. * @returns the target position
  25733. */
  25734. getRightTarget(): Nullable<Vector3>;
  25735. /**
  25736. * @hidden
  25737. */
  25738. setCameraRigMode(mode: number, rigParams: any): void;
  25739. /** @hidden */
  25740. static _setStereoscopicRigMode(camera: Camera): void;
  25741. /** @hidden */
  25742. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25743. /** @hidden */
  25744. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25745. /** @hidden */
  25746. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25747. /** @hidden */
  25748. _getVRProjectionMatrix(): Matrix;
  25749. protected _updateCameraRotationMatrix(): void;
  25750. protected _updateWebVRCameraRotationMatrix(): void;
  25751. /**
  25752. * This function MUST be overwritten by the different WebVR cameras available.
  25753. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25754. * @hidden
  25755. */
  25756. _getWebVRProjectionMatrix(): Matrix;
  25757. /**
  25758. * This function MUST be overwritten by the different WebVR cameras available.
  25759. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25760. * @hidden
  25761. */
  25762. _getWebVRViewMatrix(): Matrix;
  25763. /** @hidden */
  25764. setCameraRigParameter(name: string, value: any): void;
  25765. /**
  25766. * needs to be overridden by children so sub has required properties to be copied
  25767. * @hidden
  25768. */
  25769. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25770. /**
  25771. * May need to be overridden by children
  25772. * @hidden
  25773. */
  25774. _updateRigCameras(): void;
  25775. /** @hidden */
  25776. _setupInputs(): void;
  25777. /**
  25778. * Serialiaze the camera setup to a json represention
  25779. * @returns the JSON representation
  25780. */
  25781. serialize(): any;
  25782. /**
  25783. * Clones the current camera.
  25784. * @param name The cloned camera name
  25785. * @returns the cloned camera
  25786. */
  25787. clone(name: string): Camera;
  25788. /**
  25789. * Gets the direction of the camera relative to a given local axis.
  25790. * @param localAxis Defines the reference axis to provide a relative direction.
  25791. * @return the direction
  25792. */
  25793. getDirection(localAxis: Vector3): Vector3;
  25794. /**
  25795. * Returns the current camera absolute rotation
  25796. */
  25797. readonly absoluteRotation: Quaternion;
  25798. /**
  25799. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25800. * @param localAxis Defines the reference axis to provide a relative direction.
  25801. * @param result Defines the vector to store the result in
  25802. */
  25803. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25804. /**
  25805. * Gets a camera constructor for a given camera type
  25806. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25807. * @param name The name of the camera the result will be able to instantiate
  25808. * @param scene The scene the result will construct the camera in
  25809. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25810. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25811. * @returns a factory method to construc the camera
  25812. */
  25813. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25814. /**
  25815. * Compute the world matrix of the camera.
  25816. * @returns the camera workd matrix
  25817. */
  25818. computeWorldMatrix(): Matrix;
  25819. /**
  25820. * Parse a JSON and creates the camera from the parsed information
  25821. * @param parsedCamera The JSON to parse
  25822. * @param scene The scene to instantiate the camera in
  25823. * @returns the newly constructed camera
  25824. */
  25825. static Parse(parsedCamera: any, scene: Scene): Camera;
  25826. }
  25827. }
  25828. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25829. import { Nullable } from "babylonjs/types";
  25830. import { Scene } from "babylonjs/scene";
  25831. import { Vector4 } from "babylonjs/Maths/math.vector";
  25832. import { Mesh } from "babylonjs/Meshes/mesh";
  25833. /**
  25834. * Class containing static functions to help procedurally build meshes
  25835. */
  25836. export class DiscBuilder {
  25837. /**
  25838. * Creates a plane polygonal mesh. By default, this is a disc
  25839. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25840. * * 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
  25841. * * 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
  25842. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25843. * * 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
  25844. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25845. * @param name defines the name of the mesh
  25846. * @param options defines the options used to create the mesh
  25847. * @param scene defines the hosting scene
  25848. * @returns the plane polygonal mesh
  25849. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25850. */
  25851. static CreateDisc(name: string, options: {
  25852. radius?: number;
  25853. tessellation?: number;
  25854. arc?: number;
  25855. updatable?: boolean;
  25856. sideOrientation?: number;
  25857. frontUVs?: Vector4;
  25858. backUVs?: Vector4;
  25859. }, scene?: Nullable<Scene>): Mesh;
  25860. }
  25861. }
  25862. declare module "babylonjs/Particles/solidParticleSystem" {
  25863. import { Vector3 } from "babylonjs/Maths/math.vector";
  25864. import { Mesh } from "babylonjs/Meshes/mesh";
  25865. import { Scene, IDisposable } from "babylonjs/scene";
  25866. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  25867. /**
  25868. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  25869. *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.
  25870. * The SPS is also a particle system. It provides some methods to manage the particles.
  25871. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  25872. *
  25873. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  25874. */
  25875. export class SolidParticleSystem implements IDisposable {
  25876. /**
  25877. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  25878. * Example : var p = SPS.particles[i];
  25879. */
  25880. particles: SolidParticle[];
  25881. /**
  25882. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  25883. */
  25884. nbParticles: number;
  25885. /**
  25886. * If the particles must ever face the camera (default false). Useful for planar particles.
  25887. */
  25888. billboard: boolean;
  25889. /**
  25890. * Recompute normals when adding a shape
  25891. */
  25892. recomputeNormals: boolean;
  25893. /**
  25894. * This a counter ofr your own usage. It's not set by any SPS functions.
  25895. */
  25896. counter: number;
  25897. /**
  25898. * The SPS name. This name is also given to the underlying mesh.
  25899. */
  25900. name: string;
  25901. /**
  25902. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  25903. */
  25904. mesh: Mesh;
  25905. /**
  25906. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  25907. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  25908. */
  25909. vars: any;
  25910. /**
  25911. * This array is populated when the SPS is set as 'pickable'.
  25912. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  25913. * Each element of this array is an object `{idx: int, faceId: int}`.
  25914. * `idx` is the picked particle index in the `SPS.particles` array
  25915. * `faceId` is the picked face index counted within this particle.
  25916. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  25917. */
  25918. pickedParticles: {
  25919. idx: number;
  25920. faceId: number;
  25921. }[];
  25922. /**
  25923. * This array is populated when `enableDepthSort` is set to true.
  25924. * Each element of this array is an instance of the class DepthSortedParticle.
  25925. */
  25926. depthSortedParticles: DepthSortedParticle[];
  25927. /**
  25928. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  25929. * @hidden
  25930. */
  25931. _bSphereOnly: boolean;
  25932. /**
  25933. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  25934. * @hidden
  25935. */
  25936. _bSphereRadiusFactor: number;
  25937. private _scene;
  25938. private _positions;
  25939. private _indices;
  25940. private _normals;
  25941. private _colors;
  25942. private _uvs;
  25943. private _indices32;
  25944. private _positions32;
  25945. private _normals32;
  25946. private _fixedNormal32;
  25947. private _colors32;
  25948. private _uvs32;
  25949. private _index;
  25950. private _updatable;
  25951. private _pickable;
  25952. private _isVisibilityBoxLocked;
  25953. private _alwaysVisible;
  25954. private _depthSort;
  25955. private _expandable;
  25956. private _shapeCounter;
  25957. private _copy;
  25958. private _color;
  25959. private _computeParticleColor;
  25960. private _computeParticleTexture;
  25961. private _computeParticleRotation;
  25962. private _computeParticleVertex;
  25963. private _computeBoundingBox;
  25964. private _depthSortParticles;
  25965. private _camera;
  25966. private _mustUnrotateFixedNormals;
  25967. private _particlesIntersect;
  25968. private _needs32Bits;
  25969. /**
  25970. * Creates a SPS (Solid Particle System) object.
  25971. * @param name (String) is the SPS name, this will be the underlying mesh name.
  25972. * @param scene (Scene) is the scene in which the SPS is added.
  25973. * @param options defines the options of the sps e.g.
  25974. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  25975. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  25976. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  25977. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  25978. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  25979. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  25980. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  25981. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  25982. */
  25983. constructor(name: string, scene: Scene, options?: {
  25984. updatable?: boolean;
  25985. isPickable?: boolean;
  25986. enableDepthSort?: boolean;
  25987. particleIntersection?: boolean;
  25988. boundingSphereOnly?: boolean;
  25989. bSphereRadiusFactor?: number;
  25990. expandable?: boolean;
  25991. });
  25992. /**
  25993. * Builds the SPS underlying mesh. Returns a standard Mesh.
  25994. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  25995. * @returns the created mesh
  25996. */
  25997. buildMesh(): Mesh;
  25998. /**
  25999. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26000. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26001. * Thus the particles generated from `digest()` have their property `position` set yet.
  26002. * @param mesh ( Mesh ) is the mesh to be digested
  26003. * @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
  26004. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26005. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26006. * @returns the current SPS
  26007. */
  26008. digest(mesh: Mesh, options?: {
  26009. facetNb?: number;
  26010. number?: number;
  26011. delta?: number;
  26012. }): SolidParticleSystem;
  26013. private _unrotateFixedNormals;
  26014. private _resetCopy;
  26015. private _meshBuilder;
  26016. private _posToShape;
  26017. private _uvsToShapeUV;
  26018. private _addParticle;
  26019. /**
  26020. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26021. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26022. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26023. * @param nb (positive integer) the number of particles to be created from this model
  26024. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26025. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26026. * @returns the number of shapes in the system
  26027. */
  26028. addShape(mesh: Mesh, nb: number, options?: {
  26029. positionFunction?: any;
  26030. vertexFunction?: any;
  26031. }): number;
  26032. private _rebuildParticle;
  26033. /**
  26034. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26035. * @returns the SPS.
  26036. */
  26037. rebuildMesh(): SolidParticleSystem;
  26038. /**
  26039. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26040. * This method calls `updateParticle()` for each particle of the SPS.
  26041. * For an animated SPS, it is usually called within the render loop.
  26042. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26043. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26044. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26045. * @returns the SPS.
  26046. */
  26047. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26048. /**
  26049. * Disposes the SPS.
  26050. */
  26051. dispose(): void;
  26052. /**
  26053. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26054. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26055. * @returns the SPS.
  26056. */
  26057. refreshVisibleSize(): SolidParticleSystem;
  26058. /**
  26059. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26060. * @param size the size (float) of the visibility box
  26061. * note : this doesn't lock the SPS mesh bounding box.
  26062. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26063. */
  26064. setVisibilityBox(size: number): void;
  26065. /**
  26066. * Gets whether the SPS as always visible or not
  26067. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26068. */
  26069. /**
  26070. * Sets the SPS as always visible or not
  26071. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26072. */
  26073. isAlwaysVisible: boolean;
  26074. /**
  26075. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26077. */
  26078. /**
  26079. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26080. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26081. */
  26082. isVisibilityBoxLocked: boolean;
  26083. /**
  26084. * Tells to `setParticles()` to compute the particle rotations or not.
  26085. * Default value : true. The SPS is faster when it's set to false.
  26086. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26087. */
  26088. /**
  26089. * Gets if `setParticles()` computes the particle rotations or not.
  26090. * Default value : true. The SPS is faster when it's set to false.
  26091. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26092. */
  26093. computeParticleRotation: boolean;
  26094. /**
  26095. * Tells to `setParticles()` to compute the particle colors or not.
  26096. * Default value : true. The SPS is faster when it's set to false.
  26097. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26098. */
  26099. /**
  26100. * Gets if `setParticles()` computes the particle colors or not.
  26101. * Default value : true. The SPS is faster when it's set to false.
  26102. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26103. */
  26104. computeParticleColor: boolean;
  26105. /**
  26106. * Gets if `setParticles()` computes the particle textures or not.
  26107. * Default value : true. The SPS is faster when it's set to false.
  26108. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26109. */
  26110. computeParticleTexture: boolean;
  26111. /**
  26112. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26113. * Default value : false. The SPS is faster when it's set to false.
  26114. * Note : the particle custom vertex positions aren't stored values.
  26115. */
  26116. /**
  26117. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26118. * Default value : false. The SPS is faster when it's set to false.
  26119. * Note : the particle custom vertex positions aren't stored values.
  26120. */
  26121. computeParticleVertex: boolean;
  26122. /**
  26123. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26124. */
  26125. /**
  26126. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26127. */
  26128. computeBoundingBox: boolean;
  26129. /**
  26130. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26131. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26132. * Default : `true`
  26133. */
  26134. /**
  26135. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26136. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26137. * Default : `true`
  26138. */
  26139. depthSortParticles: boolean;
  26140. /**
  26141. * Gets if the SPS is created as expandable at construction time.
  26142. * Default : `false`
  26143. */
  26144. readonly expandable: boolean;
  26145. /**
  26146. * This function does nothing. It may be overwritten to set all the particle first values.
  26147. * The SPS doesn't call this function, you may have to call it by your own.
  26148. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26149. */
  26150. initParticles(): void;
  26151. /**
  26152. * This function does nothing. It may be overwritten to recycle a particle.
  26153. * The SPS doesn't call this function, you may have to call it by your own.
  26154. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26155. * @param particle The particle to recycle
  26156. * @returns the recycled particle
  26157. */
  26158. recycleParticle(particle: SolidParticle): SolidParticle;
  26159. /**
  26160. * Updates a particle : this function should be overwritten by the user.
  26161. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26162. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26163. * @example : just set a particle position or velocity and recycle conditions
  26164. * @param particle The particle to update
  26165. * @returns the updated particle
  26166. */
  26167. updateParticle(particle: SolidParticle): SolidParticle;
  26168. /**
  26169. * Updates a vertex of a particle : it can be overwritten by the user.
  26170. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26171. * @param particle the current particle
  26172. * @param vertex the current index of the current particle
  26173. * @param pt the index of the current vertex in the particle shape
  26174. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26175. * @example : just set a vertex particle position
  26176. * @returns the updated vertex
  26177. */
  26178. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26179. /**
  26180. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26181. * This does nothing and may be overwritten by the user.
  26182. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26183. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26184. * @param update the boolean update value actually passed to setParticles()
  26185. */
  26186. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26187. /**
  26188. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26189. * This will be passed three parameters.
  26190. * This does nothing and may be overwritten by the user.
  26191. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26192. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26193. * @param update the boolean update value actually passed to setParticles()
  26194. */
  26195. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26196. }
  26197. }
  26198. declare module "babylonjs/Particles/solidParticle" {
  26199. import { Nullable } from "babylonjs/types";
  26200. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26201. import { Color4 } from "babylonjs/Maths/math.color";
  26202. import { Mesh } from "babylonjs/Meshes/mesh";
  26203. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26204. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26205. import { Plane } from "babylonjs/Maths/math.plane";
  26206. /**
  26207. * Represents one particle of a solid particle system.
  26208. */
  26209. export class SolidParticle {
  26210. /**
  26211. * particle global index
  26212. */
  26213. idx: number;
  26214. /**
  26215. * The color of the particle
  26216. */
  26217. color: Nullable<Color4>;
  26218. /**
  26219. * The world space position of the particle.
  26220. */
  26221. position: Vector3;
  26222. /**
  26223. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26224. */
  26225. rotation: Vector3;
  26226. /**
  26227. * The world space rotation quaternion of the particle.
  26228. */
  26229. rotationQuaternion: Nullable<Quaternion>;
  26230. /**
  26231. * The scaling of the particle.
  26232. */
  26233. scaling: Vector3;
  26234. /**
  26235. * The uvs of the particle.
  26236. */
  26237. uvs: Vector4;
  26238. /**
  26239. * The current speed of the particle.
  26240. */
  26241. velocity: Vector3;
  26242. /**
  26243. * The pivot point in the particle local space.
  26244. */
  26245. pivot: Vector3;
  26246. /**
  26247. * Must the particle be translated from its pivot point in its local space ?
  26248. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26249. * Default : false
  26250. */
  26251. translateFromPivot: boolean;
  26252. /**
  26253. * Is the particle active or not ?
  26254. */
  26255. alive: boolean;
  26256. /**
  26257. * Is the particle visible or not ?
  26258. */
  26259. isVisible: boolean;
  26260. /**
  26261. * Index of this particle in the global "positions" array (Internal use)
  26262. * @hidden
  26263. */
  26264. _pos: number;
  26265. /**
  26266. * @hidden Index of this particle in the global "indices" array (Internal use)
  26267. */
  26268. _ind: number;
  26269. /**
  26270. * @hidden ModelShape of this particle (Internal use)
  26271. */
  26272. _model: ModelShape;
  26273. /**
  26274. * ModelShape id of this particle
  26275. */
  26276. shapeId: number;
  26277. /**
  26278. * Index of the particle in its shape id
  26279. */
  26280. idxInShape: number;
  26281. /**
  26282. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26283. */
  26284. _modelBoundingInfo: BoundingInfo;
  26285. /**
  26286. * @hidden Particle BoundingInfo object (Internal use)
  26287. */
  26288. _boundingInfo: BoundingInfo;
  26289. /**
  26290. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26291. */
  26292. _sps: SolidParticleSystem;
  26293. /**
  26294. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26295. */
  26296. _stillInvisible: boolean;
  26297. /**
  26298. * @hidden Last computed particle rotation matrix
  26299. */
  26300. _rotationMatrix: number[];
  26301. /**
  26302. * Parent particle Id, if any.
  26303. * Default null.
  26304. */
  26305. parentId: Nullable<number>;
  26306. /**
  26307. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26308. * The possible values are :
  26309. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26310. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26311. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26312. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26313. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26314. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26315. * */
  26316. cullingStrategy: number;
  26317. /**
  26318. * @hidden Internal global position in the SPS.
  26319. */
  26320. _globalPosition: Vector3;
  26321. /**
  26322. * Creates a Solid Particle object.
  26323. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26324. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26325. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26326. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26327. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26328. * @param shapeId (integer) is the model shape identifier in the SPS.
  26329. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26330. * @param sps defines the sps it is associated to
  26331. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26332. */
  26333. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26334. /**
  26335. * Legacy support, changed scale to scaling
  26336. */
  26337. /**
  26338. * Legacy support, changed scale to scaling
  26339. */
  26340. scale: Vector3;
  26341. /**
  26342. * Legacy support, changed quaternion to rotationQuaternion
  26343. */
  26344. /**
  26345. * Legacy support, changed quaternion to rotationQuaternion
  26346. */
  26347. quaternion: Nullable<Quaternion>;
  26348. /**
  26349. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26350. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26351. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26352. * @returns true if it intersects
  26353. */
  26354. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26355. /**
  26356. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26357. * A particle is in the frustum if its bounding box intersects the frustum
  26358. * @param frustumPlanes defines the frustum to test
  26359. * @returns true if the particle is in the frustum planes
  26360. */
  26361. isInFrustum(frustumPlanes: Plane[]): boolean;
  26362. /**
  26363. * get the rotation matrix of the particle
  26364. * @hidden
  26365. */
  26366. getRotationMatrix(m: Matrix): void;
  26367. }
  26368. /**
  26369. * Represents the shape of the model used by one particle of a solid particle system.
  26370. * SPS internal tool, don't use it manually.
  26371. */
  26372. export class ModelShape {
  26373. /**
  26374. * The shape id
  26375. * @hidden
  26376. */
  26377. shapeID: number;
  26378. /**
  26379. * flat array of model positions (internal use)
  26380. * @hidden
  26381. */
  26382. _shape: Vector3[];
  26383. /**
  26384. * flat array of model UVs (internal use)
  26385. * @hidden
  26386. */
  26387. _shapeUV: number[];
  26388. /**
  26389. * length of the shape in the model indices array (internal use)
  26390. * @hidden
  26391. */
  26392. _indicesLength: number;
  26393. /**
  26394. * Custom position function (internal use)
  26395. * @hidden
  26396. */
  26397. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26398. /**
  26399. * Custom vertex function (internal use)
  26400. * @hidden
  26401. */
  26402. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26403. /**
  26404. * 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.
  26405. * SPS internal tool, don't use it manually.
  26406. * @hidden
  26407. */
  26408. 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>);
  26409. }
  26410. /**
  26411. * Represents a Depth Sorted Particle in the solid particle system.
  26412. */
  26413. export class DepthSortedParticle {
  26414. /**
  26415. * Index of the particle in the "indices" array
  26416. */
  26417. ind: number;
  26418. /**
  26419. * Length of the particle shape in the "indices" array
  26420. */
  26421. indicesLength: number;
  26422. /**
  26423. * Squared distance from the particle to the camera
  26424. */
  26425. sqDistance: number;
  26426. }
  26427. }
  26428. declare module "babylonjs/Collisions/meshCollisionData" {
  26429. import { Collider } from "babylonjs/Collisions/collider";
  26430. import { Vector3 } from "babylonjs/Maths/math.vector";
  26431. import { Nullable } from "babylonjs/types";
  26432. import { Observer } from "babylonjs/Misc/observable";
  26433. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26434. /**
  26435. * @hidden
  26436. */
  26437. export class _MeshCollisionData {
  26438. _checkCollisions: boolean;
  26439. _collisionMask: number;
  26440. _collisionGroup: number;
  26441. _collider: Nullable<Collider>;
  26442. _oldPositionForCollisions: Vector3;
  26443. _diffPositionForCollisions: Vector3;
  26444. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26445. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26446. }
  26447. }
  26448. declare module "babylonjs/Meshes/abstractMesh" {
  26449. import { Observable } from "babylonjs/Misc/observable";
  26450. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26451. import { Camera } from "babylonjs/Cameras/camera";
  26452. import { Scene, IDisposable } from "babylonjs/scene";
  26453. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26454. import { Node } from "babylonjs/node";
  26455. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26456. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26457. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26458. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26459. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26460. import { Material } from "babylonjs/Materials/material";
  26461. import { Light } from "babylonjs/Lights/light";
  26462. import { Skeleton } from "babylonjs/Bones/skeleton";
  26463. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26464. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26465. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26466. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26467. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26468. import { Plane } from "babylonjs/Maths/math.plane";
  26469. import { Ray } from "babylonjs/Culling/ray";
  26470. import { Collider } from "babylonjs/Collisions/collider";
  26471. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26472. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26473. /** @hidden */
  26474. class _FacetDataStorage {
  26475. facetPositions: Vector3[];
  26476. facetNormals: Vector3[];
  26477. facetPartitioning: number[][];
  26478. facetNb: number;
  26479. partitioningSubdivisions: number;
  26480. partitioningBBoxRatio: number;
  26481. facetDataEnabled: boolean;
  26482. facetParameters: any;
  26483. bbSize: Vector3;
  26484. subDiv: {
  26485. max: number;
  26486. X: number;
  26487. Y: number;
  26488. Z: number;
  26489. };
  26490. facetDepthSort: boolean;
  26491. facetDepthSortEnabled: boolean;
  26492. depthSortedIndices: IndicesArray;
  26493. depthSortedFacets: {
  26494. ind: number;
  26495. sqDistance: number;
  26496. }[];
  26497. facetDepthSortFunction: (f1: {
  26498. ind: number;
  26499. sqDistance: number;
  26500. }, f2: {
  26501. ind: number;
  26502. sqDistance: number;
  26503. }) => number;
  26504. facetDepthSortFrom: Vector3;
  26505. facetDepthSortOrigin: Vector3;
  26506. invertedMatrix: Matrix;
  26507. }
  26508. /**
  26509. * @hidden
  26510. **/
  26511. class _InternalAbstractMeshDataInfo {
  26512. _hasVertexAlpha: boolean;
  26513. _useVertexColors: boolean;
  26514. _numBoneInfluencers: number;
  26515. _applyFog: boolean;
  26516. _receiveShadows: boolean;
  26517. _facetData: _FacetDataStorage;
  26518. _visibility: number;
  26519. _skeleton: Nullable<Skeleton>;
  26520. _layerMask: number;
  26521. _computeBonesUsingShaders: boolean;
  26522. _isActive: boolean;
  26523. _onlyForInstances: boolean;
  26524. _isActiveIntermediate: boolean;
  26525. _onlyForInstancesIntermediate: boolean;
  26526. _actAsRegularMesh: boolean;
  26527. }
  26528. /**
  26529. * Class used to store all common mesh properties
  26530. */
  26531. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26532. /** No occlusion */
  26533. static OCCLUSION_TYPE_NONE: number;
  26534. /** Occlusion set to optimisitic */
  26535. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26536. /** Occlusion set to strict */
  26537. static OCCLUSION_TYPE_STRICT: number;
  26538. /** Use an accurante occlusion algorithm */
  26539. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26540. /** Use a conservative occlusion algorithm */
  26541. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26542. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26543. * Test order :
  26544. * Is the bounding sphere outside the frustum ?
  26545. * If not, are the bounding box vertices outside the frustum ?
  26546. * It not, then the cullable object is in the frustum.
  26547. */
  26548. static readonly CULLINGSTRATEGY_STANDARD: number;
  26549. /** Culling strategy : Bounding Sphere Only.
  26550. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26551. * It's also less accurate than the standard because some not visible objects can still be selected.
  26552. * Test : is the bounding sphere outside the frustum ?
  26553. * If not, then the cullable object is in the frustum.
  26554. */
  26555. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26556. /** Culling strategy : Optimistic Inclusion.
  26557. * This in an inclusion test first, then the standard exclusion test.
  26558. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26559. * 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.
  26560. * Anyway, it's as accurate as the standard strategy.
  26561. * Test :
  26562. * Is the cullable object bounding sphere center in the frustum ?
  26563. * If not, apply the default culling strategy.
  26564. */
  26565. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26566. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26567. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26568. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26569. * 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.
  26570. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26571. * Test :
  26572. * Is the cullable object bounding sphere center in the frustum ?
  26573. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26574. */
  26575. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26576. /**
  26577. * No billboard
  26578. */
  26579. static readonly BILLBOARDMODE_NONE: number;
  26580. /** Billboard on X axis */
  26581. static readonly BILLBOARDMODE_X: number;
  26582. /** Billboard on Y axis */
  26583. static readonly BILLBOARDMODE_Y: number;
  26584. /** Billboard on Z axis */
  26585. static readonly BILLBOARDMODE_Z: number;
  26586. /** Billboard on all axes */
  26587. static readonly BILLBOARDMODE_ALL: number;
  26588. /** Billboard on using position instead of orientation */
  26589. static readonly BILLBOARDMODE_USE_POSITION: number;
  26590. /** @hidden */
  26591. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26592. /**
  26593. * The culling strategy to use to check whether the mesh must be rendered or not.
  26594. * This value can be changed at any time and will be used on the next render mesh selection.
  26595. * The possible values are :
  26596. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26597. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26598. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26599. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26600. * Please read each static variable documentation to get details about the culling process.
  26601. * */
  26602. cullingStrategy: number;
  26603. /**
  26604. * Gets the number of facets in the mesh
  26605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26606. */
  26607. readonly facetNb: number;
  26608. /**
  26609. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26610. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26611. */
  26612. partitioningSubdivisions: number;
  26613. /**
  26614. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26615. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26617. */
  26618. partitioningBBoxRatio: number;
  26619. /**
  26620. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26621. * Works only for updatable meshes.
  26622. * Doesn't work with multi-materials
  26623. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26624. */
  26625. mustDepthSortFacets: boolean;
  26626. /**
  26627. * The location (Vector3) where the facet depth sort must be computed from.
  26628. * By default, the active camera position.
  26629. * Used only when facet depth sort is enabled
  26630. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26631. */
  26632. facetDepthSortFrom: Vector3;
  26633. /**
  26634. * gets a boolean indicating if facetData is enabled
  26635. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26636. */
  26637. readonly isFacetDataEnabled: boolean;
  26638. /** @hidden */
  26639. _updateNonUniformScalingState(value: boolean): boolean;
  26640. /**
  26641. * An event triggered when this mesh collides with another one
  26642. */
  26643. onCollideObservable: Observable<AbstractMesh>;
  26644. /** Set a function to call when this mesh collides with another one */
  26645. onCollide: () => void;
  26646. /**
  26647. * An event triggered when the collision's position changes
  26648. */
  26649. onCollisionPositionChangeObservable: Observable<Vector3>;
  26650. /** Set a function to call when the collision's position changes */
  26651. onCollisionPositionChange: () => void;
  26652. /**
  26653. * An event triggered when material is changed
  26654. */
  26655. onMaterialChangedObservable: Observable<AbstractMesh>;
  26656. /**
  26657. * Gets or sets the orientation for POV movement & rotation
  26658. */
  26659. definedFacingForward: boolean;
  26660. /** @hidden */
  26661. _occlusionQuery: Nullable<WebGLQuery>;
  26662. /** @hidden */
  26663. _renderingGroup: Nullable<RenderingGroup>;
  26664. /**
  26665. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26666. */
  26667. /**
  26668. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26669. */
  26670. visibility: number;
  26671. /** Gets or sets the alpha index used to sort transparent meshes
  26672. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26673. */
  26674. alphaIndex: number;
  26675. /**
  26676. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26677. */
  26678. isVisible: boolean;
  26679. /**
  26680. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26681. */
  26682. isPickable: boolean;
  26683. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26684. showSubMeshesBoundingBox: boolean;
  26685. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26686. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26687. */
  26688. isBlocker: boolean;
  26689. /**
  26690. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26691. */
  26692. enablePointerMoveEvents: boolean;
  26693. /**
  26694. * Specifies the rendering group id for this mesh (0 by default)
  26695. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26696. */
  26697. renderingGroupId: number;
  26698. private _material;
  26699. /** Gets or sets current material */
  26700. material: Nullable<Material>;
  26701. /**
  26702. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26703. * @see http://doc.babylonjs.com/babylon101/shadows
  26704. */
  26705. receiveShadows: boolean;
  26706. /** Defines color to use when rendering outline */
  26707. outlineColor: Color3;
  26708. /** Define width to use when rendering outline */
  26709. outlineWidth: number;
  26710. /** Defines color to use when rendering overlay */
  26711. overlayColor: Color3;
  26712. /** Defines alpha to use when rendering overlay */
  26713. overlayAlpha: number;
  26714. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26715. hasVertexAlpha: boolean;
  26716. /** 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) */
  26717. useVertexColors: boolean;
  26718. /**
  26719. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26720. */
  26721. computeBonesUsingShaders: boolean;
  26722. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26723. numBoneInfluencers: number;
  26724. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26725. applyFog: boolean;
  26726. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26727. useOctreeForRenderingSelection: boolean;
  26728. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26729. useOctreeForPicking: boolean;
  26730. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26731. useOctreeForCollisions: boolean;
  26732. /**
  26733. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26734. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26735. */
  26736. layerMask: number;
  26737. /**
  26738. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26739. */
  26740. alwaysSelectAsActiveMesh: boolean;
  26741. /**
  26742. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26743. */
  26744. doNotSyncBoundingInfo: boolean;
  26745. /**
  26746. * Gets or sets the current action manager
  26747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26748. */
  26749. actionManager: Nullable<AbstractActionManager>;
  26750. private _meshCollisionData;
  26751. /**
  26752. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26753. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26754. */
  26755. ellipsoid: Vector3;
  26756. /**
  26757. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26758. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26759. */
  26760. ellipsoidOffset: Vector3;
  26761. /**
  26762. * Gets or sets a collision mask used to mask collisions (default is -1).
  26763. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26764. */
  26765. collisionMask: number;
  26766. /**
  26767. * Gets or sets the current collision group mask (-1 by default).
  26768. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26769. */
  26770. collisionGroup: number;
  26771. /**
  26772. * Defines edge width used when edgesRenderer is enabled
  26773. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26774. */
  26775. edgesWidth: number;
  26776. /**
  26777. * Defines edge color used when edgesRenderer is enabled
  26778. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26779. */
  26780. edgesColor: Color4;
  26781. /** @hidden */
  26782. _edgesRenderer: Nullable<IEdgesRenderer>;
  26783. /** @hidden */
  26784. _masterMesh: Nullable<AbstractMesh>;
  26785. /** @hidden */
  26786. _boundingInfo: Nullable<BoundingInfo>;
  26787. /** @hidden */
  26788. _renderId: number;
  26789. /**
  26790. * Gets or sets the list of subMeshes
  26791. * @see http://doc.babylonjs.com/how_to/multi_materials
  26792. */
  26793. subMeshes: SubMesh[];
  26794. /** @hidden */
  26795. _intersectionsInProgress: AbstractMesh[];
  26796. /** @hidden */
  26797. _unIndexed: boolean;
  26798. /** @hidden */
  26799. _lightSources: Light[];
  26800. /** Gets the list of lights affecting that mesh */
  26801. readonly lightSources: Light[];
  26802. /** @hidden */
  26803. readonly _positions: Nullable<Vector3[]>;
  26804. /** @hidden */
  26805. _waitingData: {
  26806. lods: Nullable<any>;
  26807. actions: Nullable<any>;
  26808. freezeWorldMatrix: Nullable<boolean>;
  26809. };
  26810. /** @hidden */
  26811. _bonesTransformMatrices: Nullable<Float32Array>;
  26812. /** @hidden */
  26813. _transformMatrixTexture: Nullable<RawTexture>;
  26814. /**
  26815. * Gets or sets a skeleton to apply skining transformations
  26816. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26817. */
  26818. skeleton: Nullable<Skeleton>;
  26819. /**
  26820. * An event triggered when the mesh is rebuilt.
  26821. */
  26822. onRebuildObservable: Observable<AbstractMesh>;
  26823. /**
  26824. * Creates a new AbstractMesh
  26825. * @param name defines the name of the mesh
  26826. * @param scene defines the hosting scene
  26827. */
  26828. constructor(name: string, scene?: Nullable<Scene>);
  26829. /**
  26830. * Returns the string "AbstractMesh"
  26831. * @returns "AbstractMesh"
  26832. */
  26833. getClassName(): string;
  26834. /**
  26835. * Gets a string representation of the current mesh
  26836. * @param fullDetails defines a boolean indicating if full details must be included
  26837. * @returns a string representation of the current mesh
  26838. */
  26839. toString(fullDetails?: boolean): string;
  26840. /**
  26841. * @hidden
  26842. */
  26843. protected _getEffectiveParent(): Nullable<Node>;
  26844. /** @hidden */
  26845. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26846. /** @hidden */
  26847. _rebuild(): void;
  26848. /** @hidden */
  26849. _resyncLightSources(): void;
  26850. /** @hidden */
  26851. _resyncLighSource(light: Light): void;
  26852. /** @hidden */
  26853. _unBindEffect(): void;
  26854. /** @hidden */
  26855. _removeLightSource(light: Light, dispose: boolean): void;
  26856. private _markSubMeshesAsDirty;
  26857. /** @hidden */
  26858. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26859. /** @hidden */
  26860. _markSubMeshesAsAttributesDirty(): void;
  26861. /** @hidden */
  26862. _markSubMeshesAsMiscDirty(): void;
  26863. /**
  26864. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  26865. */
  26866. scaling: Vector3;
  26867. /**
  26868. * Returns true if the mesh is blocked. Implemented by child classes
  26869. */
  26870. readonly isBlocked: boolean;
  26871. /**
  26872. * Returns the mesh itself by default. Implemented by child classes
  26873. * @param camera defines the camera to use to pick the right LOD level
  26874. * @returns the currentAbstractMesh
  26875. */
  26876. getLOD(camera: Camera): Nullable<AbstractMesh>;
  26877. /**
  26878. * Returns 0 by default. Implemented by child classes
  26879. * @returns an integer
  26880. */
  26881. getTotalVertices(): number;
  26882. /**
  26883. * Returns a positive integer : the total number of indices in this mesh geometry.
  26884. * @returns the numner of indices or zero if the mesh has no geometry.
  26885. */
  26886. getTotalIndices(): number;
  26887. /**
  26888. * Returns null by default. Implemented by child classes
  26889. * @returns null
  26890. */
  26891. getIndices(): Nullable<IndicesArray>;
  26892. /**
  26893. * Returns the array of the requested vertex data kind. Implemented by child classes
  26894. * @param kind defines the vertex data kind to use
  26895. * @returns null
  26896. */
  26897. getVerticesData(kind: string): Nullable<FloatArray>;
  26898. /**
  26899. * Sets the vertex data of the mesh geometry for the requested `kind`.
  26900. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  26901. * Note that a new underlying VertexBuffer object is created each call.
  26902. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  26903. * @param kind defines vertex data kind:
  26904. * * VertexBuffer.PositionKind
  26905. * * VertexBuffer.UVKind
  26906. * * VertexBuffer.UV2Kind
  26907. * * VertexBuffer.UV3Kind
  26908. * * VertexBuffer.UV4Kind
  26909. * * VertexBuffer.UV5Kind
  26910. * * VertexBuffer.UV6Kind
  26911. * * VertexBuffer.ColorKind
  26912. * * VertexBuffer.MatricesIndicesKind
  26913. * * VertexBuffer.MatricesIndicesExtraKind
  26914. * * VertexBuffer.MatricesWeightsKind
  26915. * * VertexBuffer.MatricesWeightsExtraKind
  26916. * @param data defines the data source
  26917. * @param updatable defines if the data must be flagged as updatable (or static)
  26918. * @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
  26919. * @returns the current mesh
  26920. */
  26921. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  26922. /**
  26923. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  26924. * If the mesh has no geometry, it is simply returned as it is.
  26925. * @param kind defines vertex data kind:
  26926. * * VertexBuffer.PositionKind
  26927. * * VertexBuffer.UVKind
  26928. * * VertexBuffer.UV2Kind
  26929. * * VertexBuffer.UV3Kind
  26930. * * VertexBuffer.UV4Kind
  26931. * * VertexBuffer.UV5Kind
  26932. * * VertexBuffer.UV6Kind
  26933. * * VertexBuffer.ColorKind
  26934. * * VertexBuffer.MatricesIndicesKind
  26935. * * VertexBuffer.MatricesIndicesExtraKind
  26936. * * VertexBuffer.MatricesWeightsKind
  26937. * * VertexBuffer.MatricesWeightsExtraKind
  26938. * @param data defines the data source
  26939. * @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
  26940. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  26941. * @returns the current mesh
  26942. */
  26943. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  26944. /**
  26945. * Sets the mesh indices,
  26946. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  26947. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  26948. * @param totalVertices Defines the total number of vertices
  26949. * @returns the current mesh
  26950. */
  26951. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  26952. /**
  26953. * Gets a boolean indicating if specific vertex data is present
  26954. * @param kind defines the vertex data kind to use
  26955. * @returns true is data kind is present
  26956. */
  26957. isVerticesDataPresent(kind: string): boolean;
  26958. /**
  26959. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  26960. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  26961. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  26962. * @returns a BoundingInfo
  26963. */
  26964. getBoundingInfo(): BoundingInfo;
  26965. /**
  26966. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  26967. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  26968. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  26969. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  26970. * @returns the current mesh
  26971. */
  26972. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  26973. /**
  26974. * Overwrite the current bounding info
  26975. * @param boundingInfo defines the new bounding info
  26976. * @returns the current mesh
  26977. */
  26978. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  26979. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  26980. readonly useBones: boolean;
  26981. /** @hidden */
  26982. _preActivate(): void;
  26983. /** @hidden */
  26984. _preActivateForIntermediateRendering(renderId: number): void;
  26985. /** @hidden */
  26986. _activate(renderId: number, intermediateRendering: boolean): boolean;
  26987. /** @hidden */
  26988. _postActivate(): void;
  26989. /** @hidden */
  26990. _freeze(): void;
  26991. /** @hidden */
  26992. _unFreeze(): void;
  26993. /**
  26994. * Gets the current world matrix
  26995. * @returns a Matrix
  26996. */
  26997. getWorldMatrix(): Matrix;
  26998. /** @hidden */
  26999. _getWorldMatrixDeterminant(): number;
  27000. /**
  27001. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27002. */
  27003. readonly isAnInstance: boolean;
  27004. /**
  27005. * Gets a boolean indicating if this mesh has instances
  27006. */
  27007. readonly hasInstances: boolean;
  27008. /**
  27009. * Perform relative position change from the point of view of behind the front of the mesh.
  27010. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27011. * Supports definition of mesh facing forward or backward
  27012. * @param amountRight defines the distance on the right axis
  27013. * @param amountUp defines the distance on the up axis
  27014. * @param amountForward defines the distance on the forward axis
  27015. * @returns the current mesh
  27016. */
  27017. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27018. /**
  27019. * Calculate relative position change from the point of view of behind the front of the mesh.
  27020. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27021. * Supports definition of mesh facing forward or backward
  27022. * @param amountRight defines the distance on the right axis
  27023. * @param amountUp defines the distance on the up axis
  27024. * @param amountForward defines the distance on the forward axis
  27025. * @returns the new displacement vector
  27026. */
  27027. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27028. /**
  27029. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27030. * Supports definition of mesh facing forward or backward
  27031. * @param flipBack defines the flip
  27032. * @param twirlClockwise defines the twirl
  27033. * @param tiltRight defines the tilt
  27034. * @returns the current mesh
  27035. */
  27036. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27037. /**
  27038. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27039. * Supports definition of mesh facing forward or backward.
  27040. * @param flipBack defines the flip
  27041. * @param twirlClockwise defines the twirl
  27042. * @param tiltRight defines the tilt
  27043. * @returns the new rotation vector
  27044. */
  27045. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27046. /**
  27047. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27048. * This means the mesh underlying bounding box and sphere are recomputed.
  27049. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27050. * @returns the current mesh
  27051. */
  27052. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27053. /** @hidden */
  27054. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27055. /** @hidden */
  27056. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27057. /** @hidden */
  27058. _updateBoundingInfo(): AbstractMesh;
  27059. /** @hidden */
  27060. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27061. /** @hidden */
  27062. protected _afterComputeWorldMatrix(): void;
  27063. /** @hidden */
  27064. readonly _effectiveMesh: AbstractMesh;
  27065. /**
  27066. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27067. * A mesh is in the frustum if its bounding box intersects the frustum
  27068. * @param frustumPlanes defines the frustum to test
  27069. * @returns true if the mesh is in the frustum planes
  27070. */
  27071. isInFrustum(frustumPlanes: Plane[]): boolean;
  27072. /**
  27073. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27074. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27075. * @param frustumPlanes defines the frustum to test
  27076. * @returns true if the mesh is completely in the frustum planes
  27077. */
  27078. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27079. /**
  27080. * True if the mesh intersects another mesh or a SolidParticle object
  27081. * @param mesh defines a target mesh or SolidParticle to test
  27082. * @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)
  27083. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27084. * @returns true if there is an intersection
  27085. */
  27086. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27087. /**
  27088. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27089. * @param point defines the point to test
  27090. * @returns true if there is an intersection
  27091. */
  27092. intersectsPoint(point: Vector3): boolean;
  27093. /**
  27094. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27095. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27096. */
  27097. checkCollisions: boolean;
  27098. /**
  27099. * Gets Collider object used to compute collisions (not physics)
  27100. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27101. */
  27102. readonly collider: Nullable<Collider>;
  27103. /**
  27104. * Move the mesh using collision engine
  27105. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27106. * @param displacement defines the requested displacement vector
  27107. * @returns the current mesh
  27108. */
  27109. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27110. private _onCollisionPositionChange;
  27111. /** @hidden */
  27112. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27113. /** @hidden */
  27114. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27115. /** @hidden */
  27116. _checkCollision(collider: Collider): AbstractMesh;
  27117. /** @hidden */
  27118. _generatePointsArray(): boolean;
  27119. /**
  27120. * Checks if the passed Ray intersects with the mesh
  27121. * @param ray defines the ray to use
  27122. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27123. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27124. * @returns the picking info
  27125. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27126. */
  27127. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27128. /**
  27129. * Clones the current mesh
  27130. * @param name defines the mesh name
  27131. * @param newParent defines the new mesh parent
  27132. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27133. * @returns the new mesh
  27134. */
  27135. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27136. /**
  27137. * Disposes all the submeshes of the current meshnp
  27138. * @returns the current mesh
  27139. */
  27140. releaseSubMeshes(): AbstractMesh;
  27141. /**
  27142. * Releases resources associated with this abstract mesh.
  27143. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27144. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27145. */
  27146. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27147. /**
  27148. * Adds the passed mesh as a child to the current mesh
  27149. * @param mesh defines the child mesh
  27150. * @returns the current mesh
  27151. */
  27152. addChild(mesh: AbstractMesh): AbstractMesh;
  27153. /**
  27154. * Removes the passed mesh from the current mesh children list
  27155. * @param mesh defines the child mesh
  27156. * @returns the current mesh
  27157. */
  27158. removeChild(mesh: AbstractMesh): AbstractMesh;
  27159. /** @hidden */
  27160. private _initFacetData;
  27161. /**
  27162. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27163. * This method can be called within the render loop.
  27164. * 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
  27165. * @returns the current mesh
  27166. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27167. */
  27168. updateFacetData(): AbstractMesh;
  27169. /**
  27170. * Returns the facetLocalNormals array.
  27171. * The normals are expressed in the mesh local spac
  27172. * @returns an array of Vector3
  27173. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27174. */
  27175. getFacetLocalNormals(): Vector3[];
  27176. /**
  27177. * Returns the facetLocalPositions array.
  27178. * The facet positions are expressed in the mesh local space
  27179. * @returns an array of Vector3
  27180. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27181. */
  27182. getFacetLocalPositions(): Vector3[];
  27183. /**
  27184. * Returns the facetLocalPartioning array
  27185. * @returns an array of array of numbers
  27186. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27187. */
  27188. getFacetLocalPartitioning(): number[][];
  27189. /**
  27190. * Returns the i-th facet position in the world system.
  27191. * This method allocates a new Vector3 per call
  27192. * @param i defines the facet index
  27193. * @returns a new Vector3
  27194. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27195. */
  27196. getFacetPosition(i: number): Vector3;
  27197. /**
  27198. * Sets the reference Vector3 with the i-th facet position in the world system
  27199. * @param i defines the facet index
  27200. * @param ref defines the target vector
  27201. * @returns the current mesh
  27202. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27203. */
  27204. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27205. /**
  27206. * Returns the i-th facet normal in the world system.
  27207. * This method allocates a new Vector3 per call
  27208. * @param i defines the facet index
  27209. * @returns a new Vector3
  27210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27211. */
  27212. getFacetNormal(i: number): Vector3;
  27213. /**
  27214. * Sets the reference Vector3 with the i-th facet normal in the world system
  27215. * @param i defines the facet index
  27216. * @param ref defines the target vector
  27217. * @returns the current mesh
  27218. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27219. */
  27220. getFacetNormalToRef(i: number, ref: Vector3): this;
  27221. /**
  27222. * 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)
  27223. * @param x defines x coordinate
  27224. * @param y defines y coordinate
  27225. * @param z defines z coordinate
  27226. * @returns the array of facet indexes
  27227. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27228. */
  27229. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27230. /**
  27231. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27232. * @param projected sets as the (x,y,z) world projection on the facet
  27233. * @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
  27234. * @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
  27235. * @param x defines x coordinate
  27236. * @param y defines y coordinate
  27237. * @param z defines z coordinate
  27238. * @returns the face index if found (or null instead)
  27239. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27240. */
  27241. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27242. /**
  27243. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27244. * @param projected sets as the (x,y,z) local projection on the facet
  27245. * @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
  27246. * @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
  27247. * @param x defines x coordinate
  27248. * @param y defines y coordinate
  27249. * @param z defines z coordinate
  27250. * @returns the face index if found (or null instead)
  27251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27252. */
  27253. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27254. /**
  27255. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27256. * @returns the parameters
  27257. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27258. */
  27259. getFacetDataParameters(): any;
  27260. /**
  27261. * Disables the feature FacetData and frees the related memory
  27262. * @returns the current mesh
  27263. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27264. */
  27265. disableFacetData(): AbstractMesh;
  27266. /**
  27267. * Updates the AbstractMesh indices array
  27268. * @param indices defines the data source
  27269. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27270. * @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)
  27271. * @returns the current mesh
  27272. */
  27273. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27274. /**
  27275. * Creates new normals data for the mesh
  27276. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27277. * @returns the current mesh
  27278. */
  27279. createNormals(updatable: boolean): AbstractMesh;
  27280. /**
  27281. * Align the mesh with a normal
  27282. * @param normal defines the normal to use
  27283. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27284. * @returns the current mesh
  27285. */
  27286. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27287. /** @hidden */
  27288. _checkOcclusionQuery(): boolean;
  27289. /**
  27290. * Disables the mesh edge rendering mode
  27291. * @returns the currentAbstractMesh
  27292. */
  27293. disableEdgesRendering(): AbstractMesh;
  27294. /**
  27295. * Enables the edge rendering mode on the mesh.
  27296. * This mode makes the mesh edges visible
  27297. * @param epsilon defines the maximal distance between two angles to detect a face
  27298. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27299. * @returns the currentAbstractMesh
  27300. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27301. */
  27302. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27303. }
  27304. }
  27305. declare module "babylonjs/Actions/actionEvent" {
  27306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27307. import { Nullable } from "babylonjs/types";
  27308. import { Sprite } from "babylonjs/Sprites/sprite";
  27309. import { Scene } from "babylonjs/scene";
  27310. import { Vector2 } from "babylonjs/Maths/math.vector";
  27311. /**
  27312. * Interface used to define ActionEvent
  27313. */
  27314. export interface IActionEvent {
  27315. /** The mesh or sprite that triggered the action */
  27316. source: any;
  27317. /** The X mouse cursor position at the time of the event */
  27318. pointerX: number;
  27319. /** The Y mouse cursor position at the time of the event */
  27320. pointerY: number;
  27321. /** The mesh that is currently pointed at (can be null) */
  27322. meshUnderPointer: Nullable<AbstractMesh>;
  27323. /** the original (browser) event that triggered the ActionEvent */
  27324. sourceEvent?: any;
  27325. /** additional data for the event */
  27326. additionalData?: any;
  27327. }
  27328. /**
  27329. * ActionEvent is the event being sent when an action is triggered.
  27330. */
  27331. export class ActionEvent implements IActionEvent {
  27332. /** The mesh or sprite that triggered the action */
  27333. source: any;
  27334. /** The X mouse cursor position at the time of the event */
  27335. pointerX: number;
  27336. /** The Y mouse cursor position at the time of the event */
  27337. pointerY: number;
  27338. /** The mesh that is currently pointed at (can be null) */
  27339. meshUnderPointer: Nullable<AbstractMesh>;
  27340. /** the original (browser) event that triggered the ActionEvent */
  27341. sourceEvent?: any;
  27342. /** additional data for the event */
  27343. additionalData?: any;
  27344. /**
  27345. * Creates a new ActionEvent
  27346. * @param source The mesh or sprite that triggered the action
  27347. * @param pointerX The X mouse cursor position at the time of the event
  27348. * @param pointerY The Y mouse cursor position at the time of the event
  27349. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27350. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27351. * @param additionalData additional data for the event
  27352. */
  27353. constructor(
  27354. /** The mesh or sprite that triggered the action */
  27355. source: any,
  27356. /** The X mouse cursor position at the time of the event */
  27357. pointerX: number,
  27358. /** The Y mouse cursor position at the time of the event */
  27359. pointerY: number,
  27360. /** The mesh that is currently pointed at (can be null) */
  27361. meshUnderPointer: Nullable<AbstractMesh>,
  27362. /** the original (browser) event that triggered the ActionEvent */
  27363. sourceEvent?: any,
  27364. /** additional data for the event */
  27365. additionalData?: any);
  27366. /**
  27367. * Helper function to auto-create an ActionEvent from a source mesh.
  27368. * @param source The source mesh that triggered the event
  27369. * @param evt The original (browser) event
  27370. * @param additionalData additional data for the event
  27371. * @returns the new ActionEvent
  27372. */
  27373. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27374. /**
  27375. * Helper function to auto-create an ActionEvent from a source sprite
  27376. * @param source The source sprite that triggered the event
  27377. * @param scene Scene associated with the sprite
  27378. * @param evt The original (browser) event
  27379. * @param additionalData additional data for the event
  27380. * @returns the new ActionEvent
  27381. */
  27382. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27383. /**
  27384. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27385. * @param scene the scene where the event occurred
  27386. * @param evt The original (browser) event
  27387. * @returns the new ActionEvent
  27388. */
  27389. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27390. /**
  27391. * Helper function to auto-create an ActionEvent from a primitive
  27392. * @param prim defines the target primitive
  27393. * @param pointerPos defines the pointer position
  27394. * @param evt The original (browser) event
  27395. * @param additionalData additional data for the event
  27396. * @returns the new ActionEvent
  27397. */
  27398. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27399. }
  27400. }
  27401. declare module "babylonjs/Actions/abstractActionManager" {
  27402. import { IDisposable } from "babylonjs/scene";
  27403. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27404. import { IAction } from "babylonjs/Actions/action";
  27405. import { Nullable } from "babylonjs/types";
  27406. /**
  27407. * Abstract class used to decouple action Manager from scene and meshes.
  27408. * Do not instantiate.
  27409. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27410. */
  27411. export abstract class AbstractActionManager implements IDisposable {
  27412. /** Gets the list of active triggers */
  27413. static Triggers: {
  27414. [key: string]: number;
  27415. };
  27416. /** Gets the cursor to use when hovering items */
  27417. hoverCursor: string;
  27418. /** Gets the list of actions */
  27419. actions: IAction[];
  27420. /**
  27421. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27422. */
  27423. isRecursive: boolean;
  27424. /**
  27425. * Releases all associated resources
  27426. */
  27427. abstract dispose(): void;
  27428. /**
  27429. * Does this action manager has pointer triggers
  27430. */
  27431. abstract readonly hasPointerTriggers: boolean;
  27432. /**
  27433. * Does this action manager has pick triggers
  27434. */
  27435. abstract readonly hasPickTriggers: boolean;
  27436. /**
  27437. * Process a specific trigger
  27438. * @param trigger defines the trigger to process
  27439. * @param evt defines the event details to be processed
  27440. */
  27441. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27442. /**
  27443. * Does this action manager handles actions of any of the given triggers
  27444. * @param triggers defines the triggers to be tested
  27445. * @return a boolean indicating whether one (or more) of the triggers is handled
  27446. */
  27447. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27448. /**
  27449. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27450. * speed.
  27451. * @param triggerA defines the trigger to be tested
  27452. * @param triggerB defines the trigger to be tested
  27453. * @return a boolean indicating whether one (or more) of the triggers is handled
  27454. */
  27455. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27456. /**
  27457. * Does this action manager handles actions of a given trigger
  27458. * @param trigger defines the trigger to be tested
  27459. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27460. * @return whether the trigger is handled
  27461. */
  27462. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27463. /**
  27464. * Serialize this manager to a JSON object
  27465. * @param name defines the property name to store this manager
  27466. * @returns a JSON representation of this manager
  27467. */
  27468. abstract serialize(name: string): any;
  27469. /**
  27470. * Registers an action to this action manager
  27471. * @param action defines the action to be registered
  27472. * @return the action amended (prepared) after registration
  27473. */
  27474. abstract registerAction(action: IAction): Nullable<IAction>;
  27475. /**
  27476. * Unregisters an action to this action manager
  27477. * @param action defines the action to be unregistered
  27478. * @return a boolean indicating whether the action has been unregistered
  27479. */
  27480. abstract unregisterAction(action: IAction): Boolean;
  27481. /**
  27482. * Does exist one action manager with at least one trigger
  27483. **/
  27484. static readonly HasTriggers: boolean;
  27485. /**
  27486. * Does exist one action manager with at least one pick trigger
  27487. **/
  27488. static readonly HasPickTriggers: boolean;
  27489. /**
  27490. * Does exist one action manager that handles actions of a given trigger
  27491. * @param trigger defines the trigger to be tested
  27492. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27493. **/
  27494. static HasSpecificTrigger(trigger: number): boolean;
  27495. }
  27496. }
  27497. declare module "babylonjs/node" {
  27498. import { Scene } from "babylonjs/scene";
  27499. import { Nullable } from "babylonjs/types";
  27500. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27501. import { Engine } from "babylonjs/Engines/engine";
  27502. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27503. import { Observable } from "babylonjs/Misc/observable";
  27504. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27505. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27506. import { Animatable } from "babylonjs/Animations/animatable";
  27507. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27508. import { Animation } from "babylonjs/Animations/animation";
  27509. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27510. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27511. /**
  27512. * Defines how a node can be built from a string name.
  27513. */
  27514. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27515. /**
  27516. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27517. */
  27518. export class Node implements IBehaviorAware<Node> {
  27519. /** @hidden */
  27520. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27521. private static _NodeConstructors;
  27522. /**
  27523. * Add a new node constructor
  27524. * @param type defines the type name of the node to construct
  27525. * @param constructorFunc defines the constructor function
  27526. */
  27527. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27528. /**
  27529. * Returns a node constructor based on type name
  27530. * @param type defines the type name
  27531. * @param name defines the new node name
  27532. * @param scene defines the hosting scene
  27533. * @param options defines optional options to transmit to constructors
  27534. * @returns the new constructor or null
  27535. */
  27536. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27537. /**
  27538. * Gets or sets the name of the node
  27539. */
  27540. name: string;
  27541. /**
  27542. * Gets or sets the id of the node
  27543. */
  27544. id: string;
  27545. /**
  27546. * Gets or sets the unique id of the node
  27547. */
  27548. uniqueId: number;
  27549. /**
  27550. * Gets or sets a string used to store user defined state for the node
  27551. */
  27552. state: string;
  27553. /**
  27554. * Gets or sets an object used to store user defined information for the node
  27555. */
  27556. metadata: any;
  27557. /**
  27558. * For internal use only. Please do not use.
  27559. */
  27560. reservedDataStore: any;
  27561. /**
  27562. * List of inspectable custom properties (used by the Inspector)
  27563. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27564. */
  27565. inspectableCustomProperties: IInspectable[];
  27566. private _doNotSerialize;
  27567. /**
  27568. * Gets or sets a boolean used to define if the node must be serialized
  27569. */
  27570. doNotSerialize: boolean;
  27571. /** @hidden */
  27572. _isDisposed: boolean;
  27573. /**
  27574. * Gets a list of Animations associated with the node
  27575. */
  27576. animations: import("babylonjs/Animations/animation").Animation[];
  27577. protected _ranges: {
  27578. [name: string]: Nullable<AnimationRange>;
  27579. };
  27580. /**
  27581. * Callback raised when the node is ready to be used
  27582. */
  27583. onReady: Nullable<(node: Node) => void>;
  27584. private _isEnabled;
  27585. private _isParentEnabled;
  27586. private _isReady;
  27587. /** @hidden */
  27588. _currentRenderId: number;
  27589. private _parentUpdateId;
  27590. /** @hidden */
  27591. _childUpdateId: number;
  27592. /** @hidden */
  27593. _waitingParentId: Nullable<string>;
  27594. /** @hidden */
  27595. _scene: Scene;
  27596. /** @hidden */
  27597. _cache: any;
  27598. private _parentNode;
  27599. private _children;
  27600. /** @hidden */
  27601. _worldMatrix: Matrix;
  27602. /** @hidden */
  27603. _worldMatrixDeterminant: number;
  27604. /** @hidden */
  27605. _worldMatrixDeterminantIsDirty: boolean;
  27606. /** @hidden */
  27607. private _sceneRootNodesIndex;
  27608. /**
  27609. * Gets a boolean indicating if the node has been disposed
  27610. * @returns true if the node was disposed
  27611. */
  27612. isDisposed(): boolean;
  27613. /**
  27614. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27615. * @see https://doc.babylonjs.com/how_to/parenting
  27616. */
  27617. parent: Nullable<Node>;
  27618. private addToSceneRootNodes;
  27619. private removeFromSceneRootNodes;
  27620. private _animationPropertiesOverride;
  27621. /**
  27622. * Gets or sets the animation properties override
  27623. */
  27624. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27625. /**
  27626. * Gets a string idenfifying the name of the class
  27627. * @returns "Node" string
  27628. */
  27629. getClassName(): string;
  27630. /** @hidden */
  27631. readonly _isNode: boolean;
  27632. /**
  27633. * An event triggered when the mesh is disposed
  27634. */
  27635. onDisposeObservable: Observable<Node>;
  27636. private _onDisposeObserver;
  27637. /**
  27638. * Sets a callback that will be raised when the node will be disposed
  27639. */
  27640. onDispose: () => void;
  27641. /**
  27642. * Creates a new Node
  27643. * @param name the name and id to be given to this node
  27644. * @param scene the scene this node will be added to
  27645. * @param addToRootNodes the node will be added to scene.rootNodes
  27646. */
  27647. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27648. /**
  27649. * Gets the scene of the node
  27650. * @returns a scene
  27651. */
  27652. getScene(): Scene;
  27653. /**
  27654. * Gets the engine of the node
  27655. * @returns a Engine
  27656. */
  27657. getEngine(): Engine;
  27658. private _behaviors;
  27659. /**
  27660. * Attach a behavior to the node
  27661. * @see http://doc.babylonjs.com/features/behaviour
  27662. * @param behavior defines the behavior to attach
  27663. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27664. * @returns the current Node
  27665. */
  27666. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27667. /**
  27668. * Remove an attached behavior
  27669. * @see http://doc.babylonjs.com/features/behaviour
  27670. * @param behavior defines the behavior to attach
  27671. * @returns the current Node
  27672. */
  27673. removeBehavior(behavior: Behavior<Node>): Node;
  27674. /**
  27675. * Gets the list of attached behaviors
  27676. * @see http://doc.babylonjs.com/features/behaviour
  27677. */
  27678. readonly behaviors: Behavior<Node>[];
  27679. /**
  27680. * Gets an attached behavior by name
  27681. * @param name defines the name of the behavior to look for
  27682. * @see http://doc.babylonjs.com/features/behaviour
  27683. * @returns null if behavior was not found else the requested behavior
  27684. */
  27685. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27686. /**
  27687. * Returns the latest update of the World matrix
  27688. * @returns a Matrix
  27689. */
  27690. getWorldMatrix(): Matrix;
  27691. /** @hidden */
  27692. _getWorldMatrixDeterminant(): number;
  27693. /**
  27694. * Returns directly the latest state of the mesh World matrix.
  27695. * A Matrix is returned.
  27696. */
  27697. readonly worldMatrixFromCache: Matrix;
  27698. /** @hidden */
  27699. _initCache(): void;
  27700. /** @hidden */
  27701. updateCache(force?: boolean): void;
  27702. /** @hidden */
  27703. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27704. /** @hidden */
  27705. _updateCache(ignoreParentClass?: boolean): void;
  27706. /** @hidden */
  27707. _isSynchronized(): boolean;
  27708. /** @hidden */
  27709. _markSyncedWithParent(): void;
  27710. /** @hidden */
  27711. isSynchronizedWithParent(): boolean;
  27712. /** @hidden */
  27713. isSynchronized(): boolean;
  27714. /**
  27715. * Is this node ready to be used/rendered
  27716. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27717. * @return true if the node is ready
  27718. */
  27719. isReady(completeCheck?: boolean): boolean;
  27720. /**
  27721. * Is this node enabled?
  27722. * 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
  27723. * @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
  27724. * @return whether this node (and its parent) is enabled
  27725. */
  27726. isEnabled(checkAncestors?: boolean): boolean;
  27727. /** @hidden */
  27728. protected _syncParentEnabledState(): void;
  27729. /**
  27730. * Set the enabled state of this node
  27731. * @param value defines the new enabled state
  27732. */
  27733. setEnabled(value: boolean): void;
  27734. /**
  27735. * Is this node a descendant of the given node?
  27736. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27737. * @param ancestor defines the parent node to inspect
  27738. * @returns a boolean indicating if this node is a descendant of the given node
  27739. */
  27740. isDescendantOf(ancestor: Node): boolean;
  27741. /** @hidden */
  27742. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27743. /**
  27744. * Will return all nodes that have this node as ascendant
  27745. * @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
  27746. * @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
  27747. * @return all children nodes of all types
  27748. */
  27749. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27750. /**
  27751. * Get all child-meshes of this node
  27752. * @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)
  27753. * @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
  27754. * @returns an array of AbstractMesh
  27755. */
  27756. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27757. /**
  27758. * Get all direct children of this node
  27759. * @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
  27760. * @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)
  27761. * @returns an array of Node
  27762. */
  27763. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27764. /** @hidden */
  27765. _setReady(state: boolean): void;
  27766. /**
  27767. * Get an animation by name
  27768. * @param name defines the name of the animation to look for
  27769. * @returns null if not found else the requested animation
  27770. */
  27771. getAnimationByName(name: string): Nullable<Animation>;
  27772. /**
  27773. * Creates an animation range for this node
  27774. * @param name defines the name of the range
  27775. * @param from defines the starting key
  27776. * @param to defines the end key
  27777. */
  27778. createAnimationRange(name: string, from: number, to: number): void;
  27779. /**
  27780. * Delete a specific animation range
  27781. * @param name defines the name of the range to delete
  27782. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27783. */
  27784. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27785. /**
  27786. * Get an animation range by name
  27787. * @param name defines the name of the animation range to look for
  27788. * @returns null if not found else the requested animation range
  27789. */
  27790. getAnimationRange(name: string): Nullable<AnimationRange>;
  27791. /**
  27792. * Gets the list of all animation ranges defined on this node
  27793. * @returns an array
  27794. */
  27795. getAnimationRanges(): Nullable<AnimationRange>[];
  27796. /**
  27797. * Will start the animation sequence
  27798. * @param name defines the range frames for animation sequence
  27799. * @param loop defines if the animation should loop (false by default)
  27800. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27801. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27802. * @returns the object created for this animation. If range does not exist, it will return null
  27803. */
  27804. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27805. /**
  27806. * Serialize animation ranges into a JSON compatible object
  27807. * @returns serialization object
  27808. */
  27809. serializeAnimationRanges(): any;
  27810. /**
  27811. * Computes the world matrix of the node
  27812. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27813. * @returns the world matrix
  27814. */
  27815. computeWorldMatrix(force?: boolean): Matrix;
  27816. /**
  27817. * Releases resources associated with this node.
  27818. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27819. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27820. */
  27821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27822. /**
  27823. * Parse animation range data from a serialization object and store them into a given node
  27824. * @param node defines where to store the animation ranges
  27825. * @param parsedNode defines the serialization object to read data from
  27826. * @param scene defines the hosting scene
  27827. */
  27828. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27829. /**
  27830. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27831. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27832. * @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
  27833. * @returns the new bounding vectors
  27834. */
  27835. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27836. min: Vector3;
  27837. max: Vector3;
  27838. };
  27839. }
  27840. }
  27841. declare module "babylonjs/Animations/animation" {
  27842. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27843. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27844. import { Color3 } from "babylonjs/Maths/math.color";
  27845. import { Nullable } from "babylonjs/types";
  27846. import { Scene } from "babylonjs/scene";
  27847. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27848. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27849. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27850. import { Node } from "babylonjs/node";
  27851. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27852. import { Size } from "babylonjs/Maths/math.size";
  27853. import { Animatable } from "babylonjs/Animations/animatable";
  27854. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27855. /**
  27856. * @hidden
  27857. */
  27858. export class _IAnimationState {
  27859. key: number;
  27860. repeatCount: number;
  27861. workValue?: any;
  27862. loopMode?: number;
  27863. offsetValue?: any;
  27864. highLimitValue?: any;
  27865. }
  27866. /**
  27867. * Class used to store any kind of animation
  27868. */
  27869. export class Animation {
  27870. /**Name of the animation */
  27871. name: string;
  27872. /**Property to animate */
  27873. targetProperty: string;
  27874. /**The frames per second of the animation */
  27875. framePerSecond: number;
  27876. /**The data type of the animation */
  27877. dataType: number;
  27878. /**The loop mode of the animation */
  27879. loopMode?: number | undefined;
  27880. /**Specifies if blending should be enabled */
  27881. enableBlending?: boolean | undefined;
  27882. /**
  27883. * Use matrix interpolation instead of using direct key value when animating matrices
  27884. */
  27885. static AllowMatricesInterpolation: boolean;
  27886. /**
  27887. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  27888. */
  27889. static AllowMatrixDecomposeForInterpolation: boolean;
  27890. /**
  27891. * Stores the key frames of the animation
  27892. */
  27893. private _keys;
  27894. /**
  27895. * Stores the easing function of the animation
  27896. */
  27897. private _easingFunction;
  27898. /**
  27899. * @hidden Internal use only
  27900. */
  27901. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  27902. /**
  27903. * The set of event that will be linked to this animation
  27904. */
  27905. private _events;
  27906. /**
  27907. * Stores an array of target property paths
  27908. */
  27909. targetPropertyPath: string[];
  27910. /**
  27911. * Stores the blending speed of the animation
  27912. */
  27913. blendingSpeed: number;
  27914. /**
  27915. * Stores the animation ranges for the animation
  27916. */
  27917. private _ranges;
  27918. /**
  27919. * @hidden Internal use
  27920. */
  27921. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  27922. /**
  27923. * Sets up an animation
  27924. * @param property The property to animate
  27925. * @param animationType The animation type to apply
  27926. * @param framePerSecond The frames per second of the animation
  27927. * @param easingFunction The easing function used in the animation
  27928. * @returns The created animation
  27929. */
  27930. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  27931. /**
  27932. * Create and start an animation on a node
  27933. * @param name defines the name of the global animation that will be run on all nodes
  27934. * @param node defines the root node where the animation will take place
  27935. * @param targetProperty defines property to animate
  27936. * @param framePerSecond defines the number of frame per second yo use
  27937. * @param totalFrame defines the number of frames in total
  27938. * @param from defines the initial value
  27939. * @param to defines the final value
  27940. * @param loopMode defines which loop mode you want to use (off by default)
  27941. * @param easingFunction defines the easing function to use (linear by default)
  27942. * @param onAnimationEnd defines the callback to call when animation end
  27943. * @returns the animatable created for this animation
  27944. */
  27945. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27946. /**
  27947. * Create and start an animation on a node and its descendants
  27948. * @param name defines the name of the global animation that will be run on all nodes
  27949. * @param node defines the root node where the animation will take place
  27950. * @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
  27951. * @param targetProperty defines property to animate
  27952. * @param framePerSecond defines the number of frame per second to use
  27953. * @param totalFrame defines the number of frames in total
  27954. * @param from defines the initial value
  27955. * @param to defines the final value
  27956. * @param loopMode defines which loop mode you want to use (off by default)
  27957. * @param easingFunction defines the easing function to use (linear by default)
  27958. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  27959. * @returns the list of animatables created for all nodes
  27960. * @example https://www.babylonjs-playground.com/#MH0VLI
  27961. */
  27962. 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[]>;
  27963. /**
  27964. * Creates a new animation, merges it with the existing animations and starts it
  27965. * @param name Name of the animation
  27966. * @param node Node which contains the scene that begins the animations
  27967. * @param targetProperty Specifies which property to animate
  27968. * @param framePerSecond The frames per second of the animation
  27969. * @param totalFrame The total number of frames
  27970. * @param from The frame at the beginning of the animation
  27971. * @param to The frame at the end of the animation
  27972. * @param loopMode Specifies the loop mode of the animation
  27973. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  27974. * @param onAnimationEnd Callback to run once the animation is complete
  27975. * @returns Nullable animation
  27976. */
  27977. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  27978. /**
  27979. * Transition property of an host to the target Value
  27980. * @param property The property to transition
  27981. * @param targetValue The target Value of the property
  27982. * @param host The object where the property to animate belongs
  27983. * @param scene Scene used to run the animation
  27984. * @param frameRate Framerate (in frame/s) to use
  27985. * @param transition The transition type we want to use
  27986. * @param duration The duration of the animation, in milliseconds
  27987. * @param onAnimationEnd Callback trigger at the end of the animation
  27988. * @returns Nullable animation
  27989. */
  27990. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  27991. /**
  27992. * Return the array of runtime animations currently using this animation
  27993. */
  27994. readonly runtimeAnimations: RuntimeAnimation[];
  27995. /**
  27996. * Specifies if any of the runtime animations are currently running
  27997. */
  27998. readonly hasRunningRuntimeAnimations: boolean;
  27999. /**
  28000. * Initializes the animation
  28001. * @param name Name of the animation
  28002. * @param targetProperty Property to animate
  28003. * @param framePerSecond The frames per second of the animation
  28004. * @param dataType The data type of the animation
  28005. * @param loopMode The loop mode of the animation
  28006. * @param enableBlending Specifies if blending should be enabled
  28007. */
  28008. constructor(
  28009. /**Name of the animation */
  28010. name: string,
  28011. /**Property to animate */
  28012. targetProperty: string,
  28013. /**The frames per second of the animation */
  28014. framePerSecond: number,
  28015. /**The data type of the animation */
  28016. dataType: number,
  28017. /**The loop mode of the animation */
  28018. loopMode?: number | undefined,
  28019. /**Specifies if blending should be enabled */
  28020. enableBlending?: boolean | undefined);
  28021. /**
  28022. * Converts the animation to a string
  28023. * @param fullDetails support for multiple levels of logging within scene loading
  28024. * @returns String form of the animation
  28025. */
  28026. toString(fullDetails?: boolean): string;
  28027. /**
  28028. * Add an event to this animation
  28029. * @param event Event to add
  28030. */
  28031. addEvent(event: AnimationEvent): void;
  28032. /**
  28033. * Remove all events found at the given frame
  28034. * @param frame The frame to remove events from
  28035. */
  28036. removeEvents(frame: number): void;
  28037. /**
  28038. * Retrieves all the events from the animation
  28039. * @returns Events from the animation
  28040. */
  28041. getEvents(): AnimationEvent[];
  28042. /**
  28043. * Creates an animation range
  28044. * @param name Name of the animation range
  28045. * @param from Starting frame of the animation range
  28046. * @param to Ending frame of the animation
  28047. */
  28048. createRange(name: string, from: number, to: number): void;
  28049. /**
  28050. * Deletes an animation range by name
  28051. * @param name Name of the animation range to delete
  28052. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28053. */
  28054. deleteRange(name: string, deleteFrames?: boolean): void;
  28055. /**
  28056. * Gets the animation range by name, or null if not defined
  28057. * @param name Name of the animation range
  28058. * @returns Nullable animation range
  28059. */
  28060. getRange(name: string): Nullable<AnimationRange>;
  28061. /**
  28062. * Gets the key frames from the animation
  28063. * @returns The key frames of the animation
  28064. */
  28065. getKeys(): Array<IAnimationKey>;
  28066. /**
  28067. * Gets the highest frame rate of the animation
  28068. * @returns Highest frame rate of the animation
  28069. */
  28070. getHighestFrame(): number;
  28071. /**
  28072. * Gets the easing function of the animation
  28073. * @returns Easing function of the animation
  28074. */
  28075. getEasingFunction(): IEasingFunction;
  28076. /**
  28077. * Sets the easing function of the animation
  28078. * @param easingFunction A custom mathematical formula for animation
  28079. */
  28080. setEasingFunction(easingFunction: EasingFunction): void;
  28081. /**
  28082. * Interpolates a scalar linearly
  28083. * @param startValue Start value of the animation curve
  28084. * @param endValue End value of the animation curve
  28085. * @param gradient Scalar amount to interpolate
  28086. * @returns Interpolated scalar value
  28087. */
  28088. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28089. /**
  28090. * Interpolates a scalar cubically
  28091. * @param startValue Start value of the animation curve
  28092. * @param outTangent End tangent of the animation
  28093. * @param endValue End value of the animation curve
  28094. * @param inTangent Start tangent of the animation curve
  28095. * @param gradient Scalar amount to interpolate
  28096. * @returns Interpolated scalar value
  28097. */
  28098. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28099. /**
  28100. * Interpolates a quaternion using a spherical linear interpolation
  28101. * @param startValue Start value of the animation curve
  28102. * @param endValue End value of the animation curve
  28103. * @param gradient Scalar amount to interpolate
  28104. * @returns Interpolated quaternion value
  28105. */
  28106. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28107. /**
  28108. * Interpolates a quaternion cubically
  28109. * @param startValue Start value of the animation curve
  28110. * @param outTangent End tangent of the animation curve
  28111. * @param endValue End value of the animation curve
  28112. * @param inTangent Start tangent of the animation curve
  28113. * @param gradient Scalar amount to interpolate
  28114. * @returns Interpolated quaternion value
  28115. */
  28116. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28117. /**
  28118. * Interpolates a Vector3 linearl
  28119. * @param startValue Start value of the animation curve
  28120. * @param endValue End value of the animation curve
  28121. * @param gradient Scalar amount to interpolate
  28122. * @returns Interpolated scalar value
  28123. */
  28124. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28125. /**
  28126. * Interpolates a Vector3 cubically
  28127. * @param startValue Start value of the animation curve
  28128. * @param outTangent End tangent of the animation
  28129. * @param endValue End value of the animation curve
  28130. * @param inTangent Start tangent of the animation curve
  28131. * @param gradient Scalar amount to interpolate
  28132. * @returns InterpolatedVector3 value
  28133. */
  28134. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28135. /**
  28136. * Interpolates a Vector2 linearly
  28137. * @param startValue Start value of the animation curve
  28138. * @param endValue End value of the animation curve
  28139. * @param gradient Scalar amount to interpolate
  28140. * @returns Interpolated Vector2 value
  28141. */
  28142. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28143. /**
  28144. * Interpolates a Vector2 cubically
  28145. * @param startValue Start value of the animation curve
  28146. * @param outTangent End tangent of the animation
  28147. * @param endValue End value of the animation curve
  28148. * @param inTangent Start tangent of the animation curve
  28149. * @param gradient Scalar amount to interpolate
  28150. * @returns Interpolated Vector2 value
  28151. */
  28152. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28153. /**
  28154. * Interpolates a size linearly
  28155. * @param startValue Start value of the animation curve
  28156. * @param endValue End value of the animation curve
  28157. * @param gradient Scalar amount to interpolate
  28158. * @returns Interpolated Size value
  28159. */
  28160. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28161. /**
  28162. * Interpolates a Color3 linearly
  28163. * @param startValue Start value of the animation curve
  28164. * @param endValue End value of the animation curve
  28165. * @param gradient Scalar amount to interpolate
  28166. * @returns Interpolated Color3 value
  28167. */
  28168. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28169. /**
  28170. * @hidden Internal use only
  28171. */
  28172. _getKeyValue(value: any): any;
  28173. /**
  28174. * @hidden Internal use only
  28175. */
  28176. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28177. /**
  28178. * Defines the function to use to interpolate matrices
  28179. * @param startValue defines the start matrix
  28180. * @param endValue defines the end matrix
  28181. * @param gradient defines the gradient between both matrices
  28182. * @param result defines an optional target matrix where to store the interpolation
  28183. * @returns the interpolated matrix
  28184. */
  28185. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28186. /**
  28187. * Makes a copy of the animation
  28188. * @returns Cloned animation
  28189. */
  28190. clone(): Animation;
  28191. /**
  28192. * Sets the key frames of the animation
  28193. * @param values The animation key frames to set
  28194. */
  28195. setKeys(values: Array<IAnimationKey>): void;
  28196. /**
  28197. * Serializes the animation to an object
  28198. * @returns Serialized object
  28199. */
  28200. serialize(): any;
  28201. /**
  28202. * Float animation type
  28203. */
  28204. private static _ANIMATIONTYPE_FLOAT;
  28205. /**
  28206. * Vector3 animation type
  28207. */
  28208. private static _ANIMATIONTYPE_VECTOR3;
  28209. /**
  28210. * Quaternion animation type
  28211. */
  28212. private static _ANIMATIONTYPE_QUATERNION;
  28213. /**
  28214. * Matrix animation type
  28215. */
  28216. private static _ANIMATIONTYPE_MATRIX;
  28217. /**
  28218. * Color3 animation type
  28219. */
  28220. private static _ANIMATIONTYPE_COLOR3;
  28221. /**
  28222. * Vector2 animation type
  28223. */
  28224. private static _ANIMATIONTYPE_VECTOR2;
  28225. /**
  28226. * Size animation type
  28227. */
  28228. private static _ANIMATIONTYPE_SIZE;
  28229. /**
  28230. * Relative Loop Mode
  28231. */
  28232. private static _ANIMATIONLOOPMODE_RELATIVE;
  28233. /**
  28234. * Cycle Loop Mode
  28235. */
  28236. private static _ANIMATIONLOOPMODE_CYCLE;
  28237. /**
  28238. * Constant Loop Mode
  28239. */
  28240. private static _ANIMATIONLOOPMODE_CONSTANT;
  28241. /**
  28242. * Get the float animation type
  28243. */
  28244. static readonly ANIMATIONTYPE_FLOAT: number;
  28245. /**
  28246. * Get the Vector3 animation type
  28247. */
  28248. static readonly ANIMATIONTYPE_VECTOR3: number;
  28249. /**
  28250. * Get the Vector2 animation type
  28251. */
  28252. static readonly ANIMATIONTYPE_VECTOR2: number;
  28253. /**
  28254. * Get the Size animation type
  28255. */
  28256. static readonly ANIMATIONTYPE_SIZE: number;
  28257. /**
  28258. * Get the Quaternion animation type
  28259. */
  28260. static readonly ANIMATIONTYPE_QUATERNION: number;
  28261. /**
  28262. * Get the Matrix animation type
  28263. */
  28264. static readonly ANIMATIONTYPE_MATRIX: number;
  28265. /**
  28266. * Get the Color3 animation type
  28267. */
  28268. static readonly ANIMATIONTYPE_COLOR3: number;
  28269. /**
  28270. * Get the Relative Loop Mode
  28271. */
  28272. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28273. /**
  28274. * Get the Cycle Loop Mode
  28275. */
  28276. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28277. /**
  28278. * Get the Constant Loop Mode
  28279. */
  28280. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28281. /** @hidden */
  28282. static _UniversalLerp(left: any, right: any, amount: number): any;
  28283. /**
  28284. * Parses an animation object and creates an animation
  28285. * @param parsedAnimation Parsed animation object
  28286. * @returns Animation object
  28287. */
  28288. static Parse(parsedAnimation: any): Animation;
  28289. /**
  28290. * Appends the serialized animations from the source animations
  28291. * @param source Source containing the animations
  28292. * @param destination Target to store the animations
  28293. */
  28294. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28295. }
  28296. }
  28297. declare module "babylonjs/Animations/animatable.interface" {
  28298. import { Nullable } from "babylonjs/types";
  28299. import { Animation } from "babylonjs/Animations/animation";
  28300. /**
  28301. * Interface containing an array of animations
  28302. */
  28303. export interface IAnimatable {
  28304. /**
  28305. * Array of animations
  28306. */
  28307. animations: Nullable<Array<Animation>>;
  28308. }
  28309. }
  28310. declare module "babylonjs/Materials/fresnelParameters" {
  28311. import { Color3 } from "babylonjs/Maths/math.color";
  28312. /**
  28313. * This represents all the required information to add a fresnel effect on a material:
  28314. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28315. */
  28316. export class FresnelParameters {
  28317. private _isEnabled;
  28318. /**
  28319. * Define if the fresnel effect is enable or not.
  28320. */
  28321. isEnabled: boolean;
  28322. /**
  28323. * Define the color used on edges (grazing angle)
  28324. */
  28325. leftColor: Color3;
  28326. /**
  28327. * Define the color used on center
  28328. */
  28329. rightColor: Color3;
  28330. /**
  28331. * Define bias applied to computed fresnel term
  28332. */
  28333. bias: number;
  28334. /**
  28335. * Defined the power exponent applied to fresnel term
  28336. */
  28337. power: number;
  28338. /**
  28339. * Clones the current fresnel and its valuues
  28340. * @returns a clone fresnel configuration
  28341. */
  28342. clone(): FresnelParameters;
  28343. /**
  28344. * Serializes the current fresnel parameters to a JSON representation.
  28345. * @return the JSON serialization
  28346. */
  28347. serialize(): any;
  28348. /**
  28349. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28350. * @param parsedFresnelParameters Define the JSON representation
  28351. * @returns the parsed parameters
  28352. */
  28353. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28354. }
  28355. }
  28356. declare module "babylonjs/Misc/decorators" {
  28357. import { Nullable } from "babylonjs/types";
  28358. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28359. import { Scene } from "babylonjs/scene";
  28360. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28361. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28362. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28363. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28364. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28365. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28366. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28367. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28368. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28369. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28370. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28371. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28372. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28373. /**
  28374. * Decorator used to define property that can be serialized as reference to a camera
  28375. * @param sourceName defines the name of the property to decorate
  28376. */
  28377. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28378. /**
  28379. * Class used to help serialization objects
  28380. */
  28381. export class SerializationHelper {
  28382. /** @hidden */
  28383. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28384. /** @hidden */
  28385. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28386. /** @hidden */
  28387. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28388. /** @hidden */
  28389. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28390. /**
  28391. * Appends the serialized animations from the source animations
  28392. * @param source Source containing the animations
  28393. * @param destination Target to store the animations
  28394. */
  28395. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28396. /**
  28397. * Static function used to serialized a specific entity
  28398. * @param entity defines the entity to serialize
  28399. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28400. * @returns a JSON compatible object representing the serialization of the entity
  28401. */
  28402. static Serialize<T>(entity: T, serializationObject?: any): any;
  28403. /**
  28404. * Creates a new entity from a serialization data object
  28405. * @param creationFunction defines a function used to instanciated the new entity
  28406. * @param source defines the source serialization data
  28407. * @param scene defines the hosting scene
  28408. * @param rootUrl defines the root url for resources
  28409. * @returns a new entity
  28410. */
  28411. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28412. /**
  28413. * Clones an object
  28414. * @param creationFunction defines the function used to instanciate the new object
  28415. * @param source defines the source object
  28416. * @returns the cloned object
  28417. */
  28418. static Clone<T>(creationFunction: () => T, source: T): T;
  28419. /**
  28420. * Instanciates a new object based on a source one (some data will be shared between both object)
  28421. * @param creationFunction defines the function used to instanciate the new object
  28422. * @param source defines the source object
  28423. * @returns the new object
  28424. */
  28425. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28426. }
  28427. }
  28428. declare module "babylonjs/Misc/guid" {
  28429. /**
  28430. * Class used to manipulate GUIDs
  28431. */
  28432. export class GUID {
  28433. /**
  28434. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28435. * Be aware Math.random() could cause collisions, but:
  28436. * "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"
  28437. * @returns a pseudo random id
  28438. */
  28439. static RandomId(): string;
  28440. }
  28441. }
  28442. declare module "babylonjs/Materials/Textures/baseTexture" {
  28443. import { Observable } from "babylonjs/Misc/observable";
  28444. import { Nullable } from "babylonjs/types";
  28445. import { Scene } from "babylonjs/scene";
  28446. import { Matrix } from "babylonjs/Maths/math.vector";
  28447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28448. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28449. import { ISize } from "babylonjs/Maths/math.size";
  28450. /**
  28451. * Base class of all the textures in babylon.
  28452. * It groups all the common properties the materials, post process, lights... might need
  28453. * in order to make a correct use of the texture.
  28454. */
  28455. export class BaseTexture implements IAnimatable {
  28456. /**
  28457. * Default anisotropic filtering level for the application.
  28458. * It is set to 4 as a good tradeoff between perf and quality.
  28459. */
  28460. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28461. /**
  28462. * Gets or sets the unique id of the texture
  28463. */
  28464. uniqueId: number;
  28465. /**
  28466. * Define the name of the texture.
  28467. */
  28468. name: string;
  28469. /**
  28470. * Gets or sets an object used to store user defined information.
  28471. */
  28472. metadata: any;
  28473. /**
  28474. * For internal use only. Please do not use.
  28475. */
  28476. reservedDataStore: any;
  28477. private _hasAlpha;
  28478. /**
  28479. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28480. */
  28481. hasAlpha: boolean;
  28482. /**
  28483. * Defines if the alpha value should be determined via the rgb values.
  28484. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28485. */
  28486. getAlphaFromRGB: boolean;
  28487. /**
  28488. * Intensity or strength of the texture.
  28489. * It is commonly used by materials to fine tune the intensity of the texture
  28490. */
  28491. level: number;
  28492. /**
  28493. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28494. * This is part of the texture as textures usually maps to one uv set.
  28495. */
  28496. coordinatesIndex: number;
  28497. private _coordinatesMode;
  28498. /**
  28499. * How a texture is mapped.
  28500. *
  28501. * | Value | Type | Description |
  28502. * | ----- | ----------------------------------- | ----------- |
  28503. * | 0 | EXPLICIT_MODE | |
  28504. * | 1 | SPHERICAL_MODE | |
  28505. * | 2 | PLANAR_MODE | |
  28506. * | 3 | CUBIC_MODE | |
  28507. * | 4 | PROJECTION_MODE | |
  28508. * | 5 | SKYBOX_MODE | |
  28509. * | 6 | INVCUBIC_MODE | |
  28510. * | 7 | EQUIRECTANGULAR_MODE | |
  28511. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28512. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28513. */
  28514. coordinatesMode: number;
  28515. /**
  28516. * | Value | Type | Description |
  28517. * | ----- | ------------------ | ----------- |
  28518. * | 0 | CLAMP_ADDRESSMODE | |
  28519. * | 1 | WRAP_ADDRESSMODE | |
  28520. * | 2 | MIRROR_ADDRESSMODE | |
  28521. */
  28522. wrapU: number;
  28523. /**
  28524. * | Value | Type | Description |
  28525. * | ----- | ------------------ | ----------- |
  28526. * | 0 | CLAMP_ADDRESSMODE | |
  28527. * | 1 | WRAP_ADDRESSMODE | |
  28528. * | 2 | MIRROR_ADDRESSMODE | |
  28529. */
  28530. wrapV: number;
  28531. /**
  28532. * | Value | Type | Description |
  28533. * | ----- | ------------------ | ----------- |
  28534. * | 0 | CLAMP_ADDRESSMODE | |
  28535. * | 1 | WRAP_ADDRESSMODE | |
  28536. * | 2 | MIRROR_ADDRESSMODE | |
  28537. */
  28538. wrapR: number;
  28539. /**
  28540. * With compliant hardware and browser (supporting anisotropic filtering)
  28541. * this defines the level of anisotropic filtering in the texture.
  28542. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28543. */
  28544. anisotropicFilteringLevel: number;
  28545. /**
  28546. * Define if the texture is a cube texture or if false a 2d texture.
  28547. */
  28548. isCube: boolean;
  28549. /**
  28550. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28551. */
  28552. is3D: boolean;
  28553. /**
  28554. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28555. * HDR texture are usually stored in linear space.
  28556. * This only impacts the PBR and Background materials
  28557. */
  28558. gammaSpace: boolean;
  28559. /**
  28560. * Gets or sets whether or not the texture contains RGBD data.
  28561. */
  28562. isRGBD: boolean;
  28563. /**
  28564. * Is Z inverted in the texture (useful in a cube texture).
  28565. */
  28566. invertZ: boolean;
  28567. /**
  28568. * Are mip maps generated for this texture or not.
  28569. */
  28570. readonly noMipmap: boolean;
  28571. /**
  28572. * @hidden
  28573. */
  28574. lodLevelInAlpha: boolean;
  28575. /**
  28576. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28577. */
  28578. lodGenerationOffset: number;
  28579. /**
  28580. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28581. */
  28582. lodGenerationScale: number;
  28583. /**
  28584. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28585. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28586. * average roughness values.
  28587. */
  28588. linearSpecularLOD: boolean;
  28589. /**
  28590. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28591. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28592. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28593. */
  28594. irradianceTexture: Nullable<BaseTexture>;
  28595. /**
  28596. * Define if the texture is a render target.
  28597. */
  28598. isRenderTarget: boolean;
  28599. /**
  28600. * Define the unique id of the texture in the scene.
  28601. */
  28602. readonly uid: string;
  28603. /**
  28604. * Return a string representation of the texture.
  28605. * @returns the texture as a string
  28606. */
  28607. toString(): string;
  28608. /**
  28609. * Get the class name of the texture.
  28610. * @returns "BaseTexture"
  28611. */
  28612. getClassName(): string;
  28613. /**
  28614. * Define the list of animation attached to the texture.
  28615. */
  28616. animations: import("babylonjs/Animations/animation").Animation[];
  28617. /**
  28618. * An event triggered when the texture is disposed.
  28619. */
  28620. onDisposeObservable: Observable<BaseTexture>;
  28621. private _onDisposeObserver;
  28622. /**
  28623. * Callback triggered when the texture has been disposed.
  28624. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28625. */
  28626. onDispose: () => void;
  28627. /**
  28628. * Define the current state of the loading sequence when in delayed load mode.
  28629. */
  28630. delayLoadState: number;
  28631. private _scene;
  28632. /** @hidden */
  28633. _texture: Nullable<InternalTexture>;
  28634. private _uid;
  28635. /**
  28636. * Define if the texture is preventinga material to render or not.
  28637. * If not and the texture is not ready, the engine will use a default black texture instead.
  28638. */
  28639. readonly isBlocking: boolean;
  28640. /**
  28641. * Instantiates a new BaseTexture.
  28642. * Base class of all the textures in babylon.
  28643. * It groups all the common properties the materials, post process, lights... might need
  28644. * in order to make a correct use of the texture.
  28645. * @param scene Define the scene the texture blongs to
  28646. */
  28647. constructor(scene: Nullable<Scene>);
  28648. /**
  28649. * Get the scene the texture belongs to.
  28650. * @returns the scene or null if undefined
  28651. */
  28652. getScene(): Nullable<Scene>;
  28653. /**
  28654. * Get the texture transform matrix used to offset tile the texture for istance.
  28655. * @returns the transformation matrix
  28656. */
  28657. getTextureMatrix(): Matrix;
  28658. /**
  28659. * Get the texture reflection matrix used to rotate/transform the reflection.
  28660. * @returns the reflection matrix
  28661. */
  28662. getReflectionTextureMatrix(): Matrix;
  28663. /**
  28664. * Get the underlying lower level texture from Babylon.
  28665. * @returns the insternal texture
  28666. */
  28667. getInternalTexture(): Nullable<InternalTexture>;
  28668. /**
  28669. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28670. * @returns true if ready or not blocking
  28671. */
  28672. isReadyOrNotBlocking(): boolean;
  28673. /**
  28674. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28675. * @returns true if fully ready
  28676. */
  28677. isReady(): boolean;
  28678. private _cachedSize;
  28679. /**
  28680. * Get the size of the texture.
  28681. * @returns the texture size.
  28682. */
  28683. getSize(): ISize;
  28684. /**
  28685. * Get the base size of the texture.
  28686. * It can be different from the size if the texture has been resized for POT for instance
  28687. * @returns the base size
  28688. */
  28689. getBaseSize(): ISize;
  28690. /**
  28691. * Update the sampling mode of the texture.
  28692. * Default is Trilinear mode.
  28693. *
  28694. * | Value | Type | Description |
  28695. * | ----- | ------------------ | ----------- |
  28696. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28697. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28698. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28699. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28700. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28701. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28702. * | 7 | NEAREST_LINEAR | |
  28703. * | 8 | NEAREST_NEAREST | |
  28704. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28705. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28706. * | 11 | LINEAR_LINEAR | |
  28707. * | 12 | LINEAR_NEAREST | |
  28708. *
  28709. * > _mag_: magnification filter (close to the viewer)
  28710. * > _min_: minification filter (far from the viewer)
  28711. * > _mip_: filter used between mip map levels
  28712. *@param samplingMode Define the new sampling mode of the texture
  28713. */
  28714. updateSamplingMode(samplingMode: number): void;
  28715. /**
  28716. * Scales the texture if is `canRescale()`
  28717. * @param ratio the resize factor we want to use to rescale
  28718. */
  28719. scale(ratio: number): void;
  28720. /**
  28721. * Get if the texture can rescale.
  28722. */
  28723. readonly canRescale: boolean;
  28724. /** @hidden */
  28725. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28726. /** @hidden */
  28727. _rebuild(): void;
  28728. /**
  28729. * Triggers the load sequence in delayed load mode.
  28730. */
  28731. delayLoad(): void;
  28732. /**
  28733. * Clones the texture.
  28734. * @returns the cloned texture
  28735. */
  28736. clone(): Nullable<BaseTexture>;
  28737. /**
  28738. * Get the texture underlying type (INT, FLOAT...)
  28739. */
  28740. readonly textureType: number;
  28741. /**
  28742. * Get the texture underlying format (RGB, RGBA...)
  28743. */
  28744. readonly textureFormat: number;
  28745. /**
  28746. * Indicates that textures need to be re-calculated for all materials
  28747. */
  28748. protected _markAllSubMeshesAsTexturesDirty(): void;
  28749. /**
  28750. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28751. * This will returns an RGBA array buffer containing either in values (0-255) or
  28752. * float values (0-1) depending of the underlying buffer type.
  28753. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  28754. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  28755. * @param buffer defines a user defined buffer to fill with data (can be null)
  28756. * @returns The Array buffer containing the pixels data.
  28757. */
  28758. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  28759. /**
  28760. * Release and destroy the underlying lower level texture aka internalTexture.
  28761. */
  28762. releaseInternalTexture(): void;
  28763. /** @hidden */
  28764. readonly _lodTextureHigh: Nullable<BaseTexture>;
  28765. /** @hidden */
  28766. readonly _lodTextureMid: Nullable<BaseTexture>;
  28767. /** @hidden */
  28768. readonly _lodTextureLow: Nullable<BaseTexture>;
  28769. /**
  28770. * Dispose the texture and release its associated resources.
  28771. */
  28772. dispose(): void;
  28773. /**
  28774. * Serialize the texture into a JSON representation that can be parsed later on.
  28775. * @returns the JSON representation of the texture
  28776. */
  28777. serialize(): any;
  28778. /**
  28779. * Helper function to be called back once a list of texture contains only ready textures.
  28780. * @param textures Define the list of textures to wait for
  28781. * @param callback Define the callback triggered once the entire list will be ready
  28782. */
  28783. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  28784. }
  28785. }
  28786. declare module "babylonjs/Materials/effect" {
  28787. import { Observable } from "babylonjs/Misc/observable";
  28788. import { Nullable } from "babylonjs/types";
  28789. import { IDisposable } from "babylonjs/scene";
  28790. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  28791. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  28792. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  28793. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  28794. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  28795. import { Engine } from "babylonjs/Engines/engine";
  28796. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28797. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28798. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  28799. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  28800. /**
  28801. * Options to be used when creating an effect.
  28802. */
  28803. export interface IEffectCreationOptions {
  28804. /**
  28805. * Atrributes that will be used in the shader.
  28806. */
  28807. attributes: string[];
  28808. /**
  28809. * Uniform varible names that will be set in the shader.
  28810. */
  28811. uniformsNames: string[];
  28812. /**
  28813. * Uniform buffer varible names that will be set in the shader.
  28814. */
  28815. uniformBuffersNames: string[];
  28816. /**
  28817. * Sampler texture variable names that will be set in the shader.
  28818. */
  28819. samplers: string[];
  28820. /**
  28821. * Define statements that will be set in the shader.
  28822. */
  28823. defines: any;
  28824. /**
  28825. * Possible fallbacks for this effect to improve performance when needed.
  28826. */
  28827. fallbacks: Nullable<IEffectFallbacks>;
  28828. /**
  28829. * Callback that will be called when the shader is compiled.
  28830. */
  28831. onCompiled: Nullable<(effect: Effect) => void>;
  28832. /**
  28833. * Callback that will be called if an error occurs during shader compilation.
  28834. */
  28835. onError: Nullable<(effect: Effect, errors: string) => void>;
  28836. /**
  28837. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28838. */
  28839. indexParameters?: any;
  28840. /**
  28841. * Max number of lights that can be used in the shader.
  28842. */
  28843. maxSimultaneousLights?: number;
  28844. /**
  28845. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  28846. */
  28847. transformFeedbackVaryings?: Nullable<string[]>;
  28848. }
  28849. /**
  28850. * Effect containing vertex and fragment shader that can be executed on an object.
  28851. */
  28852. export class Effect implements IDisposable {
  28853. /**
  28854. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28855. */
  28856. static ShadersRepository: string;
  28857. /**
  28858. * Name of the effect.
  28859. */
  28860. name: any;
  28861. /**
  28862. * String container all the define statements that should be set on the shader.
  28863. */
  28864. defines: string;
  28865. /**
  28866. * Callback that will be called when the shader is compiled.
  28867. */
  28868. onCompiled: Nullable<(effect: Effect) => void>;
  28869. /**
  28870. * Callback that will be called if an error occurs during shader compilation.
  28871. */
  28872. onError: Nullable<(effect: Effect, errors: string) => void>;
  28873. /**
  28874. * Callback that will be called when effect is bound.
  28875. */
  28876. onBind: Nullable<(effect: Effect) => void>;
  28877. /**
  28878. * Unique ID of the effect.
  28879. */
  28880. uniqueId: number;
  28881. /**
  28882. * Observable that will be called when the shader is compiled.
  28883. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  28884. */
  28885. onCompileObservable: Observable<Effect>;
  28886. /**
  28887. * Observable that will be called if an error occurs during shader compilation.
  28888. */
  28889. onErrorObservable: Observable<Effect>;
  28890. /** @hidden */
  28891. _onBindObservable: Nullable<Observable<Effect>>;
  28892. /**
  28893. * Observable that will be called when effect is bound.
  28894. */
  28895. readonly onBindObservable: Observable<Effect>;
  28896. /** @hidden */
  28897. _bonesComputationForcedToCPU: boolean;
  28898. private static _uniqueIdSeed;
  28899. private _engine;
  28900. private _uniformBuffersNames;
  28901. private _uniformsNames;
  28902. private _samplerList;
  28903. private _samplers;
  28904. private _isReady;
  28905. private _compilationError;
  28906. private _allFallbacksProcessed;
  28907. private _attributesNames;
  28908. private _attributes;
  28909. private _uniforms;
  28910. /**
  28911. * Key for the effect.
  28912. * @hidden
  28913. */
  28914. _key: string;
  28915. private _indexParameters;
  28916. private _fallbacks;
  28917. private _vertexSourceCode;
  28918. private _fragmentSourceCode;
  28919. private _vertexSourceCodeOverride;
  28920. private _fragmentSourceCodeOverride;
  28921. private _transformFeedbackVaryings;
  28922. /**
  28923. * Compiled shader to webGL program.
  28924. * @hidden
  28925. */
  28926. _pipelineContext: Nullable<IPipelineContext>;
  28927. private _valueCache;
  28928. private static _baseCache;
  28929. /**
  28930. * Instantiates an effect.
  28931. * An effect can be used to create/manage/execute vertex and fragment shaders.
  28932. * @param baseName Name of the effect.
  28933. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  28934. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  28935. * @param samplers List of sampler variables that will be passed to the shader.
  28936. * @param engine Engine to be used to render the effect
  28937. * @param defines Define statements to be added to the shader.
  28938. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  28939. * @param onCompiled Callback that will be called when the shader is compiled.
  28940. * @param onError Callback that will be called if an error occurs during shader compilation.
  28941. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  28942. */
  28943. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  28944. private _useFinalCode;
  28945. /**
  28946. * Unique key for this effect
  28947. */
  28948. readonly key: string;
  28949. /**
  28950. * If the effect has been compiled and prepared.
  28951. * @returns if the effect is compiled and prepared.
  28952. */
  28953. isReady(): boolean;
  28954. private _isReadyInternal;
  28955. /**
  28956. * The engine the effect was initialized with.
  28957. * @returns the engine.
  28958. */
  28959. getEngine(): Engine;
  28960. /**
  28961. * The pipeline context for this effect
  28962. * @returns the associated pipeline context
  28963. */
  28964. getPipelineContext(): Nullable<IPipelineContext>;
  28965. /**
  28966. * The set of names of attribute variables for the shader.
  28967. * @returns An array of attribute names.
  28968. */
  28969. getAttributesNames(): string[];
  28970. /**
  28971. * Returns the attribute at the given index.
  28972. * @param index The index of the attribute.
  28973. * @returns The location of the attribute.
  28974. */
  28975. getAttributeLocation(index: number): number;
  28976. /**
  28977. * Returns the attribute based on the name of the variable.
  28978. * @param name of the attribute to look up.
  28979. * @returns the attribute location.
  28980. */
  28981. getAttributeLocationByName(name: string): number;
  28982. /**
  28983. * The number of attributes.
  28984. * @returns the numnber of attributes.
  28985. */
  28986. getAttributesCount(): number;
  28987. /**
  28988. * Gets the index of a uniform variable.
  28989. * @param uniformName of the uniform to look up.
  28990. * @returns the index.
  28991. */
  28992. getUniformIndex(uniformName: string): number;
  28993. /**
  28994. * Returns the attribute based on the name of the variable.
  28995. * @param uniformName of the uniform to look up.
  28996. * @returns the location of the uniform.
  28997. */
  28998. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  28999. /**
  29000. * Returns an array of sampler variable names
  29001. * @returns The array of sampler variable neames.
  29002. */
  29003. getSamplers(): string[];
  29004. /**
  29005. * The error from the last compilation.
  29006. * @returns the error string.
  29007. */
  29008. getCompilationError(): string;
  29009. /**
  29010. * Gets a boolean indicating that all fallbacks were used during compilation
  29011. * @returns true if all fallbacks were used
  29012. */
  29013. allFallbacksProcessed(): boolean;
  29014. /**
  29015. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29016. * @param func The callback to be used.
  29017. */
  29018. executeWhenCompiled(func: (effect: Effect) => void): void;
  29019. private _checkIsReady;
  29020. private _loadShader;
  29021. /**
  29022. * Recompiles the webGL program
  29023. * @param vertexSourceCode The source code for the vertex shader.
  29024. * @param fragmentSourceCode The source code for the fragment shader.
  29025. * @param onCompiled Callback called when completed.
  29026. * @param onError Callback called on error.
  29027. * @hidden
  29028. */
  29029. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29030. /**
  29031. * Prepares the effect
  29032. * @hidden
  29033. */
  29034. _prepareEffect(): void;
  29035. private _processCompilationErrors;
  29036. /**
  29037. * Checks if the effect is supported. (Must be called after compilation)
  29038. */
  29039. readonly isSupported: boolean;
  29040. /**
  29041. * Binds a texture to the engine to be used as output of the shader.
  29042. * @param channel Name of the output variable.
  29043. * @param texture Texture to bind.
  29044. * @hidden
  29045. */
  29046. _bindTexture(channel: string, texture: InternalTexture): void;
  29047. /**
  29048. * Sets a texture on the engine to be used in the shader.
  29049. * @param channel Name of the sampler variable.
  29050. * @param texture Texture to set.
  29051. */
  29052. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29053. /**
  29054. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29055. * @param channel Name of the sampler variable.
  29056. * @param texture Texture to set.
  29057. */
  29058. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29059. /**
  29060. * Sets an array of textures on the engine to be used in the shader.
  29061. * @param channel Name of the variable.
  29062. * @param textures Textures to set.
  29063. */
  29064. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29065. /**
  29066. * 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)
  29067. * @param channel Name of the sampler variable.
  29068. * @param postProcess Post process to get the input texture from.
  29069. */
  29070. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29071. /**
  29072. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29073. * 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)
  29074. * @param channel Name of the sampler variable.
  29075. * @param postProcess Post process to get the output texture from.
  29076. */
  29077. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29078. /** @hidden */
  29079. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29080. /** @hidden */
  29081. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29082. /** @hidden */
  29083. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29084. /** @hidden */
  29085. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29086. /**
  29087. * Binds a buffer to a uniform.
  29088. * @param buffer Buffer to bind.
  29089. * @param name Name of the uniform variable to bind to.
  29090. */
  29091. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29092. /**
  29093. * Binds block to a uniform.
  29094. * @param blockName Name of the block to bind.
  29095. * @param index Index to bind.
  29096. */
  29097. bindUniformBlock(blockName: string, index: number): void;
  29098. /**
  29099. * Sets an interger value on a uniform variable.
  29100. * @param uniformName Name of the variable.
  29101. * @param value Value to be set.
  29102. * @returns this effect.
  29103. */
  29104. setInt(uniformName: string, value: number): Effect;
  29105. /**
  29106. * Sets an int array on a uniform variable.
  29107. * @param uniformName Name of the variable.
  29108. * @param array array to be set.
  29109. * @returns this effect.
  29110. */
  29111. setIntArray(uniformName: string, array: Int32Array): Effect;
  29112. /**
  29113. * 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)
  29114. * @param uniformName Name of the variable.
  29115. * @param array array to be set.
  29116. * @returns this effect.
  29117. */
  29118. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29119. /**
  29120. * 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)
  29121. * @param uniformName Name of the variable.
  29122. * @param array array to be set.
  29123. * @returns this effect.
  29124. */
  29125. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29126. /**
  29127. * 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)
  29128. * @param uniformName Name of the variable.
  29129. * @param array array to be set.
  29130. * @returns this effect.
  29131. */
  29132. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29133. /**
  29134. * Sets an float array on a uniform variable.
  29135. * @param uniformName Name of the variable.
  29136. * @param array array to be set.
  29137. * @returns this effect.
  29138. */
  29139. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29140. /**
  29141. * 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)
  29142. * @param uniformName Name of the variable.
  29143. * @param array array to be set.
  29144. * @returns this effect.
  29145. */
  29146. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29147. /**
  29148. * 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)
  29149. * @param uniformName Name of the variable.
  29150. * @param array array to be set.
  29151. * @returns this effect.
  29152. */
  29153. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29154. /**
  29155. * 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)
  29156. * @param uniformName Name of the variable.
  29157. * @param array array to be set.
  29158. * @returns this effect.
  29159. */
  29160. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29161. /**
  29162. * Sets an array on a uniform variable.
  29163. * @param uniformName Name of the variable.
  29164. * @param array array to be set.
  29165. * @returns this effect.
  29166. */
  29167. setArray(uniformName: string, array: number[]): Effect;
  29168. /**
  29169. * 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)
  29170. * @param uniformName Name of the variable.
  29171. * @param array array to be set.
  29172. * @returns this effect.
  29173. */
  29174. setArray2(uniformName: string, array: number[]): Effect;
  29175. /**
  29176. * 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)
  29177. * @param uniformName Name of the variable.
  29178. * @param array array to be set.
  29179. * @returns this effect.
  29180. */
  29181. setArray3(uniformName: string, array: number[]): Effect;
  29182. /**
  29183. * 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)
  29184. * @param uniformName Name of the variable.
  29185. * @param array array to be set.
  29186. * @returns this effect.
  29187. */
  29188. setArray4(uniformName: string, array: number[]): Effect;
  29189. /**
  29190. * Sets matrices on a uniform variable.
  29191. * @param uniformName Name of the variable.
  29192. * @param matrices matrices to be set.
  29193. * @returns this effect.
  29194. */
  29195. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29196. /**
  29197. * Sets matrix on a uniform variable.
  29198. * @param uniformName Name of the variable.
  29199. * @param matrix matrix to be set.
  29200. * @returns this effect.
  29201. */
  29202. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29203. /**
  29204. * 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)
  29205. * @param uniformName Name of the variable.
  29206. * @param matrix matrix to be set.
  29207. * @returns this effect.
  29208. */
  29209. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29210. /**
  29211. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29212. * @param uniformName Name of the variable.
  29213. * @param matrix matrix to be set.
  29214. * @returns this effect.
  29215. */
  29216. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29217. /**
  29218. * Sets a float on a uniform variable.
  29219. * @param uniformName Name of the variable.
  29220. * @param value value to be set.
  29221. * @returns this effect.
  29222. */
  29223. setFloat(uniformName: string, value: number): Effect;
  29224. /**
  29225. * Sets a boolean on a uniform variable.
  29226. * @param uniformName Name of the variable.
  29227. * @param bool value to be set.
  29228. * @returns this effect.
  29229. */
  29230. setBool(uniformName: string, bool: boolean): Effect;
  29231. /**
  29232. * Sets a Vector2 on a uniform variable.
  29233. * @param uniformName Name of the variable.
  29234. * @param vector2 vector2 to be set.
  29235. * @returns this effect.
  29236. */
  29237. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29238. /**
  29239. * Sets a float2 on a uniform variable.
  29240. * @param uniformName Name of the variable.
  29241. * @param x First float in float2.
  29242. * @param y Second float in float2.
  29243. * @returns this effect.
  29244. */
  29245. setFloat2(uniformName: string, x: number, y: number): Effect;
  29246. /**
  29247. * Sets a Vector3 on a uniform variable.
  29248. * @param uniformName Name of the variable.
  29249. * @param vector3 Value to be set.
  29250. * @returns this effect.
  29251. */
  29252. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29253. /**
  29254. * Sets a float3 on a uniform variable.
  29255. * @param uniformName Name of the variable.
  29256. * @param x First float in float3.
  29257. * @param y Second float in float3.
  29258. * @param z Third float in float3.
  29259. * @returns this effect.
  29260. */
  29261. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29262. /**
  29263. * Sets a Vector4 on a uniform variable.
  29264. * @param uniformName Name of the variable.
  29265. * @param vector4 Value to be set.
  29266. * @returns this effect.
  29267. */
  29268. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29269. /**
  29270. * Sets a float4 on a uniform variable.
  29271. * @param uniformName Name of the variable.
  29272. * @param x First float in float4.
  29273. * @param y Second float in float4.
  29274. * @param z Third float in float4.
  29275. * @param w Fourth float in float4.
  29276. * @returns this effect.
  29277. */
  29278. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29279. /**
  29280. * Sets a Color3 on a uniform variable.
  29281. * @param uniformName Name of the variable.
  29282. * @param color3 Value to be set.
  29283. * @returns this effect.
  29284. */
  29285. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29286. /**
  29287. * Sets a Color4 on a uniform variable.
  29288. * @param uniformName Name of the variable.
  29289. * @param color3 Value to be set.
  29290. * @param alpha Alpha value to be set.
  29291. * @returns this effect.
  29292. */
  29293. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29294. /**
  29295. * Sets a Color4 on a uniform variable
  29296. * @param uniformName defines the name of the variable
  29297. * @param color4 defines the value to be set
  29298. * @returns this effect.
  29299. */
  29300. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29301. /** Release all associated resources */
  29302. dispose(): void;
  29303. /**
  29304. * This function will add a new shader to the shader store
  29305. * @param name the name of the shader
  29306. * @param pixelShader optional pixel shader content
  29307. * @param vertexShader optional vertex shader content
  29308. */
  29309. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29310. /**
  29311. * Store of each shader (The can be looked up using effect.key)
  29312. */
  29313. static ShadersStore: {
  29314. [key: string]: string;
  29315. };
  29316. /**
  29317. * Store of each included file for a shader (The can be looked up using effect.key)
  29318. */
  29319. static IncludesShadersStore: {
  29320. [key: string]: string;
  29321. };
  29322. /**
  29323. * Resets the cache of effects.
  29324. */
  29325. static ResetCache(): void;
  29326. }
  29327. }
  29328. declare module "babylonjs/Engines/engineCapabilities" {
  29329. import { Nullable } from "babylonjs/types";
  29330. /**
  29331. * Class used to describe the capabilities of the engine relatively to the current browser
  29332. */
  29333. export class EngineCapabilities {
  29334. /** Maximum textures units per fragment shader */
  29335. maxTexturesImageUnits: number;
  29336. /** Maximum texture units per vertex shader */
  29337. maxVertexTextureImageUnits: number;
  29338. /** Maximum textures units in the entire pipeline */
  29339. maxCombinedTexturesImageUnits: number;
  29340. /** Maximum texture size */
  29341. maxTextureSize: number;
  29342. /** Maximum cube texture size */
  29343. maxCubemapTextureSize: number;
  29344. /** Maximum render texture size */
  29345. maxRenderTextureSize: number;
  29346. /** Maximum number of vertex attributes */
  29347. maxVertexAttribs: number;
  29348. /** Maximum number of varyings */
  29349. maxVaryingVectors: number;
  29350. /** Maximum number of uniforms per vertex shader */
  29351. maxVertexUniformVectors: number;
  29352. /** Maximum number of uniforms per fragment shader */
  29353. maxFragmentUniformVectors: number;
  29354. /** Defines if standard derivates (dx/dy) are supported */
  29355. standardDerivatives: boolean;
  29356. /** Defines if s3tc texture compression is supported */
  29357. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29358. /** Defines if pvrtc texture compression is supported */
  29359. pvrtc: any;
  29360. /** Defines if etc1 texture compression is supported */
  29361. etc1: any;
  29362. /** Defines if etc2 texture compression is supported */
  29363. etc2: any;
  29364. /** Defines if astc texture compression is supported */
  29365. astc: any;
  29366. /** Defines if float textures are supported */
  29367. textureFloat: boolean;
  29368. /** Defines if vertex array objects are supported */
  29369. vertexArrayObject: boolean;
  29370. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29371. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29372. /** Gets the maximum level of anisotropy supported */
  29373. maxAnisotropy: number;
  29374. /** Defines if instancing is supported */
  29375. instancedArrays: boolean;
  29376. /** Defines if 32 bits indices are supported */
  29377. uintIndices: boolean;
  29378. /** Defines if high precision shaders are supported */
  29379. highPrecisionShaderSupported: boolean;
  29380. /** Defines if depth reading in the fragment shader is supported */
  29381. fragmentDepthSupported: boolean;
  29382. /** Defines if float texture linear filtering is supported*/
  29383. textureFloatLinearFiltering: boolean;
  29384. /** Defines if rendering to float textures is supported */
  29385. textureFloatRender: boolean;
  29386. /** Defines if half float textures are supported*/
  29387. textureHalfFloat: boolean;
  29388. /** Defines if half float texture linear filtering is supported*/
  29389. textureHalfFloatLinearFiltering: boolean;
  29390. /** Defines if rendering to half float textures is supported */
  29391. textureHalfFloatRender: boolean;
  29392. /** Defines if textureLOD shader command is supported */
  29393. textureLOD: boolean;
  29394. /** Defines if draw buffers extension is supported */
  29395. drawBuffersExtension: boolean;
  29396. /** Defines if depth textures are supported */
  29397. depthTextureExtension: boolean;
  29398. /** Defines if float color buffer are supported */
  29399. colorBufferFloat: boolean;
  29400. /** Gets disjoint timer query extension (null if not supported) */
  29401. timerQuery: EXT_disjoint_timer_query;
  29402. /** Defines if timestamp can be used with timer query */
  29403. canUseTimestampForTimerQuery: boolean;
  29404. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29405. multiview: any;
  29406. /** Function used to let the system compiles shaders in background */
  29407. parallelShaderCompile: {
  29408. COMPLETION_STATUS_KHR: number;
  29409. };
  29410. /** Max number of texture samples for MSAA */
  29411. maxMSAASamples: number;
  29412. /** Defines if the blend min max extension is supported */
  29413. blendMinMax: boolean;
  29414. }
  29415. }
  29416. declare module "babylonjs/States/depthCullingState" {
  29417. import { Nullable } from "babylonjs/types";
  29418. /**
  29419. * @hidden
  29420. **/
  29421. export class DepthCullingState {
  29422. private _isDepthTestDirty;
  29423. private _isDepthMaskDirty;
  29424. private _isDepthFuncDirty;
  29425. private _isCullFaceDirty;
  29426. private _isCullDirty;
  29427. private _isZOffsetDirty;
  29428. private _isFrontFaceDirty;
  29429. private _depthTest;
  29430. private _depthMask;
  29431. private _depthFunc;
  29432. private _cull;
  29433. private _cullFace;
  29434. private _zOffset;
  29435. private _frontFace;
  29436. /**
  29437. * Initializes the state.
  29438. */
  29439. constructor();
  29440. readonly isDirty: boolean;
  29441. zOffset: number;
  29442. cullFace: Nullable<number>;
  29443. cull: Nullable<boolean>;
  29444. depthFunc: Nullable<number>;
  29445. depthMask: boolean;
  29446. depthTest: boolean;
  29447. frontFace: Nullable<number>;
  29448. reset(): void;
  29449. apply(gl: WebGLRenderingContext): void;
  29450. }
  29451. }
  29452. declare module "babylonjs/States/stencilState" {
  29453. /**
  29454. * @hidden
  29455. **/
  29456. export class StencilState {
  29457. /** 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 */
  29458. static readonly ALWAYS: number;
  29459. /** Passed to stencilOperation to specify that stencil value must be kept */
  29460. static readonly KEEP: number;
  29461. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29462. static readonly REPLACE: number;
  29463. private _isStencilTestDirty;
  29464. private _isStencilMaskDirty;
  29465. private _isStencilFuncDirty;
  29466. private _isStencilOpDirty;
  29467. private _stencilTest;
  29468. private _stencilMask;
  29469. private _stencilFunc;
  29470. private _stencilFuncRef;
  29471. private _stencilFuncMask;
  29472. private _stencilOpStencilFail;
  29473. private _stencilOpDepthFail;
  29474. private _stencilOpStencilDepthPass;
  29475. readonly isDirty: boolean;
  29476. stencilFunc: number;
  29477. stencilFuncRef: number;
  29478. stencilFuncMask: number;
  29479. stencilOpStencilFail: number;
  29480. stencilOpDepthFail: number;
  29481. stencilOpStencilDepthPass: number;
  29482. stencilMask: number;
  29483. stencilTest: boolean;
  29484. constructor();
  29485. reset(): void;
  29486. apply(gl: WebGLRenderingContext): void;
  29487. }
  29488. }
  29489. declare module "babylonjs/States/alphaCullingState" {
  29490. /**
  29491. * @hidden
  29492. **/
  29493. export class AlphaState {
  29494. private _isAlphaBlendDirty;
  29495. private _isBlendFunctionParametersDirty;
  29496. private _isBlendEquationParametersDirty;
  29497. private _isBlendConstantsDirty;
  29498. private _alphaBlend;
  29499. private _blendFunctionParameters;
  29500. private _blendEquationParameters;
  29501. private _blendConstants;
  29502. /**
  29503. * Initializes the state.
  29504. */
  29505. constructor();
  29506. readonly isDirty: boolean;
  29507. alphaBlend: boolean;
  29508. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29509. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29510. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29511. reset(): void;
  29512. apply(gl: WebGLRenderingContext): void;
  29513. }
  29514. }
  29515. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29516. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29517. /** @hidden */
  29518. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29519. attributeProcessor(attribute: string): string;
  29520. varyingProcessor(varying: string, isFragment: boolean): string;
  29521. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29522. }
  29523. }
  29524. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29525. /**
  29526. * Interface for attribute information associated with buffer instanciation
  29527. */
  29528. export class InstancingAttributeInfo {
  29529. /**
  29530. * Index/offset of the attribute in the vertex shader
  29531. */
  29532. index: number;
  29533. /**
  29534. * size of the attribute, 1, 2, 3 or 4
  29535. */
  29536. attributeSize: number;
  29537. /**
  29538. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29539. * default is FLOAT
  29540. */
  29541. attribyteType: number;
  29542. /**
  29543. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29544. */
  29545. normalized: boolean;
  29546. /**
  29547. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29548. */
  29549. offset: number;
  29550. /**
  29551. * Name of the GLSL attribute, for debugging purpose only
  29552. */
  29553. attributeName: string;
  29554. }
  29555. }
  29556. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29557. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29558. import { Nullable } from "babylonjs/types";
  29559. module "babylonjs/Engines/thinEngine" {
  29560. interface ThinEngine {
  29561. /**
  29562. * Update a video texture
  29563. * @param texture defines the texture to update
  29564. * @param video defines the video element to use
  29565. * @param invertY defines if data must be stored with Y axis inverted
  29566. */
  29567. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29568. }
  29569. }
  29570. }
  29571. declare module "babylonjs/Materials/Textures/videoTexture" {
  29572. import { Observable } from "babylonjs/Misc/observable";
  29573. import { Nullable } from "babylonjs/types";
  29574. import { Scene } from "babylonjs/scene";
  29575. import { Texture } from "babylonjs/Materials/Textures/texture";
  29576. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29577. /**
  29578. * Settings for finer control over video usage
  29579. */
  29580. export interface VideoTextureSettings {
  29581. /**
  29582. * Applies `autoplay` to video, if specified
  29583. */
  29584. autoPlay?: boolean;
  29585. /**
  29586. * Applies `loop` to video, if specified
  29587. */
  29588. loop?: boolean;
  29589. /**
  29590. * Automatically updates internal texture from video at every frame in the render loop
  29591. */
  29592. autoUpdateTexture: boolean;
  29593. /**
  29594. * Image src displayed during the video loading or until the user interacts with the video.
  29595. */
  29596. poster?: string;
  29597. }
  29598. /**
  29599. * If you want to display a video in your scene, this is the special texture for that.
  29600. * This special texture works similar to other textures, with the exception of a few parameters.
  29601. * @see https://doc.babylonjs.com/how_to/video_texture
  29602. */
  29603. export class VideoTexture extends Texture {
  29604. /**
  29605. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29606. */
  29607. readonly autoUpdateTexture: boolean;
  29608. /**
  29609. * The video instance used by the texture internally
  29610. */
  29611. readonly video: HTMLVideoElement;
  29612. private _onUserActionRequestedObservable;
  29613. /**
  29614. * Event triggerd when a dom action is required by the user to play the video.
  29615. * This happens due to recent changes in browser policies preventing video to auto start.
  29616. */
  29617. readonly onUserActionRequestedObservable: Observable<Texture>;
  29618. private _generateMipMaps;
  29619. private _engine;
  29620. private _stillImageCaptured;
  29621. private _displayingPosterTexture;
  29622. private _settings;
  29623. private _createInternalTextureOnEvent;
  29624. private _frameId;
  29625. /**
  29626. * Creates a video texture.
  29627. * If you want to display a video in your scene, this is the special texture for that.
  29628. * This special texture works similar to other textures, with the exception of a few parameters.
  29629. * @see https://doc.babylonjs.com/how_to/video_texture
  29630. * @param name optional name, will detect from video source, if not defined
  29631. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29632. * @param scene is obviously the current scene.
  29633. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29634. * @param invertY is false by default but can be used to invert video on Y axis
  29635. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29636. * @param settings allows finer control over video usage
  29637. */
  29638. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29639. private _getName;
  29640. private _getVideo;
  29641. private _createInternalTexture;
  29642. private reset;
  29643. /**
  29644. * @hidden Internal method to initiate `update`.
  29645. */
  29646. _rebuild(): void;
  29647. /**
  29648. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29649. */
  29650. update(): void;
  29651. /**
  29652. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29653. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29654. */
  29655. updateTexture(isVisible: boolean): void;
  29656. protected _updateInternalTexture: () => void;
  29657. /**
  29658. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29659. * @param url New url.
  29660. */
  29661. updateURL(url: string): void;
  29662. /**
  29663. * Dispose the texture and release its associated resources.
  29664. */
  29665. dispose(): void;
  29666. /**
  29667. * Creates a video texture straight from a stream.
  29668. * @param scene Define the scene the texture should be created in
  29669. * @param stream Define the stream the texture should be created from
  29670. * @returns The created video texture as a promise
  29671. */
  29672. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29673. /**
  29674. * Creates a video texture straight from your WebCam video feed.
  29675. * @param scene Define the scene the texture should be created in
  29676. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29677. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29678. * @returns The created video texture as a promise
  29679. */
  29680. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29681. minWidth: number;
  29682. maxWidth: number;
  29683. minHeight: number;
  29684. maxHeight: number;
  29685. deviceId: string;
  29686. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29687. /**
  29688. * Creates a video texture straight from your WebCam video feed.
  29689. * @param scene Define the scene the texture should be created in
  29690. * @param onReady Define a callback to triggered once the texture will be ready
  29691. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29692. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29693. */
  29694. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29695. minWidth: number;
  29696. maxWidth: number;
  29697. minHeight: number;
  29698. maxHeight: number;
  29699. deviceId: string;
  29700. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29701. }
  29702. }
  29703. declare module "babylonjs/Engines/thinEngine" {
  29704. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29705. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  29706. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29707. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29708. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29709. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29710. import { Observable } from "babylonjs/Misc/observable";
  29711. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29712. import { StencilState } from "babylonjs/States/stencilState";
  29713. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29714. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29715. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29716. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29717. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29718. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29719. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29720. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29721. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29722. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29723. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29724. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29725. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29726. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29727. /**
  29728. * Defines the interface used by objects working like Scene
  29729. * @hidden
  29730. */
  29731. interface ISceneLike {
  29732. _addPendingData(data: any): void;
  29733. _removePendingData(data: any): void;
  29734. offlineProvider: IOfflineProvider;
  29735. }
  29736. /** Interface defining initialization parameters for Engine class */
  29737. export interface EngineOptions extends WebGLContextAttributes {
  29738. /**
  29739. * Defines if the engine should no exceed a specified device ratio
  29740. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29741. */
  29742. limitDeviceRatio?: number;
  29743. /**
  29744. * Defines if webvr should be enabled automatically
  29745. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29746. */
  29747. autoEnableWebVR?: boolean;
  29748. /**
  29749. * Defines if webgl2 should be turned off even if supported
  29750. * @see http://doc.babylonjs.com/features/webgl2
  29751. */
  29752. disableWebGL2Support?: boolean;
  29753. /**
  29754. * Defines if webaudio should be initialized as well
  29755. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29756. */
  29757. audioEngine?: boolean;
  29758. /**
  29759. * Defines if animations should run using a deterministic lock step
  29760. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29761. */
  29762. deterministicLockstep?: boolean;
  29763. /** Defines the maximum steps to use with deterministic lock step mode */
  29764. lockstepMaxSteps?: number;
  29765. /**
  29766. * Defines that engine should ignore context lost events
  29767. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29768. */
  29769. doNotHandleContextLost?: boolean;
  29770. /**
  29771. * Defines that engine should ignore modifying touch action attribute and style
  29772. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29773. */
  29774. doNotHandleTouchAction?: boolean;
  29775. /**
  29776. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29777. */
  29778. useHighPrecisionFloats?: boolean;
  29779. }
  29780. /**
  29781. * The base engine class (root of all engines)
  29782. */
  29783. export class ThinEngine {
  29784. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29785. static ExceptionList: ({
  29786. key: string;
  29787. capture: string;
  29788. captureConstraint: number;
  29789. targets: string[];
  29790. } | {
  29791. key: string;
  29792. capture: null;
  29793. captureConstraint: null;
  29794. targets: string[];
  29795. })[];
  29796. /** @hidden */
  29797. static _TextureLoaders: IInternalTextureLoader[];
  29798. /**
  29799. * Returns the current npm package of the sdk
  29800. */
  29801. static readonly NpmPackage: string;
  29802. /**
  29803. * Returns the current version of the framework
  29804. */
  29805. static readonly Version: string;
  29806. /**
  29807. * Returns a string describing the current engine
  29808. */
  29809. readonly description: string;
  29810. /**
  29811. * Gets or sets the epsilon value used by collision engine
  29812. */
  29813. static CollisionsEpsilon: number;
  29814. /**
  29815. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29816. */
  29817. static ShadersRepository: string;
  29818. /** @hidden */
  29819. _shaderProcessor: IShaderProcessor;
  29820. /**
  29821. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29822. */
  29823. forcePOTTextures: boolean;
  29824. /**
  29825. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29826. */
  29827. isFullscreen: boolean;
  29828. /**
  29829. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29830. */
  29831. cullBackFaces: boolean;
  29832. /**
  29833. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29834. */
  29835. renderEvenInBackground: boolean;
  29836. /**
  29837. * Gets or sets a boolean indicating that cache can be kept between frames
  29838. */
  29839. preventCacheWipeBetweenFrames: boolean;
  29840. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29841. validateShaderPrograms: boolean;
  29842. /**
  29843. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29844. */
  29845. disableUniformBuffers: boolean;
  29846. /** @hidden */
  29847. _uniformBuffers: UniformBuffer[];
  29848. /**
  29849. * Gets a boolean indicating that the engine supports uniform buffers
  29850. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29851. */
  29852. readonly supportsUniformBuffers: boolean;
  29853. /** @hidden */
  29854. _gl: WebGLRenderingContext;
  29855. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  29856. protected _windowIsBackground: boolean;
  29857. protected _webGLVersion: number;
  29858. protected _highPrecisionShadersAllowed: boolean;
  29859. /** @hidden */
  29860. readonly _shouldUseHighPrecisionShader: boolean;
  29861. /**
  29862. * Gets a boolean indicating that only power of 2 textures are supported
  29863. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29864. */
  29865. readonly needPOTTextures: boolean;
  29866. /** @hidden */
  29867. _badOS: boolean;
  29868. /** @hidden */
  29869. _badDesktopOS: boolean;
  29870. private _hardwareScalingLevel;
  29871. /** @hidden */
  29872. _caps: EngineCapabilities;
  29873. private _isStencilEnable;
  29874. protected _colorWrite: boolean;
  29875. private _glVersion;
  29876. private _glRenderer;
  29877. private _glVendor;
  29878. /** @hidden */
  29879. _videoTextureSupported: boolean;
  29880. protected _renderingQueueLaunched: boolean;
  29881. protected _activeRenderLoops: (() => void)[];
  29882. /**
  29883. * Observable signaled when a context lost event is raised
  29884. */
  29885. onContextLostObservable: Observable<ThinEngine>;
  29886. /**
  29887. * Observable signaled when a context restored event is raised
  29888. */
  29889. onContextRestoredObservable: Observable<ThinEngine>;
  29890. private _onContextLost;
  29891. private _onContextRestored;
  29892. protected _contextWasLost: boolean;
  29893. /** @hidden */
  29894. _doNotHandleContextLost: boolean;
  29895. /**
  29896. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29897. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29898. */
  29899. doNotHandleContextLost: boolean;
  29900. /**
  29901. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29902. */
  29903. disableVertexArrayObjects: boolean;
  29904. /** @hidden */
  29905. protected _depthCullingState: DepthCullingState;
  29906. /** @hidden */
  29907. protected _stencilState: StencilState;
  29908. /** @hidden */
  29909. protected _alphaState: AlphaState;
  29910. /** @hidden */
  29911. _internalTexturesCache: InternalTexture[];
  29912. /** @hidden */
  29913. protected _activeChannel: number;
  29914. private _currentTextureChannel;
  29915. /** @hidden */
  29916. protected _boundTexturesCache: {
  29917. [key: string]: Nullable<InternalTexture>;
  29918. };
  29919. /** @hidden */
  29920. protected _currentEffect: Nullable<Effect>;
  29921. /** @hidden */
  29922. protected _currentProgram: Nullable<WebGLProgram>;
  29923. private _compiledEffects;
  29924. private _vertexAttribArraysEnabled;
  29925. /** @hidden */
  29926. protected _cachedViewport: Nullable<IViewportLike>;
  29927. private _cachedVertexArrayObject;
  29928. /** @hidden */
  29929. protected _cachedVertexBuffers: any;
  29930. /** @hidden */
  29931. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29932. /** @hidden */
  29933. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29934. /** @hidden */
  29935. _currentRenderTarget: Nullable<InternalTexture>;
  29936. private _uintIndicesCurrentlySet;
  29937. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  29938. /** @hidden */
  29939. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29940. private _currentBufferPointers;
  29941. private _currentInstanceLocations;
  29942. private _currentInstanceBuffers;
  29943. private _textureUnits;
  29944. /** @hidden */
  29945. _workingCanvas: Nullable<HTMLCanvasElement>;
  29946. /** @hidden */
  29947. _workingContext: Nullable<CanvasRenderingContext2D>;
  29948. /** @hidden */
  29949. _bindedRenderFunction: any;
  29950. private _vaoRecordInProgress;
  29951. private _mustWipeVertexAttributes;
  29952. private _emptyTexture;
  29953. private _emptyCubeTexture;
  29954. private _emptyTexture3D;
  29955. /** @hidden */
  29956. _frameHandler: number;
  29957. private _nextFreeTextureSlots;
  29958. private _maxSimultaneousTextures;
  29959. private _activeRequests;
  29960. protected _texturesSupported: string[];
  29961. /** @hidden */
  29962. _textureFormatInUse: Nullable<string>;
  29963. protected readonly _supportsHardwareTextureRescaling: boolean;
  29964. /**
  29965. * Gets the list of texture formats supported
  29966. */
  29967. readonly texturesSupported: Array<string>;
  29968. /**
  29969. * Gets the list of texture formats in use
  29970. */
  29971. readonly textureFormatInUse: Nullable<string>;
  29972. /**
  29973. * Gets the current viewport
  29974. */
  29975. readonly currentViewport: Nullable<IViewportLike>;
  29976. /**
  29977. * Gets the default empty texture
  29978. */
  29979. readonly emptyTexture: InternalTexture;
  29980. /**
  29981. * Gets the default empty 3D texture
  29982. */
  29983. readonly emptyTexture3D: InternalTexture;
  29984. /**
  29985. * Gets the default empty cube texture
  29986. */
  29987. readonly emptyCubeTexture: InternalTexture;
  29988. /**
  29989. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29990. */
  29991. readonly premultipliedAlpha: boolean;
  29992. /**
  29993. * Observable event triggered before each texture is initialized
  29994. */
  29995. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  29996. /**
  29997. * Creates a new engine
  29998. * @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
  29999. * @param antialias defines enable antialiasing (default: false)
  30000. * @param options defines further options to be sent to the getContext() function
  30001. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30002. */
  30003. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30004. private _rebuildInternalTextures;
  30005. private _rebuildEffects;
  30006. /**
  30007. * Gets a boolean indicating if all created effects are ready
  30008. * @returns true if all effects are ready
  30009. */
  30010. areAllEffectsReady(): boolean;
  30011. protected _rebuildBuffers(): void;
  30012. private _initGLContext;
  30013. /**
  30014. * Gets version of the current webGL context
  30015. */
  30016. readonly webGLVersion: number;
  30017. /**
  30018. * Gets a string idenfifying the name of the class
  30019. * @returns "Engine" string
  30020. */
  30021. getClassName(): string;
  30022. /**
  30023. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30024. */
  30025. readonly isStencilEnable: boolean;
  30026. /** @hidden */
  30027. _prepareWorkingCanvas(): void;
  30028. /**
  30029. * Reset the texture cache to empty state
  30030. */
  30031. resetTextureCache(): void;
  30032. /**
  30033. * Gets an object containing information about the current webGL context
  30034. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30035. */
  30036. getGlInfo(): {
  30037. vendor: string;
  30038. renderer: string;
  30039. version: string;
  30040. };
  30041. /**
  30042. * Defines the hardware scaling level.
  30043. * By default the hardware scaling level is computed from the window device ratio.
  30044. * 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.
  30045. * @param level defines the level to use
  30046. */
  30047. setHardwareScalingLevel(level: number): void;
  30048. /**
  30049. * Gets the current hardware scaling level.
  30050. * By default the hardware scaling level is computed from the window device ratio.
  30051. * 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.
  30052. * @returns a number indicating the current hardware scaling level
  30053. */
  30054. getHardwareScalingLevel(): number;
  30055. /**
  30056. * Gets the list of loaded textures
  30057. * @returns an array containing all loaded textures
  30058. */
  30059. getLoadedTexturesCache(): InternalTexture[];
  30060. /**
  30061. * Gets the object containing all engine capabilities
  30062. * @returns the EngineCapabilities object
  30063. */
  30064. getCaps(): EngineCapabilities;
  30065. /**
  30066. * stop executing a render loop function and remove it from the execution array
  30067. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30068. */
  30069. stopRenderLoop(renderFunction?: () => void): void;
  30070. /** @hidden */
  30071. _renderLoop(): void;
  30072. /**
  30073. * Gets the HTML canvas attached with the current webGL context
  30074. * @returns a HTML canvas
  30075. */
  30076. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30077. /**
  30078. * Gets host window
  30079. * @returns the host window object
  30080. */
  30081. getHostWindow(): Window;
  30082. /**
  30083. * Gets the current render width
  30084. * @param useScreen defines if screen size must be used (or the current render target if any)
  30085. * @returns a number defining the current render width
  30086. */
  30087. getRenderWidth(useScreen?: boolean): number;
  30088. /**
  30089. * Gets the current render height
  30090. * @param useScreen defines if screen size must be used (or the current render target if any)
  30091. * @returns a number defining the current render height
  30092. */
  30093. getRenderHeight(useScreen?: boolean): number;
  30094. /**
  30095. * Can be used to override the current requestAnimationFrame requester.
  30096. * @hidden
  30097. */
  30098. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30099. /**
  30100. * Register and execute a render loop. The engine can have more than one render function
  30101. * @param renderFunction defines the function to continuously execute
  30102. */
  30103. runRenderLoop(renderFunction: () => void): void;
  30104. /**
  30105. * Clear the current render buffer or the current render target (if any is set up)
  30106. * @param color defines the color to use
  30107. * @param backBuffer defines if the back buffer must be cleared
  30108. * @param depth defines if the depth buffer must be cleared
  30109. * @param stencil defines if the stencil buffer must be cleared
  30110. */
  30111. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30112. private _viewportCached;
  30113. /** @hidden */
  30114. _viewport(x: number, y: number, width: number, height: number): void;
  30115. /**
  30116. * Set the WebGL's viewport
  30117. * @param viewport defines the viewport element to be used
  30118. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30119. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30120. */
  30121. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30122. /**
  30123. * Begin a new frame
  30124. */
  30125. beginFrame(): void;
  30126. /**
  30127. * Enf the current frame
  30128. */
  30129. endFrame(): void;
  30130. /**
  30131. * Resize the view according to the canvas' size
  30132. */
  30133. resize(): void;
  30134. /**
  30135. * Force a specific size of the canvas
  30136. * @param width defines the new canvas' width
  30137. * @param height defines the new canvas' height
  30138. */
  30139. setSize(width: number, height: number): void;
  30140. /**
  30141. * Binds the frame buffer to the specified texture.
  30142. * @param texture The texture to render to or null for the default canvas
  30143. * @param faceIndex The face of the texture to render to in case of cube texture
  30144. * @param requiredWidth The width of the target to render to
  30145. * @param requiredHeight The height of the target to render to
  30146. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30147. * @param depthStencilTexture The depth stencil texture to use to render
  30148. * @param lodLevel defines le lod level to bind to the frame buffer
  30149. */
  30150. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30151. /** @hidden */
  30152. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30153. /**
  30154. * Unbind the current render target texture from the webGL context
  30155. * @param texture defines the render target texture to unbind
  30156. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30157. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30158. */
  30159. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30160. /**
  30161. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30162. */
  30163. flushFramebuffer(): void;
  30164. /**
  30165. * Unbind the current render target and bind the default framebuffer
  30166. */
  30167. restoreDefaultFramebuffer(): void;
  30168. private _resetVertexBufferBinding;
  30169. /**
  30170. * Creates a vertex buffer
  30171. * @param data the data for the vertex buffer
  30172. * @returns the new WebGL static buffer
  30173. */
  30174. createVertexBuffer(data: DataArray): DataBuffer;
  30175. private _createVertexBuffer;
  30176. /**
  30177. * Creates a dynamic vertex buffer
  30178. * @param data the data for the dynamic vertex buffer
  30179. * @returns the new WebGL dynamic buffer
  30180. */
  30181. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30182. /**
  30183. * Updates a dynamic vertex buffer.
  30184. * @param vertexBuffer the vertex buffer to update
  30185. * @param data the data used to update the vertex buffer
  30186. * @param byteOffset the byte offset of the data
  30187. * @param byteLength the byte length of the data
  30188. */
  30189. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30190. protected _resetIndexBufferBinding(): void;
  30191. /**
  30192. * Creates a new index buffer
  30193. * @param indices defines the content of the index buffer
  30194. * @param updatable defines if the index buffer must be updatable
  30195. * @returns a new webGL buffer
  30196. */
  30197. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30198. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30199. /**
  30200. * Bind a webGL buffer to the webGL context
  30201. * @param buffer defines the buffer to bind
  30202. */
  30203. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30204. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30205. private bindBuffer;
  30206. /**
  30207. * update the bound buffer with the given data
  30208. * @param data defines the data to update
  30209. */
  30210. updateArrayBuffer(data: Float32Array): void;
  30211. private _vertexAttribPointer;
  30212. private _bindIndexBufferWithCache;
  30213. private _bindVertexBuffersAttributes;
  30214. /**
  30215. * Records a vertex array object
  30216. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30217. * @param vertexBuffers defines the list of vertex buffers to store
  30218. * @param indexBuffer defines the index buffer to store
  30219. * @param effect defines the effect to store
  30220. * @returns the new vertex array object
  30221. */
  30222. recordVertexArrayObject(vertexBuffers: {
  30223. [key: string]: VertexBuffer;
  30224. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30225. /**
  30226. * Bind a specific vertex array object
  30227. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30228. * @param vertexArrayObject defines the vertex array object to bind
  30229. * @param indexBuffer defines the index buffer to bind
  30230. */
  30231. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30232. /**
  30233. * Bind webGl buffers directly to the webGL context
  30234. * @param vertexBuffer defines the vertex buffer to bind
  30235. * @param indexBuffer defines the index buffer to bind
  30236. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30237. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30238. * @param effect defines the effect associated with the vertex buffer
  30239. */
  30240. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30241. private _unbindVertexArrayObject;
  30242. /**
  30243. * Bind a list of vertex buffers to the webGL context
  30244. * @param vertexBuffers defines the list of vertex buffers to bind
  30245. * @param indexBuffer defines the index buffer to bind
  30246. * @param effect defines the effect associated with the vertex buffers
  30247. */
  30248. bindBuffers(vertexBuffers: {
  30249. [key: string]: Nullable<VertexBuffer>;
  30250. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30251. /**
  30252. * Unbind all instance attributes
  30253. */
  30254. unbindInstanceAttributes(): void;
  30255. /**
  30256. * Release and free the memory of a vertex array object
  30257. * @param vao defines the vertex array object to delete
  30258. */
  30259. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30260. /** @hidden */
  30261. _releaseBuffer(buffer: DataBuffer): boolean;
  30262. protected _deleteBuffer(buffer: DataBuffer): void;
  30263. /**
  30264. * Creates a webGL buffer to use with instanciation
  30265. * @param capacity defines the size of the buffer
  30266. * @returns the webGL buffer
  30267. */
  30268. createInstancesBuffer(capacity: number): DataBuffer;
  30269. /**
  30270. * Delete a webGL buffer used with instanciation
  30271. * @param buffer defines the webGL buffer to delete
  30272. */
  30273. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30274. /**
  30275. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30276. * @param instancesBuffer defines the webGL buffer to update and bind
  30277. * @param data defines the data to store in the buffer
  30278. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30279. */
  30280. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30281. /**
  30282. * Apply all cached states (depth, culling, stencil and alpha)
  30283. */
  30284. applyStates(): void;
  30285. /**
  30286. * Send a draw order
  30287. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30288. * @param indexStart defines the starting index
  30289. * @param indexCount defines the number of index to draw
  30290. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30291. */
  30292. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30293. /**
  30294. * Draw a list of points
  30295. * @param verticesStart defines the index of first vertex to draw
  30296. * @param verticesCount defines the count of vertices to draw
  30297. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30298. */
  30299. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30300. /**
  30301. * Draw a list of unindexed primitives
  30302. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30303. * @param verticesStart defines the index of first vertex to draw
  30304. * @param verticesCount defines the count of vertices to draw
  30305. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30306. */
  30307. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30308. /**
  30309. * Draw a list of indexed primitives
  30310. * @param fillMode defines the primitive to use
  30311. * @param indexStart defines the starting index
  30312. * @param indexCount defines the number of index to draw
  30313. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30314. */
  30315. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30316. /**
  30317. * Draw a list of unindexed primitives
  30318. * @param fillMode defines the primitive to use
  30319. * @param verticesStart defines the index of first vertex to draw
  30320. * @param verticesCount defines the count of vertices to draw
  30321. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30322. */
  30323. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30324. private _drawMode;
  30325. /** @hidden */
  30326. protected _reportDrawCall(): void;
  30327. /** @hidden */
  30328. _releaseEffect(effect: Effect): void;
  30329. /** @hidden */
  30330. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30331. /**
  30332. * Create a new effect (used to store vertex/fragment shaders)
  30333. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30334. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  30335. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30336. * @param samplers defines an array of string used to represent textures
  30337. * @param defines defines the string containing the defines to use to compile the shaders
  30338. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30339. * @param onCompiled defines a function to call when the effect creation is successful
  30340. * @param onError defines a function to call when the effect creation has failed
  30341. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30342. * @returns the new Effect
  30343. */
  30344. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30345. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30346. private _compileShader;
  30347. private _compileRawShader;
  30348. /**
  30349. * Directly creates a webGL program
  30350. * @param pipelineContext defines the pipeline context to attach to
  30351. * @param vertexCode defines the vertex shader code to use
  30352. * @param fragmentCode defines the fragment shader code to use
  30353. * @param context defines the webGL context to use (if not set, the current one will be used)
  30354. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30355. * @returns the new webGL program
  30356. */
  30357. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30358. /**
  30359. * Creates a webGL program
  30360. * @param pipelineContext defines the pipeline context to attach to
  30361. * @param vertexCode defines the vertex shader code to use
  30362. * @param fragmentCode defines the fragment shader code to use
  30363. * @param defines defines the string containing the defines to use to compile the shaders
  30364. * @param context defines the webGL context to use (if not set, the current one will be used)
  30365. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30366. * @returns the new webGL program
  30367. */
  30368. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30369. /**
  30370. * Creates a new pipeline context
  30371. * @returns the new pipeline
  30372. */
  30373. createPipelineContext(): IPipelineContext;
  30374. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30375. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30376. /** @hidden */
  30377. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30378. /** @hidden */
  30379. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30380. /** @hidden */
  30381. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30382. /**
  30383. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30384. * @param pipelineContext defines the pipeline context to use
  30385. * @param uniformsNames defines the list of uniform names
  30386. * @returns an array of webGL uniform locations
  30387. */
  30388. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30389. /**
  30390. * Gets the lsit of active attributes for a given webGL program
  30391. * @param pipelineContext defines the pipeline context to use
  30392. * @param attributesNames defines the list of attribute names to get
  30393. * @returns an array of indices indicating the offset of each attribute
  30394. */
  30395. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30396. /**
  30397. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30398. * @param effect defines the effect to activate
  30399. */
  30400. enableEffect(effect: Nullable<Effect>): void;
  30401. /**
  30402. * Set the value of an uniform to an array of int32
  30403. * @param uniform defines the webGL uniform location where to store the value
  30404. * @param array defines the array of int32 to store
  30405. */
  30406. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30407. /**
  30408. * Set the value of an uniform to an array of int32 (stored as vec2)
  30409. * @param uniform defines the webGL uniform location where to store the value
  30410. * @param array defines the array of int32 to store
  30411. */
  30412. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30413. /**
  30414. * Set the value of an uniform to an array of int32 (stored as vec3)
  30415. * @param uniform defines the webGL uniform location where to store the value
  30416. * @param array defines the array of int32 to store
  30417. */
  30418. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30419. /**
  30420. * Set the value of an uniform to an array of int32 (stored as vec4)
  30421. * @param uniform defines the webGL uniform location where to store the value
  30422. * @param array defines the array of int32 to store
  30423. */
  30424. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30425. /**
  30426. * Set the value of an uniform to an array of float32
  30427. * @param uniform defines the webGL uniform location where to store the value
  30428. * @param array defines the array of float32 to store
  30429. */
  30430. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30431. /**
  30432. * Set the value of an uniform to an array of float32 (stored as vec2)
  30433. * @param uniform defines the webGL uniform location where to store the value
  30434. * @param array defines the array of float32 to store
  30435. */
  30436. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30437. /**
  30438. * Set the value of an uniform to an array of float32 (stored as vec3)
  30439. * @param uniform defines the webGL uniform location where to store the value
  30440. * @param array defines the array of float32 to store
  30441. */
  30442. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30443. /**
  30444. * Set the value of an uniform to an array of float32 (stored as vec4)
  30445. * @param uniform defines the webGL uniform location where to store the value
  30446. * @param array defines the array of float32 to store
  30447. */
  30448. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30449. /**
  30450. * Set the value of an uniform to an array of number
  30451. * @param uniform defines the webGL uniform location where to store the value
  30452. * @param array defines the array of number to store
  30453. */
  30454. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30455. /**
  30456. * Set the value of an uniform to an array of number (stored as vec2)
  30457. * @param uniform defines the webGL uniform location where to store the value
  30458. * @param array defines the array of number to store
  30459. */
  30460. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30461. /**
  30462. * Set the value of an uniform to an array of number (stored as vec3)
  30463. * @param uniform defines the webGL uniform location where to store the value
  30464. * @param array defines the array of number to store
  30465. */
  30466. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30467. /**
  30468. * Set the value of an uniform to an array of number (stored as vec4)
  30469. * @param uniform defines the webGL uniform location where to store the value
  30470. * @param array defines the array of number to store
  30471. */
  30472. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30473. /**
  30474. * Set the value of an uniform to an array of float32 (stored as matrices)
  30475. * @param uniform defines the webGL uniform location where to store the value
  30476. * @param matrices defines the array of float32 to store
  30477. */
  30478. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30479. /**
  30480. * Set the value of an uniform to a matrix (3x3)
  30481. * @param uniform defines the webGL uniform location where to store the value
  30482. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30483. */
  30484. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30485. /**
  30486. * Set the value of an uniform to a matrix (2x2)
  30487. * @param uniform defines the webGL uniform location where to store the value
  30488. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30489. */
  30490. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30491. /**
  30492. * Set the value of an uniform to a number (int)
  30493. * @param uniform defines the webGL uniform location where to store the value
  30494. * @param value defines the int number to store
  30495. */
  30496. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30497. /**
  30498. * Set the value of an uniform to a number (float)
  30499. * @param uniform defines the webGL uniform location where to store the value
  30500. * @param value defines the float number to store
  30501. */
  30502. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30503. /**
  30504. * Set the value of an uniform to a vec2
  30505. * @param uniform defines the webGL uniform location where to store the value
  30506. * @param x defines the 1st component of the value
  30507. * @param y defines the 2nd component of the value
  30508. */
  30509. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30510. /**
  30511. * Set the value of an uniform to a vec3
  30512. * @param uniform defines the webGL uniform location where to store the value
  30513. * @param x defines the 1st component of the value
  30514. * @param y defines the 2nd component of the value
  30515. * @param z defines the 3rd component of the value
  30516. */
  30517. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30518. /**
  30519. * Set the value of an uniform to a boolean
  30520. * @param uniform defines the webGL uniform location where to store the value
  30521. * @param bool defines the boolean to store
  30522. */
  30523. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30524. /**
  30525. * Set the value of an uniform to a vec4
  30526. * @param uniform defines the webGL uniform location where to store the value
  30527. * @param x defines the 1st component of the value
  30528. * @param y defines the 2nd component of the value
  30529. * @param z defines the 3rd component of the value
  30530. * @param w defines the 4th component of the value
  30531. */
  30532. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30533. /**
  30534. * Sets a Color4 on a uniform variable
  30535. * @param uniform defines the uniform location
  30536. * @param color4 defines the value to be set
  30537. */
  30538. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30539. /**
  30540. * Gets the depth culling state manager
  30541. */
  30542. readonly depthCullingState: DepthCullingState;
  30543. /**
  30544. * Gets the alpha state manager
  30545. */
  30546. readonly alphaState: AlphaState;
  30547. /**
  30548. * Gets the stencil state manager
  30549. */
  30550. readonly stencilState: StencilState;
  30551. /**
  30552. * Clears the list of texture accessible through engine.
  30553. * This can help preventing texture load conflict due to name collision.
  30554. */
  30555. clearInternalTexturesCache(): void;
  30556. /**
  30557. * Force the entire cache to be cleared
  30558. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30559. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30560. */
  30561. wipeCaches(bruteForce?: boolean): void;
  30562. /** @hidden */
  30563. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30564. min: number;
  30565. mag: number;
  30566. };
  30567. /** @hidden */
  30568. _createTexture(): WebGLTexture;
  30569. /**
  30570. * Usually called from Texture.ts.
  30571. * Passed information to create a WebGLTexture
  30572. * @param urlArg defines a value which contains one of the following:
  30573. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30574. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30575. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30576. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30577. * @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)
  30578. * @param scene needed for loading to the correct scene
  30579. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30580. * @param onLoad optional callback to be called upon successful completion
  30581. * @param onError optional callback to be called upon failure
  30582. * @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
  30583. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30584. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30585. * @param forcedExtension defines the extension to use to pick the right loader
  30586. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30587. * @param mimeType defines an optional mime type
  30588. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30589. */
  30590. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  30591. /**
  30592. * @hidden
  30593. */
  30594. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30595. /**
  30596. * Creates a raw texture
  30597. * @param data defines the data to store in the texture
  30598. * @param width defines the width of the texture
  30599. * @param height defines the height of the texture
  30600. * @param format defines the format of the data
  30601. * @param generateMipMaps defines if the engine should generate the mip levels
  30602. * @param invertY defines if data must be stored with Y axis inverted
  30603. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30604. * @param compression defines the compression used (null by default)
  30605. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30606. * @returns the raw texture inside an InternalTexture
  30607. */
  30608. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30609. /**
  30610. * Creates a new raw cube texture
  30611. * @param data defines the array of data to use to create each face
  30612. * @param size defines the size of the textures
  30613. * @param format defines the format of the data
  30614. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30615. * @param generateMipMaps defines if the engine should generate the mip levels
  30616. * @param invertY defines if data must be stored with Y axis inverted
  30617. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30618. * @param compression defines the compression used (null by default)
  30619. * @returns the cube texture as an InternalTexture
  30620. */
  30621. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30622. /**
  30623. * Creates a new raw 3D texture
  30624. * @param data defines the data used to create the texture
  30625. * @param width defines the width of the texture
  30626. * @param height defines the height of the texture
  30627. * @param depth defines the depth of the texture
  30628. * @param format defines the format of the texture
  30629. * @param generateMipMaps defines if the engine must generate mip levels
  30630. * @param invertY defines if data must be stored with Y axis inverted
  30631. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30632. * @param compression defines the compressed used (can be null)
  30633. * @param textureType defines the compressed used (can be null)
  30634. * @returns a new raw 3D texture (stored in an InternalTexture)
  30635. */
  30636. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30637. private _unpackFlipYCached;
  30638. /**
  30639. * In case you are sharing the context with other applications, it might
  30640. * be interested to not cache the unpack flip y state to ensure a consistent
  30641. * value would be set.
  30642. */
  30643. enableUnpackFlipYCached: boolean;
  30644. /** @hidden */
  30645. _unpackFlipY(value: boolean): void;
  30646. /** @hidden */
  30647. _getUnpackAlignement(): number;
  30648. /**
  30649. * Update the sampling mode of a given texture
  30650. * @param samplingMode defines the required sampling mode
  30651. * @param texture defines the texture to update
  30652. */
  30653. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30654. /**
  30655. * Updates a depth texture Comparison Mode and Function.
  30656. * If the comparison Function is equal to 0, the mode will be set to none.
  30657. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30658. * @param texture The texture to set the comparison function for
  30659. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30660. */
  30661. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30662. /** @hidden */
  30663. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30664. width: number;
  30665. height: number;
  30666. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30667. /**
  30668. * Creates a depth stencil texture.
  30669. * This is only available in WebGL 2 or with the depth texture extension available.
  30670. * @param size The size of face edge in the texture.
  30671. * @param options The options defining the texture.
  30672. * @returns The texture
  30673. */
  30674. createDepthStencilTexture(size: number | {
  30675. width: number;
  30676. height: number;
  30677. }, options: DepthTextureCreationOptions): InternalTexture;
  30678. /**
  30679. * Creates a depth stencil texture.
  30680. * This is only available in WebGL 2 or with the depth texture extension available.
  30681. * @param size The size of face edge in the texture.
  30682. * @param options The options defining the texture.
  30683. * @returns The texture
  30684. */
  30685. private _createDepthStencilTexture;
  30686. /** @hidden */
  30687. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30688. /** @hidden */
  30689. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30690. /** @hidden */
  30691. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30692. /** @hidden */
  30693. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30694. /**
  30695. * @hidden
  30696. */
  30697. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30698. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30699. private _prepareWebGLTexture;
  30700. /** @hidden */
  30701. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30702. /** @hidden */
  30703. _releaseFramebufferObjects(texture: InternalTexture): void;
  30704. /** @hidden */
  30705. _releaseTexture(texture: InternalTexture): void;
  30706. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30707. protected _setProgram(program: WebGLProgram): void;
  30708. protected _boundUniforms: {
  30709. [key: number]: WebGLUniformLocation;
  30710. };
  30711. /**
  30712. * Binds an effect to the webGL context
  30713. * @param effect defines the effect to bind
  30714. */
  30715. bindSamplers(effect: Effect): void;
  30716. private _activateCurrentTexture;
  30717. /** @hidden */
  30718. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30719. /** @hidden */
  30720. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30721. /**
  30722. * Unbind all textures from the webGL context
  30723. */
  30724. unbindAllTextures(): void;
  30725. /**
  30726. * Sets a texture to the according uniform.
  30727. * @param channel The texture channel
  30728. * @param uniform The uniform to set
  30729. * @param texture The texture to apply
  30730. */
  30731. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30732. private _bindSamplerUniformToChannel;
  30733. private _getTextureWrapMode;
  30734. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30735. /**
  30736. * Sets an array of texture to the webGL context
  30737. * @param channel defines the channel where the texture array must be set
  30738. * @param uniform defines the associated uniform location
  30739. * @param textures defines the array of textures to bind
  30740. */
  30741. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30742. /** @hidden */
  30743. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30744. private _setTextureParameterFloat;
  30745. private _setTextureParameterInteger;
  30746. /**
  30747. * Unbind all vertex attributes from the webGL context
  30748. */
  30749. unbindAllAttributes(): void;
  30750. /**
  30751. * 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
  30752. */
  30753. releaseEffects(): void;
  30754. /**
  30755. * Dispose and release all associated resources
  30756. */
  30757. dispose(): void;
  30758. /**
  30759. * Attach a new callback raised when context lost event is fired
  30760. * @param callback defines the callback to call
  30761. */
  30762. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30763. /**
  30764. * Attach a new callback raised when context restored event is fired
  30765. * @param callback defines the callback to call
  30766. */
  30767. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30768. /**
  30769. * Get the current error code of the webGL context
  30770. * @returns the error code
  30771. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30772. */
  30773. getError(): number;
  30774. private _canRenderToFloatFramebuffer;
  30775. private _canRenderToHalfFloatFramebuffer;
  30776. private _canRenderToFramebuffer;
  30777. /** @hidden */
  30778. _getWebGLTextureType(type: number): number;
  30779. /** @hidden */
  30780. _getInternalFormat(format: number): number;
  30781. /** @hidden */
  30782. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30783. /** @hidden */
  30784. _getRGBAMultiSampleBufferFormat(type: number): number;
  30785. /** @hidden */
  30786. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  30787. /**
  30788. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30789. * @returns true if the engine can be created
  30790. * @ignorenaming
  30791. */
  30792. static isSupported(): boolean;
  30793. /**
  30794. * Find the next highest power of two.
  30795. * @param x Number to start search from.
  30796. * @return Next highest power of two.
  30797. */
  30798. static CeilingPOT(x: number): number;
  30799. /**
  30800. * Find the next lowest power of two.
  30801. * @param x Number to start search from.
  30802. * @return Next lowest power of two.
  30803. */
  30804. static FloorPOT(x: number): number;
  30805. /**
  30806. * Find the nearest power of two.
  30807. * @param x Number to start search from.
  30808. * @return Next nearest power of two.
  30809. */
  30810. static NearestPOT(x: number): number;
  30811. /**
  30812. * Get the closest exponent of two
  30813. * @param value defines the value to approximate
  30814. * @param max defines the maximum value to return
  30815. * @param mode defines how to define the closest value
  30816. * @returns closest exponent of two of the given value
  30817. */
  30818. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30819. /**
  30820. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30821. * @param func - the function to be called
  30822. * @param requester - the object that will request the next frame. Falls back to window.
  30823. * @returns frame number
  30824. */
  30825. static QueueNewFrame(func: () => void, requester?: any): number;
  30826. }
  30827. }
  30828. declare module "babylonjs/Maths/sphericalPolynomial" {
  30829. import { Vector3 } from "babylonjs/Maths/math.vector";
  30830. import { Color3 } from "babylonjs/Maths/math.color";
  30831. /**
  30832. * Class representing spherical harmonics coefficients to the 3rd degree
  30833. */
  30834. export class SphericalHarmonics {
  30835. /**
  30836. * Defines whether or not the harmonics have been prescaled for rendering.
  30837. */
  30838. preScaled: boolean;
  30839. /**
  30840. * The l0,0 coefficients of the spherical harmonics
  30841. */
  30842. l00: Vector3;
  30843. /**
  30844. * The l1,-1 coefficients of the spherical harmonics
  30845. */
  30846. l1_1: Vector3;
  30847. /**
  30848. * The l1,0 coefficients of the spherical harmonics
  30849. */
  30850. l10: Vector3;
  30851. /**
  30852. * The l1,1 coefficients of the spherical harmonics
  30853. */
  30854. l11: Vector3;
  30855. /**
  30856. * The l2,-2 coefficients of the spherical harmonics
  30857. */
  30858. l2_2: Vector3;
  30859. /**
  30860. * The l2,-1 coefficients of the spherical harmonics
  30861. */
  30862. l2_1: Vector3;
  30863. /**
  30864. * The l2,0 coefficients of the spherical harmonics
  30865. */
  30866. l20: Vector3;
  30867. /**
  30868. * The l2,1 coefficients of the spherical harmonics
  30869. */
  30870. l21: Vector3;
  30871. /**
  30872. * The l2,2 coefficients of the spherical harmonics
  30873. */
  30874. l22: Vector3;
  30875. /**
  30876. * Adds a light to the spherical harmonics
  30877. * @param direction the direction of the light
  30878. * @param color the color of the light
  30879. * @param deltaSolidAngle the delta solid angle of the light
  30880. */
  30881. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  30882. /**
  30883. * Scales the spherical harmonics by the given amount
  30884. * @param scale the amount to scale
  30885. */
  30886. scaleInPlace(scale: number): void;
  30887. /**
  30888. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  30889. *
  30890. * ```
  30891. * E_lm = A_l * L_lm
  30892. * ```
  30893. *
  30894. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  30895. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  30896. * the scaling factors are given in equation 9.
  30897. */
  30898. convertIncidentRadianceToIrradiance(): void;
  30899. /**
  30900. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  30901. *
  30902. * ```
  30903. * L = (1/pi) * E * rho
  30904. * ```
  30905. *
  30906. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  30907. */
  30908. convertIrradianceToLambertianRadiance(): void;
  30909. /**
  30910. * Integrates the reconstruction coefficients directly in to the SH preventing further
  30911. * required operations at run time.
  30912. *
  30913. * This is simply done by scaling back the SH with Ylm constants parameter.
  30914. * The trigonometric part being applied by the shader at run time.
  30915. */
  30916. preScaleForRendering(): void;
  30917. /**
  30918. * Constructs a spherical harmonics from an array.
  30919. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  30920. * @returns the spherical harmonics
  30921. */
  30922. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  30923. /**
  30924. * Gets the spherical harmonics from polynomial
  30925. * @param polynomial the spherical polynomial
  30926. * @returns the spherical harmonics
  30927. */
  30928. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  30929. }
  30930. /**
  30931. * Class representing spherical polynomial coefficients to the 3rd degree
  30932. */
  30933. export class SphericalPolynomial {
  30934. private _harmonics;
  30935. /**
  30936. * The spherical harmonics used to create the polynomials.
  30937. */
  30938. readonly preScaledHarmonics: SphericalHarmonics;
  30939. /**
  30940. * The x coefficients of the spherical polynomial
  30941. */
  30942. x: Vector3;
  30943. /**
  30944. * The y coefficients of the spherical polynomial
  30945. */
  30946. y: Vector3;
  30947. /**
  30948. * The z coefficients of the spherical polynomial
  30949. */
  30950. z: Vector3;
  30951. /**
  30952. * The xx coefficients of the spherical polynomial
  30953. */
  30954. xx: Vector3;
  30955. /**
  30956. * The yy coefficients of the spherical polynomial
  30957. */
  30958. yy: Vector3;
  30959. /**
  30960. * The zz coefficients of the spherical polynomial
  30961. */
  30962. zz: Vector3;
  30963. /**
  30964. * The xy coefficients of the spherical polynomial
  30965. */
  30966. xy: Vector3;
  30967. /**
  30968. * The yz coefficients of the spherical polynomial
  30969. */
  30970. yz: Vector3;
  30971. /**
  30972. * The zx coefficients of the spherical polynomial
  30973. */
  30974. zx: Vector3;
  30975. /**
  30976. * Adds an ambient color to the spherical polynomial
  30977. * @param color the color to add
  30978. */
  30979. addAmbient(color: Color3): void;
  30980. /**
  30981. * Scales the spherical polynomial by the given amount
  30982. * @param scale the amount to scale
  30983. */
  30984. scaleInPlace(scale: number): void;
  30985. /**
  30986. * Gets the spherical polynomial from harmonics
  30987. * @param harmonics the spherical harmonics
  30988. * @returns the spherical polynomial
  30989. */
  30990. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  30991. /**
  30992. * Constructs a spherical polynomial from an array.
  30993. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  30994. * @returns the spherical polynomial
  30995. */
  30996. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  30997. }
  30998. }
  30999. declare module "babylonjs/Materials/Textures/internalTexture" {
  31000. import { Observable } from "babylonjs/Misc/observable";
  31001. import { Nullable, int } from "babylonjs/types";
  31002. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31003. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31004. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31005. /**
  31006. * Defines the source of the internal texture
  31007. */
  31008. export enum InternalTextureSource {
  31009. /**
  31010. * The source of the texture data is unknown
  31011. */
  31012. Unknown = 0,
  31013. /**
  31014. * Texture data comes from an URL
  31015. */
  31016. Url = 1,
  31017. /**
  31018. * Texture data is only used for temporary storage
  31019. */
  31020. Temp = 2,
  31021. /**
  31022. * Texture data comes from raw data (ArrayBuffer)
  31023. */
  31024. Raw = 3,
  31025. /**
  31026. * Texture content is dynamic (video or dynamic texture)
  31027. */
  31028. Dynamic = 4,
  31029. /**
  31030. * Texture content is generated by rendering to it
  31031. */
  31032. RenderTarget = 5,
  31033. /**
  31034. * Texture content is part of a multi render target process
  31035. */
  31036. MultiRenderTarget = 6,
  31037. /**
  31038. * Texture data comes from a cube data file
  31039. */
  31040. Cube = 7,
  31041. /**
  31042. * Texture data comes from a raw cube data
  31043. */
  31044. CubeRaw = 8,
  31045. /**
  31046. * Texture data come from a prefiltered cube data file
  31047. */
  31048. CubePrefiltered = 9,
  31049. /**
  31050. * Texture content is raw 3D data
  31051. */
  31052. Raw3D = 10,
  31053. /**
  31054. * Texture content is a depth texture
  31055. */
  31056. Depth = 11,
  31057. /**
  31058. * Texture data comes from a raw cube data encoded with RGBD
  31059. */
  31060. CubeRawRGBD = 12
  31061. }
  31062. /**
  31063. * Class used to store data associated with WebGL texture data for the engine
  31064. * This class should not be used directly
  31065. */
  31066. export class InternalTexture {
  31067. /** @hidden */
  31068. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31069. /**
  31070. * Defines if the texture is ready
  31071. */
  31072. isReady: boolean;
  31073. /**
  31074. * Defines if the texture is a cube texture
  31075. */
  31076. isCube: boolean;
  31077. /**
  31078. * Defines if the texture contains 3D data
  31079. */
  31080. is3D: boolean;
  31081. /**
  31082. * Defines if the texture contains multiview data
  31083. */
  31084. isMultiview: boolean;
  31085. /**
  31086. * Gets the URL used to load this texture
  31087. */
  31088. url: string;
  31089. /**
  31090. * Gets the sampling mode of the texture
  31091. */
  31092. samplingMode: number;
  31093. /**
  31094. * Gets a boolean indicating if the texture needs mipmaps generation
  31095. */
  31096. generateMipMaps: boolean;
  31097. /**
  31098. * Gets the number of samples used by the texture (WebGL2+ only)
  31099. */
  31100. samples: number;
  31101. /**
  31102. * Gets the type of the texture (int, float...)
  31103. */
  31104. type: number;
  31105. /**
  31106. * Gets the format of the texture (RGB, RGBA...)
  31107. */
  31108. format: number;
  31109. /**
  31110. * Observable called when the texture is loaded
  31111. */
  31112. onLoadedObservable: Observable<InternalTexture>;
  31113. /**
  31114. * Gets the width of the texture
  31115. */
  31116. width: number;
  31117. /**
  31118. * Gets the height of the texture
  31119. */
  31120. height: number;
  31121. /**
  31122. * Gets the depth of the texture
  31123. */
  31124. depth: number;
  31125. /**
  31126. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31127. */
  31128. baseWidth: number;
  31129. /**
  31130. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31131. */
  31132. baseHeight: number;
  31133. /**
  31134. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31135. */
  31136. baseDepth: number;
  31137. /**
  31138. * Gets a boolean indicating if the texture is inverted on Y axis
  31139. */
  31140. invertY: boolean;
  31141. /** @hidden */
  31142. _invertVScale: boolean;
  31143. /** @hidden */
  31144. _associatedChannel: number;
  31145. /** @hidden */
  31146. _source: InternalTextureSource;
  31147. /** @hidden */
  31148. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31149. /** @hidden */
  31150. _bufferView: Nullable<ArrayBufferView>;
  31151. /** @hidden */
  31152. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31153. /** @hidden */
  31154. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31155. /** @hidden */
  31156. _size: number;
  31157. /** @hidden */
  31158. _extension: string;
  31159. /** @hidden */
  31160. _files: Nullable<string[]>;
  31161. /** @hidden */
  31162. _workingCanvas: Nullable<HTMLCanvasElement>;
  31163. /** @hidden */
  31164. _workingContext: Nullable<CanvasRenderingContext2D>;
  31165. /** @hidden */
  31166. _framebuffer: Nullable<WebGLFramebuffer>;
  31167. /** @hidden */
  31168. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31169. /** @hidden */
  31170. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31171. /** @hidden */
  31172. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31173. /** @hidden */
  31174. _attachments: Nullable<number[]>;
  31175. /** @hidden */
  31176. _cachedCoordinatesMode: Nullable<number>;
  31177. /** @hidden */
  31178. _cachedWrapU: Nullable<number>;
  31179. /** @hidden */
  31180. _cachedWrapV: Nullable<number>;
  31181. /** @hidden */
  31182. _cachedWrapR: Nullable<number>;
  31183. /** @hidden */
  31184. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31185. /** @hidden */
  31186. _isDisabled: boolean;
  31187. /** @hidden */
  31188. _compression: Nullable<string>;
  31189. /** @hidden */
  31190. _generateStencilBuffer: boolean;
  31191. /** @hidden */
  31192. _generateDepthBuffer: boolean;
  31193. /** @hidden */
  31194. _comparisonFunction: number;
  31195. /** @hidden */
  31196. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31197. /** @hidden */
  31198. _lodGenerationScale: number;
  31199. /** @hidden */
  31200. _lodGenerationOffset: number;
  31201. /** @hidden */
  31202. _colorTextureArray: Nullable<WebGLTexture>;
  31203. /** @hidden */
  31204. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31205. /** @hidden */
  31206. _lodTextureHigh: Nullable<BaseTexture>;
  31207. /** @hidden */
  31208. _lodTextureMid: Nullable<BaseTexture>;
  31209. /** @hidden */
  31210. _lodTextureLow: Nullable<BaseTexture>;
  31211. /** @hidden */
  31212. _isRGBD: boolean;
  31213. /** @hidden */
  31214. _linearSpecularLOD: boolean;
  31215. /** @hidden */
  31216. _irradianceTexture: Nullable<BaseTexture>;
  31217. /** @hidden */
  31218. _webGLTexture: Nullable<WebGLTexture>;
  31219. /** @hidden */
  31220. _references: number;
  31221. private _engine;
  31222. /**
  31223. * Gets the Engine the texture belongs to.
  31224. * @returns The babylon engine
  31225. */
  31226. getEngine(): ThinEngine;
  31227. /**
  31228. * Gets the data source type of the texture
  31229. */
  31230. readonly source: InternalTextureSource;
  31231. /**
  31232. * Creates a new InternalTexture
  31233. * @param engine defines the engine to use
  31234. * @param source defines the type of data that will be used
  31235. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31236. */
  31237. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31238. /**
  31239. * Increments the number of references (ie. the number of Texture that point to it)
  31240. */
  31241. incrementReferences(): void;
  31242. /**
  31243. * Change the size of the texture (not the size of the content)
  31244. * @param width defines the new width
  31245. * @param height defines the new height
  31246. * @param depth defines the new depth (1 by default)
  31247. */
  31248. updateSize(width: int, height: int, depth?: int): void;
  31249. /** @hidden */
  31250. _rebuild(): void;
  31251. /** @hidden */
  31252. _swapAndDie(target: InternalTexture): void;
  31253. /**
  31254. * Dispose the current allocated resources
  31255. */
  31256. dispose(): void;
  31257. }
  31258. }
  31259. declare module "babylonjs/Audio/analyser" {
  31260. import { Scene } from "babylonjs/scene";
  31261. /**
  31262. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31264. */
  31265. export class Analyser {
  31266. /**
  31267. * Gets or sets the smoothing
  31268. * @ignorenaming
  31269. */
  31270. SMOOTHING: number;
  31271. /**
  31272. * Gets or sets the FFT table size
  31273. * @ignorenaming
  31274. */
  31275. FFT_SIZE: number;
  31276. /**
  31277. * Gets or sets the bar graph amplitude
  31278. * @ignorenaming
  31279. */
  31280. BARGRAPHAMPLITUDE: number;
  31281. /**
  31282. * Gets or sets the position of the debug canvas
  31283. * @ignorenaming
  31284. */
  31285. DEBUGCANVASPOS: {
  31286. x: number;
  31287. y: number;
  31288. };
  31289. /**
  31290. * Gets or sets the debug canvas size
  31291. * @ignorenaming
  31292. */
  31293. DEBUGCANVASSIZE: {
  31294. width: number;
  31295. height: number;
  31296. };
  31297. private _byteFreqs;
  31298. private _byteTime;
  31299. private _floatFreqs;
  31300. private _webAudioAnalyser;
  31301. private _debugCanvas;
  31302. private _debugCanvasContext;
  31303. private _scene;
  31304. private _registerFunc;
  31305. private _audioEngine;
  31306. /**
  31307. * Creates a new analyser
  31308. * @param scene defines hosting scene
  31309. */
  31310. constructor(scene: Scene);
  31311. /**
  31312. * Get the number of data values you will have to play with for the visualization
  31313. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31314. * @returns a number
  31315. */
  31316. getFrequencyBinCount(): number;
  31317. /**
  31318. * Gets the current frequency data as a byte array
  31319. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31320. * @returns a Uint8Array
  31321. */
  31322. getByteFrequencyData(): Uint8Array;
  31323. /**
  31324. * Gets the current waveform as a byte array
  31325. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31326. * @returns a Uint8Array
  31327. */
  31328. getByteTimeDomainData(): Uint8Array;
  31329. /**
  31330. * Gets the current frequency data as a float array
  31331. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31332. * @returns a Float32Array
  31333. */
  31334. getFloatFrequencyData(): Float32Array;
  31335. /**
  31336. * Renders the debug canvas
  31337. */
  31338. drawDebugCanvas(): void;
  31339. /**
  31340. * Stops rendering the debug canvas and removes it
  31341. */
  31342. stopDebugCanvas(): void;
  31343. /**
  31344. * Connects two audio nodes
  31345. * @param inputAudioNode defines first node to connect
  31346. * @param outputAudioNode defines second node to connect
  31347. */
  31348. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31349. /**
  31350. * Releases all associated resources
  31351. */
  31352. dispose(): void;
  31353. }
  31354. }
  31355. declare module "babylonjs/Audio/audioEngine" {
  31356. import { IDisposable } from "babylonjs/scene";
  31357. import { Analyser } from "babylonjs/Audio/analyser";
  31358. import { Nullable } from "babylonjs/types";
  31359. import { Observable } from "babylonjs/Misc/observable";
  31360. /**
  31361. * This represents an audio engine and it is responsible
  31362. * to play, synchronize and analyse sounds throughout the application.
  31363. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31364. */
  31365. export interface IAudioEngine extends IDisposable {
  31366. /**
  31367. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31368. */
  31369. readonly canUseWebAudio: boolean;
  31370. /**
  31371. * Gets the current AudioContext if available.
  31372. */
  31373. readonly audioContext: Nullable<AudioContext>;
  31374. /**
  31375. * The master gain node defines the global audio volume of your audio engine.
  31376. */
  31377. readonly masterGain: GainNode;
  31378. /**
  31379. * Gets whether or not mp3 are supported by your browser.
  31380. */
  31381. readonly isMP3supported: boolean;
  31382. /**
  31383. * Gets whether or not ogg are supported by your browser.
  31384. */
  31385. readonly isOGGsupported: boolean;
  31386. /**
  31387. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31388. * @ignoreNaming
  31389. */
  31390. WarnedWebAudioUnsupported: boolean;
  31391. /**
  31392. * Defines if the audio engine relies on a custom unlocked button.
  31393. * In this case, the embedded button will not be displayed.
  31394. */
  31395. useCustomUnlockedButton: boolean;
  31396. /**
  31397. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31398. */
  31399. readonly unlocked: boolean;
  31400. /**
  31401. * Event raised when audio has been unlocked on the browser.
  31402. */
  31403. onAudioUnlockedObservable: Observable<AudioEngine>;
  31404. /**
  31405. * Event raised when audio has been locked on the browser.
  31406. */
  31407. onAudioLockedObservable: Observable<AudioEngine>;
  31408. /**
  31409. * Flags the audio engine in Locked state.
  31410. * This happens due to new browser policies preventing audio to autoplay.
  31411. */
  31412. lock(): void;
  31413. /**
  31414. * Unlocks the audio engine once a user action has been done on the dom.
  31415. * This is helpful to resume play once browser policies have been satisfied.
  31416. */
  31417. unlock(): void;
  31418. }
  31419. /**
  31420. * This represents the default audio engine used in babylon.
  31421. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31422. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31423. */
  31424. export class AudioEngine implements IAudioEngine {
  31425. private _audioContext;
  31426. private _audioContextInitialized;
  31427. private _muteButton;
  31428. private _hostElement;
  31429. /**
  31430. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31431. */
  31432. canUseWebAudio: boolean;
  31433. /**
  31434. * The master gain node defines the global audio volume of your audio engine.
  31435. */
  31436. masterGain: GainNode;
  31437. /**
  31438. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31439. * @ignoreNaming
  31440. */
  31441. WarnedWebAudioUnsupported: boolean;
  31442. /**
  31443. * Gets whether or not mp3 are supported by your browser.
  31444. */
  31445. isMP3supported: boolean;
  31446. /**
  31447. * Gets whether or not ogg are supported by your browser.
  31448. */
  31449. isOGGsupported: boolean;
  31450. /**
  31451. * Gets whether audio has been unlocked on the device.
  31452. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31453. * a user interaction has happened.
  31454. */
  31455. unlocked: boolean;
  31456. /**
  31457. * Defines if the audio engine relies on a custom unlocked button.
  31458. * In this case, the embedded button will not be displayed.
  31459. */
  31460. useCustomUnlockedButton: boolean;
  31461. /**
  31462. * Event raised when audio has been unlocked on the browser.
  31463. */
  31464. onAudioUnlockedObservable: Observable<AudioEngine>;
  31465. /**
  31466. * Event raised when audio has been locked on the browser.
  31467. */
  31468. onAudioLockedObservable: Observable<AudioEngine>;
  31469. /**
  31470. * Gets the current AudioContext if available.
  31471. */
  31472. readonly audioContext: Nullable<AudioContext>;
  31473. private _connectedAnalyser;
  31474. /**
  31475. * Instantiates a new audio engine.
  31476. *
  31477. * There should be only one per page as some browsers restrict the number
  31478. * of audio contexts you can create.
  31479. * @param hostElement defines the host element where to display the mute icon if necessary
  31480. */
  31481. constructor(hostElement?: Nullable<HTMLElement>);
  31482. /**
  31483. * Flags the audio engine in Locked state.
  31484. * This happens due to new browser policies preventing audio to autoplay.
  31485. */
  31486. lock(): void;
  31487. /**
  31488. * Unlocks the audio engine once a user action has been done on the dom.
  31489. * This is helpful to resume play once browser policies have been satisfied.
  31490. */
  31491. unlock(): void;
  31492. private _resumeAudioContext;
  31493. private _initializeAudioContext;
  31494. private _tryToRun;
  31495. private _triggerRunningState;
  31496. private _triggerSuspendedState;
  31497. private _displayMuteButton;
  31498. private _moveButtonToTopLeft;
  31499. private _onResize;
  31500. private _hideMuteButton;
  31501. /**
  31502. * Destroy and release the resources associated with the audio ccontext.
  31503. */
  31504. dispose(): void;
  31505. /**
  31506. * Gets the global volume sets on the master gain.
  31507. * @returns the global volume if set or -1 otherwise
  31508. */
  31509. getGlobalVolume(): number;
  31510. /**
  31511. * Sets the global volume of your experience (sets on the master gain).
  31512. * @param newVolume Defines the new global volume of the application
  31513. */
  31514. setGlobalVolume(newVolume: number): void;
  31515. /**
  31516. * Connect the audio engine to an audio analyser allowing some amazing
  31517. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31518. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31519. * @param analyser The analyser to connect to the engine
  31520. */
  31521. connectToAnalyser(analyser: Analyser): void;
  31522. }
  31523. }
  31524. declare module "babylonjs/Loading/loadingScreen" {
  31525. /**
  31526. * Interface used to present a loading screen while loading a scene
  31527. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31528. */
  31529. export interface ILoadingScreen {
  31530. /**
  31531. * Function called to display the loading screen
  31532. */
  31533. displayLoadingUI: () => void;
  31534. /**
  31535. * Function called to hide the loading screen
  31536. */
  31537. hideLoadingUI: () => void;
  31538. /**
  31539. * Gets or sets the color to use for the background
  31540. */
  31541. loadingUIBackgroundColor: string;
  31542. /**
  31543. * Gets or sets the text to display while loading
  31544. */
  31545. loadingUIText: string;
  31546. }
  31547. /**
  31548. * Class used for the default loading screen
  31549. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31550. */
  31551. export class DefaultLoadingScreen implements ILoadingScreen {
  31552. private _renderingCanvas;
  31553. private _loadingText;
  31554. private _loadingDivBackgroundColor;
  31555. private _loadingDiv;
  31556. private _loadingTextDiv;
  31557. /** Gets or sets the logo url to use for the default loading screen */
  31558. static DefaultLogoUrl: string;
  31559. /** Gets or sets the spinner url to use for the default loading screen */
  31560. static DefaultSpinnerUrl: string;
  31561. /**
  31562. * Creates a new default loading screen
  31563. * @param _renderingCanvas defines the canvas used to render the scene
  31564. * @param _loadingText defines the default text to display
  31565. * @param _loadingDivBackgroundColor defines the default background color
  31566. */
  31567. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31568. /**
  31569. * Function called to display the loading screen
  31570. */
  31571. displayLoadingUI(): void;
  31572. /**
  31573. * Function called to hide the loading screen
  31574. */
  31575. hideLoadingUI(): void;
  31576. /**
  31577. * Gets or sets the text to display while loading
  31578. */
  31579. loadingUIText: string;
  31580. /**
  31581. * Gets or sets the color to use for the background
  31582. */
  31583. loadingUIBackgroundColor: string;
  31584. private _resizeLoadingUI;
  31585. }
  31586. }
  31587. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31588. /**
  31589. * Interface for any object that can request an animation frame
  31590. */
  31591. export interface ICustomAnimationFrameRequester {
  31592. /**
  31593. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31594. */
  31595. renderFunction?: Function;
  31596. /**
  31597. * Called to request the next frame to render to
  31598. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31599. */
  31600. requestAnimationFrame: Function;
  31601. /**
  31602. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31603. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31604. */
  31605. requestID?: number;
  31606. }
  31607. }
  31608. declare module "babylonjs/Misc/performanceMonitor" {
  31609. /**
  31610. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31611. */
  31612. export class PerformanceMonitor {
  31613. private _enabled;
  31614. private _rollingFrameTime;
  31615. private _lastFrameTimeMs;
  31616. /**
  31617. * constructor
  31618. * @param frameSampleSize The number of samples required to saturate the sliding window
  31619. */
  31620. constructor(frameSampleSize?: number);
  31621. /**
  31622. * Samples current frame
  31623. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31624. */
  31625. sampleFrame(timeMs?: number): void;
  31626. /**
  31627. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31628. */
  31629. readonly averageFrameTime: number;
  31630. /**
  31631. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31632. */
  31633. readonly averageFrameTimeVariance: number;
  31634. /**
  31635. * Returns the frame time of the most recent frame
  31636. */
  31637. readonly instantaneousFrameTime: number;
  31638. /**
  31639. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31640. */
  31641. readonly averageFPS: number;
  31642. /**
  31643. * Returns the average framerate in frames per second using the most recent frame time
  31644. */
  31645. readonly instantaneousFPS: number;
  31646. /**
  31647. * Returns true if enough samples have been taken to completely fill the sliding window
  31648. */
  31649. readonly isSaturated: boolean;
  31650. /**
  31651. * Enables contributions to the sliding window sample set
  31652. */
  31653. enable(): void;
  31654. /**
  31655. * Disables contributions to the sliding window sample set
  31656. * Samples will not be interpolated over the disabled period
  31657. */
  31658. disable(): void;
  31659. /**
  31660. * Returns true if sampling is enabled
  31661. */
  31662. readonly isEnabled: boolean;
  31663. /**
  31664. * Resets performance monitor
  31665. */
  31666. reset(): void;
  31667. }
  31668. /**
  31669. * RollingAverage
  31670. *
  31671. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31672. */
  31673. export class RollingAverage {
  31674. /**
  31675. * Current average
  31676. */
  31677. average: number;
  31678. /**
  31679. * Current variance
  31680. */
  31681. variance: number;
  31682. protected _samples: Array<number>;
  31683. protected _sampleCount: number;
  31684. protected _pos: number;
  31685. protected _m2: number;
  31686. /**
  31687. * constructor
  31688. * @param length The number of samples required to saturate the sliding window
  31689. */
  31690. constructor(length: number);
  31691. /**
  31692. * Adds a sample to the sample set
  31693. * @param v The sample value
  31694. */
  31695. add(v: number): void;
  31696. /**
  31697. * Returns previously added values or null if outside of history or outside the sliding window domain
  31698. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31699. * @return Value previously recorded with add() or null if outside of range
  31700. */
  31701. history(i: number): number;
  31702. /**
  31703. * Returns true if enough samples have been taken to completely fill the sliding window
  31704. * @return true if sample-set saturated
  31705. */
  31706. isSaturated(): boolean;
  31707. /**
  31708. * Resets the rolling average (equivalent to 0 samples taken so far)
  31709. */
  31710. reset(): void;
  31711. /**
  31712. * Wraps a value around the sample range boundaries
  31713. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31714. * @return Wrapped position in sample range
  31715. */
  31716. protected _wrapPosition(i: number): number;
  31717. }
  31718. }
  31719. declare module "babylonjs/Misc/perfCounter" {
  31720. /**
  31721. * This class is used to track a performance counter which is number based.
  31722. * The user has access to many properties which give statistics of different nature.
  31723. *
  31724. * The implementer can track two kinds of Performance Counter: time and count.
  31725. * 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.
  31726. * 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.
  31727. */
  31728. export class PerfCounter {
  31729. /**
  31730. * Gets or sets a global boolean to turn on and off all the counters
  31731. */
  31732. static Enabled: boolean;
  31733. /**
  31734. * Returns the smallest value ever
  31735. */
  31736. readonly min: number;
  31737. /**
  31738. * Returns the biggest value ever
  31739. */
  31740. readonly max: number;
  31741. /**
  31742. * Returns the average value since the performance counter is running
  31743. */
  31744. readonly average: number;
  31745. /**
  31746. * Returns the average value of the last second the counter was monitored
  31747. */
  31748. readonly lastSecAverage: number;
  31749. /**
  31750. * Returns the current value
  31751. */
  31752. readonly current: number;
  31753. /**
  31754. * Gets the accumulated total
  31755. */
  31756. readonly total: number;
  31757. /**
  31758. * Gets the total value count
  31759. */
  31760. readonly count: number;
  31761. /**
  31762. * Creates a new counter
  31763. */
  31764. constructor();
  31765. /**
  31766. * Call this method to start monitoring a new frame.
  31767. * 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.
  31768. */
  31769. fetchNewFrame(): void;
  31770. /**
  31771. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31772. * @param newCount the count value to add to the monitored count
  31773. * @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.
  31774. */
  31775. addCount(newCount: number, fetchResult: boolean): void;
  31776. /**
  31777. * Start monitoring this performance counter
  31778. */
  31779. beginMonitoring(): void;
  31780. /**
  31781. * Compute the time lapsed since the previous beginMonitoring() call.
  31782. * @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
  31783. */
  31784. endMonitoring(newFrame?: boolean): void;
  31785. private _fetchResult;
  31786. private _startMonitoringTime;
  31787. private _min;
  31788. private _max;
  31789. private _average;
  31790. private _current;
  31791. private _totalValueCount;
  31792. private _totalAccumulated;
  31793. private _lastSecAverage;
  31794. private _lastSecAccumulated;
  31795. private _lastSecTime;
  31796. private _lastSecValueCount;
  31797. }
  31798. }
  31799. declare module "babylonjs/Engines/engine" {
  31800. import { Observable } from "babylonjs/Misc/observable";
  31801. import { Nullable, IndicesArray } from "babylonjs/types";
  31802. import { Scene } from "babylonjs/scene";
  31803. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31804. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31805. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31806. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31807. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31808. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31809. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31810. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31811. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31812. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31813. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31814. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31815. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31816. import { Material } from "babylonjs/Materials/material";
  31817. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31818. /**
  31819. * Defines the interface used by display changed events
  31820. */
  31821. export interface IDisplayChangedEventArgs {
  31822. /** Gets the vrDisplay object (if any) */
  31823. vrDisplay: Nullable<any>;
  31824. /** Gets a boolean indicating if webVR is supported */
  31825. vrSupported: boolean;
  31826. }
  31827. /**
  31828. * Defines the interface used by objects containing a viewport (like a camera)
  31829. */
  31830. interface IViewportOwnerLike {
  31831. /**
  31832. * Gets or sets the viewport
  31833. */
  31834. viewport: IViewportLike;
  31835. }
  31836. /**
  31837. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31838. */
  31839. export class Engine extends ThinEngine {
  31840. /** Defines that alpha blending is disabled */
  31841. static readonly ALPHA_DISABLE: number;
  31842. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31843. static readonly ALPHA_ADD: number;
  31844. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31845. static readonly ALPHA_COMBINE: number;
  31846. /** Defines that alpha blending to DEST - SRC * DEST */
  31847. static readonly ALPHA_SUBTRACT: number;
  31848. /** Defines that alpha blending to SRC * DEST */
  31849. static readonly ALPHA_MULTIPLY: number;
  31850. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31851. static readonly ALPHA_MAXIMIZED: number;
  31852. /** Defines that alpha blending to SRC + DEST */
  31853. static readonly ALPHA_ONEONE: number;
  31854. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31855. static readonly ALPHA_PREMULTIPLIED: number;
  31856. /**
  31857. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31858. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31859. */
  31860. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31861. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31862. static readonly ALPHA_INTERPOLATE: number;
  31863. /**
  31864. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31865. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31866. */
  31867. static readonly ALPHA_SCREENMODE: number;
  31868. /** Defines that the ressource is not delayed*/
  31869. static readonly DELAYLOADSTATE_NONE: number;
  31870. /** Defines that the ressource was successfully delay loaded */
  31871. static readonly DELAYLOADSTATE_LOADED: number;
  31872. /** Defines that the ressource is currently delay loading */
  31873. static readonly DELAYLOADSTATE_LOADING: number;
  31874. /** Defines that the ressource is delayed and has not started loading */
  31875. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31876. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31877. static readonly NEVER: number;
  31878. /** 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 */
  31879. static readonly ALWAYS: number;
  31880. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31881. static readonly LESS: number;
  31882. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31883. static readonly EQUAL: number;
  31884. /** 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 */
  31885. static readonly LEQUAL: number;
  31886. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31887. static readonly GREATER: number;
  31888. /** 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 */
  31889. static readonly GEQUAL: number;
  31890. /** 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 */
  31891. static readonly NOTEQUAL: number;
  31892. /** Passed to stencilOperation to specify that stencil value must be kept */
  31893. static readonly KEEP: number;
  31894. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31895. static readonly REPLACE: number;
  31896. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31897. static readonly INCR: number;
  31898. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31899. static readonly DECR: number;
  31900. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31901. static readonly INVERT: number;
  31902. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31903. static readonly INCR_WRAP: number;
  31904. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31905. static readonly DECR_WRAP: number;
  31906. /** Texture is not repeating outside of 0..1 UVs */
  31907. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31908. /** Texture is repeating outside of 0..1 UVs */
  31909. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31910. /** Texture is repeating and mirrored */
  31911. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31912. /** ALPHA */
  31913. static readonly TEXTUREFORMAT_ALPHA: number;
  31914. /** LUMINANCE */
  31915. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31916. /** LUMINANCE_ALPHA */
  31917. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31918. /** RGB */
  31919. static readonly TEXTUREFORMAT_RGB: number;
  31920. /** RGBA */
  31921. static readonly TEXTUREFORMAT_RGBA: number;
  31922. /** RED */
  31923. static readonly TEXTUREFORMAT_RED: number;
  31924. /** RED (2nd reference) */
  31925. static readonly TEXTUREFORMAT_R: number;
  31926. /** RG */
  31927. static readonly TEXTUREFORMAT_RG: number;
  31928. /** RED_INTEGER */
  31929. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  31930. /** RED_INTEGER (2nd reference) */
  31931. static readonly TEXTUREFORMAT_R_INTEGER: number;
  31932. /** RG_INTEGER */
  31933. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  31934. /** RGB_INTEGER */
  31935. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  31936. /** RGBA_INTEGER */
  31937. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  31938. /** UNSIGNED_BYTE */
  31939. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  31940. /** UNSIGNED_BYTE (2nd reference) */
  31941. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  31942. /** FLOAT */
  31943. static readonly TEXTURETYPE_FLOAT: number;
  31944. /** HALF_FLOAT */
  31945. static readonly TEXTURETYPE_HALF_FLOAT: number;
  31946. /** BYTE */
  31947. static readonly TEXTURETYPE_BYTE: number;
  31948. /** SHORT */
  31949. static readonly TEXTURETYPE_SHORT: number;
  31950. /** UNSIGNED_SHORT */
  31951. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  31952. /** INT */
  31953. static readonly TEXTURETYPE_INT: number;
  31954. /** UNSIGNED_INT */
  31955. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  31956. /** UNSIGNED_SHORT_4_4_4_4 */
  31957. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  31958. /** UNSIGNED_SHORT_5_5_5_1 */
  31959. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  31960. /** UNSIGNED_SHORT_5_6_5 */
  31961. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  31962. /** UNSIGNED_INT_2_10_10_10_REV */
  31963. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  31964. /** UNSIGNED_INT_24_8 */
  31965. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  31966. /** UNSIGNED_INT_10F_11F_11F_REV */
  31967. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  31968. /** UNSIGNED_INT_5_9_9_9_REV */
  31969. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  31970. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  31971. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  31972. /** nearest is mag = nearest and min = nearest and mip = linear */
  31973. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  31974. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31975. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  31976. /** Trilinear is mag = linear and min = linear and mip = linear */
  31977. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  31978. /** nearest is mag = nearest and min = nearest and mip = linear */
  31979. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  31980. /** Bilinear is mag = linear and min = linear and mip = nearest */
  31981. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  31982. /** Trilinear is mag = linear and min = linear and mip = linear */
  31983. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  31984. /** mag = nearest and min = nearest and mip = nearest */
  31985. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  31986. /** mag = nearest and min = linear and mip = nearest */
  31987. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  31988. /** mag = nearest and min = linear and mip = linear */
  31989. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  31990. /** mag = nearest and min = linear and mip = none */
  31991. static readonly TEXTURE_NEAREST_LINEAR: number;
  31992. /** mag = nearest and min = nearest and mip = none */
  31993. static readonly TEXTURE_NEAREST_NEAREST: number;
  31994. /** mag = linear and min = nearest and mip = nearest */
  31995. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  31996. /** mag = linear and min = nearest and mip = linear */
  31997. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  31998. /** mag = linear and min = linear and mip = none */
  31999. static readonly TEXTURE_LINEAR_LINEAR: number;
  32000. /** mag = linear and min = nearest and mip = none */
  32001. static readonly TEXTURE_LINEAR_NEAREST: number;
  32002. /** Explicit coordinates mode */
  32003. static readonly TEXTURE_EXPLICIT_MODE: number;
  32004. /** Spherical coordinates mode */
  32005. static readonly TEXTURE_SPHERICAL_MODE: number;
  32006. /** Planar coordinates mode */
  32007. static readonly TEXTURE_PLANAR_MODE: number;
  32008. /** Cubic coordinates mode */
  32009. static readonly TEXTURE_CUBIC_MODE: number;
  32010. /** Projection coordinates mode */
  32011. static readonly TEXTURE_PROJECTION_MODE: number;
  32012. /** Skybox coordinates mode */
  32013. static readonly TEXTURE_SKYBOX_MODE: number;
  32014. /** Inverse Cubic coordinates mode */
  32015. static readonly TEXTURE_INVCUBIC_MODE: number;
  32016. /** Equirectangular coordinates mode */
  32017. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32018. /** Equirectangular Fixed coordinates mode */
  32019. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32020. /** Equirectangular Fixed Mirrored coordinates mode */
  32021. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32022. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32023. static readonly SCALEMODE_FLOOR: number;
  32024. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32025. static readonly SCALEMODE_NEAREST: number;
  32026. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32027. static readonly SCALEMODE_CEILING: number;
  32028. /**
  32029. * Returns the current npm package of the sdk
  32030. */
  32031. static readonly NpmPackage: string;
  32032. /**
  32033. * Returns the current version of the framework
  32034. */
  32035. static readonly Version: string;
  32036. /** Gets the list of created engines */
  32037. static readonly Instances: Engine[];
  32038. /**
  32039. * Gets the latest created engine
  32040. */
  32041. static readonly LastCreatedEngine: Nullable<Engine>;
  32042. /**
  32043. * Gets the latest created scene
  32044. */
  32045. static readonly LastCreatedScene: Nullable<Scene>;
  32046. /**
  32047. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32048. * @param flag defines which part of the materials must be marked as dirty
  32049. * @param predicate defines a predicate used to filter which materials should be affected
  32050. */
  32051. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32052. /**
  32053. * Method called to create the default loading screen.
  32054. * This can be overriden in your own app.
  32055. * @param canvas The rendering canvas element
  32056. * @returns The loading screen
  32057. */
  32058. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32059. /**
  32060. * Method called to create the default rescale post process on each engine.
  32061. */
  32062. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32063. /**
  32064. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32065. **/
  32066. enableOfflineSupport: boolean;
  32067. /**
  32068. * 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)
  32069. **/
  32070. disableManifestCheck: boolean;
  32071. /**
  32072. * Gets the list of created scenes
  32073. */
  32074. scenes: Scene[];
  32075. /**
  32076. * Event raised when a new scene is created
  32077. */
  32078. onNewSceneAddedObservable: Observable<Scene>;
  32079. /**
  32080. * Gets the list of created postprocesses
  32081. */
  32082. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32083. /**
  32084. * Gets a boolean indicating if the pointer is currently locked
  32085. */
  32086. isPointerLock: boolean;
  32087. /**
  32088. * Observable event triggered each time the rendering canvas is resized
  32089. */
  32090. onResizeObservable: Observable<Engine>;
  32091. /**
  32092. * Observable event triggered each time the canvas loses focus
  32093. */
  32094. onCanvasBlurObservable: Observable<Engine>;
  32095. /**
  32096. * Observable event triggered each time the canvas gains focus
  32097. */
  32098. onCanvasFocusObservable: Observable<Engine>;
  32099. /**
  32100. * Observable event triggered each time the canvas receives pointerout event
  32101. */
  32102. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32103. /**
  32104. * Observable raised when the engine begins a new frame
  32105. */
  32106. onBeginFrameObservable: Observable<Engine>;
  32107. /**
  32108. * If set, will be used to request the next animation frame for the render loop
  32109. */
  32110. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32111. /**
  32112. * Observable raised when the engine ends the current frame
  32113. */
  32114. onEndFrameObservable: Observable<Engine>;
  32115. /**
  32116. * Observable raised when the engine is about to compile a shader
  32117. */
  32118. onBeforeShaderCompilationObservable: Observable<Engine>;
  32119. /**
  32120. * Observable raised when the engine has jsut compiled a shader
  32121. */
  32122. onAfterShaderCompilationObservable: Observable<Engine>;
  32123. /**
  32124. * Gets the audio engine
  32125. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32126. * @ignorenaming
  32127. */
  32128. static audioEngine: IAudioEngine;
  32129. /**
  32130. * Default AudioEngine factory responsible of creating the Audio Engine.
  32131. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32132. */
  32133. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32134. /**
  32135. * Default offline support factory responsible of creating a tool used to store data locally.
  32136. * By default, this will create a Database object if the workload has been embedded.
  32137. */
  32138. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32139. private _loadingScreen;
  32140. private _pointerLockRequested;
  32141. private _dummyFramebuffer;
  32142. private _rescalePostProcess;
  32143. /** @hidden */
  32144. protected _alphaMode: number;
  32145. /** @hidden */
  32146. protected _alphaEquation: number;
  32147. private _deterministicLockstep;
  32148. private _lockstepMaxSteps;
  32149. protected readonly _supportsHardwareTextureRescaling: boolean;
  32150. private _fps;
  32151. private _deltaTime;
  32152. /** @hidden */
  32153. _drawCalls: PerfCounter;
  32154. /**
  32155. * Turn this value on if you want to pause FPS computation when in background
  32156. */
  32157. disablePerformanceMonitorInBackground: boolean;
  32158. private _performanceMonitor;
  32159. /**
  32160. * Gets the performance monitor attached to this engine
  32161. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32162. */
  32163. readonly performanceMonitor: PerformanceMonitor;
  32164. private _onFocus;
  32165. private _onBlur;
  32166. private _onCanvasPointerOut;
  32167. private _onCanvasBlur;
  32168. private _onCanvasFocus;
  32169. private _onFullscreenChange;
  32170. private _onPointerLockChange;
  32171. /**
  32172. * Creates a new engine
  32173. * @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
  32174. * @param antialias defines enable antialiasing (default: false)
  32175. * @param options defines further options to be sent to the getContext() function
  32176. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32177. */
  32178. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32179. /**
  32180. * Gets current aspect ratio
  32181. * @param viewportOwner defines the camera to use to get the aspect ratio
  32182. * @param useScreen defines if screen size must be used (or the current render target if any)
  32183. * @returns a number defining the aspect ratio
  32184. */
  32185. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32186. /**
  32187. * Gets current screen aspect ratio
  32188. * @returns a number defining the aspect ratio
  32189. */
  32190. getScreenAspectRatio(): number;
  32191. /**
  32192. * Gets host document
  32193. * @returns the host document object
  32194. */
  32195. getHostDocument(): Document;
  32196. /**
  32197. * Gets the client rect of the HTML canvas attached with the current webGL context
  32198. * @returns a client rectanglee
  32199. */
  32200. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32201. /**
  32202. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32203. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32204. * @returns true if engine is in deterministic lock step mode
  32205. */
  32206. isDeterministicLockStep(): boolean;
  32207. /**
  32208. * Gets the max steps when engine is running in deterministic lock step
  32209. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32210. * @returns the max steps
  32211. */
  32212. getLockstepMaxSteps(): number;
  32213. /**
  32214. * Force the mipmap generation for the given render target texture
  32215. * @param texture defines the render target texture to use
  32216. */
  32217. generateMipMapsForCubemap(texture: InternalTexture): void;
  32218. /** States */
  32219. /**
  32220. * Set various states to the webGL context
  32221. * @param culling defines backface culling state
  32222. * @param zOffset defines the value to apply to zOffset (0 by default)
  32223. * @param force defines if states must be applied even if cache is up to date
  32224. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32225. */
  32226. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32227. /**
  32228. * Set the z offset to apply to current rendering
  32229. * @param value defines the offset to apply
  32230. */
  32231. setZOffset(value: number): void;
  32232. /**
  32233. * Gets the current value of the zOffset
  32234. * @returns the current zOffset state
  32235. */
  32236. getZOffset(): number;
  32237. /**
  32238. * Enable or disable depth buffering
  32239. * @param enable defines the state to set
  32240. */
  32241. setDepthBuffer(enable: boolean): void;
  32242. /**
  32243. * Gets a boolean indicating if depth writing is enabled
  32244. * @returns the current depth writing state
  32245. */
  32246. getDepthWrite(): boolean;
  32247. /**
  32248. * Enable or disable depth writing
  32249. * @param enable defines the state to set
  32250. */
  32251. setDepthWrite(enable: boolean): void;
  32252. /**
  32253. * Enable or disable color writing
  32254. * @param enable defines the state to set
  32255. */
  32256. setColorWrite(enable: boolean): void;
  32257. /**
  32258. * Gets a boolean indicating if color writing is enabled
  32259. * @returns the current color writing state
  32260. */
  32261. getColorWrite(): boolean;
  32262. /**
  32263. * Sets alpha constants used by some alpha blending modes
  32264. * @param r defines the red component
  32265. * @param g defines the green component
  32266. * @param b defines the blue component
  32267. * @param a defines the alpha component
  32268. */
  32269. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32270. /**
  32271. * Sets the current alpha mode
  32272. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32273. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32274. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32275. */
  32276. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32277. /**
  32278. * Gets the current alpha mode
  32279. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32280. * @returns the current alpha mode
  32281. */
  32282. getAlphaMode(): number;
  32283. /**
  32284. * Sets the current alpha equation
  32285. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32286. */
  32287. setAlphaEquation(equation: number): void;
  32288. /**
  32289. * Gets the current alpha equation.
  32290. * @returns the current alpha equation
  32291. */
  32292. getAlphaEquation(): number;
  32293. /**
  32294. * Gets a boolean indicating if stencil buffer is enabled
  32295. * @returns the current stencil buffer state
  32296. */
  32297. getStencilBuffer(): boolean;
  32298. /**
  32299. * Enable or disable the stencil buffer
  32300. * @param enable defines if the stencil buffer must be enabled or disabled
  32301. */
  32302. setStencilBuffer(enable: boolean): void;
  32303. /**
  32304. * Gets the current stencil mask
  32305. * @returns a number defining the new stencil mask to use
  32306. */
  32307. getStencilMask(): number;
  32308. /**
  32309. * Sets the current stencil mask
  32310. * @param mask defines the new stencil mask to use
  32311. */
  32312. setStencilMask(mask: number): void;
  32313. /**
  32314. * Gets the current stencil function
  32315. * @returns a number defining the stencil function to use
  32316. */
  32317. getStencilFunction(): number;
  32318. /**
  32319. * Gets the current stencil reference value
  32320. * @returns a number defining the stencil reference value to use
  32321. */
  32322. getStencilFunctionReference(): number;
  32323. /**
  32324. * Gets the current stencil mask
  32325. * @returns a number defining the stencil mask to use
  32326. */
  32327. getStencilFunctionMask(): number;
  32328. /**
  32329. * Sets the current stencil function
  32330. * @param stencilFunc defines the new stencil function to use
  32331. */
  32332. setStencilFunction(stencilFunc: number): void;
  32333. /**
  32334. * Sets the current stencil reference
  32335. * @param reference defines the new stencil reference to use
  32336. */
  32337. setStencilFunctionReference(reference: number): void;
  32338. /**
  32339. * Sets the current stencil mask
  32340. * @param mask defines the new stencil mask to use
  32341. */
  32342. setStencilFunctionMask(mask: number): void;
  32343. /**
  32344. * Gets the current stencil operation when stencil fails
  32345. * @returns a number defining stencil operation to use when stencil fails
  32346. */
  32347. getStencilOperationFail(): number;
  32348. /**
  32349. * Gets the current stencil operation when depth fails
  32350. * @returns a number defining stencil operation to use when depth fails
  32351. */
  32352. getStencilOperationDepthFail(): number;
  32353. /**
  32354. * Gets the current stencil operation when stencil passes
  32355. * @returns a number defining stencil operation to use when stencil passes
  32356. */
  32357. getStencilOperationPass(): number;
  32358. /**
  32359. * Sets the stencil operation to use when stencil fails
  32360. * @param operation defines the stencil operation to use when stencil fails
  32361. */
  32362. setStencilOperationFail(operation: number): void;
  32363. /**
  32364. * Sets the stencil operation to use when depth fails
  32365. * @param operation defines the stencil operation to use when depth fails
  32366. */
  32367. setStencilOperationDepthFail(operation: number): void;
  32368. /**
  32369. * Sets the stencil operation to use when stencil passes
  32370. * @param operation defines the stencil operation to use when stencil passes
  32371. */
  32372. setStencilOperationPass(operation: number): void;
  32373. /**
  32374. * Sets a boolean indicating if the dithering state is enabled or disabled
  32375. * @param value defines the dithering state
  32376. */
  32377. setDitheringState(value: boolean): void;
  32378. /**
  32379. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32380. * @param value defines the rasterizer state
  32381. */
  32382. setRasterizerState(value: boolean): void;
  32383. /**
  32384. * Gets the current depth function
  32385. * @returns a number defining the depth function
  32386. */
  32387. getDepthFunction(): Nullable<number>;
  32388. /**
  32389. * Sets the current depth function
  32390. * @param depthFunc defines the function to use
  32391. */
  32392. setDepthFunction(depthFunc: number): void;
  32393. /**
  32394. * Sets the current depth function to GREATER
  32395. */
  32396. setDepthFunctionToGreater(): void;
  32397. /**
  32398. * Sets the current depth function to GEQUAL
  32399. */
  32400. setDepthFunctionToGreaterOrEqual(): void;
  32401. /**
  32402. * Sets the current depth function to LESS
  32403. */
  32404. setDepthFunctionToLess(): void;
  32405. /**
  32406. * Sets the current depth function to LEQUAL
  32407. */
  32408. setDepthFunctionToLessOrEqual(): void;
  32409. private _cachedStencilBuffer;
  32410. private _cachedStencilFunction;
  32411. private _cachedStencilMask;
  32412. private _cachedStencilOperationPass;
  32413. private _cachedStencilOperationFail;
  32414. private _cachedStencilOperationDepthFail;
  32415. private _cachedStencilReference;
  32416. /**
  32417. * Caches the the state of the stencil buffer
  32418. */
  32419. cacheStencilState(): void;
  32420. /**
  32421. * Restores the state of the stencil buffer
  32422. */
  32423. restoreStencilState(): void;
  32424. /**
  32425. * Directly set the WebGL Viewport
  32426. * @param x defines the x coordinate of the viewport (in screen space)
  32427. * @param y defines the y coordinate of the viewport (in screen space)
  32428. * @param width defines the width of the viewport (in screen space)
  32429. * @param height defines the height of the viewport (in screen space)
  32430. * @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
  32431. */
  32432. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32433. /**
  32434. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32435. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32436. * @param y defines the y-coordinate of the corner of the clear rectangle
  32437. * @param width defines the width of the clear rectangle
  32438. * @param height defines the height of the clear rectangle
  32439. * @param clearColor defines the clear color
  32440. */
  32441. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32442. /**
  32443. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32444. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32445. * @param y defines the y-coordinate of the corner of the clear rectangle
  32446. * @param width defines the width of the clear rectangle
  32447. * @param height defines the height of the clear rectangle
  32448. */
  32449. enableScissor(x: number, y: number, width: number, height: number): void;
  32450. /**
  32451. * Disable previously set scissor test rectangle
  32452. */
  32453. disableScissor(): void;
  32454. protected _reportDrawCall(): void;
  32455. /**
  32456. * Initializes a webVR display and starts listening to display change events
  32457. * The onVRDisplayChangedObservable will be notified upon these changes
  32458. * @returns The onVRDisplayChangedObservable
  32459. */
  32460. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32461. /** @hidden */
  32462. _prepareVRComponent(): void;
  32463. /** @hidden */
  32464. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32465. /** @hidden */
  32466. _submitVRFrame(): void;
  32467. /**
  32468. * Call this function to leave webVR mode
  32469. * Will do nothing if webVR is not supported or if there is no webVR device
  32470. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32471. */
  32472. disableVR(): void;
  32473. /**
  32474. * Gets a boolean indicating that the system is in VR mode and is presenting
  32475. * @returns true if VR mode is engaged
  32476. */
  32477. isVRPresenting(): boolean;
  32478. /** @hidden */
  32479. _requestVRFrame(): void;
  32480. /** @hidden */
  32481. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32482. /**
  32483. * Gets the source code of the vertex shader associated with a specific webGL program
  32484. * @param program defines the program to use
  32485. * @returns a string containing the source code of the vertex shader associated with the program
  32486. */
  32487. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32488. /**
  32489. * Gets the source code of the fragment shader associated with a specific webGL program
  32490. * @param program defines the program to use
  32491. * @returns a string containing the source code of the fragment shader associated with the program
  32492. */
  32493. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32494. /**
  32495. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32496. * @param x defines the x coordinate of the rectangle where pixels must be read
  32497. * @param y defines the y coordinate of the rectangle where pixels must be read
  32498. * @param width defines the width of the rectangle where pixels must be read
  32499. * @param height defines the height of the rectangle where pixels must be read
  32500. * @returns a Uint8Array containing RGBA colors
  32501. */
  32502. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32503. /**
  32504. * Sets a depth stencil texture from a render target to the according uniform.
  32505. * @param channel The texture channel
  32506. * @param uniform The uniform to set
  32507. * @param texture The render target texture containing the depth stencil texture to apply
  32508. */
  32509. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32510. /**
  32511. * Sets a texture to the webGL context from a postprocess
  32512. * @param channel defines the channel to use
  32513. * @param postProcess defines the source postprocess
  32514. */
  32515. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32516. /**
  32517. * Binds the output of the passed in post process to the texture channel specified
  32518. * @param channel The channel the texture should be bound to
  32519. * @param postProcess The post process which's output should be bound
  32520. */
  32521. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32522. /** @hidden */
  32523. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32524. protected _rebuildBuffers(): void;
  32525. _renderLoop(): void;
  32526. /**
  32527. * Toggle full screen mode
  32528. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32529. */
  32530. switchFullscreen(requestPointerLock: boolean): void;
  32531. /**
  32532. * Enters full screen mode
  32533. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32534. */
  32535. enterFullscreen(requestPointerLock: boolean): void;
  32536. /**
  32537. * Exits full screen mode
  32538. */
  32539. exitFullscreen(): void;
  32540. /**
  32541. * Enters Pointerlock mode
  32542. */
  32543. enterPointerlock(): void;
  32544. /**
  32545. * Exits Pointerlock mode
  32546. */
  32547. exitPointerlock(): void;
  32548. /**
  32549. * Begin a new frame
  32550. */
  32551. beginFrame(): void;
  32552. /**
  32553. * Enf the current frame
  32554. */
  32555. endFrame(): void;
  32556. resize(): void;
  32557. /**
  32558. * Set the compressed texture format to use, based on the formats you have, and the formats
  32559. * supported by the hardware / browser.
  32560. *
  32561. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32562. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32563. * to API arguments needed to compressed textures. This puts the burden on the container
  32564. * generator to house the arcane code for determining these for current & future formats.
  32565. *
  32566. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32567. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32568. *
  32569. * Note: The result of this call is not taken into account when a texture is base64.
  32570. *
  32571. * @param formatsAvailable defines the list of those format families you have created
  32572. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32573. *
  32574. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32575. * @returns The extension selected.
  32576. */
  32577. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32578. /**
  32579. * Force a specific size of the canvas
  32580. * @param width defines the new canvas' width
  32581. * @param height defines the new canvas' height
  32582. */
  32583. setSize(width: number, height: number): void;
  32584. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32585. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32586. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32587. _releaseTexture(texture: InternalTexture): void;
  32588. /**
  32589. * @hidden
  32590. * Rescales a texture
  32591. * @param source input texutre
  32592. * @param destination destination texture
  32593. * @param scene scene to use to render the resize
  32594. * @param internalFormat format to use when resizing
  32595. * @param onComplete callback to be called when resize has completed
  32596. */
  32597. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32598. /**
  32599. * Gets the current framerate
  32600. * @returns a number representing the framerate
  32601. */
  32602. getFps(): number;
  32603. /**
  32604. * Gets the time spent between current and previous frame
  32605. * @returns a number representing the delta time in ms
  32606. */
  32607. getDeltaTime(): number;
  32608. private _measureFps;
  32609. /**
  32610. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32611. * @param renderTarget The render target to set the frame buffer for
  32612. */
  32613. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32614. /**
  32615. * Update a dynamic index buffer
  32616. * @param indexBuffer defines the target index buffer
  32617. * @param indices defines the data to update
  32618. * @param offset defines the offset in the target index buffer where update should start
  32619. */
  32620. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32621. /**
  32622. * Updates the sample count of a render target texture
  32623. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32624. * @param texture defines the texture to update
  32625. * @param samples defines the sample count to set
  32626. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32627. */
  32628. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32629. /** @hidden */
  32630. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32631. dispose(): void;
  32632. private _disableTouchAction;
  32633. /**
  32634. * Display the loading screen
  32635. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32636. */
  32637. displayLoadingUI(): void;
  32638. /**
  32639. * Hide the loading screen
  32640. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32641. */
  32642. hideLoadingUI(): void;
  32643. /**
  32644. * Gets the current loading screen object
  32645. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32646. */
  32647. /**
  32648. * Sets the current loading screen object
  32649. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32650. */
  32651. loadingScreen: ILoadingScreen;
  32652. /**
  32653. * Sets the current loading screen text
  32654. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32655. */
  32656. loadingUIText: string;
  32657. /**
  32658. * Sets the current loading screen background color
  32659. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32660. */
  32661. loadingUIBackgroundColor: string;
  32662. /** Pointerlock and fullscreen */
  32663. /**
  32664. * Ask the browser to promote the current element to pointerlock mode
  32665. * @param element defines the DOM element to promote
  32666. */
  32667. static _RequestPointerlock(element: HTMLElement): void;
  32668. /**
  32669. * Asks the browser to exit pointerlock mode
  32670. */
  32671. static _ExitPointerlock(): void;
  32672. /**
  32673. * Ask the browser to promote the current element to fullscreen rendering mode
  32674. * @param element defines the DOM element to promote
  32675. */
  32676. static _RequestFullscreen(element: HTMLElement): void;
  32677. /**
  32678. * Asks the browser to exit fullscreen mode
  32679. */
  32680. static _ExitFullscreen(): void;
  32681. }
  32682. }
  32683. declare module "babylonjs/Engines/engineStore" {
  32684. import { Nullable } from "babylonjs/types";
  32685. import { Engine } from "babylonjs/Engines/engine";
  32686. import { Scene } from "babylonjs/scene";
  32687. /**
  32688. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32689. * during the life time of the application.
  32690. */
  32691. export class EngineStore {
  32692. /** Gets the list of created engines */
  32693. static Instances: import("babylonjs/Engines/engine").Engine[];
  32694. /** @hidden */
  32695. static _LastCreatedScene: Nullable<Scene>;
  32696. /**
  32697. * Gets the latest created engine
  32698. */
  32699. static readonly LastCreatedEngine: Nullable<Engine>;
  32700. /**
  32701. * Gets the latest created scene
  32702. */
  32703. static readonly LastCreatedScene: Nullable<Scene>;
  32704. /**
  32705. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32706. * @ignorenaming
  32707. */
  32708. static UseFallbackTexture: boolean;
  32709. /**
  32710. * Texture content used if a texture cannot loaded
  32711. * @ignorenaming
  32712. */
  32713. static FallbackTexture: string;
  32714. }
  32715. }
  32716. declare module "babylonjs/Misc/promise" {
  32717. /**
  32718. * Helper class that provides a small promise polyfill
  32719. */
  32720. export class PromisePolyfill {
  32721. /**
  32722. * Static function used to check if the polyfill is required
  32723. * If this is the case then the function will inject the polyfill to window.Promise
  32724. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32725. */
  32726. static Apply(force?: boolean): void;
  32727. }
  32728. }
  32729. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32730. /**
  32731. * Interface for screenshot methods with describe argument called `size` as object with options
  32732. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32733. */
  32734. export interface IScreenshotSize {
  32735. /**
  32736. * number in pixels for canvas height
  32737. */
  32738. height?: number;
  32739. /**
  32740. * multiplier allowing render at a higher or lower resolution
  32741. * If value is defined then height and width will be ignored and taken from camera
  32742. */
  32743. precision?: number;
  32744. /**
  32745. * number in pixels for canvas width
  32746. */
  32747. width?: number;
  32748. }
  32749. }
  32750. declare module "babylonjs/Misc/tools" {
  32751. import { Nullable, float } from "babylonjs/types";
  32752. import { DomManagement } from "babylonjs/Misc/domManagement";
  32753. import { WebRequest } from "babylonjs/Misc/webRequest";
  32754. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32755. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32756. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32757. import { Camera } from "babylonjs/Cameras/camera";
  32758. import { Engine } from "babylonjs/Engines/engine";
  32759. interface IColor4Like {
  32760. r: float;
  32761. g: float;
  32762. b: float;
  32763. a: float;
  32764. }
  32765. /**
  32766. * Class containing a set of static utilities functions
  32767. */
  32768. export class Tools {
  32769. /**
  32770. * Gets or sets the base URL to use to load assets
  32771. */
  32772. static BaseUrl: string;
  32773. /**
  32774. * Enable/Disable Custom HTTP Request Headers globally.
  32775. * default = false
  32776. * @see CustomRequestHeaders
  32777. */
  32778. static UseCustomRequestHeaders: boolean;
  32779. /**
  32780. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32781. * i.e. when loading files, where the server/service expects an Authorization header
  32782. */
  32783. static CustomRequestHeaders: {
  32784. [key: string]: string;
  32785. };
  32786. /**
  32787. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32788. */
  32789. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32790. /**
  32791. * Default behaviour for cors in the application.
  32792. * It can be a string if the expected behavior is identical in the entire app.
  32793. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32794. */
  32795. static CorsBehavior: string | ((url: string | string[]) => string);
  32796. /**
  32797. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32798. * @ignorenaming
  32799. */
  32800. static UseFallbackTexture: boolean;
  32801. /**
  32802. * Use this object to register external classes like custom textures or material
  32803. * to allow the laoders to instantiate them
  32804. */
  32805. static RegisteredExternalClasses: {
  32806. [key: string]: Object;
  32807. };
  32808. /**
  32809. * Texture content used if a texture cannot loaded
  32810. * @ignorenaming
  32811. */
  32812. static fallbackTexture: string;
  32813. /**
  32814. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32815. * @param u defines the coordinate on X axis
  32816. * @param v defines the coordinate on Y axis
  32817. * @param width defines the width of the source data
  32818. * @param height defines the height of the source data
  32819. * @param pixels defines the source byte array
  32820. * @param color defines the output color
  32821. */
  32822. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32823. /**
  32824. * Interpolates between a and b via alpha
  32825. * @param a The lower value (returned when alpha = 0)
  32826. * @param b The upper value (returned when alpha = 1)
  32827. * @param alpha The interpolation-factor
  32828. * @return The mixed value
  32829. */
  32830. static Mix(a: number, b: number, alpha: number): number;
  32831. /**
  32832. * Tries to instantiate a new object from a given class name
  32833. * @param className defines the class name to instantiate
  32834. * @returns the new object or null if the system was not able to do the instantiation
  32835. */
  32836. static Instantiate(className: string): any;
  32837. /**
  32838. * Provides a slice function that will work even on IE
  32839. * @param data defines the array to slice
  32840. * @param start defines the start of the data (optional)
  32841. * @param end defines the end of the data (optional)
  32842. * @returns the new sliced array
  32843. */
  32844. static Slice<T>(data: T, start?: number, end?: number): T;
  32845. /**
  32846. * Polyfill for setImmediate
  32847. * @param action defines the action to execute after the current execution block
  32848. */
  32849. static SetImmediate(action: () => void): void;
  32850. /**
  32851. * Function indicating if a number is an exponent of 2
  32852. * @param value defines the value to test
  32853. * @returns true if the value is an exponent of 2
  32854. */
  32855. static IsExponentOfTwo(value: number): boolean;
  32856. private static _tmpFloatArray;
  32857. /**
  32858. * Returns the nearest 32-bit single precision float representation of a Number
  32859. * @param value A Number. If the parameter is of a different type, it will get converted
  32860. * to a number or to NaN if it cannot be converted
  32861. * @returns number
  32862. */
  32863. static FloatRound(value: number): number;
  32864. /**
  32865. * Extracts the filename from a path
  32866. * @param path defines the path to use
  32867. * @returns the filename
  32868. */
  32869. static GetFilename(path: string): string;
  32870. /**
  32871. * Extracts the "folder" part of a path (everything before the filename).
  32872. * @param uri The URI to extract the info from
  32873. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32874. * @returns The "folder" part of the path
  32875. */
  32876. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32877. /**
  32878. * Extracts text content from a DOM element hierarchy
  32879. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32880. */
  32881. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32882. /**
  32883. * Convert an angle in radians to degrees
  32884. * @param angle defines the angle to convert
  32885. * @returns the angle in degrees
  32886. */
  32887. static ToDegrees(angle: number): number;
  32888. /**
  32889. * Convert an angle in degrees to radians
  32890. * @param angle defines the angle to convert
  32891. * @returns the angle in radians
  32892. */
  32893. static ToRadians(angle: number): number;
  32894. /**
  32895. * Encode a buffer to a base64 string
  32896. * @param buffer defines the buffer to encode
  32897. * @returns the encoded string
  32898. */
  32899. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32900. /**
  32901. * Returns an array if obj is not an array
  32902. * @param obj defines the object to evaluate as an array
  32903. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32904. * @returns either obj directly if obj is an array or a new array containing obj
  32905. */
  32906. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32907. /**
  32908. * Gets the pointer prefix to use
  32909. * @returns "pointer" if touch is enabled. Else returns "mouse"
  32910. */
  32911. static GetPointerPrefix(): string;
  32912. /**
  32913. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  32914. * @param url define the url we are trying
  32915. * @param element define the dom element where to configure the cors policy
  32916. */
  32917. static SetCorsBehavior(url: string | string[], element: {
  32918. crossOrigin: string | null;
  32919. }): void;
  32920. /**
  32921. * Removes unwanted characters from an url
  32922. * @param url defines the url to clean
  32923. * @returns the cleaned url
  32924. */
  32925. static CleanUrl(url: string): string;
  32926. /**
  32927. * Gets or sets a function used to pre-process url before using them to load assets
  32928. */
  32929. static PreprocessUrl: (url: string) => string;
  32930. /**
  32931. * Loads an image as an HTMLImageElement.
  32932. * @param input url string, ArrayBuffer, or Blob to load
  32933. * @param onLoad callback called when the image successfully loads
  32934. * @param onError callback called when the image fails to load
  32935. * @param offlineProvider offline provider for caching
  32936. * @param mimeType optional mime type
  32937. * @returns the HTMLImageElement of the loaded image
  32938. */
  32939. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): HTMLImageElement;
  32940. /**
  32941. * Loads a file
  32942. * @param url url string, ArrayBuffer, or Blob to load
  32943. * @param onSuccess callback called when the file successfully loads
  32944. * @param onProgress callback called while file is loading (if the server supports this mode)
  32945. * @param offlineProvider defines the offline provider for caching
  32946. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32947. * @param onError callback called when the file fails to load
  32948. * @returns a file request object
  32949. */
  32950. 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;
  32951. /**
  32952. * Loads a file from a url
  32953. * @param url the file url to load
  32954. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  32955. */
  32956. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  32957. /**
  32958. * Load a script (identified by an url). When the url returns, the
  32959. * content of this file is added into a new script element, attached to the DOM (body element)
  32960. * @param scriptUrl defines the url of the script to laod
  32961. * @param onSuccess defines the callback called when the script is loaded
  32962. * @param onError defines the callback to call if an error occurs
  32963. * @param scriptId defines the id of the script element
  32964. */
  32965. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  32966. /**
  32967. * Load an asynchronous script (identified by an url). When the url returns, the
  32968. * content of this file is added into a new script element, attached to the DOM (body element)
  32969. * @param scriptUrl defines the url of the script to laod
  32970. * @param scriptId defines the id of the script element
  32971. * @returns a promise request object
  32972. */
  32973. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  32974. /**
  32975. * Loads a file from a blob
  32976. * @param fileToLoad defines the blob to use
  32977. * @param callback defines the callback to call when data is loaded
  32978. * @param progressCallback defines the callback to call during loading process
  32979. * @returns a file request object
  32980. */
  32981. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  32982. /**
  32983. * Loads a file
  32984. * @param fileToLoad defines the file to load
  32985. * @param callback defines the callback to call when data is loaded
  32986. * @param progressCallBack defines the callback to call during loading process
  32987. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  32988. * @returns a file request object
  32989. */
  32990. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  32991. /**
  32992. * Creates a data url from a given string content
  32993. * @param content defines the content to convert
  32994. * @returns the new data url link
  32995. */
  32996. static FileAsURL(content: string): string;
  32997. /**
  32998. * Format the given number to a specific decimal format
  32999. * @param value defines the number to format
  33000. * @param decimals defines the number of decimals to use
  33001. * @returns the formatted string
  33002. */
  33003. static Format(value: number, decimals?: number): string;
  33004. /**
  33005. * Tries to copy an object by duplicating every property
  33006. * @param source defines the source object
  33007. * @param destination defines the target object
  33008. * @param doNotCopyList defines a list of properties to avoid
  33009. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33010. */
  33011. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33012. /**
  33013. * Gets a boolean indicating if the given object has no own property
  33014. * @param obj defines the object to test
  33015. * @returns true if object has no own property
  33016. */
  33017. static IsEmpty(obj: any): boolean;
  33018. /**
  33019. * Function used to register events at window level
  33020. * @param windowElement defines the Window object to use
  33021. * @param events defines the events to register
  33022. */
  33023. static RegisterTopRootEvents(windowElement: Window, events: {
  33024. name: string;
  33025. handler: Nullable<(e: FocusEvent) => any>;
  33026. }[]): void;
  33027. /**
  33028. * Function used to unregister events from window level
  33029. * @param windowElement defines the Window object to use
  33030. * @param events defines the events to unregister
  33031. */
  33032. static UnregisterTopRootEvents(windowElement: Window, events: {
  33033. name: string;
  33034. handler: Nullable<(e: FocusEvent) => any>;
  33035. }[]): void;
  33036. /**
  33037. * @ignore
  33038. */
  33039. static _ScreenshotCanvas: HTMLCanvasElement;
  33040. /**
  33041. * Dumps the current bound framebuffer
  33042. * @param width defines the rendering width
  33043. * @param height defines the rendering height
  33044. * @param engine defines the hosting engine
  33045. * @param successCallback defines the callback triggered once the data are available
  33046. * @param mimeType defines the mime type of the result
  33047. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33048. */
  33049. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33050. /**
  33051. * Converts the canvas data to blob.
  33052. * This acts as a polyfill for browsers not supporting the to blob function.
  33053. * @param canvas Defines the canvas to extract the data from
  33054. * @param successCallback Defines the callback triggered once the data are available
  33055. * @param mimeType Defines the mime type of the result
  33056. */
  33057. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33058. /**
  33059. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33060. * @param successCallback defines the callback triggered once the data are available
  33061. * @param mimeType defines the mime type of the result
  33062. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33063. */
  33064. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33065. /**
  33066. * Downloads a blob in the browser
  33067. * @param blob defines the blob to download
  33068. * @param fileName defines the name of the downloaded file
  33069. */
  33070. static Download(blob: Blob, fileName: string): void;
  33071. /**
  33072. * Captures a screenshot of the current rendering
  33073. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33074. * @param engine defines the rendering engine
  33075. * @param camera defines the source camera
  33076. * @param size This parameter can be set to a single number or to an object with the
  33077. * following (optional) properties: precision, width, height. If a single number is passed,
  33078. * it will be used for both width and height. If an object is passed, the screenshot size
  33079. * will be derived from the parameters. The precision property is a multiplier allowing
  33080. * rendering at a higher or lower resolution
  33081. * @param successCallback defines the callback receives a single parameter which contains the
  33082. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33083. * src parameter of an <img> to display it
  33084. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33085. * Check your browser for supported MIME types
  33086. */
  33087. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33088. /**
  33089. * Captures a screenshot of the current rendering
  33090. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33091. * @param engine defines the rendering engine
  33092. * @param camera defines the source camera
  33093. * @param size This parameter can be set to a single number or to an object with the
  33094. * following (optional) properties: precision, width, height. If a single number is passed,
  33095. * it will be used for both width and height. If an object is passed, the screenshot size
  33096. * will be derived from the parameters. The precision property is a multiplier allowing
  33097. * rendering at a higher or lower resolution
  33098. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33099. * Check your browser for supported MIME types
  33100. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33101. * to the src parameter of an <img> to display it
  33102. */
  33103. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33104. /**
  33105. * Generates an image screenshot from the specified camera.
  33106. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33107. * @param engine The engine to use for rendering
  33108. * @param camera The camera to use for rendering
  33109. * @param size This parameter can be set to a single number or to an object with the
  33110. * following (optional) properties: precision, width, height. If a single number is passed,
  33111. * it will be used for both width and height. If an object is passed, the screenshot size
  33112. * will be derived from the parameters. The precision property is a multiplier allowing
  33113. * rendering at a higher or lower resolution
  33114. * @param successCallback The callback receives a single parameter which contains the
  33115. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33116. * src parameter of an <img> to display it
  33117. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33118. * Check your browser for supported MIME types
  33119. * @param samples Texture samples (default: 1)
  33120. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33121. * @param fileName A name for for the downloaded file.
  33122. */
  33123. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33124. /**
  33125. * Generates an image screenshot from the specified camera.
  33126. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33127. * @param engine The engine to use for rendering
  33128. * @param camera The camera to use for rendering
  33129. * @param size This parameter can be set to a single number or to an object with the
  33130. * following (optional) properties: precision, width, height. If a single number is passed,
  33131. * it will be used for both width and height. If an object is passed, the screenshot size
  33132. * will be derived from the parameters. The precision property is a multiplier allowing
  33133. * rendering at a higher or lower resolution
  33134. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33135. * Check your browser for supported MIME types
  33136. * @param samples Texture samples (default: 1)
  33137. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33138. * @param fileName A name for for the downloaded file.
  33139. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33140. * to the src parameter of an <img> to display it
  33141. */
  33142. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33143. /**
  33144. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33145. * Be aware Math.random() could cause collisions, but:
  33146. * "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"
  33147. * @returns a pseudo random id
  33148. */
  33149. static RandomId(): string;
  33150. /**
  33151. * Test if the given uri is a base64 string
  33152. * @param uri The uri to test
  33153. * @return True if the uri is a base64 string or false otherwise
  33154. */
  33155. static IsBase64(uri: string): boolean;
  33156. /**
  33157. * Decode the given base64 uri.
  33158. * @param uri The uri to decode
  33159. * @return The decoded base64 data.
  33160. */
  33161. static DecodeBase64(uri: string): ArrayBuffer;
  33162. /**
  33163. * Gets the absolute url.
  33164. * @param url the input url
  33165. * @return the absolute url
  33166. */
  33167. static GetAbsoluteUrl(url: string): string;
  33168. /**
  33169. * No log
  33170. */
  33171. static readonly NoneLogLevel: number;
  33172. /**
  33173. * Only message logs
  33174. */
  33175. static readonly MessageLogLevel: number;
  33176. /**
  33177. * Only warning logs
  33178. */
  33179. static readonly WarningLogLevel: number;
  33180. /**
  33181. * Only error logs
  33182. */
  33183. static readonly ErrorLogLevel: number;
  33184. /**
  33185. * All logs
  33186. */
  33187. static readonly AllLogLevel: number;
  33188. /**
  33189. * Gets a value indicating the number of loading errors
  33190. * @ignorenaming
  33191. */
  33192. static readonly errorsCount: number;
  33193. /**
  33194. * Callback called when a new log is added
  33195. */
  33196. static OnNewCacheEntry: (entry: string) => void;
  33197. /**
  33198. * Log a message to the console
  33199. * @param message defines the message to log
  33200. */
  33201. static Log(message: string): void;
  33202. /**
  33203. * Write a warning message to the console
  33204. * @param message defines the message to log
  33205. */
  33206. static Warn(message: string): void;
  33207. /**
  33208. * Write an error message to the console
  33209. * @param message defines the message to log
  33210. */
  33211. static Error(message: string): void;
  33212. /**
  33213. * Gets current log cache (list of logs)
  33214. */
  33215. static readonly LogCache: string;
  33216. /**
  33217. * Clears the log cache
  33218. */
  33219. static ClearLogCache(): void;
  33220. /**
  33221. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33222. */
  33223. static LogLevels: number;
  33224. /**
  33225. * Checks if the window object exists
  33226. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33227. */
  33228. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33229. /**
  33230. * No performance log
  33231. */
  33232. static readonly PerformanceNoneLogLevel: number;
  33233. /**
  33234. * Use user marks to log performance
  33235. */
  33236. static readonly PerformanceUserMarkLogLevel: number;
  33237. /**
  33238. * Log performance to the console
  33239. */
  33240. static readonly PerformanceConsoleLogLevel: number;
  33241. private static _performance;
  33242. /**
  33243. * Sets the current performance log level
  33244. */
  33245. static PerformanceLogLevel: number;
  33246. private static _StartPerformanceCounterDisabled;
  33247. private static _EndPerformanceCounterDisabled;
  33248. private static _StartUserMark;
  33249. private static _EndUserMark;
  33250. private static _StartPerformanceConsole;
  33251. private static _EndPerformanceConsole;
  33252. /**
  33253. * Starts a performance counter
  33254. */
  33255. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33256. /**
  33257. * Ends a specific performance coutner
  33258. */
  33259. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33260. /**
  33261. * Gets either window.performance.now() if supported or Date.now() else
  33262. */
  33263. static readonly Now: number;
  33264. /**
  33265. * This method will return the name of the class used to create the instance of the given object.
  33266. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33267. * @param object the object to get the class name from
  33268. * @param isType defines if the object is actually a type
  33269. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33270. */
  33271. static GetClassName(object: any, isType?: boolean): string;
  33272. /**
  33273. * Gets the first element of an array satisfying a given predicate
  33274. * @param array defines the array to browse
  33275. * @param predicate defines the predicate to use
  33276. * @returns null if not found or the element
  33277. */
  33278. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33279. /**
  33280. * This method will return the name of the full name of the class, including its owning module (if any).
  33281. * 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).
  33282. * @param object the object to get the class name from
  33283. * @param isType defines if the object is actually a type
  33284. * @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.
  33285. * @ignorenaming
  33286. */
  33287. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33288. /**
  33289. * Returns a promise that resolves after the given amount of time.
  33290. * @param delay Number of milliseconds to delay
  33291. * @returns Promise that resolves after the given amount of time
  33292. */
  33293. static DelayAsync(delay: number): Promise<void>;
  33294. }
  33295. /**
  33296. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33297. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33298. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33299. * @param name The name of the class, case should be preserved
  33300. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33301. */
  33302. export function className(name: string, module?: string): (target: Object) => void;
  33303. /**
  33304. * An implementation of a loop for asynchronous functions.
  33305. */
  33306. export class AsyncLoop {
  33307. /**
  33308. * Defines the number of iterations for the loop
  33309. */
  33310. iterations: number;
  33311. /**
  33312. * Defines the current index of the loop.
  33313. */
  33314. index: number;
  33315. private _done;
  33316. private _fn;
  33317. private _successCallback;
  33318. /**
  33319. * Constructor.
  33320. * @param iterations the number of iterations.
  33321. * @param func the function to run each iteration
  33322. * @param successCallback the callback that will be called upon succesful execution
  33323. * @param offset starting offset.
  33324. */
  33325. constructor(
  33326. /**
  33327. * Defines the number of iterations for the loop
  33328. */
  33329. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33330. /**
  33331. * Execute the next iteration. Must be called after the last iteration was finished.
  33332. */
  33333. executeNext(): void;
  33334. /**
  33335. * Break the loop and run the success callback.
  33336. */
  33337. breakLoop(): void;
  33338. /**
  33339. * Create and run an async loop.
  33340. * @param iterations the number of iterations.
  33341. * @param fn the function to run each iteration
  33342. * @param successCallback the callback that will be called upon succesful execution
  33343. * @param offset starting offset.
  33344. * @returns the created async loop object
  33345. */
  33346. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33347. /**
  33348. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33349. * @param iterations total number of iterations
  33350. * @param syncedIterations number of synchronous iterations in each async iteration.
  33351. * @param fn the function to call each iteration.
  33352. * @param callback a success call back that will be called when iterating stops.
  33353. * @param breakFunction a break condition (optional)
  33354. * @param timeout timeout settings for the setTimeout function. default - 0.
  33355. * @returns the created async loop object
  33356. */
  33357. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33358. }
  33359. }
  33360. declare module "babylonjs/Misc/stringDictionary" {
  33361. import { Nullable } from "babylonjs/types";
  33362. /**
  33363. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33364. * The underlying implementation relies on an associative array to ensure the best performances.
  33365. * The value can be anything including 'null' but except 'undefined'
  33366. */
  33367. export class StringDictionary<T> {
  33368. /**
  33369. * This will clear this dictionary and copy the content from the 'source' one.
  33370. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33371. * @param source the dictionary to take the content from and copy to this dictionary
  33372. */
  33373. copyFrom(source: StringDictionary<T>): void;
  33374. /**
  33375. * Get a value based from its key
  33376. * @param key the given key to get the matching value from
  33377. * @return the value if found, otherwise undefined is returned
  33378. */
  33379. get(key: string): T | undefined;
  33380. /**
  33381. * Get a value from its key or add it if it doesn't exist.
  33382. * This method will ensure you that a given key/data will be present in the dictionary.
  33383. * @param key the given key to get the matching value from
  33384. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33385. * The factory will only be invoked if there's no data for the given key.
  33386. * @return the value corresponding to the key.
  33387. */
  33388. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33389. /**
  33390. * Get a value from its key if present in the dictionary otherwise add it
  33391. * @param key the key to get the value from
  33392. * @param val if there's no such key/value pair in the dictionary add it with this value
  33393. * @return the value corresponding to the key
  33394. */
  33395. getOrAdd(key: string, val: T): T;
  33396. /**
  33397. * Check if there's a given key in the dictionary
  33398. * @param key the key to check for
  33399. * @return true if the key is present, false otherwise
  33400. */
  33401. contains(key: string): boolean;
  33402. /**
  33403. * Add a new key and its corresponding value
  33404. * @param key the key to add
  33405. * @param value the value corresponding to the key
  33406. * @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
  33407. */
  33408. add(key: string, value: T): boolean;
  33409. /**
  33410. * Update a specific value associated to a key
  33411. * @param key defines the key to use
  33412. * @param value defines the value to store
  33413. * @returns true if the value was updated (or false if the key was not found)
  33414. */
  33415. set(key: string, value: T): boolean;
  33416. /**
  33417. * Get the element of the given key and remove it from the dictionary
  33418. * @param key defines the key to search
  33419. * @returns the value associated with the key or null if not found
  33420. */
  33421. getAndRemove(key: string): Nullable<T>;
  33422. /**
  33423. * Remove a key/value from the dictionary.
  33424. * @param key the key to remove
  33425. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33426. */
  33427. remove(key: string): boolean;
  33428. /**
  33429. * Clear the whole content of the dictionary
  33430. */
  33431. clear(): void;
  33432. /**
  33433. * Gets the current count
  33434. */
  33435. readonly count: number;
  33436. /**
  33437. * Execute a callback on each key/val of the dictionary.
  33438. * Note that you can remove any element in this dictionary in the callback implementation
  33439. * @param callback the callback to execute on a given key/value pair
  33440. */
  33441. forEach(callback: (key: string, val: T) => void): void;
  33442. /**
  33443. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33444. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33445. * Note that you can remove any element in this dictionary in the callback implementation
  33446. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33447. * @returns the first item
  33448. */
  33449. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33450. private _count;
  33451. private _data;
  33452. }
  33453. }
  33454. declare module "babylonjs/Collisions/collisionCoordinator" {
  33455. import { Nullable } from "babylonjs/types";
  33456. import { Scene } from "babylonjs/scene";
  33457. import { Vector3 } from "babylonjs/Maths/math.vector";
  33458. import { Collider } from "babylonjs/Collisions/collider";
  33459. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33460. /** @hidden */
  33461. export interface ICollisionCoordinator {
  33462. createCollider(): Collider;
  33463. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33464. init(scene: Scene): void;
  33465. }
  33466. /** @hidden */
  33467. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33468. private _scene;
  33469. private _scaledPosition;
  33470. private _scaledVelocity;
  33471. private _finalPosition;
  33472. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33473. createCollider(): Collider;
  33474. init(scene: Scene): void;
  33475. private _collideWithWorld;
  33476. }
  33477. }
  33478. declare module "babylonjs/Inputs/scene.inputManager" {
  33479. import { Nullable } from "babylonjs/types";
  33480. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33481. import { Vector2 } from "babylonjs/Maths/math.vector";
  33482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33483. import { Scene } from "babylonjs/scene";
  33484. /**
  33485. * Class used to manage all inputs for the scene.
  33486. */
  33487. export class InputManager {
  33488. /** The distance in pixel that you have to move to prevent some events */
  33489. static DragMovementThreshold: number;
  33490. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33491. static LongPressDelay: number;
  33492. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33493. static DoubleClickDelay: number;
  33494. /** If you need to check double click without raising a single click at first click, enable this flag */
  33495. static ExclusiveDoubleClickMode: boolean;
  33496. private _wheelEventName;
  33497. private _onPointerMove;
  33498. private _onPointerDown;
  33499. private _onPointerUp;
  33500. private _initClickEvent;
  33501. private _initActionManager;
  33502. private _delayedSimpleClick;
  33503. private _delayedSimpleClickTimeout;
  33504. private _previousDelayedSimpleClickTimeout;
  33505. private _meshPickProceed;
  33506. private _previousButtonPressed;
  33507. private _currentPickResult;
  33508. private _previousPickResult;
  33509. private _totalPointersPressed;
  33510. private _doubleClickOccured;
  33511. private _pointerOverMesh;
  33512. private _pickedDownMesh;
  33513. private _pickedUpMesh;
  33514. private _pointerX;
  33515. private _pointerY;
  33516. private _unTranslatedPointerX;
  33517. private _unTranslatedPointerY;
  33518. private _startingPointerPosition;
  33519. private _previousStartingPointerPosition;
  33520. private _startingPointerTime;
  33521. private _previousStartingPointerTime;
  33522. private _pointerCaptures;
  33523. private _onKeyDown;
  33524. private _onKeyUp;
  33525. private _onCanvasFocusObserver;
  33526. private _onCanvasBlurObserver;
  33527. private _scene;
  33528. /**
  33529. * Creates a new InputManager
  33530. * @param scene defines the hosting scene
  33531. */
  33532. constructor(scene: Scene);
  33533. /**
  33534. * Gets the mesh that is currently under the pointer
  33535. */
  33536. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33537. /**
  33538. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33539. */
  33540. readonly unTranslatedPointer: Vector2;
  33541. /**
  33542. * Gets or sets the current on-screen X position of the pointer
  33543. */
  33544. pointerX: number;
  33545. /**
  33546. * Gets or sets the current on-screen Y position of the pointer
  33547. */
  33548. pointerY: number;
  33549. private _updatePointerPosition;
  33550. private _processPointerMove;
  33551. private _setRayOnPointerInfo;
  33552. private _checkPrePointerObservable;
  33553. /**
  33554. * Use this method to simulate a pointer move on a mesh
  33555. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33556. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33557. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33558. */
  33559. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33560. /**
  33561. * Use this method to simulate a pointer down on a mesh
  33562. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33563. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33564. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33565. */
  33566. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33567. private _processPointerDown;
  33568. /** @hidden */
  33569. _isPointerSwiping(): boolean;
  33570. /**
  33571. * Use this method to simulate a pointer up on a mesh
  33572. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33573. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33574. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33575. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33576. */
  33577. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33578. private _processPointerUp;
  33579. /**
  33580. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33581. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33582. * @returns true if the pointer was captured
  33583. */
  33584. isPointerCaptured(pointerId?: number): boolean;
  33585. /**
  33586. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33587. * @param attachUp defines if you want to attach events to pointerup
  33588. * @param attachDown defines if you want to attach events to pointerdown
  33589. * @param attachMove defines if you want to attach events to pointermove
  33590. */
  33591. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33592. /**
  33593. * Detaches all event handlers
  33594. */
  33595. detachControl(): void;
  33596. /**
  33597. * Force the value of meshUnderPointer
  33598. * @param mesh defines the mesh to use
  33599. */
  33600. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33601. /**
  33602. * Gets the mesh under the pointer
  33603. * @returns a Mesh or null if no mesh is under the pointer
  33604. */
  33605. getPointerOverMesh(): Nullable<AbstractMesh>;
  33606. }
  33607. }
  33608. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33609. /**
  33610. * Helper class used to generate session unique ID
  33611. */
  33612. export class UniqueIdGenerator {
  33613. private static _UniqueIdCounter;
  33614. /**
  33615. * Gets an unique (relatively to the current scene) Id
  33616. */
  33617. static readonly UniqueId: number;
  33618. }
  33619. }
  33620. declare module "babylonjs/Animations/animationGroup" {
  33621. import { Animatable } from "babylonjs/Animations/animatable";
  33622. import { Animation } from "babylonjs/Animations/animation";
  33623. import { Scene, IDisposable } from "babylonjs/scene";
  33624. import { Observable } from "babylonjs/Misc/observable";
  33625. import { Nullable } from "babylonjs/types";
  33626. import "babylonjs/Animations/animatable";
  33627. /**
  33628. * This class defines the direct association between an animation and a target
  33629. */
  33630. export class TargetedAnimation {
  33631. /**
  33632. * Animation to perform
  33633. */
  33634. animation: Animation;
  33635. /**
  33636. * Target to animate
  33637. */
  33638. target: any;
  33639. /**
  33640. * Serialize the object
  33641. * @returns the JSON object representing the current entity
  33642. */
  33643. serialize(): any;
  33644. }
  33645. /**
  33646. * Use this class to create coordinated animations on multiple targets
  33647. */
  33648. export class AnimationGroup implements IDisposable {
  33649. /** The name of the animation group */
  33650. name: string;
  33651. private _scene;
  33652. private _targetedAnimations;
  33653. private _animatables;
  33654. private _from;
  33655. private _to;
  33656. private _isStarted;
  33657. private _isPaused;
  33658. private _speedRatio;
  33659. private _loopAnimation;
  33660. /**
  33661. * Gets or sets the unique id of the node
  33662. */
  33663. uniqueId: number;
  33664. /**
  33665. * This observable will notify when one animation have ended
  33666. */
  33667. onAnimationEndObservable: Observable<TargetedAnimation>;
  33668. /**
  33669. * Observer raised when one animation loops
  33670. */
  33671. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33672. /**
  33673. * This observable will notify when all animations have ended.
  33674. */
  33675. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33676. /**
  33677. * This observable will notify when all animations have paused.
  33678. */
  33679. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33680. /**
  33681. * This observable will notify when all animations are playing.
  33682. */
  33683. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33684. /**
  33685. * Gets the first frame
  33686. */
  33687. readonly from: number;
  33688. /**
  33689. * Gets the last frame
  33690. */
  33691. readonly to: number;
  33692. /**
  33693. * Define if the animations are started
  33694. */
  33695. readonly isStarted: boolean;
  33696. /**
  33697. * Gets a value indicating that the current group is playing
  33698. */
  33699. readonly isPlaying: boolean;
  33700. /**
  33701. * Gets or sets the speed ratio to use for all animations
  33702. */
  33703. /**
  33704. * Gets or sets the speed ratio to use for all animations
  33705. */
  33706. speedRatio: number;
  33707. /**
  33708. * Gets or sets if all animations should loop or not
  33709. */
  33710. loopAnimation: boolean;
  33711. /**
  33712. * Gets the targeted animations for this animation group
  33713. */
  33714. readonly targetedAnimations: Array<TargetedAnimation>;
  33715. /**
  33716. * returning the list of animatables controlled by this animation group.
  33717. */
  33718. readonly animatables: Array<Animatable>;
  33719. /**
  33720. * Instantiates a new Animation Group.
  33721. * This helps managing several animations at once.
  33722. * @see http://doc.babylonjs.com/how_to/group
  33723. * @param name Defines the name of the group
  33724. * @param scene Defines the scene the group belongs to
  33725. */
  33726. constructor(
  33727. /** The name of the animation group */
  33728. name: string, scene?: Nullable<Scene>);
  33729. /**
  33730. * Add an animation (with its target) in the group
  33731. * @param animation defines the animation we want to add
  33732. * @param target defines the target of the animation
  33733. * @returns the TargetedAnimation object
  33734. */
  33735. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33736. /**
  33737. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33738. * It can add constant keys at begin or end
  33739. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33740. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33741. * @returns the animation group
  33742. */
  33743. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33744. /**
  33745. * Start all animations on given targets
  33746. * @param loop defines if animations must loop
  33747. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33748. * @param from defines the from key (optional)
  33749. * @param to defines the to key (optional)
  33750. * @returns the current animation group
  33751. */
  33752. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33753. /**
  33754. * Pause all animations
  33755. * @returns the animation group
  33756. */
  33757. pause(): AnimationGroup;
  33758. /**
  33759. * Play all animations to initial state
  33760. * This function will start() the animations if they were not started or will restart() them if they were paused
  33761. * @param loop defines if animations must loop
  33762. * @returns the animation group
  33763. */
  33764. play(loop?: boolean): AnimationGroup;
  33765. /**
  33766. * Reset all animations to initial state
  33767. * @returns the animation group
  33768. */
  33769. reset(): AnimationGroup;
  33770. /**
  33771. * Restart animations from key 0
  33772. * @returns the animation group
  33773. */
  33774. restart(): AnimationGroup;
  33775. /**
  33776. * Stop all animations
  33777. * @returns the animation group
  33778. */
  33779. stop(): AnimationGroup;
  33780. /**
  33781. * Set animation weight for all animatables
  33782. * @param weight defines the weight to use
  33783. * @return the animationGroup
  33784. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33785. */
  33786. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33787. /**
  33788. * Synchronize and normalize all animatables with a source animatable
  33789. * @param root defines the root animatable to synchronize with
  33790. * @return the animationGroup
  33791. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33792. */
  33793. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33794. /**
  33795. * Goes to a specific frame in this animation group
  33796. * @param frame the frame number to go to
  33797. * @return the animationGroup
  33798. */
  33799. goToFrame(frame: number): AnimationGroup;
  33800. /**
  33801. * Dispose all associated resources
  33802. */
  33803. dispose(): void;
  33804. private _checkAnimationGroupEnded;
  33805. /**
  33806. * Clone the current animation group and returns a copy
  33807. * @param newName defines the name of the new group
  33808. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33809. * @returns the new aniamtion group
  33810. */
  33811. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33812. /**
  33813. * Serializes the animationGroup to an object
  33814. * @returns Serialized object
  33815. */
  33816. serialize(): any;
  33817. /**
  33818. * Returns a new AnimationGroup object parsed from the source provided.
  33819. * @param parsedAnimationGroup defines the source
  33820. * @param scene defines the scene that will receive the animationGroup
  33821. * @returns a new AnimationGroup
  33822. */
  33823. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33824. /**
  33825. * Returns the string "AnimationGroup"
  33826. * @returns "AnimationGroup"
  33827. */
  33828. getClassName(): string;
  33829. /**
  33830. * Creates a detailled string about the object
  33831. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33832. * @returns a string representing the object
  33833. */
  33834. toString(fullDetails?: boolean): string;
  33835. }
  33836. }
  33837. declare module "babylonjs/scene" {
  33838. import { Nullable } from "babylonjs/types";
  33839. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33840. import { Observable } from "babylonjs/Misc/observable";
  33841. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33842. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33843. import { Geometry } from "babylonjs/Meshes/geometry";
  33844. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33845. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33846. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33847. import { Mesh } from "babylonjs/Meshes/mesh";
  33848. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33849. import { Bone } from "babylonjs/Bones/bone";
  33850. import { Skeleton } from "babylonjs/Bones/skeleton";
  33851. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33852. import { Camera } from "babylonjs/Cameras/camera";
  33853. import { AbstractScene } from "babylonjs/abstractScene";
  33854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33855. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33856. import { Material } from "babylonjs/Materials/material";
  33857. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33858. import { Effect } from "babylonjs/Materials/effect";
  33859. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33860. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33861. import { Light } from "babylonjs/Lights/light";
  33862. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33863. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33864. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33865. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33866. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33867. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33868. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33869. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33870. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33871. import { Engine } from "babylonjs/Engines/engine";
  33872. import { Node } from "babylonjs/node";
  33873. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33874. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33875. import { WebRequest } from "babylonjs/Misc/webRequest";
  33876. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33877. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33878. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33879. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33880. import { Plane } from "babylonjs/Maths/math.plane";
  33881. import { Ray } from "babylonjs/Culling/ray";
  33882. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33883. import { Animation } from "babylonjs/Animations/animation";
  33884. import { Animatable } from "babylonjs/Animations/animatable";
  33885. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33886. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33887. import { Collider } from "babylonjs/Collisions/collider";
  33888. /**
  33889. * Define an interface for all classes that will hold resources
  33890. */
  33891. export interface IDisposable {
  33892. /**
  33893. * Releases all held resources
  33894. */
  33895. dispose(): void;
  33896. }
  33897. /** Interface defining initialization parameters for Scene class */
  33898. export interface SceneOptions {
  33899. /**
  33900. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33901. * It will improve performance when the number of geometries becomes important.
  33902. */
  33903. useGeometryUniqueIdsMap?: boolean;
  33904. /**
  33905. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33906. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33907. */
  33908. useMaterialMeshMap?: boolean;
  33909. /**
  33910. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  33911. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33912. */
  33913. useClonedMeshhMap?: boolean;
  33914. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  33915. virtual?: boolean;
  33916. }
  33917. /**
  33918. * Represents a scene to be rendered by the engine.
  33919. * @see http://doc.babylonjs.com/features/scene
  33920. */
  33921. export class Scene extends AbstractScene implements IAnimatable {
  33922. /** The fog is deactivated */
  33923. static readonly FOGMODE_NONE: number;
  33924. /** The fog density is following an exponential function */
  33925. static readonly FOGMODE_EXP: number;
  33926. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  33927. static readonly FOGMODE_EXP2: number;
  33928. /** The fog density is following a linear function. */
  33929. static readonly FOGMODE_LINEAR: number;
  33930. /**
  33931. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  33932. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33933. */
  33934. static MinDeltaTime: number;
  33935. /**
  33936. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  33937. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33938. */
  33939. static MaxDeltaTime: number;
  33940. /**
  33941. * Factory used to create the default material.
  33942. * @param name The name of the material to create
  33943. * @param scene The scene to create the material for
  33944. * @returns The default material
  33945. */
  33946. static DefaultMaterialFactory(scene: Scene): Material;
  33947. /**
  33948. * Factory used to create the a collision coordinator.
  33949. * @returns The collision coordinator
  33950. */
  33951. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  33952. /** @hidden */
  33953. _inputManager: InputManager;
  33954. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  33955. cameraToUseForPointers: Nullable<Camera>;
  33956. /** @hidden */
  33957. readonly _isScene: boolean;
  33958. /**
  33959. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  33960. */
  33961. autoClear: boolean;
  33962. /**
  33963. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  33964. */
  33965. autoClearDepthAndStencil: boolean;
  33966. /**
  33967. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  33968. */
  33969. clearColor: Color4;
  33970. /**
  33971. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  33972. */
  33973. ambientColor: Color3;
  33974. /**
  33975. * This is use to store the default BRDF lookup for PBR materials in your scene.
  33976. * It should only be one of the following (if not the default embedded one):
  33977. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  33978. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  33979. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  33980. * The material properties need to be setup according to the type of texture in use.
  33981. */
  33982. environmentBRDFTexture: BaseTexture;
  33983. /** @hidden */
  33984. protected _environmentTexture: Nullable<BaseTexture>;
  33985. /**
  33986. * Texture used in all pbr material as the reflection texture.
  33987. * As in the majority of the scene they are the same (exception for multi room and so on),
  33988. * this is easier to reference from here than from all the materials.
  33989. */
  33990. /**
  33991. * Texture used in all pbr material as the reflection texture.
  33992. * As in the majority of the scene they are the same (exception for multi room and so on),
  33993. * this is easier to set here than in all the materials.
  33994. */
  33995. environmentTexture: Nullable<BaseTexture>;
  33996. /** @hidden */
  33997. protected _environmentIntensity: number;
  33998. /**
  33999. * Intensity of the environment in all pbr material.
  34000. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34001. * As in the majority of the scene they are the same (exception for multi room and so on),
  34002. * this is easier to reference from here than from all the materials.
  34003. */
  34004. /**
  34005. * Intensity of the environment in all pbr material.
  34006. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34007. * As in the majority of the scene they are the same (exception for multi room and so on),
  34008. * this is easier to set here than in all the materials.
  34009. */
  34010. environmentIntensity: number;
  34011. /** @hidden */
  34012. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34013. /**
  34014. * Default image processing configuration used either in the rendering
  34015. * Forward main pass or through the imageProcessingPostProcess if present.
  34016. * As in the majority of the scene they are the same (exception for multi camera),
  34017. * this is easier to reference from here than from all the materials and post process.
  34018. *
  34019. * No setter as we it is a shared configuration, you can set the values instead.
  34020. */
  34021. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34022. private _forceWireframe;
  34023. /**
  34024. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34025. */
  34026. forceWireframe: boolean;
  34027. private _forcePointsCloud;
  34028. /**
  34029. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34030. */
  34031. forcePointsCloud: boolean;
  34032. /**
  34033. * Gets or sets the active clipplane 1
  34034. */
  34035. clipPlane: Nullable<Plane>;
  34036. /**
  34037. * Gets or sets the active clipplane 2
  34038. */
  34039. clipPlane2: Nullable<Plane>;
  34040. /**
  34041. * Gets or sets the active clipplane 3
  34042. */
  34043. clipPlane3: Nullable<Plane>;
  34044. /**
  34045. * Gets or sets the active clipplane 4
  34046. */
  34047. clipPlane4: Nullable<Plane>;
  34048. /**
  34049. * Gets or sets a boolean indicating if animations are enabled
  34050. */
  34051. animationsEnabled: boolean;
  34052. private _animationPropertiesOverride;
  34053. /**
  34054. * Gets or sets the animation properties override
  34055. */
  34056. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34057. /**
  34058. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34059. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34060. */
  34061. useConstantAnimationDeltaTime: boolean;
  34062. /**
  34063. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34064. * Please note that it requires to run a ray cast through the scene on every frame
  34065. */
  34066. constantlyUpdateMeshUnderPointer: boolean;
  34067. /**
  34068. * Defines the HTML cursor to use when hovering over interactive elements
  34069. */
  34070. hoverCursor: string;
  34071. /**
  34072. * Defines the HTML default cursor to use (empty by default)
  34073. */
  34074. defaultCursor: string;
  34075. /**
  34076. * This is used to call preventDefault() on pointer down
  34077. * in order to block unwanted artifacts like system double clicks
  34078. */
  34079. preventDefaultOnPointerDown: boolean;
  34080. /**
  34081. * This is used to call preventDefault() on pointer up
  34082. * in order to block unwanted artifacts like system double clicks
  34083. */
  34084. preventDefaultOnPointerUp: boolean;
  34085. /**
  34086. * Gets or sets user defined metadata
  34087. */
  34088. metadata: any;
  34089. /**
  34090. * For internal use only. Please do not use.
  34091. */
  34092. reservedDataStore: any;
  34093. /**
  34094. * Gets the name of the plugin used to load this scene (null by default)
  34095. */
  34096. loadingPluginName: string;
  34097. /**
  34098. * Use this array to add regular expressions used to disable offline support for specific urls
  34099. */
  34100. disableOfflineSupportExceptionRules: RegExp[];
  34101. /**
  34102. * An event triggered when the scene is disposed.
  34103. */
  34104. onDisposeObservable: Observable<Scene>;
  34105. private _onDisposeObserver;
  34106. /** Sets a function to be executed when this scene is disposed. */
  34107. onDispose: () => void;
  34108. /**
  34109. * An event triggered before rendering the scene (right after animations and physics)
  34110. */
  34111. onBeforeRenderObservable: Observable<Scene>;
  34112. private _onBeforeRenderObserver;
  34113. /** Sets a function to be executed before rendering this scene */
  34114. beforeRender: Nullable<() => void>;
  34115. /**
  34116. * An event triggered after rendering the scene
  34117. */
  34118. onAfterRenderObservable: Observable<Scene>;
  34119. /**
  34120. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34121. */
  34122. onAfterRenderCameraObservable: Observable<Camera>;
  34123. private _onAfterRenderObserver;
  34124. /** Sets a function to be executed after rendering this scene */
  34125. afterRender: Nullable<() => void>;
  34126. /**
  34127. * An event triggered before animating the scene
  34128. */
  34129. onBeforeAnimationsObservable: Observable<Scene>;
  34130. /**
  34131. * An event triggered after animations processing
  34132. */
  34133. onAfterAnimationsObservable: Observable<Scene>;
  34134. /**
  34135. * An event triggered before draw calls are ready to be sent
  34136. */
  34137. onBeforeDrawPhaseObservable: Observable<Scene>;
  34138. /**
  34139. * An event triggered after draw calls have been sent
  34140. */
  34141. onAfterDrawPhaseObservable: Observable<Scene>;
  34142. /**
  34143. * An event triggered when the scene is ready
  34144. */
  34145. onReadyObservable: Observable<Scene>;
  34146. /**
  34147. * An event triggered before rendering a camera
  34148. */
  34149. onBeforeCameraRenderObservable: Observable<Camera>;
  34150. private _onBeforeCameraRenderObserver;
  34151. /** Sets a function to be executed before rendering a camera*/
  34152. beforeCameraRender: () => void;
  34153. /**
  34154. * An event triggered after rendering a camera
  34155. */
  34156. onAfterCameraRenderObservable: Observable<Camera>;
  34157. private _onAfterCameraRenderObserver;
  34158. /** Sets a function to be executed after rendering a camera*/
  34159. afterCameraRender: () => void;
  34160. /**
  34161. * An event triggered when active meshes evaluation is about to start
  34162. */
  34163. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34164. /**
  34165. * An event triggered when active meshes evaluation is done
  34166. */
  34167. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34168. /**
  34169. * An event triggered when particles rendering is about to start
  34170. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34171. */
  34172. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34173. /**
  34174. * An event triggered when particles rendering is done
  34175. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34176. */
  34177. onAfterParticlesRenderingObservable: Observable<Scene>;
  34178. /**
  34179. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34180. */
  34181. onDataLoadedObservable: Observable<Scene>;
  34182. /**
  34183. * An event triggered when a camera is created
  34184. */
  34185. onNewCameraAddedObservable: Observable<Camera>;
  34186. /**
  34187. * An event triggered when a camera is removed
  34188. */
  34189. onCameraRemovedObservable: Observable<Camera>;
  34190. /**
  34191. * An event triggered when a light is created
  34192. */
  34193. onNewLightAddedObservable: Observable<Light>;
  34194. /**
  34195. * An event triggered when a light is removed
  34196. */
  34197. onLightRemovedObservable: Observable<Light>;
  34198. /**
  34199. * An event triggered when a geometry is created
  34200. */
  34201. onNewGeometryAddedObservable: Observable<Geometry>;
  34202. /**
  34203. * An event triggered when a geometry is removed
  34204. */
  34205. onGeometryRemovedObservable: Observable<Geometry>;
  34206. /**
  34207. * An event triggered when a transform node is created
  34208. */
  34209. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34210. /**
  34211. * An event triggered when a transform node is removed
  34212. */
  34213. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34214. /**
  34215. * An event triggered when a mesh is created
  34216. */
  34217. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34218. /**
  34219. * An event triggered when a mesh is removed
  34220. */
  34221. onMeshRemovedObservable: Observable<AbstractMesh>;
  34222. /**
  34223. * An event triggered when a skeleton is created
  34224. */
  34225. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34226. /**
  34227. * An event triggered when a skeleton is removed
  34228. */
  34229. onSkeletonRemovedObservable: Observable<Skeleton>;
  34230. /**
  34231. * An event triggered when a material is created
  34232. */
  34233. onNewMaterialAddedObservable: Observable<Material>;
  34234. /**
  34235. * An event triggered when a material is removed
  34236. */
  34237. onMaterialRemovedObservable: Observable<Material>;
  34238. /**
  34239. * An event triggered when a texture is created
  34240. */
  34241. onNewTextureAddedObservable: Observable<BaseTexture>;
  34242. /**
  34243. * An event triggered when a texture is removed
  34244. */
  34245. onTextureRemovedObservable: Observable<BaseTexture>;
  34246. /**
  34247. * An event triggered when render targets are about to be rendered
  34248. * Can happen multiple times per frame.
  34249. */
  34250. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34251. /**
  34252. * An event triggered when render targets were rendered.
  34253. * Can happen multiple times per frame.
  34254. */
  34255. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34256. /**
  34257. * An event triggered before calculating deterministic simulation step
  34258. */
  34259. onBeforeStepObservable: Observable<Scene>;
  34260. /**
  34261. * An event triggered after calculating deterministic simulation step
  34262. */
  34263. onAfterStepObservable: Observable<Scene>;
  34264. /**
  34265. * An event triggered when the activeCamera property is updated
  34266. */
  34267. onActiveCameraChanged: Observable<Scene>;
  34268. /**
  34269. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34270. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34271. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  34272. */
  34273. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34274. /**
  34275. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34276. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34277. * 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)
  34278. */
  34279. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34280. /**
  34281. * This Observable will when a mesh has been imported into the scene.
  34282. */
  34283. onMeshImportedObservable: Observable<AbstractMesh>;
  34284. /**
  34285. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34286. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34287. */
  34288. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34289. /** @hidden */
  34290. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34291. /**
  34292. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34293. */
  34294. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34295. /**
  34296. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34297. */
  34298. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34299. /**
  34300. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34301. */
  34302. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34303. /** Callback called when a pointer move is detected */
  34304. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34305. /** Callback called when a pointer down is detected */
  34306. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34307. /** Callback called when a pointer up is detected */
  34308. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34309. /** Callback called when a pointer pick is detected */
  34310. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34311. /**
  34312. * 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).
  34313. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34314. */
  34315. onPrePointerObservable: Observable<PointerInfoPre>;
  34316. /**
  34317. * Observable event triggered each time an input event is received from the rendering canvas
  34318. */
  34319. onPointerObservable: Observable<PointerInfo>;
  34320. /**
  34321. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34322. */
  34323. readonly unTranslatedPointer: Vector2;
  34324. /**
  34325. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34326. */
  34327. static DragMovementThreshold: number;
  34328. /**
  34329. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34330. */
  34331. static LongPressDelay: number;
  34332. /**
  34333. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34334. */
  34335. static DoubleClickDelay: number;
  34336. /** If you need to check double click without raising a single click at first click, enable this flag */
  34337. static ExclusiveDoubleClickMode: boolean;
  34338. /** @hidden */
  34339. _mirroredCameraPosition: Nullable<Vector3>;
  34340. /**
  34341. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34342. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34343. */
  34344. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34345. /**
  34346. * Observable event triggered each time an keyboard event is received from the hosting window
  34347. */
  34348. onKeyboardObservable: Observable<KeyboardInfo>;
  34349. private _useRightHandedSystem;
  34350. /**
  34351. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34352. */
  34353. useRightHandedSystem: boolean;
  34354. private _timeAccumulator;
  34355. private _currentStepId;
  34356. private _currentInternalStep;
  34357. /**
  34358. * Sets the step Id used by deterministic lock step
  34359. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34360. * @param newStepId defines the step Id
  34361. */
  34362. setStepId(newStepId: number): void;
  34363. /**
  34364. * Gets the step Id used by deterministic lock step
  34365. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34366. * @returns the step Id
  34367. */
  34368. getStepId(): number;
  34369. /**
  34370. * Gets the internal step used by deterministic lock step
  34371. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34372. * @returns the internal step
  34373. */
  34374. getInternalStep(): number;
  34375. private _fogEnabled;
  34376. /**
  34377. * Gets or sets a boolean indicating if fog is enabled on this scene
  34378. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34379. * (Default is true)
  34380. */
  34381. fogEnabled: boolean;
  34382. private _fogMode;
  34383. /**
  34384. * Gets or sets the fog mode to use
  34385. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34386. * | mode | value |
  34387. * | --- | --- |
  34388. * | FOGMODE_NONE | 0 |
  34389. * | FOGMODE_EXP | 1 |
  34390. * | FOGMODE_EXP2 | 2 |
  34391. * | FOGMODE_LINEAR | 3 |
  34392. */
  34393. fogMode: number;
  34394. /**
  34395. * Gets or sets the fog color to use
  34396. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34397. * (Default is Color3(0.2, 0.2, 0.3))
  34398. */
  34399. fogColor: Color3;
  34400. /**
  34401. * Gets or sets the fog density to use
  34402. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34403. * (Default is 0.1)
  34404. */
  34405. fogDensity: number;
  34406. /**
  34407. * Gets or sets the fog start distance to use
  34408. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34409. * (Default is 0)
  34410. */
  34411. fogStart: number;
  34412. /**
  34413. * Gets or sets the fog end distance to use
  34414. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34415. * (Default is 1000)
  34416. */
  34417. fogEnd: number;
  34418. private _shadowsEnabled;
  34419. /**
  34420. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34421. */
  34422. shadowsEnabled: boolean;
  34423. private _lightsEnabled;
  34424. /**
  34425. * Gets or sets a boolean indicating if lights are enabled on this scene
  34426. */
  34427. lightsEnabled: boolean;
  34428. /** All of the active cameras added to this scene. */
  34429. activeCameras: Camera[];
  34430. /** @hidden */
  34431. _activeCamera: Nullable<Camera>;
  34432. /** Gets or sets the current active camera */
  34433. activeCamera: Nullable<Camera>;
  34434. private _defaultMaterial;
  34435. /** The default material used on meshes when no material is affected */
  34436. /** The default material used on meshes when no material is affected */
  34437. defaultMaterial: Material;
  34438. private _texturesEnabled;
  34439. /**
  34440. * Gets or sets a boolean indicating if textures are enabled on this scene
  34441. */
  34442. texturesEnabled: boolean;
  34443. /**
  34444. * Gets or sets a boolean indicating if particles are enabled on this scene
  34445. */
  34446. particlesEnabled: boolean;
  34447. /**
  34448. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34449. */
  34450. spritesEnabled: boolean;
  34451. private _skeletonsEnabled;
  34452. /**
  34453. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34454. */
  34455. skeletonsEnabled: boolean;
  34456. /**
  34457. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34458. */
  34459. lensFlaresEnabled: boolean;
  34460. /**
  34461. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34462. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34463. */
  34464. collisionsEnabled: boolean;
  34465. private _collisionCoordinator;
  34466. /** @hidden */
  34467. readonly collisionCoordinator: ICollisionCoordinator;
  34468. /**
  34469. * Defines the gravity applied to this scene (used only for collisions)
  34470. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34471. */
  34472. gravity: Vector3;
  34473. /**
  34474. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34475. */
  34476. postProcessesEnabled: boolean;
  34477. /**
  34478. * The list of postprocesses added to the scene
  34479. */
  34480. postProcesses: PostProcess[];
  34481. /**
  34482. * Gets the current postprocess manager
  34483. */
  34484. postProcessManager: PostProcessManager;
  34485. /**
  34486. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34487. */
  34488. renderTargetsEnabled: boolean;
  34489. /**
  34490. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34491. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34492. */
  34493. dumpNextRenderTargets: boolean;
  34494. /**
  34495. * The list of user defined render targets added to the scene
  34496. */
  34497. customRenderTargets: RenderTargetTexture[];
  34498. /**
  34499. * Defines if texture loading must be delayed
  34500. * If true, textures will only be loaded when they need to be rendered
  34501. */
  34502. useDelayedTextureLoading: boolean;
  34503. /**
  34504. * Gets the list of meshes imported to the scene through SceneLoader
  34505. */
  34506. importedMeshesFiles: String[];
  34507. /**
  34508. * Gets or sets a boolean indicating if probes are enabled on this scene
  34509. */
  34510. probesEnabled: boolean;
  34511. /**
  34512. * Gets or sets the current offline provider to use to store scene data
  34513. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34514. */
  34515. offlineProvider: IOfflineProvider;
  34516. /**
  34517. * Gets or sets the action manager associated with the scene
  34518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34519. */
  34520. actionManager: AbstractActionManager;
  34521. private _meshesForIntersections;
  34522. /**
  34523. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34524. */
  34525. proceduralTexturesEnabled: boolean;
  34526. private _engine;
  34527. private _totalVertices;
  34528. /** @hidden */
  34529. _activeIndices: PerfCounter;
  34530. /** @hidden */
  34531. _activeParticles: PerfCounter;
  34532. /** @hidden */
  34533. _activeBones: PerfCounter;
  34534. private _animationRatio;
  34535. /** @hidden */
  34536. _animationTimeLast: number;
  34537. /** @hidden */
  34538. _animationTime: number;
  34539. /**
  34540. * Gets or sets a general scale for animation speed
  34541. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34542. */
  34543. animationTimeScale: number;
  34544. /** @hidden */
  34545. _cachedMaterial: Nullable<Material>;
  34546. /** @hidden */
  34547. _cachedEffect: Nullable<Effect>;
  34548. /** @hidden */
  34549. _cachedVisibility: Nullable<number>;
  34550. private _renderId;
  34551. private _frameId;
  34552. private _executeWhenReadyTimeoutId;
  34553. private _intermediateRendering;
  34554. private _viewUpdateFlag;
  34555. private _projectionUpdateFlag;
  34556. /** @hidden */
  34557. _toBeDisposed: Nullable<IDisposable>[];
  34558. private _activeRequests;
  34559. /** @hidden */
  34560. _pendingData: any[];
  34561. private _isDisposed;
  34562. /**
  34563. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34564. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34565. */
  34566. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34567. private _activeMeshes;
  34568. private _processedMaterials;
  34569. private _renderTargets;
  34570. /** @hidden */
  34571. _activeParticleSystems: SmartArray<IParticleSystem>;
  34572. private _activeSkeletons;
  34573. private _softwareSkinnedMeshes;
  34574. private _renderingManager;
  34575. /** @hidden */
  34576. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34577. private _transformMatrix;
  34578. private _sceneUbo;
  34579. /** @hidden */
  34580. _viewMatrix: Matrix;
  34581. private _projectionMatrix;
  34582. /** @hidden */
  34583. _forcedViewPosition: Nullable<Vector3>;
  34584. /** @hidden */
  34585. _frustumPlanes: Plane[];
  34586. /**
  34587. * Gets the list of frustum planes (built from the active camera)
  34588. */
  34589. readonly frustumPlanes: Plane[];
  34590. /**
  34591. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34592. * This is useful if there are more lights that the maximum simulteanous authorized
  34593. */
  34594. requireLightSorting: boolean;
  34595. /** @hidden */
  34596. readonly useMaterialMeshMap: boolean;
  34597. /** @hidden */
  34598. readonly useClonedMeshhMap: boolean;
  34599. private _externalData;
  34600. private _uid;
  34601. /**
  34602. * @hidden
  34603. * Backing store of defined scene components.
  34604. */
  34605. _components: ISceneComponent[];
  34606. /**
  34607. * @hidden
  34608. * Backing store of defined scene components.
  34609. */
  34610. _serializableComponents: ISceneSerializableComponent[];
  34611. /**
  34612. * List of components to register on the next registration step.
  34613. */
  34614. private _transientComponents;
  34615. /**
  34616. * Registers the transient components if needed.
  34617. */
  34618. private _registerTransientComponents;
  34619. /**
  34620. * @hidden
  34621. * Add a component to the scene.
  34622. * Note that the ccomponent could be registered on th next frame if this is called after
  34623. * the register component stage.
  34624. * @param component Defines the component to add to the scene
  34625. */
  34626. _addComponent(component: ISceneComponent): void;
  34627. /**
  34628. * @hidden
  34629. * Gets a component from the scene.
  34630. * @param name defines the name of the component to retrieve
  34631. * @returns the component or null if not present
  34632. */
  34633. _getComponent(name: string): Nullable<ISceneComponent>;
  34634. /**
  34635. * @hidden
  34636. * Defines the actions happening before camera updates.
  34637. */
  34638. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34639. /**
  34640. * @hidden
  34641. * Defines the actions happening before clear the canvas.
  34642. */
  34643. _beforeClearStage: Stage<SimpleStageAction>;
  34644. /**
  34645. * @hidden
  34646. * Defines the actions when collecting render targets for the frame.
  34647. */
  34648. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34649. /**
  34650. * @hidden
  34651. * Defines the actions happening for one camera in the frame.
  34652. */
  34653. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34654. /**
  34655. * @hidden
  34656. * Defines the actions happening during the per mesh ready checks.
  34657. */
  34658. _isReadyForMeshStage: Stage<MeshStageAction>;
  34659. /**
  34660. * @hidden
  34661. * Defines the actions happening before evaluate active mesh checks.
  34662. */
  34663. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34664. /**
  34665. * @hidden
  34666. * Defines the actions happening during the evaluate sub mesh checks.
  34667. */
  34668. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34669. /**
  34670. * @hidden
  34671. * Defines the actions happening during the active mesh stage.
  34672. */
  34673. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34674. /**
  34675. * @hidden
  34676. * Defines the actions happening during the per camera render target step.
  34677. */
  34678. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34679. /**
  34680. * @hidden
  34681. * Defines the actions happening just before the active camera is drawing.
  34682. */
  34683. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34684. /**
  34685. * @hidden
  34686. * Defines the actions happening just before a render target is drawing.
  34687. */
  34688. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34689. /**
  34690. * @hidden
  34691. * Defines the actions happening just before a rendering group is drawing.
  34692. */
  34693. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34694. /**
  34695. * @hidden
  34696. * Defines the actions happening just before a mesh is drawing.
  34697. */
  34698. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34699. /**
  34700. * @hidden
  34701. * Defines the actions happening just after a mesh has been drawn.
  34702. */
  34703. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34704. /**
  34705. * @hidden
  34706. * Defines the actions happening just after a rendering group has been drawn.
  34707. */
  34708. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34709. /**
  34710. * @hidden
  34711. * Defines the actions happening just after the active camera has been drawn.
  34712. */
  34713. _afterCameraDrawStage: Stage<CameraStageAction>;
  34714. /**
  34715. * @hidden
  34716. * Defines the actions happening just after a render target has been drawn.
  34717. */
  34718. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34719. /**
  34720. * @hidden
  34721. * Defines the actions happening just after rendering all cameras and computing intersections.
  34722. */
  34723. _afterRenderStage: Stage<SimpleStageAction>;
  34724. /**
  34725. * @hidden
  34726. * Defines the actions happening when a pointer move event happens.
  34727. */
  34728. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34729. /**
  34730. * @hidden
  34731. * Defines the actions happening when a pointer down event happens.
  34732. */
  34733. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34734. /**
  34735. * @hidden
  34736. * Defines the actions happening when a pointer up event happens.
  34737. */
  34738. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34739. /**
  34740. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34741. */
  34742. private geometriesByUniqueId;
  34743. /**
  34744. * Creates a new Scene
  34745. * @param engine defines the engine to use to render this scene
  34746. * @param options defines the scene options
  34747. */
  34748. constructor(engine: Engine, options?: SceneOptions);
  34749. /**
  34750. * Gets a string idenfifying the name of the class
  34751. * @returns "Scene" string
  34752. */
  34753. getClassName(): string;
  34754. private _defaultMeshCandidates;
  34755. /**
  34756. * @hidden
  34757. */
  34758. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34759. private _defaultSubMeshCandidates;
  34760. /**
  34761. * @hidden
  34762. */
  34763. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34764. /**
  34765. * Sets the default candidate providers for the scene.
  34766. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34767. * and getCollidingSubMeshCandidates to their default function
  34768. */
  34769. setDefaultCandidateProviders(): void;
  34770. /**
  34771. * Gets the mesh that is currently under the pointer
  34772. */
  34773. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34774. /**
  34775. * Gets or sets the current on-screen X position of the pointer
  34776. */
  34777. pointerX: number;
  34778. /**
  34779. * Gets or sets the current on-screen Y position of the pointer
  34780. */
  34781. pointerY: number;
  34782. /**
  34783. * Gets the cached material (ie. the latest rendered one)
  34784. * @returns the cached material
  34785. */
  34786. getCachedMaterial(): Nullable<Material>;
  34787. /**
  34788. * Gets the cached effect (ie. the latest rendered one)
  34789. * @returns the cached effect
  34790. */
  34791. getCachedEffect(): Nullable<Effect>;
  34792. /**
  34793. * Gets the cached visibility state (ie. the latest rendered one)
  34794. * @returns the cached visibility state
  34795. */
  34796. getCachedVisibility(): Nullable<number>;
  34797. /**
  34798. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34799. * @param material defines the current material
  34800. * @param effect defines the current effect
  34801. * @param visibility defines the current visibility state
  34802. * @returns true if one parameter is not cached
  34803. */
  34804. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34805. /**
  34806. * Gets the engine associated with the scene
  34807. * @returns an Engine
  34808. */
  34809. getEngine(): Engine;
  34810. /**
  34811. * Gets the total number of vertices rendered per frame
  34812. * @returns the total number of vertices rendered per frame
  34813. */
  34814. getTotalVertices(): number;
  34815. /**
  34816. * Gets the performance counter for total vertices
  34817. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34818. */
  34819. readonly totalVerticesPerfCounter: PerfCounter;
  34820. /**
  34821. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34822. * @returns the total number of active indices rendered per frame
  34823. */
  34824. getActiveIndices(): number;
  34825. /**
  34826. * Gets the performance counter for active indices
  34827. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34828. */
  34829. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34830. /**
  34831. * Gets the total number of active particles rendered per frame
  34832. * @returns the total number of active particles rendered per frame
  34833. */
  34834. getActiveParticles(): number;
  34835. /**
  34836. * Gets the performance counter for active particles
  34837. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34838. */
  34839. readonly activeParticlesPerfCounter: PerfCounter;
  34840. /**
  34841. * Gets the total number of active bones rendered per frame
  34842. * @returns the total number of active bones rendered per frame
  34843. */
  34844. getActiveBones(): number;
  34845. /**
  34846. * Gets the performance counter for active bones
  34847. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34848. */
  34849. readonly activeBonesPerfCounter: PerfCounter;
  34850. /**
  34851. * Gets the array of active meshes
  34852. * @returns an array of AbstractMesh
  34853. */
  34854. getActiveMeshes(): SmartArray<AbstractMesh>;
  34855. /**
  34856. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34857. * @returns a number
  34858. */
  34859. getAnimationRatio(): number;
  34860. /**
  34861. * Gets an unique Id for the current render phase
  34862. * @returns a number
  34863. */
  34864. getRenderId(): number;
  34865. /**
  34866. * Gets an unique Id for the current frame
  34867. * @returns a number
  34868. */
  34869. getFrameId(): number;
  34870. /** Call this function if you want to manually increment the render Id*/
  34871. incrementRenderId(): void;
  34872. private _createUbo;
  34873. /**
  34874. * Use this method to simulate a pointer move on a mesh
  34875. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34876. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34877. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34878. * @returns the current scene
  34879. */
  34880. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34881. /**
  34882. * Use this method to simulate a pointer down on a mesh
  34883. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34884. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34885. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34886. * @returns the current scene
  34887. */
  34888. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34889. /**
  34890. * Use this method to simulate a pointer up on a mesh
  34891. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34892. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34893. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34894. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34895. * @returns the current scene
  34896. */
  34897. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34898. /**
  34899. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34900. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34901. * @returns true if the pointer was captured
  34902. */
  34903. isPointerCaptured(pointerId?: number): boolean;
  34904. /**
  34905. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34906. * @param attachUp defines if you want to attach events to pointerup
  34907. * @param attachDown defines if you want to attach events to pointerdown
  34908. * @param attachMove defines if you want to attach events to pointermove
  34909. */
  34910. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  34911. /** Detaches all event handlers*/
  34912. detachControl(): void;
  34913. /**
  34914. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  34915. * Delay loaded resources are not taking in account
  34916. * @return true if all required resources are ready
  34917. */
  34918. isReady(): boolean;
  34919. /** Resets all cached information relative to material (including effect and visibility) */
  34920. resetCachedMaterial(): void;
  34921. /**
  34922. * Registers a function to be called before every frame render
  34923. * @param func defines the function to register
  34924. */
  34925. registerBeforeRender(func: () => void): void;
  34926. /**
  34927. * Unregisters a function called before every frame render
  34928. * @param func defines the function to unregister
  34929. */
  34930. unregisterBeforeRender(func: () => void): void;
  34931. /**
  34932. * Registers a function to be called after every frame render
  34933. * @param func defines the function to register
  34934. */
  34935. registerAfterRender(func: () => void): void;
  34936. /**
  34937. * Unregisters a function called after every frame render
  34938. * @param func defines the function to unregister
  34939. */
  34940. unregisterAfterRender(func: () => void): void;
  34941. private _executeOnceBeforeRender;
  34942. /**
  34943. * The provided function will run before render once and will be disposed afterwards.
  34944. * A timeout delay can be provided so that the function will be executed in N ms.
  34945. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  34946. * @param func The function to be executed.
  34947. * @param timeout optional delay in ms
  34948. */
  34949. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  34950. /** @hidden */
  34951. _addPendingData(data: any): void;
  34952. /** @hidden */
  34953. _removePendingData(data: any): void;
  34954. /**
  34955. * Returns the number of items waiting to be loaded
  34956. * @returns the number of items waiting to be loaded
  34957. */
  34958. getWaitingItemsCount(): number;
  34959. /**
  34960. * Returns a boolean indicating if the scene is still loading data
  34961. */
  34962. readonly isLoading: boolean;
  34963. /**
  34964. * Registers a function to be executed when the scene is ready
  34965. * @param {Function} func - the function to be executed
  34966. */
  34967. executeWhenReady(func: () => void): void;
  34968. /**
  34969. * Returns a promise that resolves when the scene is ready
  34970. * @returns A promise that resolves when the scene is ready
  34971. */
  34972. whenReadyAsync(): Promise<void>;
  34973. /** @hidden */
  34974. _checkIsReady(): void;
  34975. /**
  34976. * Gets all animatable attached to the scene
  34977. */
  34978. readonly animatables: Animatable[];
  34979. /**
  34980. * Resets the last animation time frame.
  34981. * Useful to override when animations start running when loading a scene for the first time.
  34982. */
  34983. resetLastAnimationTimeFrame(): void;
  34984. /**
  34985. * Gets the current view matrix
  34986. * @returns a Matrix
  34987. */
  34988. getViewMatrix(): Matrix;
  34989. /**
  34990. * Gets the current projection matrix
  34991. * @returns a Matrix
  34992. */
  34993. getProjectionMatrix(): Matrix;
  34994. /**
  34995. * Gets the current transform matrix
  34996. * @returns a Matrix made of View * Projection
  34997. */
  34998. getTransformMatrix(): Matrix;
  34999. /**
  35000. * Sets the current transform matrix
  35001. * @param viewL defines the View matrix to use
  35002. * @param projectionL defines the Projection matrix to use
  35003. * @param viewR defines the right View matrix to use (if provided)
  35004. * @param projectionR defines the right Projection matrix to use (if provided)
  35005. */
  35006. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35007. /**
  35008. * Gets the uniform buffer used to store scene data
  35009. * @returns a UniformBuffer
  35010. */
  35011. getSceneUniformBuffer(): UniformBuffer;
  35012. /**
  35013. * Gets an unique (relatively to the current scene) Id
  35014. * @returns an unique number for the scene
  35015. */
  35016. getUniqueId(): number;
  35017. /**
  35018. * Add a mesh to the list of scene's meshes
  35019. * @param newMesh defines the mesh to add
  35020. * @param recursive if all child meshes should also be added to the scene
  35021. */
  35022. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35023. /**
  35024. * Remove a mesh for the list of scene's meshes
  35025. * @param toRemove defines the mesh to remove
  35026. * @param recursive if all child meshes should also be removed from the scene
  35027. * @returns the index where the mesh was in the mesh list
  35028. */
  35029. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35030. /**
  35031. * Add a transform node to the list of scene's transform nodes
  35032. * @param newTransformNode defines the transform node to add
  35033. */
  35034. addTransformNode(newTransformNode: TransformNode): void;
  35035. /**
  35036. * Remove a transform node for the list of scene's transform nodes
  35037. * @param toRemove defines the transform node to remove
  35038. * @returns the index where the transform node was in the transform node list
  35039. */
  35040. removeTransformNode(toRemove: TransformNode): number;
  35041. /**
  35042. * Remove a skeleton for the list of scene's skeletons
  35043. * @param toRemove defines the skeleton to remove
  35044. * @returns the index where the skeleton was in the skeleton list
  35045. */
  35046. removeSkeleton(toRemove: Skeleton): number;
  35047. /**
  35048. * Remove a morph target for the list of scene's morph targets
  35049. * @param toRemove defines the morph target to remove
  35050. * @returns the index where the morph target was in the morph target list
  35051. */
  35052. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35053. /**
  35054. * Remove a light for the list of scene's lights
  35055. * @param toRemove defines the light to remove
  35056. * @returns the index where the light was in the light list
  35057. */
  35058. removeLight(toRemove: Light): number;
  35059. /**
  35060. * Remove a camera for the list of scene's cameras
  35061. * @param toRemove defines the camera to remove
  35062. * @returns the index where the camera was in the camera list
  35063. */
  35064. removeCamera(toRemove: Camera): number;
  35065. /**
  35066. * Remove a particle system for the list of scene's particle systems
  35067. * @param toRemove defines the particle system to remove
  35068. * @returns the index where the particle system was in the particle system list
  35069. */
  35070. removeParticleSystem(toRemove: IParticleSystem): number;
  35071. /**
  35072. * Remove a animation for the list of scene's animations
  35073. * @param toRemove defines the animation to remove
  35074. * @returns the index where the animation was in the animation list
  35075. */
  35076. removeAnimation(toRemove: Animation): number;
  35077. /**
  35078. * Will stop the animation of the given target
  35079. * @param target - the target
  35080. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35081. * @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)
  35082. */
  35083. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35084. /**
  35085. * Removes the given animation group from this scene.
  35086. * @param toRemove The animation group to remove
  35087. * @returns The index of the removed animation group
  35088. */
  35089. removeAnimationGroup(toRemove: AnimationGroup): number;
  35090. /**
  35091. * Removes the given multi-material from this scene.
  35092. * @param toRemove The multi-material to remove
  35093. * @returns The index of the removed multi-material
  35094. */
  35095. removeMultiMaterial(toRemove: MultiMaterial): number;
  35096. /**
  35097. * Removes the given material from this scene.
  35098. * @param toRemove The material to remove
  35099. * @returns The index of the removed material
  35100. */
  35101. removeMaterial(toRemove: Material): number;
  35102. /**
  35103. * Removes the given action manager from this scene.
  35104. * @param toRemove The action manager to remove
  35105. * @returns The index of the removed action manager
  35106. */
  35107. removeActionManager(toRemove: AbstractActionManager): number;
  35108. /**
  35109. * Removes the given texture from this scene.
  35110. * @param toRemove The texture to remove
  35111. * @returns The index of the removed texture
  35112. */
  35113. removeTexture(toRemove: BaseTexture): number;
  35114. /**
  35115. * Adds the given light to this scene
  35116. * @param newLight The light to add
  35117. */
  35118. addLight(newLight: Light): void;
  35119. /**
  35120. * Sorts the list list based on light priorities
  35121. */
  35122. sortLightsByPriority(): void;
  35123. /**
  35124. * Adds the given camera to this scene
  35125. * @param newCamera The camera to add
  35126. */
  35127. addCamera(newCamera: Camera): void;
  35128. /**
  35129. * Adds the given skeleton to this scene
  35130. * @param newSkeleton The skeleton to add
  35131. */
  35132. addSkeleton(newSkeleton: Skeleton): void;
  35133. /**
  35134. * Adds the given particle system to this scene
  35135. * @param newParticleSystem The particle system to add
  35136. */
  35137. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35138. /**
  35139. * Adds the given animation to this scene
  35140. * @param newAnimation The animation to add
  35141. */
  35142. addAnimation(newAnimation: Animation): void;
  35143. /**
  35144. * Adds the given animation group to this scene.
  35145. * @param newAnimationGroup The animation group to add
  35146. */
  35147. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35148. /**
  35149. * Adds the given multi-material to this scene
  35150. * @param newMultiMaterial The multi-material to add
  35151. */
  35152. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35153. /**
  35154. * Adds the given material to this scene
  35155. * @param newMaterial The material to add
  35156. */
  35157. addMaterial(newMaterial: Material): void;
  35158. /**
  35159. * Adds the given morph target to this scene
  35160. * @param newMorphTargetManager The morph target to add
  35161. */
  35162. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35163. /**
  35164. * Adds the given geometry to this scene
  35165. * @param newGeometry The geometry to add
  35166. */
  35167. addGeometry(newGeometry: Geometry): void;
  35168. /**
  35169. * Adds the given action manager to this scene
  35170. * @param newActionManager The action manager to add
  35171. */
  35172. addActionManager(newActionManager: AbstractActionManager): void;
  35173. /**
  35174. * Adds the given texture to this scene.
  35175. * @param newTexture The texture to add
  35176. */
  35177. addTexture(newTexture: BaseTexture): void;
  35178. /**
  35179. * Switch active camera
  35180. * @param newCamera defines the new active camera
  35181. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35182. */
  35183. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35184. /**
  35185. * sets the active camera of the scene using its ID
  35186. * @param id defines the camera's ID
  35187. * @return the new active camera or null if none found.
  35188. */
  35189. setActiveCameraByID(id: string): Nullable<Camera>;
  35190. /**
  35191. * sets the active camera of the scene using its name
  35192. * @param name defines the camera's name
  35193. * @returns the new active camera or null if none found.
  35194. */
  35195. setActiveCameraByName(name: string): Nullable<Camera>;
  35196. /**
  35197. * get an animation group using its name
  35198. * @param name defines the material's name
  35199. * @return the animation group or null if none found.
  35200. */
  35201. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35202. /**
  35203. * Get a material using its unique id
  35204. * @param uniqueId defines the material's unique id
  35205. * @return the material or null if none found.
  35206. */
  35207. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35208. /**
  35209. * get a material using its id
  35210. * @param id defines the material's ID
  35211. * @return the material or null if none found.
  35212. */
  35213. getMaterialByID(id: string): Nullable<Material>;
  35214. /**
  35215. * Gets a the last added material using a given id
  35216. * @param id defines the material's ID
  35217. * @return the last material with the given id or null if none found.
  35218. */
  35219. getLastMaterialByID(id: string): Nullable<Material>;
  35220. /**
  35221. * Gets a material using its name
  35222. * @param name defines the material's name
  35223. * @return the material or null if none found.
  35224. */
  35225. getMaterialByName(name: string): Nullable<Material>;
  35226. /**
  35227. * Get a texture using its unique id
  35228. * @param uniqueId defines the texture's unique id
  35229. * @return the texture or null if none found.
  35230. */
  35231. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35232. /**
  35233. * Gets a camera using its id
  35234. * @param id defines the id to look for
  35235. * @returns the camera or null if not found
  35236. */
  35237. getCameraByID(id: string): Nullable<Camera>;
  35238. /**
  35239. * Gets a camera using its unique id
  35240. * @param uniqueId defines the unique id to look for
  35241. * @returns the camera or null if not found
  35242. */
  35243. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35244. /**
  35245. * Gets a camera using its name
  35246. * @param name defines the camera's name
  35247. * @return the camera or null if none found.
  35248. */
  35249. getCameraByName(name: string): Nullable<Camera>;
  35250. /**
  35251. * Gets a bone using its id
  35252. * @param id defines the bone's id
  35253. * @return the bone or null if not found
  35254. */
  35255. getBoneByID(id: string): Nullable<Bone>;
  35256. /**
  35257. * Gets a bone using its id
  35258. * @param name defines the bone's name
  35259. * @return the bone or null if not found
  35260. */
  35261. getBoneByName(name: string): Nullable<Bone>;
  35262. /**
  35263. * Gets a light node using its name
  35264. * @param name defines the the light's name
  35265. * @return the light or null if none found.
  35266. */
  35267. getLightByName(name: string): Nullable<Light>;
  35268. /**
  35269. * Gets a light node using its id
  35270. * @param id defines the light's id
  35271. * @return the light or null if none found.
  35272. */
  35273. getLightByID(id: string): Nullable<Light>;
  35274. /**
  35275. * Gets a light node using its scene-generated unique ID
  35276. * @param uniqueId defines the light's unique id
  35277. * @return the light or null if none found.
  35278. */
  35279. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35280. /**
  35281. * Gets a particle system by id
  35282. * @param id defines the particle system id
  35283. * @return the corresponding system or null if none found
  35284. */
  35285. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35286. /**
  35287. * Gets a geometry using its ID
  35288. * @param id defines the geometry's id
  35289. * @return the geometry or null if none found.
  35290. */
  35291. getGeometryByID(id: string): Nullable<Geometry>;
  35292. private _getGeometryByUniqueID;
  35293. /**
  35294. * Add a new geometry to this scene
  35295. * @param geometry defines the geometry to be added to the scene.
  35296. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35297. * @return a boolean defining if the geometry was added or not
  35298. */
  35299. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35300. /**
  35301. * Removes an existing geometry
  35302. * @param geometry defines the geometry to be removed from the scene
  35303. * @return a boolean defining if the geometry was removed or not
  35304. */
  35305. removeGeometry(geometry: Geometry): boolean;
  35306. /**
  35307. * Gets the list of geometries attached to the scene
  35308. * @returns an array of Geometry
  35309. */
  35310. getGeometries(): Geometry[];
  35311. /**
  35312. * Gets the first added mesh found of a given ID
  35313. * @param id defines the id to search for
  35314. * @return the mesh found or null if not found at all
  35315. */
  35316. getMeshByID(id: string): Nullable<AbstractMesh>;
  35317. /**
  35318. * Gets a list of meshes using their id
  35319. * @param id defines the id to search for
  35320. * @returns a list of meshes
  35321. */
  35322. getMeshesByID(id: string): Array<AbstractMesh>;
  35323. /**
  35324. * Gets the first added transform node found of a given ID
  35325. * @param id defines the id to search for
  35326. * @return the found transform node or null if not found at all.
  35327. */
  35328. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35329. /**
  35330. * Gets a transform node with its auto-generated unique id
  35331. * @param uniqueId efines the unique id to search for
  35332. * @return the found transform node or null if not found at all.
  35333. */
  35334. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35335. /**
  35336. * Gets a list of transform nodes using their id
  35337. * @param id defines the id to search for
  35338. * @returns a list of transform nodes
  35339. */
  35340. getTransformNodesByID(id: string): Array<TransformNode>;
  35341. /**
  35342. * Gets a mesh with its auto-generated unique id
  35343. * @param uniqueId defines the unique id to search for
  35344. * @return the found mesh or null if not found at all.
  35345. */
  35346. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35347. /**
  35348. * Gets a the last added mesh using a given id
  35349. * @param id defines the id to search for
  35350. * @return the found mesh or null if not found at all.
  35351. */
  35352. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35353. /**
  35354. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35355. * @param id defines the id to search for
  35356. * @return the found node or null if not found at all
  35357. */
  35358. getLastEntryByID(id: string): Nullable<Node>;
  35359. /**
  35360. * Gets a node (Mesh, Camera, Light) using a given id
  35361. * @param id defines the id to search for
  35362. * @return the found node or null if not found at all
  35363. */
  35364. getNodeByID(id: string): Nullable<Node>;
  35365. /**
  35366. * Gets a node (Mesh, Camera, Light) using a given name
  35367. * @param name defines the name to search for
  35368. * @return the found node or null if not found at all.
  35369. */
  35370. getNodeByName(name: string): Nullable<Node>;
  35371. /**
  35372. * Gets a mesh using a given name
  35373. * @param name defines the name to search for
  35374. * @return the found mesh or null if not found at all.
  35375. */
  35376. getMeshByName(name: string): Nullable<AbstractMesh>;
  35377. /**
  35378. * Gets a transform node using a given name
  35379. * @param name defines the name to search for
  35380. * @return the found transform node or null if not found at all.
  35381. */
  35382. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35383. /**
  35384. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35385. * @param id defines the id to search for
  35386. * @return the found skeleton or null if not found at all.
  35387. */
  35388. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35389. /**
  35390. * Gets a skeleton using a given auto generated unique id
  35391. * @param uniqueId defines the unique id to search for
  35392. * @return the found skeleton or null if not found at all.
  35393. */
  35394. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35395. /**
  35396. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35397. * @param id defines the id to search for
  35398. * @return the found skeleton or null if not found at all.
  35399. */
  35400. getSkeletonById(id: string): Nullable<Skeleton>;
  35401. /**
  35402. * Gets a skeleton using a given name
  35403. * @param name defines the name to search for
  35404. * @return the found skeleton or null if not found at all.
  35405. */
  35406. getSkeletonByName(name: string): Nullable<Skeleton>;
  35407. /**
  35408. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35409. * @param id defines the id to search for
  35410. * @return the found morph target manager or null if not found at all.
  35411. */
  35412. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35413. /**
  35414. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35415. * @param id defines the id to search for
  35416. * @return the found morph target or null if not found at all.
  35417. */
  35418. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35419. /**
  35420. * Gets a boolean indicating if the given mesh is active
  35421. * @param mesh defines the mesh to look for
  35422. * @returns true if the mesh is in the active list
  35423. */
  35424. isActiveMesh(mesh: AbstractMesh): boolean;
  35425. /**
  35426. * Return a unique id as a string which can serve as an identifier for the scene
  35427. */
  35428. readonly uid: string;
  35429. /**
  35430. * Add an externaly attached data from its key.
  35431. * This method call will fail and return false, if such key already exists.
  35432. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35433. * @param key the unique key that identifies the data
  35434. * @param data the data object to associate to the key for this Engine instance
  35435. * @return true if no such key were already present and the data was added successfully, false otherwise
  35436. */
  35437. addExternalData<T>(key: string, data: T): boolean;
  35438. /**
  35439. * Get an externaly attached data from its key
  35440. * @param key the unique key that identifies the data
  35441. * @return the associated data, if present (can be null), or undefined if not present
  35442. */
  35443. getExternalData<T>(key: string): Nullable<T>;
  35444. /**
  35445. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35446. * @param key the unique key that identifies the data
  35447. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35448. * @return the associated data, can be null if the factory returned null.
  35449. */
  35450. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35451. /**
  35452. * Remove an externaly attached data from the Engine instance
  35453. * @param key the unique key that identifies the data
  35454. * @return true if the data was successfully removed, false if it doesn't exist
  35455. */
  35456. removeExternalData(key: string): boolean;
  35457. private _evaluateSubMesh;
  35458. /**
  35459. * Clear the processed materials smart array preventing retention point in material dispose.
  35460. */
  35461. freeProcessedMaterials(): void;
  35462. private _preventFreeActiveMeshesAndRenderingGroups;
  35463. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35464. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35465. * when disposing several meshes in a row or a hierarchy of meshes.
  35466. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35467. */
  35468. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35469. /**
  35470. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35471. */
  35472. freeActiveMeshes(): void;
  35473. /**
  35474. * Clear the info related to rendering groups preventing retention points during dispose.
  35475. */
  35476. freeRenderingGroups(): void;
  35477. /** @hidden */
  35478. _isInIntermediateRendering(): boolean;
  35479. /**
  35480. * Lambda returning the list of potentially active meshes.
  35481. */
  35482. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35483. /**
  35484. * Lambda returning the list of potentially active sub meshes.
  35485. */
  35486. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35487. /**
  35488. * Lambda returning the list of potentially intersecting sub meshes.
  35489. */
  35490. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35491. /**
  35492. * Lambda returning the list of potentially colliding sub meshes.
  35493. */
  35494. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35495. private _activeMeshesFrozen;
  35496. /**
  35497. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35498. * @returns the current scene
  35499. */
  35500. freezeActiveMeshes(): Scene;
  35501. /**
  35502. * Use this function to restart evaluating active meshes on every frame
  35503. * @returns the current scene
  35504. */
  35505. unfreezeActiveMeshes(): Scene;
  35506. private _evaluateActiveMeshes;
  35507. private _activeMesh;
  35508. /**
  35509. * Update the transform matrix to update from the current active camera
  35510. * @param force defines a boolean used to force the update even if cache is up to date
  35511. */
  35512. updateTransformMatrix(force?: boolean): void;
  35513. private _bindFrameBuffer;
  35514. /** @hidden */
  35515. _allowPostProcessClearColor: boolean;
  35516. /** @hidden */
  35517. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35518. private _processSubCameras;
  35519. private _checkIntersections;
  35520. /** @hidden */
  35521. _advancePhysicsEngineStep(step: number): void;
  35522. /**
  35523. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35524. */
  35525. getDeterministicFrameTime: () => number;
  35526. /** @hidden */
  35527. _animate(): void;
  35528. /** Execute all animations (for a frame) */
  35529. animate(): void;
  35530. /**
  35531. * Render the scene
  35532. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35533. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35534. */
  35535. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35536. /**
  35537. * Freeze all materials
  35538. * A frozen material will not be updatable but should be faster to render
  35539. */
  35540. freezeMaterials(): void;
  35541. /**
  35542. * Unfreeze all materials
  35543. * A frozen material will not be updatable but should be faster to render
  35544. */
  35545. unfreezeMaterials(): void;
  35546. /**
  35547. * Releases all held ressources
  35548. */
  35549. dispose(): void;
  35550. /**
  35551. * Gets if the scene is already disposed
  35552. */
  35553. readonly isDisposed: boolean;
  35554. /**
  35555. * Call this function to reduce memory footprint of the scene.
  35556. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35557. */
  35558. clearCachedVertexData(): void;
  35559. /**
  35560. * This function will remove the local cached buffer data from texture.
  35561. * It will save memory but will prevent the texture from being rebuilt
  35562. */
  35563. cleanCachedTextureBuffer(): void;
  35564. /**
  35565. * Get the world extend vectors with an optional filter
  35566. *
  35567. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35568. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35569. */
  35570. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35571. min: Vector3;
  35572. max: Vector3;
  35573. };
  35574. /**
  35575. * Creates a ray that can be used to pick in the scene
  35576. * @param x defines the x coordinate of the origin (on-screen)
  35577. * @param y defines the y coordinate of the origin (on-screen)
  35578. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35579. * @param camera defines the camera to use for the picking
  35580. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35581. * @returns a Ray
  35582. */
  35583. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35584. /**
  35585. * Creates a ray that can be used to pick in the scene
  35586. * @param x defines the x coordinate of the origin (on-screen)
  35587. * @param y defines the y coordinate of the origin (on-screen)
  35588. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35589. * @param result defines the ray where to store the picking ray
  35590. * @param camera defines the camera to use for the picking
  35591. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35592. * @returns the current scene
  35593. */
  35594. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35595. /**
  35596. * Creates a ray that can be used to pick in the scene
  35597. * @param x defines the x coordinate of the origin (on-screen)
  35598. * @param y defines the y coordinate of the origin (on-screen)
  35599. * @param camera defines the camera to use for the picking
  35600. * @returns a Ray
  35601. */
  35602. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35603. /**
  35604. * Creates a ray that can be used to pick in the scene
  35605. * @param x defines the x coordinate of the origin (on-screen)
  35606. * @param y defines the y coordinate of the origin (on-screen)
  35607. * @param result defines the ray where to store the picking ray
  35608. * @param camera defines the camera to use for the picking
  35609. * @returns the current scene
  35610. */
  35611. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35612. /** Launch a ray to try to pick a mesh in the scene
  35613. * @param x position on screen
  35614. * @param y position on screen
  35615. * @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
  35616. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35617. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35618. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35619. * @returns a PickingInfo
  35620. */
  35621. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35622. /** Use the given ray to pick a mesh in the scene
  35623. * @param ray The ray to use to pick meshes
  35624. * @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
  35625. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35626. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35627. * @returns a PickingInfo
  35628. */
  35629. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35630. /**
  35631. * Launch a ray to try to pick a mesh in the scene
  35632. * @param x X position on screen
  35633. * @param y Y position on screen
  35634. * @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
  35635. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35636. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35637. * @returns an array of PickingInfo
  35638. */
  35639. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35640. /**
  35641. * Launch a ray to try to pick a mesh in the scene
  35642. * @param ray Ray to use
  35643. * @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
  35644. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35645. * @returns an array of PickingInfo
  35646. */
  35647. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35648. /**
  35649. * Force the value of meshUnderPointer
  35650. * @param mesh defines the mesh to use
  35651. */
  35652. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35653. /**
  35654. * Gets the mesh under the pointer
  35655. * @returns a Mesh or null if no mesh is under the pointer
  35656. */
  35657. getPointerOverMesh(): Nullable<AbstractMesh>;
  35658. /** @hidden */
  35659. _rebuildGeometries(): void;
  35660. /** @hidden */
  35661. _rebuildTextures(): void;
  35662. private _getByTags;
  35663. /**
  35664. * Get a list of meshes by tags
  35665. * @param tagsQuery defines the tags query to use
  35666. * @param forEach defines a predicate used to filter results
  35667. * @returns an array of Mesh
  35668. */
  35669. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35670. /**
  35671. * Get a list of cameras by tags
  35672. * @param tagsQuery defines the tags query to use
  35673. * @param forEach defines a predicate used to filter results
  35674. * @returns an array of Camera
  35675. */
  35676. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35677. /**
  35678. * Get a list of lights by tags
  35679. * @param tagsQuery defines the tags query to use
  35680. * @param forEach defines a predicate used to filter results
  35681. * @returns an array of Light
  35682. */
  35683. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35684. /**
  35685. * Get a list of materials by tags
  35686. * @param tagsQuery defines the tags query to use
  35687. * @param forEach defines a predicate used to filter results
  35688. * @returns an array of Material
  35689. */
  35690. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35691. /**
  35692. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35693. * This allowed control for front to back rendering or reversly depending of the special needs.
  35694. *
  35695. * @param renderingGroupId The rendering group id corresponding to its index
  35696. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35697. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35698. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35699. */
  35700. 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;
  35701. /**
  35702. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35703. *
  35704. * @param renderingGroupId The rendering group id corresponding to its index
  35705. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35706. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35707. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35708. */
  35709. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35710. /**
  35711. * Gets the current auto clear configuration for one rendering group of the rendering
  35712. * manager.
  35713. * @param index the rendering group index to get the information for
  35714. * @returns The auto clear setup for the requested rendering group
  35715. */
  35716. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35717. private _blockMaterialDirtyMechanism;
  35718. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35719. blockMaterialDirtyMechanism: boolean;
  35720. /**
  35721. * Will flag all materials as dirty to trigger new shader compilation
  35722. * @param flag defines the flag used to specify which material part must be marked as dirty
  35723. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35724. */
  35725. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35726. /** @hidden */
  35727. _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;
  35728. /** @hidden */
  35729. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35730. }
  35731. }
  35732. declare module "babylonjs/assetContainer" {
  35733. import { AbstractScene } from "babylonjs/abstractScene";
  35734. import { Scene } from "babylonjs/scene";
  35735. import { Mesh } from "babylonjs/Meshes/mesh";
  35736. /**
  35737. * Set of assets to keep when moving a scene into an asset container.
  35738. */
  35739. export class KeepAssets extends AbstractScene {
  35740. }
  35741. /**
  35742. * Container with a set of assets that can be added or removed from a scene.
  35743. */
  35744. export class AssetContainer extends AbstractScene {
  35745. /**
  35746. * The scene the AssetContainer belongs to.
  35747. */
  35748. scene: Scene;
  35749. /**
  35750. * Instantiates an AssetContainer.
  35751. * @param scene The scene the AssetContainer belongs to.
  35752. */
  35753. constructor(scene: Scene);
  35754. /**
  35755. * Adds all the assets from the container to the scene.
  35756. */
  35757. addAllToScene(): void;
  35758. /**
  35759. * Removes all the assets in the container from the scene
  35760. */
  35761. removeAllFromScene(): void;
  35762. /**
  35763. * Disposes all the assets in the container
  35764. */
  35765. dispose(): void;
  35766. private _moveAssets;
  35767. /**
  35768. * Removes all the assets contained in the scene and adds them to the container.
  35769. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35770. */
  35771. moveAllFromScene(keepAssets?: KeepAssets): void;
  35772. /**
  35773. * 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.
  35774. * @returns the root mesh
  35775. */
  35776. createRootMesh(): Mesh;
  35777. }
  35778. }
  35779. declare module "babylonjs/abstractScene" {
  35780. import { Scene } from "babylonjs/scene";
  35781. import { Nullable } from "babylonjs/types";
  35782. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35783. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35784. import { Geometry } from "babylonjs/Meshes/geometry";
  35785. import { Skeleton } from "babylonjs/Bones/skeleton";
  35786. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35787. import { AssetContainer } from "babylonjs/assetContainer";
  35788. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35789. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35790. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35791. import { Material } from "babylonjs/Materials/material";
  35792. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35793. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35794. import { Camera } from "babylonjs/Cameras/camera";
  35795. import { Light } from "babylonjs/Lights/light";
  35796. import { Node } from "babylonjs/node";
  35797. import { Animation } from "babylonjs/Animations/animation";
  35798. /**
  35799. * Defines how the parser contract is defined.
  35800. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35801. */
  35802. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35803. /**
  35804. * Defines how the individual parser contract is defined.
  35805. * These parser can parse an individual asset
  35806. */
  35807. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35808. /**
  35809. * Base class of the scene acting as a container for the different elements composing a scene.
  35810. * This class is dynamically extended by the different components of the scene increasing
  35811. * flexibility and reducing coupling
  35812. */
  35813. export abstract class AbstractScene {
  35814. /**
  35815. * Stores the list of available parsers in the application.
  35816. */
  35817. private static _BabylonFileParsers;
  35818. /**
  35819. * Stores the list of available individual parsers in the application.
  35820. */
  35821. private static _IndividualBabylonFileParsers;
  35822. /**
  35823. * Adds a parser in the list of available ones
  35824. * @param name Defines the name of the parser
  35825. * @param parser Defines the parser to add
  35826. */
  35827. static AddParser(name: string, parser: BabylonFileParser): void;
  35828. /**
  35829. * Gets a general parser from the list of avaialble ones
  35830. * @param name Defines the name of the parser
  35831. * @returns the requested parser or null
  35832. */
  35833. static GetParser(name: string): Nullable<BabylonFileParser>;
  35834. /**
  35835. * Adds n individual parser in the list of available ones
  35836. * @param name Defines the name of the parser
  35837. * @param parser Defines the parser to add
  35838. */
  35839. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35840. /**
  35841. * Gets an individual parser from the list of avaialble ones
  35842. * @param name Defines the name of the parser
  35843. * @returns the requested parser or null
  35844. */
  35845. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35846. /**
  35847. * Parser json data and populate both a scene and its associated container object
  35848. * @param jsonData Defines the data to parse
  35849. * @param scene Defines the scene to parse the data for
  35850. * @param container Defines the container attached to the parsing sequence
  35851. * @param rootUrl Defines the root url of the data
  35852. */
  35853. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35854. /**
  35855. * Gets the list of root nodes (ie. nodes with no parent)
  35856. */
  35857. rootNodes: Node[];
  35858. /** All of the cameras added to this scene
  35859. * @see http://doc.babylonjs.com/babylon101/cameras
  35860. */
  35861. cameras: Camera[];
  35862. /**
  35863. * All of the lights added to this scene
  35864. * @see http://doc.babylonjs.com/babylon101/lights
  35865. */
  35866. lights: Light[];
  35867. /**
  35868. * All of the (abstract) meshes added to this scene
  35869. */
  35870. meshes: AbstractMesh[];
  35871. /**
  35872. * The list of skeletons added to the scene
  35873. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35874. */
  35875. skeletons: Skeleton[];
  35876. /**
  35877. * All of the particle systems added to this scene
  35878. * @see http://doc.babylonjs.com/babylon101/particles
  35879. */
  35880. particleSystems: IParticleSystem[];
  35881. /**
  35882. * Gets a list of Animations associated with the scene
  35883. */
  35884. animations: Animation[];
  35885. /**
  35886. * All of the animation groups added to this scene
  35887. * @see http://doc.babylonjs.com/how_to/group
  35888. */
  35889. animationGroups: AnimationGroup[];
  35890. /**
  35891. * All of the multi-materials added to this scene
  35892. * @see http://doc.babylonjs.com/how_to/multi_materials
  35893. */
  35894. multiMaterials: MultiMaterial[];
  35895. /**
  35896. * All of the materials added to this scene
  35897. * In the context of a Scene, it is not supposed to be modified manually.
  35898. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35899. * Note also that the order of the Material wihin the array is not significant and might change.
  35900. * @see http://doc.babylonjs.com/babylon101/materials
  35901. */
  35902. materials: Material[];
  35903. /**
  35904. * The list of morph target managers added to the scene
  35905. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35906. */
  35907. morphTargetManagers: MorphTargetManager[];
  35908. /**
  35909. * The list of geometries used in the scene.
  35910. */
  35911. geometries: Geometry[];
  35912. /**
  35913. * All of the tranform nodes added to this scene
  35914. * In the context of a Scene, it is not supposed to be modified manually.
  35915. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  35916. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  35917. * @see http://doc.babylonjs.com/how_to/transformnode
  35918. */
  35919. transformNodes: TransformNode[];
  35920. /**
  35921. * ActionManagers available on the scene.
  35922. */
  35923. actionManagers: AbstractActionManager[];
  35924. /**
  35925. * Textures to keep.
  35926. */
  35927. textures: BaseTexture[];
  35928. /**
  35929. * Environment texture for the scene
  35930. */
  35931. environmentTexture: Nullable<BaseTexture>;
  35932. }
  35933. }
  35934. declare module "babylonjs/Audio/sound" {
  35935. import { Observable } from "babylonjs/Misc/observable";
  35936. import { Vector3 } from "babylonjs/Maths/math.vector";
  35937. import { Nullable } from "babylonjs/types";
  35938. import { Scene } from "babylonjs/scene";
  35939. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35940. /**
  35941. * Interface used to define options for Sound class
  35942. */
  35943. export interface ISoundOptions {
  35944. /**
  35945. * Does the sound autoplay once loaded.
  35946. */
  35947. autoplay?: boolean;
  35948. /**
  35949. * Does the sound loop after it finishes playing once.
  35950. */
  35951. loop?: boolean;
  35952. /**
  35953. * Sound's volume
  35954. */
  35955. volume?: number;
  35956. /**
  35957. * Is it a spatial sound?
  35958. */
  35959. spatialSound?: boolean;
  35960. /**
  35961. * Maximum distance to hear that sound
  35962. */
  35963. maxDistance?: number;
  35964. /**
  35965. * Uses user defined attenuation function
  35966. */
  35967. useCustomAttenuation?: boolean;
  35968. /**
  35969. * Define the roll off factor of spatial sounds.
  35970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35971. */
  35972. rolloffFactor?: number;
  35973. /**
  35974. * Define the reference distance the sound should be heard perfectly.
  35975. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35976. */
  35977. refDistance?: number;
  35978. /**
  35979. * Define the distance attenuation model the sound will follow.
  35980. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35981. */
  35982. distanceModel?: string;
  35983. /**
  35984. * Defines the playback speed (1 by default)
  35985. */
  35986. playbackRate?: number;
  35987. /**
  35988. * Defines if the sound is from a streaming source
  35989. */
  35990. streaming?: boolean;
  35991. /**
  35992. * Defines an optional length (in seconds) inside the sound file
  35993. */
  35994. length?: number;
  35995. /**
  35996. * Defines an optional offset (in seconds) inside the sound file
  35997. */
  35998. offset?: number;
  35999. /**
  36000. * If true, URLs will not be required to state the audio file codec to use.
  36001. */
  36002. skipCodecCheck?: boolean;
  36003. }
  36004. /**
  36005. * Defines a sound that can be played in the application.
  36006. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36008. */
  36009. export class Sound {
  36010. /**
  36011. * The name of the sound in the scene.
  36012. */
  36013. name: string;
  36014. /**
  36015. * Does the sound autoplay once loaded.
  36016. */
  36017. autoplay: boolean;
  36018. /**
  36019. * Does the sound loop after it finishes playing once.
  36020. */
  36021. loop: boolean;
  36022. /**
  36023. * Does the sound use a custom attenuation curve to simulate the falloff
  36024. * happening when the source gets further away from the camera.
  36025. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36026. */
  36027. useCustomAttenuation: boolean;
  36028. /**
  36029. * The sound track id this sound belongs to.
  36030. */
  36031. soundTrackId: number;
  36032. /**
  36033. * Is this sound currently played.
  36034. */
  36035. isPlaying: boolean;
  36036. /**
  36037. * Is this sound currently paused.
  36038. */
  36039. isPaused: boolean;
  36040. /**
  36041. * Does this sound enables spatial sound.
  36042. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36043. */
  36044. spatialSound: boolean;
  36045. /**
  36046. * Define the reference distance the sound should be heard perfectly.
  36047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36048. */
  36049. refDistance: number;
  36050. /**
  36051. * Define the roll off factor of spatial sounds.
  36052. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36053. */
  36054. rolloffFactor: number;
  36055. /**
  36056. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36058. */
  36059. maxDistance: number;
  36060. /**
  36061. * Define the distance attenuation model the sound will follow.
  36062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36063. */
  36064. distanceModel: string;
  36065. /**
  36066. * @hidden
  36067. * Back Compat
  36068. **/
  36069. onended: () => any;
  36070. /**
  36071. * Observable event when the current playing sound finishes.
  36072. */
  36073. onEndedObservable: Observable<Sound>;
  36074. private _panningModel;
  36075. private _playbackRate;
  36076. private _streaming;
  36077. private _startTime;
  36078. private _startOffset;
  36079. private _position;
  36080. /** @hidden */
  36081. _positionInEmitterSpace: boolean;
  36082. private _localDirection;
  36083. private _volume;
  36084. private _isReadyToPlay;
  36085. private _isDirectional;
  36086. private _readyToPlayCallback;
  36087. private _audioBuffer;
  36088. private _soundSource;
  36089. private _streamingSource;
  36090. private _soundPanner;
  36091. private _soundGain;
  36092. private _inputAudioNode;
  36093. private _outputAudioNode;
  36094. private _coneInnerAngle;
  36095. private _coneOuterAngle;
  36096. private _coneOuterGain;
  36097. private _scene;
  36098. private _connectedTransformNode;
  36099. private _customAttenuationFunction;
  36100. private _registerFunc;
  36101. private _isOutputConnected;
  36102. private _htmlAudioElement;
  36103. private _urlType;
  36104. private _length?;
  36105. private _offset?;
  36106. /** @hidden */
  36107. static _SceneComponentInitialization: (scene: Scene) => void;
  36108. /**
  36109. * Create a sound and attach it to a scene
  36110. * @param name Name of your sound
  36111. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36112. * @param scene defines the scene the sound belongs to
  36113. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36114. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36115. */
  36116. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36117. /**
  36118. * Release the sound and its associated resources
  36119. */
  36120. dispose(): void;
  36121. /**
  36122. * Gets if the sounds is ready to be played or not.
  36123. * @returns true if ready, otherwise false
  36124. */
  36125. isReady(): boolean;
  36126. private _soundLoaded;
  36127. /**
  36128. * Sets the data of the sound from an audiobuffer
  36129. * @param audioBuffer The audioBuffer containing the data
  36130. */
  36131. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36132. /**
  36133. * Updates the current sounds options such as maxdistance, loop...
  36134. * @param options A JSON object containing values named as the object properties
  36135. */
  36136. updateOptions(options: ISoundOptions): void;
  36137. private _createSpatialParameters;
  36138. private _updateSpatialParameters;
  36139. /**
  36140. * Switch the panning model to HRTF:
  36141. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36142. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36143. */
  36144. switchPanningModelToHRTF(): void;
  36145. /**
  36146. * Switch the panning model to Equal Power:
  36147. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36149. */
  36150. switchPanningModelToEqualPower(): void;
  36151. private _switchPanningModel;
  36152. /**
  36153. * Connect this sound to a sound track audio node like gain...
  36154. * @param soundTrackAudioNode the sound track audio node to connect to
  36155. */
  36156. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36157. /**
  36158. * Transform this sound into a directional source
  36159. * @param coneInnerAngle Size of the inner cone in degree
  36160. * @param coneOuterAngle Size of the outer cone in degree
  36161. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36162. */
  36163. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36164. /**
  36165. * Gets or sets the inner angle for the directional cone.
  36166. */
  36167. /**
  36168. * Gets or sets the inner angle for the directional cone.
  36169. */
  36170. directionalConeInnerAngle: number;
  36171. /**
  36172. * Gets or sets the outer angle for the directional cone.
  36173. */
  36174. /**
  36175. * Gets or sets the outer angle for the directional cone.
  36176. */
  36177. directionalConeOuterAngle: number;
  36178. /**
  36179. * Sets the position of the emitter if spatial sound is enabled
  36180. * @param newPosition Defines the new posisiton
  36181. */
  36182. setPosition(newPosition: Vector3): void;
  36183. /**
  36184. * Sets the local direction of the emitter if spatial sound is enabled
  36185. * @param newLocalDirection Defines the new local direction
  36186. */
  36187. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36188. private _updateDirection;
  36189. /** @hidden */
  36190. updateDistanceFromListener(): void;
  36191. /**
  36192. * Sets a new custom attenuation function for the sound.
  36193. * @param callback Defines the function used for the attenuation
  36194. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36195. */
  36196. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36197. /**
  36198. * Play the sound
  36199. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36200. * @param offset (optional) Start the sound at a specific time in seconds
  36201. * @param length (optional) Sound duration (in seconds)
  36202. */
  36203. play(time?: number, offset?: number, length?: number): void;
  36204. private _onended;
  36205. /**
  36206. * Stop the sound
  36207. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36208. */
  36209. stop(time?: number): void;
  36210. /**
  36211. * Put the sound in pause
  36212. */
  36213. pause(): void;
  36214. /**
  36215. * Sets a dedicated volume for this sounds
  36216. * @param newVolume Define the new volume of the sound
  36217. * @param time Define time for gradual change to new volume
  36218. */
  36219. setVolume(newVolume: number, time?: number): void;
  36220. /**
  36221. * Set the sound play back rate
  36222. * @param newPlaybackRate Define the playback rate the sound should be played at
  36223. */
  36224. setPlaybackRate(newPlaybackRate: number): void;
  36225. /**
  36226. * Gets the volume of the sound.
  36227. * @returns the volume of the sound
  36228. */
  36229. getVolume(): number;
  36230. /**
  36231. * Attach the sound to a dedicated mesh
  36232. * @param transformNode The transform node to connect the sound with
  36233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36234. */
  36235. attachToMesh(transformNode: TransformNode): void;
  36236. /**
  36237. * Detach the sound from the previously attached mesh
  36238. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36239. */
  36240. detachFromMesh(): void;
  36241. private _onRegisterAfterWorldMatrixUpdate;
  36242. /**
  36243. * Clone the current sound in the scene.
  36244. * @returns the new sound clone
  36245. */
  36246. clone(): Nullable<Sound>;
  36247. /**
  36248. * Gets the current underlying audio buffer containing the data
  36249. * @returns the audio buffer
  36250. */
  36251. getAudioBuffer(): Nullable<AudioBuffer>;
  36252. /**
  36253. * Serializes the Sound in a JSON representation
  36254. * @returns the JSON representation of the sound
  36255. */
  36256. serialize(): any;
  36257. /**
  36258. * Parse a JSON representation of a sound to innstantiate in a given scene
  36259. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36260. * @param scene Define the scene the new parsed sound should be created in
  36261. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36262. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36263. * @returns the newly parsed sound
  36264. */
  36265. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36266. }
  36267. }
  36268. declare module "babylonjs/Actions/directAudioActions" {
  36269. import { Action } from "babylonjs/Actions/action";
  36270. import { Condition } from "babylonjs/Actions/condition";
  36271. import { Sound } from "babylonjs/Audio/sound";
  36272. /**
  36273. * This defines an action helpful to play a defined sound on a triggered action.
  36274. */
  36275. export class PlaySoundAction extends Action {
  36276. private _sound;
  36277. /**
  36278. * Instantiate the action
  36279. * @param triggerOptions defines the trigger options
  36280. * @param sound defines the sound to play
  36281. * @param condition defines the trigger related conditions
  36282. */
  36283. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36284. /** @hidden */
  36285. _prepare(): void;
  36286. /**
  36287. * Execute the action and play the sound.
  36288. */
  36289. execute(): void;
  36290. /**
  36291. * Serializes the actions and its related information.
  36292. * @param parent defines the object to serialize in
  36293. * @returns the serialized object
  36294. */
  36295. serialize(parent: any): any;
  36296. }
  36297. /**
  36298. * This defines an action helpful to stop a defined sound on a triggered action.
  36299. */
  36300. export class StopSoundAction extends Action {
  36301. private _sound;
  36302. /**
  36303. * Instantiate the action
  36304. * @param triggerOptions defines the trigger options
  36305. * @param sound defines the sound to stop
  36306. * @param condition defines the trigger related conditions
  36307. */
  36308. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36309. /** @hidden */
  36310. _prepare(): void;
  36311. /**
  36312. * Execute the action and stop the sound.
  36313. */
  36314. execute(): void;
  36315. /**
  36316. * Serializes the actions and its related information.
  36317. * @param parent defines the object to serialize in
  36318. * @returns the serialized object
  36319. */
  36320. serialize(parent: any): any;
  36321. }
  36322. }
  36323. declare module "babylonjs/Actions/interpolateValueAction" {
  36324. import { Action } from "babylonjs/Actions/action";
  36325. import { Condition } from "babylonjs/Actions/condition";
  36326. import { Observable } from "babylonjs/Misc/observable";
  36327. /**
  36328. * This defines an action responsible to change the value of a property
  36329. * by interpolating between its current value and the newly set one once triggered.
  36330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36331. */
  36332. export class InterpolateValueAction extends Action {
  36333. /**
  36334. * Defines the path of the property where the value should be interpolated
  36335. */
  36336. propertyPath: string;
  36337. /**
  36338. * Defines the target value at the end of the interpolation.
  36339. */
  36340. value: any;
  36341. /**
  36342. * Defines the time it will take for the property to interpolate to the value.
  36343. */
  36344. duration: number;
  36345. /**
  36346. * Defines if the other scene animations should be stopped when the action has been triggered
  36347. */
  36348. stopOtherAnimations?: boolean;
  36349. /**
  36350. * Defines a callback raised once the interpolation animation has been done.
  36351. */
  36352. onInterpolationDone?: () => void;
  36353. /**
  36354. * Observable triggered once the interpolation animation has been done.
  36355. */
  36356. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36357. private _target;
  36358. private _effectiveTarget;
  36359. private _property;
  36360. /**
  36361. * Instantiate the action
  36362. * @param triggerOptions defines the trigger options
  36363. * @param target defines the object containing the value to interpolate
  36364. * @param propertyPath defines the path to the property in the target object
  36365. * @param value defines the target value at the end of the interpolation
  36366. * @param duration deines the time it will take for the property to interpolate to the value.
  36367. * @param condition defines the trigger related conditions
  36368. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36369. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36370. */
  36371. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36372. /** @hidden */
  36373. _prepare(): void;
  36374. /**
  36375. * Execute the action starts the value interpolation.
  36376. */
  36377. execute(): void;
  36378. /**
  36379. * Serializes the actions and its related information.
  36380. * @param parent defines the object to serialize in
  36381. * @returns the serialized object
  36382. */
  36383. serialize(parent: any): any;
  36384. }
  36385. }
  36386. declare module "babylonjs/Actions/index" {
  36387. export * from "babylonjs/Actions/abstractActionManager";
  36388. export * from "babylonjs/Actions/action";
  36389. export * from "babylonjs/Actions/actionEvent";
  36390. export * from "babylonjs/Actions/actionManager";
  36391. export * from "babylonjs/Actions/condition";
  36392. export * from "babylonjs/Actions/directActions";
  36393. export * from "babylonjs/Actions/directAudioActions";
  36394. export * from "babylonjs/Actions/interpolateValueAction";
  36395. }
  36396. declare module "babylonjs/Animations/index" {
  36397. export * from "babylonjs/Animations/animatable";
  36398. export * from "babylonjs/Animations/animation";
  36399. export * from "babylonjs/Animations/animationGroup";
  36400. export * from "babylonjs/Animations/animationPropertiesOverride";
  36401. export * from "babylonjs/Animations/easing";
  36402. export * from "babylonjs/Animations/runtimeAnimation";
  36403. export * from "babylonjs/Animations/animationEvent";
  36404. export * from "babylonjs/Animations/animationGroup";
  36405. export * from "babylonjs/Animations/animationKey";
  36406. export * from "babylonjs/Animations/animationRange";
  36407. export * from "babylonjs/Animations/animatable.interface";
  36408. }
  36409. declare module "babylonjs/Audio/soundTrack" {
  36410. import { Sound } from "babylonjs/Audio/sound";
  36411. import { Analyser } from "babylonjs/Audio/analyser";
  36412. import { Scene } from "babylonjs/scene";
  36413. /**
  36414. * Options allowed during the creation of a sound track.
  36415. */
  36416. export interface ISoundTrackOptions {
  36417. /**
  36418. * The volume the sound track should take during creation
  36419. */
  36420. volume?: number;
  36421. /**
  36422. * Define if the sound track is the main sound track of the scene
  36423. */
  36424. mainTrack?: boolean;
  36425. }
  36426. /**
  36427. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36428. * It will be also used in a future release to apply effects on a specific track.
  36429. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36430. */
  36431. export class SoundTrack {
  36432. /**
  36433. * The unique identifier of the sound track in the scene.
  36434. */
  36435. id: number;
  36436. /**
  36437. * The list of sounds included in the sound track.
  36438. */
  36439. soundCollection: Array<Sound>;
  36440. private _outputAudioNode;
  36441. private _scene;
  36442. private _isMainTrack;
  36443. private _connectedAnalyser;
  36444. private _options;
  36445. private _isInitialized;
  36446. /**
  36447. * Creates a new sound track.
  36448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36449. * @param scene Define the scene the sound track belongs to
  36450. * @param options
  36451. */
  36452. constructor(scene: Scene, options?: ISoundTrackOptions);
  36453. private _initializeSoundTrackAudioGraph;
  36454. /**
  36455. * Release the sound track and its associated resources
  36456. */
  36457. dispose(): void;
  36458. /**
  36459. * Adds a sound to this sound track
  36460. * @param sound define the cound to add
  36461. * @ignoreNaming
  36462. */
  36463. AddSound(sound: Sound): void;
  36464. /**
  36465. * Removes a sound to this sound track
  36466. * @param sound define the cound to remove
  36467. * @ignoreNaming
  36468. */
  36469. RemoveSound(sound: Sound): void;
  36470. /**
  36471. * Set a global volume for the full sound track.
  36472. * @param newVolume Define the new volume of the sound track
  36473. */
  36474. setVolume(newVolume: number): void;
  36475. /**
  36476. * Switch the panning model to HRTF:
  36477. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36478. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36479. */
  36480. switchPanningModelToHRTF(): void;
  36481. /**
  36482. * Switch the panning model to Equal Power:
  36483. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36484. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36485. */
  36486. switchPanningModelToEqualPower(): void;
  36487. /**
  36488. * Connect the sound track to an audio analyser allowing some amazing
  36489. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36490. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36491. * @param analyser The analyser to connect to the engine
  36492. */
  36493. connectToAnalyser(analyser: Analyser): void;
  36494. }
  36495. }
  36496. declare module "babylonjs/Audio/audioSceneComponent" {
  36497. import { Sound } from "babylonjs/Audio/sound";
  36498. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36499. import { Nullable } from "babylonjs/types";
  36500. import { Vector3 } from "babylonjs/Maths/math.vector";
  36501. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36502. import { Scene } from "babylonjs/scene";
  36503. import { AbstractScene } from "babylonjs/abstractScene";
  36504. import "babylonjs/Audio/audioEngine";
  36505. module "babylonjs/abstractScene" {
  36506. interface AbstractScene {
  36507. /**
  36508. * The list of sounds used in the scene.
  36509. */
  36510. sounds: Nullable<Array<Sound>>;
  36511. }
  36512. }
  36513. module "babylonjs/scene" {
  36514. interface Scene {
  36515. /**
  36516. * @hidden
  36517. * Backing field
  36518. */
  36519. _mainSoundTrack: SoundTrack;
  36520. /**
  36521. * The main sound track played by the scene.
  36522. * It cotains your primary collection of sounds.
  36523. */
  36524. mainSoundTrack: SoundTrack;
  36525. /**
  36526. * The list of sound tracks added to the scene
  36527. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36528. */
  36529. soundTracks: Nullable<Array<SoundTrack>>;
  36530. /**
  36531. * Gets a sound using a given name
  36532. * @param name defines the name to search for
  36533. * @return the found sound or null if not found at all.
  36534. */
  36535. getSoundByName(name: string): Nullable<Sound>;
  36536. /**
  36537. * Gets or sets if audio support is enabled
  36538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36539. */
  36540. audioEnabled: boolean;
  36541. /**
  36542. * Gets or sets if audio will be output to headphones
  36543. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36544. */
  36545. headphone: boolean;
  36546. /**
  36547. * Gets or sets custom audio listener position provider
  36548. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36549. */
  36550. audioListenerPositionProvider: Nullable<() => Vector3>;
  36551. }
  36552. }
  36553. /**
  36554. * Defines the sound scene component responsible to manage any sounds
  36555. * in a given scene.
  36556. */
  36557. export class AudioSceneComponent implements ISceneSerializableComponent {
  36558. /**
  36559. * The component name helpfull to identify the component in the list of scene components.
  36560. */
  36561. readonly name: string;
  36562. /**
  36563. * The scene the component belongs to.
  36564. */
  36565. scene: Scene;
  36566. private _audioEnabled;
  36567. /**
  36568. * Gets whether audio is enabled or not.
  36569. * Please use related enable/disable method to switch state.
  36570. */
  36571. readonly audioEnabled: boolean;
  36572. private _headphone;
  36573. /**
  36574. * Gets whether audio is outputing to headphone or not.
  36575. * Please use the according Switch methods to change output.
  36576. */
  36577. readonly headphone: boolean;
  36578. private _audioListenerPositionProvider;
  36579. /**
  36580. * Gets the current audio listener position provider
  36581. */
  36582. /**
  36583. * Sets a custom listener position for all sounds in the scene
  36584. * By default, this is the position of the first active camera
  36585. */
  36586. audioListenerPositionProvider: Nullable<() => Vector3>;
  36587. /**
  36588. * Creates a new instance of the component for the given scene
  36589. * @param scene Defines the scene to register the component in
  36590. */
  36591. constructor(scene: Scene);
  36592. /**
  36593. * Registers the component in a given scene
  36594. */
  36595. register(): void;
  36596. /**
  36597. * Rebuilds the elements related to this component in case of
  36598. * context lost for instance.
  36599. */
  36600. rebuild(): void;
  36601. /**
  36602. * Serializes the component data to the specified json object
  36603. * @param serializationObject The object to serialize to
  36604. */
  36605. serialize(serializationObject: any): void;
  36606. /**
  36607. * Adds all the elements from the container to the scene
  36608. * @param container the container holding the elements
  36609. */
  36610. addFromContainer(container: AbstractScene): void;
  36611. /**
  36612. * Removes all the elements in the container from the scene
  36613. * @param container contains the elements to remove
  36614. * @param dispose if the removed element should be disposed (default: false)
  36615. */
  36616. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36617. /**
  36618. * Disposes the component and the associated ressources.
  36619. */
  36620. dispose(): void;
  36621. /**
  36622. * Disables audio in the associated scene.
  36623. */
  36624. disableAudio(): void;
  36625. /**
  36626. * Enables audio in the associated scene.
  36627. */
  36628. enableAudio(): void;
  36629. /**
  36630. * Switch audio to headphone output.
  36631. */
  36632. switchAudioModeForHeadphones(): void;
  36633. /**
  36634. * Switch audio to normal speakers.
  36635. */
  36636. switchAudioModeForNormalSpeakers(): void;
  36637. private _afterRender;
  36638. }
  36639. }
  36640. declare module "babylonjs/Audio/weightedsound" {
  36641. import { Sound } from "babylonjs/Audio/sound";
  36642. /**
  36643. * Wraps one or more Sound objects and selects one with random weight for playback.
  36644. */
  36645. export class WeightedSound {
  36646. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36647. loop: boolean;
  36648. private _coneInnerAngle;
  36649. private _coneOuterAngle;
  36650. private _volume;
  36651. /** A Sound is currently playing. */
  36652. isPlaying: boolean;
  36653. /** A Sound is currently paused. */
  36654. isPaused: boolean;
  36655. private _sounds;
  36656. private _weights;
  36657. private _currentIndex?;
  36658. /**
  36659. * Creates a new WeightedSound from the list of sounds given.
  36660. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36661. * @param sounds Array of Sounds that will be selected from.
  36662. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36663. */
  36664. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36665. /**
  36666. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36667. */
  36668. /**
  36669. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36670. */
  36671. directionalConeInnerAngle: number;
  36672. /**
  36673. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36674. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36675. */
  36676. /**
  36677. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36678. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36679. */
  36680. directionalConeOuterAngle: number;
  36681. /**
  36682. * Playback volume.
  36683. */
  36684. /**
  36685. * Playback volume.
  36686. */
  36687. volume: number;
  36688. private _onended;
  36689. /**
  36690. * Suspend playback
  36691. */
  36692. pause(): void;
  36693. /**
  36694. * Stop playback
  36695. */
  36696. stop(): void;
  36697. /**
  36698. * Start playback.
  36699. * @param startOffset Position the clip head at a specific time in seconds.
  36700. */
  36701. play(startOffset?: number): void;
  36702. }
  36703. }
  36704. declare module "babylonjs/Audio/index" {
  36705. export * from "babylonjs/Audio/analyser";
  36706. export * from "babylonjs/Audio/audioEngine";
  36707. export * from "babylonjs/Audio/audioSceneComponent";
  36708. export * from "babylonjs/Audio/sound";
  36709. export * from "babylonjs/Audio/soundTrack";
  36710. export * from "babylonjs/Audio/weightedsound";
  36711. }
  36712. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36713. import { Behavior } from "babylonjs/Behaviors/behavior";
  36714. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36715. import { BackEase } from "babylonjs/Animations/easing";
  36716. /**
  36717. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36718. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36719. */
  36720. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36721. /**
  36722. * Gets the name of the behavior.
  36723. */
  36724. readonly name: string;
  36725. /**
  36726. * The easing function used by animations
  36727. */
  36728. static EasingFunction: BackEase;
  36729. /**
  36730. * The easing mode used by animations
  36731. */
  36732. static EasingMode: number;
  36733. /**
  36734. * The duration of the animation, in milliseconds
  36735. */
  36736. transitionDuration: number;
  36737. /**
  36738. * Length of the distance animated by the transition when lower radius is reached
  36739. */
  36740. lowerRadiusTransitionRange: number;
  36741. /**
  36742. * Length of the distance animated by the transition when upper radius is reached
  36743. */
  36744. upperRadiusTransitionRange: number;
  36745. private _autoTransitionRange;
  36746. /**
  36747. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36748. */
  36749. /**
  36750. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36751. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36752. */
  36753. autoTransitionRange: boolean;
  36754. private _attachedCamera;
  36755. private _onAfterCheckInputsObserver;
  36756. private _onMeshTargetChangedObserver;
  36757. /**
  36758. * Initializes the behavior.
  36759. */
  36760. init(): void;
  36761. /**
  36762. * Attaches the behavior to its arc rotate camera.
  36763. * @param camera Defines the camera to attach the behavior to
  36764. */
  36765. attach(camera: ArcRotateCamera): void;
  36766. /**
  36767. * Detaches the behavior from its current arc rotate camera.
  36768. */
  36769. detach(): void;
  36770. private _radiusIsAnimating;
  36771. private _radiusBounceTransition;
  36772. private _animatables;
  36773. private _cachedWheelPrecision;
  36774. /**
  36775. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36776. * @param radiusLimit The limit to check against.
  36777. * @return Bool to indicate if at limit.
  36778. */
  36779. private _isRadiusAtLimit;
  36780. /**
  36781. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36782. * @param radiusDelta The delta by which to animate to. Can be negative.
  36783. */
  36784. private _applyBoundRadiusAnimation;
  36785. /**
  36786. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36787. */
  36788. protected _clearAnimationLocks(): void;
  36789. /**
  36790. * Stops and removes all animations that have been applied to the camera
  36791. */
  36792. stopAllAnimations(): void;
  36793. }
  36794. }
  36795. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36796. import { Behavior } from "babylonjs/Behaviors/behavior";
  36797. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36798. import { ExponentialEase } from "babylonjs/Animations/easing";
  36799. import { Nullable } from "babylonjs/types";
  36800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36801. import { Vector3 } from "babylonjs/Maths/math.vector";
  36802. /**
  36803. * 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.
  36804. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36805. */
  36806. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36807. /**
  36808. * Gets the name of the behavior.
  36809. */
  36810. readonly name: string;
  36811. private _mode;
  36812. private _radiusScale;
  36813. private _positionScale;
  36814. private _defaultElevation;
  36815. private _elevationReturnTime;
  36816. private _elevationReturnWaitTime;
  36817. private _zoomStopsAnimation;
  36818. private _framingTime;
  36819. /**
  36820. * The easing function used by animations
  36821. */
  36822. static EasingFunction: ExponentialEase;
  36823. /**
  36824. * The easing mode used by animations
  36825. */
  36826. static EasingMode: number;
  36827. /**
  36828. * Sets the current mode used by the behavior
  36829. */
  36830. /**
  36831. * Gets current mode used by the behavior.
  36832. */
  36833. mode: number;
  36834. /**
  36835. * Sets the scale applied to the radius (1 by default)
  36836. */
  36837. /**
  36838. * Gets the scale applied to the radius
  36839. */
  36840. radiusScale: number;
  36841. /**
  36842. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36843. */
  36844. /**
  36845. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36846. */
  36847. positionScale: number;
  36848. /**
  36849. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36850. * behaviour is triggered, in radians.
  36851. */
  36852. /**
  36853. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36854. * behaviour is triggered, in radians.
  36855. */
  36856. defaultElevation: number;
  36857. /**
  36858. * Sets the time (in milliseconds) taken to return to the default beta position.
  36859. * Negative value indicates camera should not return to default.
  36860. */
  36861. /**
  36862. * Gets the time (in milliseconds) taken to return to the default beta position.
  36863. * Negative value indicates camera should not return to default.
  36864. */
  36865. elevationReturnTime: number;
  36866. /**
  36867. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36868. */
  36869. /**
  36870. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36871. */
  36872. elevationReturnWaitTime: number;
  36873. /**
  36874. * Sets the flag that indicates if user zooming should stop animation.
  36875. */
  36876. /**
  36877. * Gets the flag that indicates if user zooming should stop animation.
  36878. */
  36879. zoomStopsAnimation: boolean;
  36880. /**
  36881. * Sets the transition time when framing the mesh, in milliseconds
  36882. */
  36883. /**
  36884. * Gets the transition time when framing the mesh, in milliseconds
  36885. */
  36886. framingTime: number;
  36887. /**
  36888. * Define if the behavior should automatically change the configured
  36889. * camera limits and sensibilities.
  36890. */
  36891. autoCorrectCameraLimitsAndSensibility: boolean;
  36892. private _onPrePointerObservableObserver;
  36893. private _onAfterCheckInputsObserver;
  36894. private _onMeshTargetChangedObserver;
  36895. private _attachedCamera;
  36896. private _isPointerDown;
  36897. private _lastInteractionTime;
  36898. /**
  36899. * Initializes the behavior.
  36900. */
  36901. init(): void;
  36902. /**
  36903. * Attaches the behavior to its arc rotate camera.
  36904. * @param camera Defines the camera to attach the behavior to
  36905. */
  36906. attach(camera: ArcRotateCamera): void;
  36907. /**
  36908. * Detaches the behavior from its current arc rotate camera.
  36909. */
  36910. detach(): void;
  36911. private _animatables;
  36912. private _betaIsAnimating;
  36913. private _betaTransition;
  36914. private _radiusTransition;
  36915. private _vectorTransition;
  36916. /**
  36917. * Targets the given mesh and updates zoom level accordingly.
  36918. * @param mesh The mesh to target.
  36919. * @param radius Optional. If a cached radius position already exists, overrides default.
  36920. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36921. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36922. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36923. */
  36924. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36925. /**
  36926. * Targets the given mesh with its children and updates zoom level accordingly.
  36927. * @param mesh The mesh to target.
  36928. * @param radius Optional. If a cached radius position already exists, overrides default.
  36929. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36930. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36931. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36932. */
  36933. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36934. /**
  36935. * Targets the given meshes with their children and updates zoom level accordingly.
  36936. * @param meshes The mesh to target.
  36937. * @param radius Optional. If a cached radius position already exists, overrides default.
  36938. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  36939. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36940. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36941. */
  36942. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36943. /**
  36944. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  36945. * @param minimumWorld Determines the smaller position of the bounding box extend
  36946. * @param maximumWorld Determines the bigger position of the bounding box extend
  36947. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  36948. * @param onAnimationEnd Callback triggered at the end of the framing animation
  36949. */
  36950. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  36951. /**
  36952. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  36953. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  36954. * frustum width.
  36955. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  36956. * to fully enclose the mesh in the viewing frustum.
  36957. */
  36958. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  36959. /**
  36960. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  36961. * is automatically returned to its default position (expected to be above ground plane).
  36962. */
  36963. private _maintainCameraAboveGround;
  36964. /**
  36965. * Returns the frustum slope based on the canvas ratio and camera FOV
  36966. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  36967. */
  36968. private _getFrustumSlope;
  36969. /**
  36970. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  36971. */
  36972. private _clearAnimationLocks;
  36973. /**
  36974. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36975. */
  36976. private _applyUserInteraction;
  36977. /**
  36978. * Stops and removes all animations that have been applied to the camera
  36979. */
  36980. stopAllAnimations(): void;
  36981. /**
  36982. * Gets a value indicating if the user is moving the camera
  36983. */
  36984. readonly isUserIsMoving: boolean;
  36985. /**
  36986. * The camera can move all the way towards the mesh.
  36987. */
  36988. static IgnoreBoundsSizeMode: number;
  36989. /**
  36990. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  36991. */
  36992. static FitFrustumSidesMode: number;
  36993. }
  36994. }
  36995. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  36996. import { Nullable } from "babylonjs/types";
  36997. import { Camera } from "babylonjs/Cameras/camera";
  36998. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36999. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37000. /**
  37001. * Base class for Camera Pointer Inputs.
  37002. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37003. * for example usage.
  37004. */
  37005. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37006. /**
  37007. * Defines the camera the input is attached to.
  37008. */
  37009. abstract camera: Camera;
  37010. /**
  37011. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37012. */
  37013. protected _altKey: boolean;
  37014. protected _ctrlKey: boolean;
  37015. protected _metaKey: boolean;
  37016. protected _shiftKey: boolean;
  37017. /**
  37018. * Which mouse buttons were pressed at time of last mouse event.
  37019. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37020. */
  37021. protected _buttonsPressed: number;
  37022. /**
  37023. * Defines the buttons associated with the input to handle camera move.
  37024. */
  37025. buttons: number[];
  37026. /**
  37027. * Attach the input controls to a specific dom element to get the input from.
  37028. * @param element Defines the element the controls should be listened from
  37029. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37030. */
  37031. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37032. /**
  37033. * Detach the current controls from the specified dom element.
  37034. * @param element Defines the element to stop listening the inputs from
  37035. */
  37036. detachControl(element: Nullable<HTMLElement>): void;
  37037. /**
  37038. * Gets the class name of the current input.
  37039. * @returns the class name
  37040. */
  37041. getClassName(): string;
  37042. /**
  37043. * Get the friendly name associated with the input class.
  37044. * @returns the input friendly name
  37045. */
  37046. getSimpleName(): string;
  37047. /**
  37048. * Called on pointer POINTERDOUBLETAP event.
  37049. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37050. */
  37051. protected onDoubleTap(type: string): void;
  37052. /**
  37053. * Called on pointer POINTERMOVE event if only a single touch is active.
  37054. * Override this method to provide functionality.
  37055. */
  37056. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37057. /**
  37058. * Called on pointer POINTERMOVE event if multiple touches are active.
  37059. * Override this method to provide functionality.
  37060. */
  37061. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37062. /**
  37063. * Called on JS contextmenu event.
  37064. * Override this method to provide functionality.
  37065. */
  37066. protected onContextMenu(evt: PointerEvent): void;
  37067. /**
  37068. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37069. * press.
  37070. * Override this method to provide functionality.
  37071. */
  37072. protected onButtonDown(evt: PointerEvent): void;
  37073. /**
  37074. * Called each time a new POINTERUP event occurs. Ie, for each button
  37075. * release.
  37076. * Override this method to provide functionality.
  37077. */
  37078. protected onButtonUp(evt: PointerEvent): void;
  37079. /**
  37080. * Called when window becomes inactive.
  37081. * Override this method to provide functionality.
  37082. */
  37083. protected onLostFocus(): void;
  37084. private _pointerInput;
  37085. private _observer;
  37086. private _onLostFocus;
  37087. private pointA;
  37088. private pointB;
  37089. }
  37090. }
  37091. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37092. import { Nullable } from "babylonjs/types";
  37093. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37094. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37095. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37096. /**
  37097. * Manage the pointers inputs to control an arc rotate camera.
  37098. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37099. */
  37100. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37101. /**
  37102. * Defines the camera the input is attached to.
  37103. */
  37104. camera: ArcRotateCamera;
  37105. /**
  37106. * Gets the class name of the current input.
  37107. * @returns the class name
  37108. */
  37109. getClassName(): string;
  37110. /**
  37111. * Defines the buttons associated with the input to handle camera move.
  37112. */
  37113. buttons: number[];
  37114. /**
  37115. * Defines the pointer angular sensibility along the X axis or how fast is
  37116. * the camera rotating.
  37117. */
  37118. angularSensibilityX: number;
  37119. /**
  37120. * Defines the pointer angular sensibility along the Y axis or how fast is
  37121. * the camera rotating.
  37122. */
  37123. angularSensibilityY: number;
  37124. /**
  37125. * Defines the pointer pinch precision or how fast is the camera zooming.
  37126. */
  37127. pinchPrecision: number;
  37128. /**
  37129. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37130. * from 0.
  37131. * It defines the percentage of current camera.radius to use as delta when
  37132. * pinch zoom is used.
  37133. */
  37134. pinchDeltaPercentage: number;
  37135. /**
  37136. * Defines the pointer panning sensibility or how fast is the camera moving.
  37137. */
  37138. panningSensibility: number;
  37139. /**
  37140. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37141. */
  37142. multiTouchPanning: boolean;
  37143. /**
  37144. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37145. * zoom (pinch) through multitouch.
  37146. */
  37147. multiTouchPanAndZoom: boolean;
  37148. /**
  37149. * Revers pinch action direction.
  37150. */
  37151. pinchInwards: boolean;
  37152. private _isPanClick;
  37153. private _twoFingerActivityCount;
  37154. private _isPinching;
  37155. /**
  37156. * Called on pointer POINTERMOVE event if only a single touch is active.
  37157. */
  37158. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37159. /**
  37160. * Called on pointer POINTERDOUBLETAP event.
  37161. */
  37162. protected onDoubleTap(type: string): void;
  37163. /**
  37164. * Called on pointer POINTERMOVE event if multiple touches are active.
  37165. */
  37166. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37167. /**
  37168. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37169. * press.
  37170. */
  37171. protected onButtonDown(evt: PointerEvent): void;
  37172. /**
  37173. * Called each time a new POINTERUP event occurs. Ie, for each button
  37174. * release.
  37175. */
  37176. protected onButtonUp(evt: PointerEvent): void;
  37177. /**
  37178. * Called when window becomes inactive.
  37179. */
  37180. protected onLostFocus(): void;
  37181. }
  37182. }
  37183. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37184. import { Nullable } from "babylonjs/types";
  37185. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37186. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37187. /**
  37188. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37190. */
  37191. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37192. /**
  37193. * Defines the camera the input is attached to.
  37194. */
  37195. camera: ArcRotateCamera;
  37196. /**
  37197. * Defines the list of key codes associated with the up action (increase alpha)
  37198. */
  37199. keysUp: number[];
  37200. /**
  37201. * Defines the list of key codes associated with the down action (decrease alpha)
  37202. */
  37203. keysDown: number[];
  37204. /**
  37205. * Defines the list of key codes associated with the left action (increase beta)
  37206. */
  37207. keysLeft: number[];
  37208. /**
  37209. * Defines the list of key codes associated with the right action (decrease beta)
  37210. */
  37211. keysRight: number[];
  37212. /**
  37213. * Defines the list of key codes associated with the reset action.
  37214. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37215. */
  37216. keysReset: number[];
  37217. /**
  37218. * Defines the panning sensibility of the inputs.
  37219. * (How fast is the camera paning)
  37220. */
  37221. panningSensibility: number;
  37222. /**
  37223. * Defines the zooming sensibility of the inputs.
  37224. * (How fast is the camera zooming)
  37225. */
  37226. zoomingSensibility: number;
  37227. /**
  37228. * Defines wether maintaining the alt key down switch the movement mode from
  37229. * orientation to zoom.
  37230. */
  37231. useAltToZoom: boolean;
  37232. /**
  37233. * Rotation speed of the camera
  37234. */
  37235. angularSpeed: number;
  37236. private _keys;
  37237. private _ctrlPressed;
  37238. private _altPressed;
  37239. private _onCanvasBlurObserver;
  37240. private _onKeyboardObserver;
  37241. private _engine;
  37242. private _scene;
  37243. /**
  37244. * Attach the input controls to a specific dom element to get the input from.
  37245. * @param element Defines the element the controls should be listened from
  37246. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37247. */
  37248. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37249. /**
  37250. * Detach the current controls from the specified dom element.
  37251. * @param element Defines the element to stop listening the inputs from
  37252. */
  37253. detachControl(element: Nullable<HTMLElement>): void;
  37254. /**
  37255. * Update the current camera state depending on the inputs that have been used this frame.
  37256. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37257. */
  37258. checkInputs(): void;
  37259. /**
  37260. * Gets the class name of the current intput.
  37261. * @returns the class name
  37262. */
  37263. getClassName(): string;
  37264. /**
  37265. * Get the friendly name associated with the input class.
  37266. * @returns the input friendly name
  37267. */
  37268. getSimpleName(): string;
  37269. }
  37270. }
  37271. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37272. import { Nullable } from "babylonjs/types";
  37273. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37274. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37275. /**
  37276. * Manage the mouse wheel inputs to control an arc rotate camera.
  37277. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37278. */
  37279. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37280. /**
  37281. * Defines the camera the input is attached to.
  37282. */
  37283. camera: ArcRotateCamera;
  37284. /**
  37285. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37286. */
  37287. wheelPrecision: number;
  37288. /**
  37289. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37290. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37291. */
  37292. wheelDeltaPercentage: number;
  37293. private _wheel;
  37294. private _observer;
  37295. private computeDeltaFromMouseWheelLegacyEvent;
  37296. /**
  37297. * Attach the input controls to a specific dom element to get the input from.
  37298. * @param element Defines the element the controls should be listened from
  37299. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37300. */
  37301. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37302. /**
  37303. * Detach the current controls from the specified dom element.
  37304. * @param element Defines the element to stop listening the inputs from
  37305. */
  37306. detachControl(element: Nullable<HTMLElement>): void;
  37307. /**
  37308. * Gets the class name of the current intput.
  37309. * @returns the class name
  37310. */
  37311. getClassName(): string;
  37312. /**
  37313. * Get the friendly name associated with the input class.
  37314. * @returns the input friendly name
  37315. */
  37316. getSimpleName(): string;
  37317. }
  37318. }
  37319. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37320. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37321. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37322. /**
  37323. * Default Inputs manager for the ArcRotateCamera.
  37324. * It groups all the default supported inputs for ease of use.
  37325. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37326. */
  37327. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37328. /**
  37329. * Instantiates a new ArcRotateCameraInputsManager.
  37330. * @param camera Defines the camera the inputs belong to
  37331. */
  37332. constructor(camera: ArcRotateCamera);
  37333. /**
  37334. * Add mouse wheel input support to the input manager.
  37335. * @returns the current input manager
  37336. */
  37337. addMouseWheel(): ArcRotateCameraInputsManager;
  37338. /**
  37339. * Add pointers input support to the input manager.
  37340. * @returns the current input manager
  37341. */
  37342. addPointers(): ArcRotateCameraInputsManager;
  37343. /**
  37344. * Add keyboard input support to the input manager.
  37345. * @returns the current input manager
  37346. */
  37347. addKeyboard(): ArcRotateCameraInputsManager;
  37348. }
  37349. }
  37350. declare module "babylonjs/Cameras/arcRotateCamera" {
  37351. import { Observable } from "babylonjs/Misc/observable";
  37352. import { Nullable } from "babylonjs/types";
  37353. import { Scene } from "babylonjs/scene";
  37354. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37355. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37356. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37357. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37358. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37359. import { Camera } from "babylonjs/Cameras/camera";
  37360. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37361. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37362. import { Collider } from "babylonjs/Collisions/collider";
  37363. /**
  37364. * This represents an orbital type of camera.
  37365. *
  37366. * 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.
  37367. * 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.
  37368. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37369. */
  37370. export class ArcRotateCamera extends TargetCamera {
  37371. /**
  37372. * Defines the rotation angle of the camera along the longitudinal axis.
  37373. */
  37374. alpha: number;
  37375. /**
  37376. * Defines the rotation angle of the camera along the latitudinal axis.
  37377. */
  37378. beta: number;
  37379. /**
  37380. * Defines the radius of the camera from it s target point.
  37381. */
  37382. radius: number;
  37383. protected _target: Vector3;
  37384. protected _targetHost: Nullable<AbstractMesh>;
  37385. /**
  37386. * Defines the target point of the camera.
  37387. * The camera looks towards it form the radius distance.
  37388. */
  37389. target: Vector3;
  37390. /**
  37391. * Define the current local position of the camera in the scene
  37392. */
  37393. position: Vector3;
  37394. protected _upVector: Vector3;
  37395. protected _upToYMatrix: Matrix;
  37396. protected _YToUpMatrix: Matrix;
  37397. /**
  37398. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37399. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37400. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37401. */
  37402. upVector: Vector3;
  37403. /**
  37404. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37405. */
  37406. setMatUp(): void;
  37407. /**
  37408. * Current inertia value on the longitudinal axis.
  37409. * The bigger this number the longer it will take for the camera to stop.
  37410. */
  37411. inertialAlphaOffset: number;
  37412. /**
  37413. * Current inertia value on the latitudinal axis.
  37414. * The bigger this number the longer it will take for the camera to stop.
  37415. */
  37416. inertialBetaOffset: number;
  37417. /**
  37418. * Current inertia value on the radius axis.
  37419. * The bigger this number the longer it will take for the camera to stop.
  37420. */
  37421. inertialRadiusOffset: number;
  37422. /**
  37423. * Minimum allowed angle on the longitudinal axis.
  37424. * This can help limiting how the Camera is able to move in the scene.
  37425. */
  37426. lowerAlphaLimit: Nullable<number>;
  37427. /**
  37428. * Maximum allowed angle on the longitudinal axis.
  37429. * This can help limiting how the Camera is able to move in the scene.
  37430. */
  37431. upperAlphaLimit: Nullable<number>;
  37432. /**
  37433. * Minimum allowed angle on the latitudinal axis.
  37434. * This can help limiting how the Camera is able to move in the scene.
  37435. */
  37436. lowerBetaLimit: number;
  37437. /**
  37438. * Maximum allowed angle on the latitudinal axis.
  37439. * This can help limiting how the Camera is able to move in the scene.
  37440. */
  37441. upperBetaLimit: number;
  37442. /**
  37443. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37444. * This can help limiting how the Camera is able to move in the scene.
  37445. */
  37446. lowerRadiusLimit: Nullable<number>;
  37447. /**
  37448. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37449. * This can help limiting how the Camera is able to move in the scene.
  37450. */
  37451. upperRadiusLimit: Nullable<number>;
  37452. /**
  37453. * Defines the current inertia value used during panning of the camera along the X axis.
  37454. */
  37455. inertialPanningX: number;
  37456. /**
  37457. * Defines the current inertia value used during panning of the camera along the Y axis.
  37458. */
  37459. inertialPanningY: number;
  37460. /**
  37461. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37462. * Basically if your fingers moves away from more than this distance you will be considered
  37463. * in pinch mode.
  37464. */
  37465. pinchToPanMaxDistance: number;
  37466. /**
  37467. * Defines the maximum distance the camera can pan.
  37468. * This could help keeping the cammera always in your scene.
  37469. */
  37470. panningDistanceLimit: Nullable<number>;
  37471. /**
  37472. * Defines the target of the camera before paning.
  37473. */
  37474. panningOriginTarget: Vector3;
  37475. /**
  37476. * Defines the value of the inertia used during panning.
  37477. * 0 would mean stop inertia and one would mean no decelleration at all.
  37478. */
  37479. panningInertia: number;
  37480. /**
  37481. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37482. */
  37483. angularSensibilityX: number;
  37484. /**
  37485. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37486. */
  37487. angularSensibilityY: number;
  37488. /**
  37489. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37490. */
  37491. pinchPrecision: number;
  37492. /**
  37493. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37494. * It will be used instead of pinchDeltaPrecision if different from 0.
  37495. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37496. */
  37497. pinchDeltaPercentage: number;
  37498. /**
  37499. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37500. */
  37501. panningSensibility: number;
  37502. /**
  37503. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37504. */
  37505. keysUp: number[];
  37506. /**
  37507. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37508. */
  37509. keysDown: number[];
  37510. /**
  37511. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37512. */
  37513. keysLeft: number[];
  37514. /**
  37515. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37516. */
  37517. keysRight: number[];
  37518. /**
  37519. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37520. */
  37521. wheelPrecision: number;
  37522. /**
  37523. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37524. * It will be used instead of pinchDeltaPrecision if different from 0.
  37525. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37526. */
  37527. wheelDeltaPercentage: number;
  37528. /**
  37529. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37530. */
  37531. zoomOnFactor: number;
  37532. /**
  37533. * Defines a screen offset for the camera position.
  37534. */
  37535. targetScreenOffset: Vector2;
  37536. /**
  37537. * Allows the camera to be completely reversed.
  37538. * If false the camera can not arrive upside down.
  37539. */
  37540. allowUpsideDown: boolean;
  37541. /**
  37542. * Define if double tap/click is used to restore the previously saved state of the camera.
  37543. */
  37544. useInputToRestoreState: boolean;
  37545. /** @hidden */
  37546. _viewMatrix: Matrix;
  37547. /** @hidden */
  37548. _useCtrlForPanning: boolean;
  37549. /** @hidden */
  37550. _panningMouseButton: number;
  37551. /**
  37552. * Defines the input associated to the camera.
  37553. */
  37554. inputs: ArcRotateCameraInputsManager;
  37555. /** @hidden */
  37556. _reset: () => void;
  37557. /**
  37558. * Defines the allowed panning axis.
  37559. */
  37560. panningAxis: Vector3;
  37561. protected _localDirection: Vector3;
  37562. protected _transformedDirection: Vector3;
  37563. private _bouncingBehavior;
  37564. /**
  37565. * Gets the bouncing behavior of the camera if it has been enabled.
  37566. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37567. */
  37568. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37569. /**
  37570. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37571. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37572. */
  37573. useBouncingBehavior: boolean;
  37574. private _framingBehavior;
  37575. /**
  37576. * Gets the framing behavior of the camera if it has been enabled.
  37577. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37578. */
  37579. readonly framingBehavior: Nullable<FramingBehavior>;
  37580. /**
  37581. * Defines if the framing behavior of the camera is enabled on the camera.
  37582. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37583. */
  37584. useFramingBehavior: boolean;
  37585. private _autoRotationBehavior;
  37586. /**
  37587. * Gets the auto rotation behavior of the camera if it has been enabled.
  37588. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37589. */
  37590. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37591. /**
  37592. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37593. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37594. */
  37595. useAutoRotationBehavior: boolean;
  37596. /**
  37597. * Observable triggered when the mesh target has been changed on the camera.
  37598. */
  37599. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37600. /**
  37601. * Event raised when the camera is colliding with a mesh.
  37602. */
  37603. onCollide: (collidedMesh: AbstractMesh) => void;
  37604. /**
  37605. * Defines whether the camera should check collision with the objects oh the scene.
  37606. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37607. */
  37608. checkCollisions: boolean;
  37609. /**
  37610. * Defines the collision radius of the camera.
  37611. * This simulates a sphere around the camera.
  37612. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37613. */
  37614. collisionRadius: Vector3;
  37615. protected _collider: Collider;
  37616. protected _previousPosition: Vector3;
  37617. protected _collisionVelocity: Vector3;
  37618. protected _newPosition: Vector3;
  37619. protected _previousAlpha: number;
  37620. protected _previousBeta: number;
  37621. protected _previousRadius: number;
  37622. protected _collisionTriggered: boolean;
  37623. protected _targetBoundingCenter: Nullable<Vector3>;
  37624. private _computationVector;
  37625. /**
  37626. * Instantiates a new ArcRotateCamera in a given scene
  37627. * @param name Defines the name of the camera
  37628. * @param alpha Defines the camera rotation along the logitudinal axis
  37629. * @param beta Defines the camera rotation along the latitudinal axis
  37630. * @param radius Defines the camera distance from its target
  37631. * @param target Defines the camera target
  37632. * @param scene Defines the scene the camera belongs to
  37633. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37634. */
  37635. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37636. /** @hidden */
  37637. _initCache(): void;
  37638. /** @hidden */
  37639. _updateCache(ignoreParentClass?: boolean): void;
  37640. protected _getTargetPosition(): Vector3;
  37641. private _storedAlpha;
  37642. private _storedBeta;
  37643. private _storedRadius;
  37644. private _storedTarget;
  37645. private _storedTargetScreenOffset;
  37646. /**
  37647. * Stores the current state of the camera (alpha, beta, radius and target)
  37648. * @returns the camera itself
  37649. */
  37650. storeState(): Camera;
  37651. /**
  37652. * @hidden
  37653. * Restored camera state. You must call storeState() first
  37654. */
  37655. _restoreStateValues(): boolean;
  37656. /** @hidden */
  37657. _isSynchronizedViewMatrix(): boolean;
  37658. /**
  37659. * Attached controls to the current camera.
  37660. * @param element Defines the element the controls should be listened from
  37661. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37662. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37663. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37664. */
  37665. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37666. /**
  37667. * Detach the current controls from the camera.
  37668. * The camera will stop reacting to inputs.
  37669. * @param element Defines the element to stop listening the inputs from
  37670. */
  37671. detachControl(element: HTMLElement): void;
  37672. /** @hidden */
  37673. _checkInputs(): void;
  37674. protected _checkLimits(): void;
  37675. /**
  37676. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37677. */
  37678. rebuildAnglesAndRadius(): void;
  37679. /**
  37680. * Use a position to define the current camera related information like alpha, beta and radius
  37681. * @param position Defines the position to set the camera at
  37682. */
  37683. setPosition(position: Vector3): void;
  37684. /**
  37685. * Defines the target the camera should look at.
  37686. * This will automatically adapt alpha beta and radius to fit within the new target.
  37687. * @param target Defines the new target as a Vector or a mesh
  37688. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37689. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37690. */
  37691. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37692. /** @hidden */
  37693. _getViewMatrix(): Matrix;
  37694. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37695. /**
  37696. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37697. * @param meshes Defines the mesh to zoom on
  37698. * @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)
  37699. */
  37700. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37701. /**
  37702. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37703. * The target will be changed but the radius
  37704. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37705. * @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)
  37706. */
  37707. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37708. min: Vector3;
  37709. max: Vector3;
  37710. distance: number;
  37711. }, doNotUpdateMaxZ?: boolean): void;
  37712. /**
  37713. * @override
  37714. * Override Camera.createRigCamera
  37715. */
  37716. createRigCamera(name: string, cameraIndex: number): Camera;
  37717. /**
  37718. * @hidden
  37719. * @override
  37720. * Override Camera._updateRigCameras
  37721. */
  37722. _updateRigCameras(): void;
  37723. /**
  37724. * Destroy the camera and release the current resources hold by it.
  37725. */
  37726. dispose(): void;
  37727. /**
  37728. * Gets the current object class name.
  37729. * @return the class name
  37730. */
  37731. getClassName(): string;
  37732. }
  37733. }
  37734. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37735. import { Behavior } from "babylonjs/Behaviors/behavior";
  37736. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37737. /**
  37738. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37739. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37740. */
  37741. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37742. /**
  37743. * Gets the name of the behavior.
  37744. */
  37745. readonly name: string;
  37746. private _zoomStopsAnimation;
  37747. private _idleRotationSpeed;
  37748. private _idleRotationWaitTime;
  37749. private _idleRotationSpinupTime;
  37750. /**
  37751. * Sets the flag that indicates if user zooming should stop animation.
  37752. */
  37753. /**
  37754. * Gets the flag that indicates if user zooming should stop animation.
  37755. */
  37756. zoomStopsAnimation: boolean;
  37757. /**
  37758. * Sets the default speed at which the camera rotates around the model.
  37759. */
  37760. /**
  37761. * Gets the default speed at which the camera rotates around the model.
  37762. */
  37763. idleRotationSpeed: number;
  37764. /**
  37765. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37766. */
  37767. /**
  37768. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37769. */
  37770. idleRotationWaitTime: number;
  37771. /**
  37772. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37773. */
  37774. /**
  37775. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37776. */
  37777. idleRotationSpinupTime: number;
  37778. /**
  37779. * Gets a value indicating if the camera is currently rotating because of this behavior
  37780. */
  37781. readonly rotationInProgress: boolean;
  37782. private _onPrePointerObservableObserver;
  37783. private _onAfterCheckInputsObserver;
  37784. private _attachedCamera;
  37785. private _isPointerDown;
  37786. private _lastFrameTime;
  37787. private _lastInteractionTime;
  37788. private _cameraRotationSpeed;
  37789. /**
  37790. * Initializes the behavior.
  37791. */
  37792. init(): void;
  37793. /**
  37794. * Attaches the behavior to its arc rotate camera.
  37795. * @param camera Defines the camera to attach the behavior to
  37796. */
  37797. attach(camera: ArcRotateCamera): void;
  37798. /**
  37799. * Detaches the behavior from its current arc rotate camera.
  37800. */
  37801. detach(): void;
  37802. /**
  37803. * Returns true if user is scrolling.
  37804. * @return true if user is scrolling.
  37805. */
  37806. private _userIsZooming;
  37807. private _lastFrameRadius;
  37808. private _shouldAnimationStopForInteraction;
  37809. /**
  37810. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37811. */
  37812. private _applyUserInteraction;
  37813. private _userIsMoving;
  37814. }
  37815. }
  37816. declare module "babylonjs/Behaviors/Cameras/index" {
  37817. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37818. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37819. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37820. }
  37821. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37822. import { Mesh } from "babylonjs/Meshes/mesh";
  37823. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37824. import { Behavior } from "babylonjs/Behaviors/behavior";
  37825. /**
  37826. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37827. */
  37828. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37829. private ui;
  37830. /**
  37831. * The name of the behavior
  37832. */
  37833. name: string;
  37834. /**
  37835. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37836. */
  37837. distanceAwayFromFace: number;
  37838. /**
  37839. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37840. */
  37841. distanceAwayFromBottomOfFace: number;
  37842. private _faceVectors;
  37843. private _target;
  37844. private _scene;
  37845. private _onRenderObserver;
  37846. private _tmpMatrix;
  37847. private _tmpVector;
  37848. /**
  37849. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37850. * @param ui The transform node that should be attched to the mesh
  37851. */
  37852. constructor(ui: TransformNode);
  37853. /**
  37854. * Initializes the behavior
  37855. */
  37856. init(): void;
  37857. private _closestFace;
  37858. private _zeroVector;
  37859. private _lookAtTmpMatrix;
  37860. private _lookAtToRef;
  37861. /**
  37862. * Attaches the AttachToBoxBehavior to the passed in mesh
  37863. * @param target The mesh that the specified node will be attached to
  37864. */
  37865. attach(target: Mesh): void;
  37866. /**
  37867. * Detaches the behavior from the mesh
  37868. */
  37869. detach(): void;
  37870. }
  37871. }
  37872. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37873. import { Behavior } from "babylonjs/Behaviors/behavior";
  37874. import { Mesh } from "babylonjs/Meshes/mesh";
  37875. /**
  37876. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37877. */
  37878. export class FadeInOutBehavior implements Behavior<Mesh> {
  37879. /**
  37880. * Time in milliseconds to delay before fading in (Default: 0)
  37881. */
  37882. delay: number;
  37883. /**
  37884. * Time in milliseconds for the mesh to fade in (Default: 300)
  37885. */
  37886. fadeInTime: number;
  37887. private _millisecondsPerFrame;
  37888. private _hovered;
  37889. private _hoverValue;
  37890. private _ownerNode;
  37891. /**
  37892. * Instatiates the FadeInOutBehavior
  37893. */
  37894. constructor();
  37895. /**
  37896. * The name of the behavior
  37897. */
  37898. readonly name: string;
  37899. /**
  37900. * Initializes the behavior
  37901. */
  37902. init(): void;
  37903. /**
  37904. * Attaches the fade behavior on the passed in mesh
  37905. * @param ownerNode The mesh that will be faded in/out once attached
  37906. */
  37907. attach(ownerNode: Mesh): void;
  37908. /**
  37909. * Detaches the behavior from the mesh
  37910. */
  37911. detach(): void;
  37912. /**
  37913. * Triggers the mesh to begin fading in or out
  37914. * @param value if the object should fade in or out (true to fade in)
  37915. */
  37916. fadeIn(value: boolean): void;
  37917. private _update;
  37918. private _setAllVisibility;
  37919. }
  37920. }
  37921. declare module "babylonjs/Misc/pivotTools" {
  37922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37923. /**
  37924. * Class containing a set of static utilities functions for managing Pivots
  37925. * @hidden
  37926. */
  37927. export class PivotTools {
  37928. private static _PivotCached;
  37929. private static _OldPivotPoint;
  37930. private static _PivotTranslation;
  37931. private static _PivotTmpVector;
  37932. /** @hidden */
  37933. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  37934. /** @hidden */
  37935. static _RestorePivotPoint(mesh: AbstractMesh): void;
  37936. }
  37937. }
  37938. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  37939. import { Scene } from "babylonjs/scene";
  37940. import { Vector4 } from "babylonjs/Maths/math.vector";
  37941. import { Mesh } from "babylonjs/Meshes/mesh";
  37942. import { Nullable } from "babylonjs/types";
  37943. import { Plane } from "babylonjs/Maths/math.plane";
  37944. /**
  37945. * Class containing static functions to help procedurally build meshes
  37946. */
  37947. export class PlaneBuilder {
  37948. /**
  37949. * Creates a plane mesh
  37950. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  37951. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  37952. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  37953. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  37954. * * 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
  37955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  37956. * @param name defines the name of the mesh
  37957. * @param options defines the options used to create the mesh
  37958. * @param scene defines the hosting scene
  37959. * @returns the plane mesh
  37960. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  37961. */
  37962. static CreatePlane(name: string, options: {
  37963. size?: number;
  37964. width?: number;
  37965. height?: number;
  37966. sideOrientation?: number;
  37967. frontUVs?: Vector4;
  37968. backUVs?: Vector4;
  37969. updatable?: boolean;
  37970. sourcePlane?: Plane;
  37971. }, scene?: Nullable<Scene>): Mesh;
  37972. }
  37973. }
  37974. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  37975. import { Behavior } from "babylonjs/Behaviors/behavior";
  37976. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37977. import { Observable } from "babylonjs/Misc/observable";
  37978. import { Vector3 } from "babylonjs/Maths/math.vector";
  37979. import { Ray } from "babylonjs/Culling/ray";
  37980. import "babylonjs/Meshes/Builders/planeBuilder";
  37981. /**
  37982. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  37983. */
  37984. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  37985. private static _AnyMouseID;
  37986. /**
  37987. * Abstract mesh the behavior is set on
  37988. */
  37989. attachedNode: AbstractMesh;
  37990. private _dragPlane;
  37991. private _scene;
  37992. private _pointerObserver;
  37993. private _beforeRenderObserver;
  37994. private static _planeScene;
  37995. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  37996. /**
  37997. * 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)
  37998. */
  37999. maxDragAngle: number;
  38000. /**
  38001. * @hidden
  38002. */
  38003. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38004. /**
  38005. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38006. */
  38007. currentDraggingPointerID: number;
  38008. /**
  38009. * The last position where the pointer hit the drag plane in world space
  38010. */
  38011. lastDragPosition: Vector3;
  38012. /**
  38013. * If the behavior is currently in a dragging state
  38014. */
  38015. dragging: boolean;
  38016. /**
  38017. * 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)
  38018. */
  38019. dragDeltaRatio: number;
  38020. /**
  38021. * If the drag plane orientation should be updated during the dragging (Default: true)
  38022. */
  38023. updateDragPlane: boolean;
  38024. private _debugMode;
  38025. private _moving;
  38026. /**
  38027. * Fires each time the attached mesh is dragged with the pointer
  38028. * * delta between last drag position and current drag position in world space
  38029. * * dragDistance along the drag axis
  38030. * * dragPlaneNormal normal of the current drag plane used during the drag
  38031. * * dragPlanePoint in world space where the drag intersects the drag plane
  38032. */
  38033. onDragObservable: Observable<{
  38034. delta: Vector3;
  38035. dragPlanePoint: Vector3;
  38036. dragPlaneNormal: Vector3;
  38037. dragDistance: number;
  38038. pointerId: number;
  38039. }>;
  38040. /**
  38041. * Fires each time a drag begins (eg. mouse down on mesh)
  38042. */
  38043. onDragStartObservable: Observable<{
  38044. dragPlanePoint: Vector3;
  38045. pointerId: number;
  38046. }>;
  38047. /**
  38048. * Fires each time a drag ends (eg. mouse release after drag)
  38049. */
  38050. onDragEndObservable: Observable<{
  38051. dragPlanePoint: Vector3;
  38052. pointerId: number;
  38053. }>;
  38054. /**
  38055. * If the attached mesh should be moved when dragged
  38056. */
  38057. moveAttached: boolean;
  38058. /**
  38059. * If the drag behavior will react to drag events (Default: true)
  38060. */
  38061. enabled: boolean;
  38062. /**
  38063. * If pointer events should start and release the drag (Default: true)
  38064. */
  38065. startAndReleaseDragOnPointerEvents: boolean;
  38066. /**
  38067. * If camera controls should be detached during the drag
  38068. */
  38069. detachCameraControls: boolean;
  38070. /**
  38071. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38072. */
  38073. useObjectOrienationForDragging: boolean;
  38074. private _options;
  38075. /**
  38076. * Creates a pointer drag behavior that can be attached to a mesh
  38077. * @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)
  38078. */
  38079. constructor(options?: {
  38080. dragAxis?: Vector3;
  38081. dragPlaneNormal?: Vector3;
  38082. });
  38083. /**
  38084. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38085. */
  38086. validateDrag: (targetPosition: Vector3) => boolean;
  38087. /**
  38088. * The name of the behavior
  38089. */
  38090. readonly name: string;
  38091. /**
  38092. * Initializes the behavior
  38093. */
  38094. init(): void;
  38095. private _tmpVector;
  38096. private _alternatePickedPoint;
  38097. private _worldDragAxis;
  38098. private _targetPosition;
  38099. private _attachedElement;
  38100. /**
  38101. * Attaches the drag behavior the passed in mesh
  38102. * @param ownerNode The mesh that will be dragged around once attached
  38103. * @param predicate Predicate to use for pick filtering
  38104. */
  38105. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38106. /**
  38107. * Force relase the drag action by code.
  38108. */
  38109. releaseDrag(): void;
  38110. private _startDragRay;
  38111. private _lastPointerRay;
  38112. /**
  38113. * Simulates the start of a pointer drag event on the behavior
  38114. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38115. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38116. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38117. */
  38118. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38119. private _startDrag;
  38120. private _dragDelta;
  38121. private _moveDrag;
  38122. private _pickWithRayOnDragPlane;
  38123. private _pointA;
  38124. private _pointB;
  38125. private _pointC;
  38126. private _lineA;
  38127. private _lineB;
  38128. private _localAxis;
  38129. private _lookAt;
  38130. private _updateDragPlanePosition;
  38131. /**
  38132. * Detaches the behavior from the mesh
  38133. */
  38134. detach(): void;
  38135. }
  38136. }
  38137. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38138. import { Mesh } from "babylonjs/Meshes/mesh";
  38139. import { Behavior } from "babylonjs/Behaviors/behavior";
  38140. /**
  38141. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38142. */
  38143. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38144. private _dragBehaviorA;
  38145. private _dragBehaviorB;
  38146. private _startDistance;
  38147. private _initialScale;
  38148. private _targetScale;
  38149. private _ownerNode;
  38150. private _sceneRenderObserver;
  38151. /**
  38152. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38153. */
  38154. constructor();
  38155. /**
  38156. * The name of the behavior
  38157. */
  38158. readonly name: string;
  38159. /**
  38160. * Initializes the behavior
  38161. */
  38162. init(): void;
  38163. private _getCurrentDistance;
  38164. /**
  38165. * Attaches the scale behavior the passed in mesh
  38166. * @param ownerNode The mesh that will be scaled around once attached
  38167. */
  38168. attach(ownerNode: Mesh): void;
  38169. /**
  38170. * Detaches the behavior from the mesh
  38171. */
  38172. detach(): void;
  38173. }
  38174. }
  38175. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38176. import { Behavior } from "babylonjs/Behaviors/behavior";
  38177. import { Mesh } from "babylonjs/Meshes/mesh";
  38178. import { Observable } from "babylonjs/Misc/observable";
  38179. /**
  38180. * 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
  38181. */
  38182. export class SixDofDragBehavior implements Behavior<Mesh> {
  38183. private static _virtualScene;
  38184. private _ownerNode;
  38185. private _sceneRenderObserver;
  38186. private _scene;
  38187. private _targetPosition;
  38188. private _virtualOriginMesh;
  38189. private _virtualDragMesh;
  38190. private _pointerObserver;
  38191. private _moving;
  38192. private _startingOrientation;
  38193. /**
  38194. * 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)
  38195. */
  38196. private zDragFactor;
  38197. /**
  38198. * If the object should rotate to face the drag origin
  38199. */
  38200. rotateDraggedObject: boolean;
  38201. /**
  38202. * If the behavior is currently in a dragging state
  38203. */
  38204. dragging: boolean;
  38205. /**
  38206. * 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)
  38207. */
  38208. dragDeltaRatio: number;
  38209. /**
  38210. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38211. */
  38212. currentDraggingPointerID: number;
  38213. /**
  38214. * If camera controls should be detached during the drag
  38215. */
  38216. detachCameraControls: boolean;
  38217. /**
  38218. * Fires each time a drag starts
  38219. */
  38220. onDragStartObservable: Observable<{}>;
  38221. /**
  38222. * Fires each time a drag ends (eg. mouse release after drag)
  38223. */
  38224. onDragEndObservable: Observable<{}>;
  38225. /**
  38226. * 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
  38227. */
  38228. constructor();
  38229. /**
  38230. * The name of the behavior
  38231. */
  38232. readonly name: string;
  38233. /**
  38234. * Initializes the behavior
  38235. */
  38236. init(): void;
  38237. /**
  38238. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38239. */
  38240. private readonly _pointerCamera;
  38241. /**
  38242. * Attaches the scale behavior the passed in mesh
  38243. * @param ownerNode The mesh that will be scaled around once attached
  38244. */
  38245. attach(ownerNode: Mesh): void;
  38246. /**
  38247. * Detaches the behavior from the mesh
  38248. */
  38249. detach(): void;
  38250. }
  38251. }
  38252. declare module "babylonjs/Behaviors/Meshes/index" {
  38253. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38254. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38255. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38256. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38257. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38258. }
  38259. declare module "babylonjs/Behaviors/index" {
  38260. export * from "babylonjs/Behaviors/behavior";
  38261. export * from "babylonjs/Behaviors/Cameras/index";
  38262. export * from "babylonjs/Behaviors/Meshes/index";
  38263. }
  38264. declare module "babylonjs/Bones/boneIKController" {
  38265. import { Bone } from "babylonjs/Bones/bone";
  38266. import { Vector3 } from "babylonjs/Maths/math.vector";
  38267. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38268. import { Nullable } from "babylonjs/types";
  38269. /**
  38270. * Class used to apply inverse kinematics to bones
  38271. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38272. */
  38273. export class BoneIKController {
  38274. private static _tmpVecs;
  38275. private static _tmpQuat;
  38276. private static _tmpMats;
  38277. /**
  38278. * Gets or sets the target mesh
  38279. */
  38280. targetMesh: AbstractMesh;
  38281. /** Gets or sets the mesh used as pole */
  38282. poleTargetMesh: AbstractMesh;
  38283. /**
  38284. * Gets or sets the bone used as pole
  38285. */
  38286. poleTargetBone: Nullable<Bone>;
  38287. /**
  38288. * Gets or sets the target position
  38289. */
  38290. targetPosition: Vector3;
  38291. /**
  38292. * Gets or sets the pole target position
  38293. */
  38294. poleTargetPosition: Vector3;
  38295. /**
  38296. * Gets or sets the pole target local offset
  38297. */
  38298. poleTargetLocalOffset: Vector3;
  38299. /**
  38300. * Gets or sets the pole angle
  38301. */
  38302. poleAngle: number;
  38303. /**
  38304. * Gets or sets the mesh associated with the controller
  38305. */
  38306. mesh: AbstractMesh;
  38307. /**
  38308. * 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)
  38309. */
  38310. slerpAmount: number;
  38311. private _bone1Quat;
  38312. private _bone1Mat;
  38313. private _bone2Ang;
  38314. private _bone1;
  38315. private _bone2;
  38316. private _bone1Length;
  38317. private _bone2Length;
  38318. private _maxAngle;
  38319. private _maxReach;
  38320. private _rightHandedSystem;
  38321. private _bendAxis;
  38322. private _slerping;
  38323. private _adjustRoll;
  38324. /**
  38325. * Gets or sets maximum allowed angle
  38326. */
  38327. maxAngle: number;
  38328. /**
  38329. * Creates a new BoneIKController
  38330. * @param mesh defines the mesh to control
  38331. * @param bone defines the bone to control
  38332. * @param options defines options to set up the controller
  38333. */
  38334. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38335. targetMesh?: AbstractMesh;
  38336. poleTargetMesh?: AbstractMesh;
  38337. poleTargetBone?: Bone;
  38338. poleTargetLocalOffset?: Vector3;
  38339. poleAngle?: number;
  38340. bendAxis?: Vector3;
  38341. maxAngle?: number;
  38342. slerpAmount?: number;
  38343. });
  38344. private _setMaxAngle;
  38345. /**
  38346. * Force the controller to update the bones
  38347. */
  38348. update(): void;
  38349. }
  38350. }
  38351. declare module "babylonjs/Bones/boneLookController" {
  38352. import { Vector3 } from "babylonjs/Maths/math.vector";
  38353. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38354. import { Bone } from "babylonjs/Bones/bone";
  38355. import { Space } from "babylonjs/Maths/math.axis";
  38356. /**
  38357. * Class used to make a bone look toward a point in space
  38358. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38359. */
  38360. export class BoneLookController {
  38361. private static _tmpVecs;
  38362. private static _tmpQuat;
  38363. private static _tmpMats;
  38364. /**
  38365. * The target Vector3 that the bone will look at
  38366. */
  38367. target: Vector3;
  38368. /**
  38369. * The mesh that the bone is attached to
  38370. */
  38371. mesh: AbstractMesh;
  38372. /**
  38373. * The bone that will be looking to the target
  38374. */
  38375. bone: Bone;
  38376. /**
  38377. * The up axis of the coordinate system that is used when the bone is rotated
  38378. */
  38379. upAxis: Vector3;
  38380. /**
  38381. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38382. */
  38383. upAxisSpace: Space;
  38384. /**
  38385. * Used to make an adjustment to the yaw of the bone
  38386. */
  38387. adjustYaw: number;
  38388. /**
  38389. * Used to make an adjustment to the pitch of the bone
  38390. */
  38391. adjustPitch: number;
  38392. /**
  38393. * Used to make an adjustment to the roll of the bone
  38394. */
  38395. adjustRoll: number;
  38396. /**
  38397. * 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)
  38398. */
  38399. slerpAmount: number;
  38400. private _minYaw;
  38401. private _maxYaw;
  38402. private _minPitch;
  38403. private _maxPitch;
  38404. private _minYawSin;
  38405. private _minYawCos;
  38406. private _maxYawSin;
  38407. private _maxYawCos;
  38408. private _midYawConstraint;
  38409. private _minPitchTan;
  38410. private _maxPitchTan;
  38411. private _boneQuat;
  38412. private _slerping;
  38413. private _transformYawPitch;
  38414. private _transformYawPitchInv;
  38415. private _firstFrameSkipped;
  38416. private _yawRange;
  38417. private _fowardAxis;
  38418. /**
  38419. * Gets or sets the minimum yaw angle that the bone can look to
  38420. */
  38421. minYaw: number;
  38422. /**
  38423. * Gets or sets the maximum yaw angle that the bone can look to
  38424. */
  38425. maxYaw: number;
  38426. /**
  38427. * Gets or sets the minimum pitch angle that the bone can look to
  38428. */
  38429. minPitch: number;
  38430. /**
  38431. * Gets or sets the maximum pitch angle that the bone can look to
  38432. */
  38433. maxPitch: number;
  38434. /**
  38435. * Create a BoneLookController
  38436. * @param mesh the mesh that the bone belongs to
  38437. * @param bone the bone that will be looking to the target
  38438. * @param target the target Vector3 to look at
  38439. * @param options optional settings:
  38440. * * maxYaw: the maximum angle the bone will yaw to
  38441. * * minYaw: the minimum angle the bone will yaw to
  38442. * * maxPitch: the maximum angle the bone will pitch to
  38443. * * minPitch: the minimum angle the bone will yaw to
  38444. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38445. * * upAxis: the up axis of the coordinate system
  38446. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38447. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38448. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38449. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38450. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38451. * * adjustRoll: used to make an adjustment to the roll of the bone
  38452. **/
  38453. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38454. maxYaw?: number;
  38455. minYaw?: number;
  38456. maxPitch?: number;
  38457. minPitch?: number;
  38458. slerpAmount?: number;
  38459. upAxis?: Vector3;
  38460. upAxisSpace?: Space;
  38461. yawAxis?: Vector3;
  38462. pitchAxis?: Vector3;
  38463. adjustYaw?: number;
  38464. adjustPitch?: number;
  38465. adjustRoll?: number;
  38466. });
  38467. /**
  38468. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38469. */
  38470. update(): void;
  38471. private _getAngleDiff;
  38472. private _getAngleBetween;
  38473. private _isAngleBetween;
  38474. }
  38475. }
  38476. declare module "babylonjs/Bones/index" {
  38477. export * from "babylonjs/Bones/bone";
  38478. export * from "babylonjs/Bones/boneIKController";
  38479. export * from "babylonjs/Bones/boneLookController";
  38480. export * from "babylonjs/Bones/skeleton";
  38481. }
  38482. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38483. import { Nullable } from "babylonjs/types";
  38484. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38485. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38486. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38487. /**
  38488. * Manage the gamepad inputs to control an arc rotate camera.
  38489. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38490. */
  38491. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38492. /**
  38493. * Defines the camera the input is attached to.
  38494. */
  38495. camera: ArcRotateCamera;
  38496. /**
  38497. * Defines the gamepad the input is gathering event from.
  38498. */
  38499. gamepad: Nullable<Gamepad>;
  38500. /**
  38501. * Defines the gamepad rotation sensiblity.
  38502. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38503. */
  38504. gamepadRotationSensibility: number;
  38505. /**
  38506. * Defines the gamepad move sensiblity.
  38507. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38508. */
  38509. gamepadMoveSensibility: number;
  38510. private _yAxisScale;
  38511. /**
  38512. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  38513. */
  38514. invertYAxis: boolean;
  38515. private _onGamepadConnectedObserver;
  38516. private _onGamepadDisconnectedObserver;
  38517. /**
  38518. * Attach the input controls to a specific dom element to get the input from.
  38519. * @param element Defines the element the controls should be listened from
  38520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38521. */
  38522. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38523. /**
  38524. * Detach the current controls from the specified dom element.
  38525. * @param element Defines the element to stop listening the inputs from
  38526. */
  38527. detachControl(element: Nullable<HTMLElement>): void;
  38528. /**
  38529. * Update the current camera state depending on the inputs that have been used this frame.
  38530. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38531. */
  38532. checkInputs(): void;
  38533. /**
  38534. * Gets the class name of the current intput.
  38535. * @returns the class name
  38536. */
  38537. getClassName(): string;
  38538. /**
  38539. * Get the friendly name associated with the input class.
  38540. * @returns the input friendly name
  38541. */
  38542. getSimpleName(): string;
  38543. }
  38544. }
  38545. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38546. import { Nullable } from "babylonjs/types";
  38547. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38548. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38549. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38550. interface ArcRotateCameraInputsManager {
  38551. /**
  38552. * Add orientation input support to the input manager.
  38553. * @returns the current input manager
  38554. */
  38555. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38556. }
  38557. }
  38558. /**
  38559. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38561. */
  38562. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38563. /**
  38564. * Defines the camera the input is attached to.
  38565. */
  38566. camera: ArcRotateCamera;
  38567. /**
  38568. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38569. */
  38570. alphaCorrection: number;
  38571. /**
  38572. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38573. */
  38574. gammaCorrection: number;
  38575. private _alpha;
  38576. private _gamma;
  38577. private _dirty;
  38578. private _deviceOrientationHandler;
  38579. /**
  38580. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38581. */
  38582. constructor();
  38583. /**
  38584. * Attach the input controls to a specific dom element to get the input from.
  38585. * @param element Defines the element the controls should be listened from
  38586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38587. */
  38588. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38589. /** @hidden */
  38590. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38591. /**
  38592. * Update the current camera state depending on the inputs that have been used this frame.
  38593. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38594. */
  38595. checkInputs(): void;
  38596. /**
  38597. * Detach the current controls from the specified dom element.
  38598. * @param element Defines the element to stop listening the inputs from
  38599. */
  38600. detachControl(element: Nullable<HTMLElement>): void;
  38601. /**
  38602. * Gets the class name of the current intput.
  38603. * @returns the class name
  38604. */
  38605. getClassName(): string;
  38606. /**
  38607. * Get the friendly name associated with the input class.
  38608. * @returns the input friendly name
  38609. */
  38610. getSimpleName(): string;
  38611. }
  38612. }
  38613. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38614. import { Nullable } from "babylonjs/types";
  38615. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38616. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38617. /**
  38618. * Listen to mouse events to control the camera.
  38619. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38620. */
  38621. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38622. /**
  38623. * Defines the camera the input is attached to.
  38624. */
  38625. camera: FlyCamera;
  38626. /**
  38627. * Defines if touch is enabled. (Default is true.)
  38628. */
  38629. touchEnabled: boolean;
  38630. /**
  38631. * Defines the buttons associated with the input to handle camera rotation.
  38632. */
  38633. buttons: number[];
  38634. /**
  38635. * Assign buttons for Yaw control.
  38636. */
  38637. buttonsYaw: number[];
  38638. /**
  38639. * Assign buttons for Pitch control.
  38640. */
  38641. buttonsPitch: number[];
  38642. /**
  38643. * Assign buttons for Roll control.
  38644. */
  38645. buttonsRoll: number[];
  38646. /**
  38647. * Detect if any button is being pressed while mouse is moved.
  38648. * -1 = Mouse locked.
  38649. * 0 = Left button.
  38650. * 1 = Middle Button.
  38651. * 2 = Right Button.
  38652. */
  38653. activeButton: number;
  38654. /**
  38655. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38656. * Higher values reduce its sensitivity.
  38657. */
  38658. angularSensibility: number;
  38659. private _mousemoveCallback;
  38660. private _observer;
  38661. private _rollObserver;
  38662. private previousPosition;
  38663. private noPreventDefault;
  38664. private element;
  38665. /**
  38666. * Listen to mouse events to control the camera.
  38667. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38668. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38669. */
  38670. constructor(touchEnabled?: boolean);
  38671. /**
  38672. * Attach the mouse control to the HTML DOM element.
  38673. * @param element Defines the element that listens to the input events.
  38674. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38675. */
  38676. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38677. /**
  38678. * Detach the current controls from the specified dom element.
  38679. * @param element Defines the element to stop listening the inputs from
  38680. */
  38681. detachControl(element: Nullable<HTMLElement>): void;
  38682. /**
  38683. * Gets the class name of the current input.
  38684. * @returns the class name.
  38685. */
  38686. getClassName(): string;
  38687. /**
  38688. * Get the friendly name associated with the input class.
  38689. * @returns the input's friendly name.
  38690. */
  38691. getSimpleName(): string;
  38692. private _pointerInput;
  38693. private _onMouseMove;
  38694. /**
  38695. * Rotate camera by mouse offset.
  38696. */
  38697. private rotateCamera;
  38698. }
  38699. }
  38700. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38701. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38702. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38703. /**
  38704. * Default Inputs manager for the FlyCamera.
  38705. * It groups all the default supported inputs for ease of use.
  38706. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38707. */
  38708. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38709. /**
  38710. * Instantiates a new FlyCameraInputsManager.
  38711. * @param camera Defines the camera the inputs belong to.
  38712. */
  38713. constructor(camera: FlyCamera);
  38714. /**
  38715. * Add keyboard input support to the input manager.
  38716. * @returns the new FlyCameraKeyboardMoveInput().
  38717. */
  38718. addKeyboard(): FlyCameraInputsManager;
  38719. /**
  38720. * Add mouse input support to the input manager.
  38721. * @param touchEnabled Enable touch screen support.
  38722. * @returns the new FlyCameraMouseInput().
  38723. */
  38724. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38725. }
  38726. }
  38727. declare module "babylonjs/Cameras/flyCamera" {
  38728. import { Scene } from "babylonjs/scene";
  38729. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38730. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38731. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38732. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38733. /**
  38734. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38735. * such as in a 3D Space Shooter or a Flight Simulator.
  38736. */
  38737. export class FlyCamera extends TargetCamera {
  38738. /**
  38739. * Define the collision ellipsoid of the camera.
  38740. * This is helpful for simulating a camera body, like a player's body.
  38741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38742. */
  38743. ellipsoid: Vector3;
  38744. /**
  38745. * Define an offset for the position of the ellipsoid around the camera.
  38746. * This can be helpful if the camera is attached away from the player's body center,
  38747. * such as at its head.
  38748. */
  38749. ellipsoidOffset: Vector3;
  38750. /**
  38751. * Enable or disable collisions of the camera with the rest of the scene objects.
  38752. */
  38753. checkCollisions: boolean;
  38754. /**
  38755. * Enable or disable gravity on the camera.
  38756. */
  38757. applyGravity: boolean;
  38758. /**
  38759. * Define the current direction the camera is moving to.
  38760. */
  38761. cameraDirection: Vector3;
  38762. /**
  38763. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38764. * This overrides and empties cameraRotation.
  38765. */
  38766. rotationQuaternion: Quaternion;
  38767. /**
  38768. * Track Roll to maintain the wanted Rolling when looking around.
  38769. */
  38770. _trackRoll: number;
  38771. /**
  38772. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38773. */
  38774. rollCorrect: number;
  38775. /**
  38776. * Mimic a banked turn, Rolling the camera when Yawing.
  38777. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38778. */
  38779. bankedTurn: boolean;
  38780. /**
  38781. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38782. */
  38783. bankedTurnLimit: number;
  38784. /**
  38785. * Value of 0 disables the banked Roll.
  38786. * Value of 1 is equal to the Yaw angle in radians.
  38787. */
  38788. bankedTurnMultiplier: number;
  38789. /**
  38790. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38791. */
  38792. inputs: FlyCameraInputsManager;
  38793. /**
  38794. * Gets the input sensibility for mouse input.
  38795. * Higher values reduce sensitivity.
  38796. */
  38797. /**
  38798. * Sets the input sensibility for a mouse input.
  38799. * Higher values reduce sensitivity.
  38800. */
  38801. angularSensibility: number;
  38802. /**
  38803. * Get the keys for camera movement forward.
  38804. */
  38805. /**
  38806. * Set the keys for camera movement forward.
  38807. */
  38808. keysForward: number[];
  38809. /**
  38810. * Get the keys for camera movement backward.
  38811. */
  38812. keysBackward: number[];
  38813. /**
  38814. * Get the keys for camera movement up.
  38815. */
  38816. /**
  38817. * Set the keys for camera movement up.
  38818. */
  38819. keysUp: number[];
  38820. /**
  38821. * Get the keys for camera movement down.
  38822. */
  38823. /**
  38824. * Set the keys for camera movement down.
  38825. */
  38826. keysDown: number[];
  38827. /**
  38828. * Get the keys for camera movement left.
  38829. */
  38830. /**
  38831. * Set the keys for camera movement left.
  38832. */
  38833. keysLeft: number[];
  38834. /**
  38835. * Set the keys for camera movement right.
  38836. */
  38837. /**
  38838. * Set the keys for camera movement right.
  38839. */
  38840. keysRight: number[];
  38841. /**
  38842. * Event raised when the camera collides with a mesh in the scene.
  38843. */
  38844. onCollide: (collidedMesh: AbstractMesh) => void;
  38845. private _collider;
  38846. private _needMoveForGravity;
  38847. private _oldPosition;
  38848. private _diffPosition;
  38849. private _newPosition;
  38850. /** @hidden */
  38851. _localDirection: Vector3;
  38852. /** @hidden */
  38853. _transformedDirection: Vector3;
  38854. /**
  38855. * Instantiates a FlyCamera.
  38856. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38857. * such as in a 3D Space Shooter or a Flight Simulator.
  38858. * @param name Define the name of the camera in the scene.
  38859. * @param position Define the starting position of the camera in the scene.
  38860. * @param scene Define the scene the camera belongs to.
  38861. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38862. */
  38863. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38864. /**
  38865. * Attach a control to the HTML DOM element.
  38866. * @param element Defines the element that listens to the input events.
  38867. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38868. */
  38869. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38870. /**
  38871. * Detach a control from the HTML DOM element.
  38872. * The camera will stop reacting to that input.
  38873. * @param element Defines the element that listens to the input events.
  38874. */
  38875. detachControl(element: HTMLElement): void;
  38876. private _collisionMask;
  38877. /**
  38878. * Get the mask that the camera ignores in collision events.
  38879. */
  38880. /**
  38881. * Set the mask that the camera ignores in collision events.
  38882. */
  38883. collisionMask: number;
  38884. /** @hidden */
  38885. _collideWithWorld(displacement: Vector3): void;
  38886. /** @hidden */
  38887. private _onCollisionPositionChange;
  38888. /** @hidden */
  38889. _checkInputs(): void;
  38890. /** @hidden */
  38891. _decideIfNeedsToMove(): boolean;
  38892. /** @hidden */
  38893. _updatePosition(): void;
  38894. /**
  38895. * Restore the Roll to its target value at the rate specified.
  38896. * @param rate - Higher means slower restoring.
  38897. * @hidden
  38898. */
  38899. restoreRoll(rate: number): void;
  38900. /**
  38901. * Destroy the camera and release the current resources held by it.
  38902. */
  38903. dispose(): void;
  38904. /**
  38905. * Get the current object class name.
  38906. * @returns the class name.
  38907. */
  38908. getClassName(): string;
  38909. }
  38910. }
  38911. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38912. import { Nullable } from "babylonjs/types";
  38913. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38914. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38915. /**
  38916. * Listen to keyboard events to control the camera.
  38917. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38918. */
  38919. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  38920. /**
  38921. * Defines the camera the input is attached to.
  38922. */
  38923. camera: FlyCamera;
  38924. /**
  38925. * The list of keyboard keys used to control the forward move of the camera.
  38926. */
  38927. keysForward: number[];
  38928. /**
  38929. * The list of keyboard keys used to control the backward move of the camera.
  38930. */
  38931. keysBackward: number[];
  38932. /**
  38933. * The list of keyboard keys used to control the forward move of the camera.
  38934. */
  38935. keysUp: number[];
  38936. /**
  38937. * The list of keyboard keys used to control the backward move of the camera.
  38938. */
  38939. keysDown: number[];
  38940. /**
  38941. * The list of keyboard keys used to control the right strafe move of the camera.
  38942. */
  38943. keysRight: number[];
  38944. /**
  38945. * The list of keyboard keys used to control the left strafe move of the camera.
  38946. */
  38947. keysLeft: number[];
  38948. private _keys;
  38949. private _onCanvasBlurObserver;
  38950. private _onKeyboardObserver;
  38951. private _engine;
  38952. private _scene;
  38953. /**
  38954. * Attach the input controls to a specific dom element to get the input from.
  38955. * @param element Defines the element the controls should be listened from
  38956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38957. */
  38958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38959. /**
  38960. * Detach the current controls from the specified dom element.
  38961. * @param element Defines the element to stop listening the inputs from
  38962. */
  38963. detachControl(element: Nullable<HTMLElement>): void;
  38964. /**
  38965. * Gets the class name of the current intput.
  38966. * @returns the class name
  38967. */
  38968. getClassName(): string;
  38969. /** @hidden */
  38970. _onLostFocus(e: FocusEvent): void;
  38971. /**
  38972. * Get the friendly name associated with the input class.
  38973. * @returns the input friendly name
  38974. */
  38975. getSimpleName(): string;
  38976. /**
  38977. * Update the current camera state depending on the inputs that have been used this frame.
  38978. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38979. */
  38980. checkInputs(): void;
  38981. }
  38982. }
  38983. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  38984. import { Nullable } from "babylonjs/types";
  38985. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38986. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38987. /**
  38988. * Manage the mouse wheel inputs to control a follow camera.
  38989. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38990. */
  38991. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  38992. /**
  38993. * Defines the camera the input is attached to.
  38994. */
  38995. camera: FollowCamera;
  38996. /**
  38997. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  38998. */
  38999. axisControlRadius: boolean;
  39000. /**
  39001. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39002. */
  39003. axisControlHeight: boolean;
  39004. /**
  39005. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39006. */
  39007. axisControlRotation: boolean;
  39008. /**
  39009. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39010. * relation to mouseWheel events.
  39011. */
  39012. wheelPrecision: number;
  39013. /**
  39014. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39015. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39016. */
  39017. wheelDeltaPercentage: number;
  39018. private _wheel;
  39019. private _observer;
  39020. /**
  39021. * Attach the input controls to a specific dom element to get the input from.
  39022. * @param element Defines the element the controls should be listened from
  39023. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39024. */
  39025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39026. /**
  39027. * Detach the current controls from the specified dom element.
  39028. * @param element Defines the element to stop listening the inputs from
  39029. */
  39030. detachControl(element: Nullable<HTMLElement>): void;
  39031. /**
  39032. * Gets the class name of the current intput.
  39033. * @returns the class name
  39034. */
  39035. getClassName(): string;
  39036. /**
  39037. * Get the friendly name associated with the input class.
  39038. * @returns the input friendly name
  39039. */
  39040. getSimpleName(): string;
  39041. }
  39042. }
  39043. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39044. import { Nullable } from "babylonjs/types";
  39045. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39046. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39047. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39048. /**
  39049. * Manage the pointers inputs to control an follow camera.
  39050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39051. */
  39052. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39053. /**
  39054. * Defines the camera the input is attached to.
  39055. */
  39056. camera: FollowCamera;
  39057. /**
  39058. * Gets the class name of the current input.
  39059. * @returns the class name
  39060. */
  39061. getClassName(): string;
  39062. /**
  39063. * Defines the pointer angular sensibility along the X axis or how fast is
  39064. * the camera rotating.
  39065. * A negative number will reverse the axis direction.
  39066. */
  39067. angularSensibilityX: number;
  39068. /**
  39069. * Defines the pointer angular sensibility along the Y axis or how fast is
  39070. * the camera rotating.
  39071. * A negative number will reverse the axis direction.
  39072. */
  39073. angularSensibilityY: number;
  39074. /**
  39075. * Defines the pointer pinch precision or how fast is the camera zooming.
  39076. * A negative number will reverse the axis direction.
  39077. */
  39078. pinchPrecision: number;
  39079. /**
  39080. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39081. * from 0.
  39082. * It defines the percentage of current camera.radius to use as delta when
  39083. * pinch zoom is used.
  39084. */
  39085. pinchDeltaPercentage: number;
  39086. /**
  39087. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39088. */
  39089. axisXControlRadius: boolean;
  39090. /**
  39091. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39092. */
  39093. axisXControlHeight: boolean;
  39094. /**
  39095. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39096. */
  39097. axisXControlRotation: boolean;
  39098. /**
  39099. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39100. */
  39101. axisYControlRadius: boolean;
  39102. /**
  39103. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39104. */
  39105. axisYControlHeight: boolean;
  39106. /**
  39107. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39108. */
  39109. axisYControlRotation: boolean;
  39110. /**
  39111. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39112. */
  39113. axisPinchControlRadius: boolean;
  39114. /**
  39115. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39116. */
  39117. axisPinchControlHeight: boolean;
  39118. /**
  39119. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39120. */
  39121. axisPinchControlRotation: boolean;
  39122. /**
  39123. * Log error messages if basic misconfiguration has occurred.
  39124. */
  39125. warningEnable: boolean;
  39126. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39127. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39128. private _warningCounter;
  39129. private _warning;
  39130. }
  39131. }
  39132. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39133. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39134. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39135. /**
  39136. * Default Inputs manager for the FollowCamera.
  39137. * It groups all the default supported inputs for ease of use.
  39138. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39139. */
  39140. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39141. /**
  39142. * Instantiates a new FollowCameraInputsManager.
  39143. * @param camera Defines the camera the inputs belong to
  39144. */
  39145. constructor(camera: FollowCamera);
  39146. /**
  39147. * Add keyboard input support to the input manager.
  39148. * @returns the current input manager
  39149. */
  39150. addKeyboard(): FollowCameraInputsManager;
  39151. /**
  39152. * Add mouse wheel input support to the input manager.
  39153. * @returns the current input manager
  39154. */
  39155. addMouseWheel(): FollowCameraInputsManager;
  39156. /**
  39157. * Add pointers input support to the input manager.
  39158. * @returns the current input manager
  39159. */
  39160. addPointers(): FollowCameraInputsManager;
  39161. /**
  39162. * Add orientation input support to the input manager.
  39163. * @returns the current input manager
  39164. */
  39165. addVRDeviceOrientation(): FollowCameraInputsManager;
  39166. }
  39167. }
  39168. declare module "babylonjs/Cameras/followCamera" {
  39169. import { Nullable } from "babylonjs/types";
  39170. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39171. import { Scene } from "babylonjs/scene";
  39172. import { Vector3 } from "babylonjs/Maths/math.vector";
  39173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39174. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39175. /**
  39176. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39177. * an arc rotate version arcFollowCamera are available.
  39178. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39179. */
  39180. export class FollowCamera extends TargetCamera {
  39181. /**
  39182. * Distance the follow camera should follow an object at
  39183. */
  39184. radius: number;
  39185. /**
  39186. * Minimum allowed distance of the camera to the axis of rotation
  39187. * (The camera can not get closer).
  39188. * This can help limiting how the Camera is able to move in the scene.
  39189. */
  39190. lowerRadiusLimit: Nullable<number>;
  39191. /**
  39192. * Maximum allowed distance of the camera to the axis of rotation
  39193. * (The camera can not get further).
  39194. * This can help limiting how the Camera is able to move in the scene.
  39195. */
  39196. upperRadiusLimit: Nullable<number>;
  39197. /**
  39198. * Define a rotation offset between the camera and the object it follows
  39199. */
  39200. rotationOffset: number;
  39201. /**
  39202. * Minimum allowed angle to camera position relative to target object.
  39203. * This can help limiting how the Camera is able to move in the scene.
  39204. */
  39205. lowerRotationOffsetLimit: Nullable<number>;
  39206. /**
  39207. * Maximum allowed angle to camera position relative to target object.
  39208. * This can help limiting how the Camera is able to move in the scene.
  39209. */
  39210. upperRotationOffsetLimit: Nullable<number>;
  39211. /**
  39212. * Define a height offset between the camera and the object it follows.
  39213. * It can help following an object from the top (like a car chaing a plane)
  39214. */
  39215. heightOffset: number;
  39216. /**
  39217. * Minimum allowed height of camera position relative to target object.
  39218. * This can help limiting how the Camera is able to move in the scene.
  39219. */
  39220. lowerHeightOffsetLimit: Nullable<number>;
  39221. /**
  39222. * Maximum allowed height of camera position relative to target object.
  39223. * This can help limiting how the Camera is able to move in the scene.
  39224. */
  39225. upperHeightOffsetLimit: Nullable<number>;
  39226. /**
  39227. * Define how fast the camera can accelerate to follow it s target.
  39228. */
  39229. cameraAcceleration: number;
  39230. /**
  39231. * Define the speed limit of the camera following an object.
  39232. */
  39233. maxCameraSpeed: number;
  39234. /**
  39235. * Define the target of the camera.
  39236. */
  39237. lockedTarget: Nullable<AbstractMesh>;
  39238. /**
  39239. * Defines the input associated with the camera.
  39240. */
  39241. inputs: FollowCameraInputsManager;
  39242. /**
  39243. * Instantiates the follow camera.
  39244. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39245. * @param name Define the name of the camera in the scene
  39246. * @param position Define the position of the camera
  39247. * @param scene Define the scene the camera belong to
  39248. * @param lockedTarget Define the target of the camera
  39249. */
  39250. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39251. private _follow;
  39252. /**
  39253. * Attached controls to the current camera.
  39254. * @param element Defines the element the controls should be listened from
  39255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39256. */
  39257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39258. /**
  39259. * Detach the current controls from the camera.
  39260. * The camera will stop reacting to inputs.
  39261. * @param element Defines the element to stop listening the inputs from
  39262. */
  39263. detachControl(element: HTMLElement): void;
  39264. /** @hidden */
  39265. _checkInputs(): void;
  39266. private _checkLimits;
  39267. /**
  39268. * Gets the camera class name.
  39269. * @returns the class name
  39270. */
  39271. getClassName(): string;
  39272. }
  39273. /**
  39274. * Arc Rotate version of the follow camera.
  39275. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39276. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39277. */
  39278. export class ArcFollowCamera extends TargetCamera {
  39279. /** The longitudinal angle of the camera */
  39280. alpha: number;
  39281. /** The latitudinal angle of the camera */
  39282. beta: number;
  39283. /** The radius of the camera from its target */
  39284. radius: number;
  39285. /** Define the camera target (the messh it should follow) */
  39286. target: Nullable<AbstractMesh>;
  39287. private _cartesianCoordinates;
  39288. /**
  39289. * Instantiates a new ArcFollowCamera
  39290. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39291. * @param name Define the name of the camera
  39292. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39293. * @param beta Define the rotation angle of the camera around the elevation axis
  39294. * @param radius Define the radius of the camera from its target point
  39295. * @param target Define the target of the camera
  39296. * @param scene Define the scene the camera belongs to
  39297. */
  39298. constructor(name: string,
  39299. /** The longitudinal angle of the camera */
  39300. alpha: number,
  39301. /** The latitudinal angle of the camera */
  39302. beta: number,
  39303. /** The radius of the camera from its target */
  39304. radius: number,
  39305. /** Define the camera target (the messh it should follow) */
  39306. target: Nullable<AbstractMesh>, scene: Scene);
  39307. private _follow;
  39308. /** @hidden */
  39309. _checkInputs(): void;
  39310. /**
  39311. * Returns the class name of the object.
  39312. * It is mostly used internally for serialization purposes.
  39313. */
  39314. getClassName(): string;
  39315. }
  39316. }
  39317. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39318. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39319. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39320. import { Nullable } from "babylonjs/types";
  39321. /**
  39322. * Manage the keyboard inputs to control the movement of a follow camera.
  39323. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39324. */
  39325. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39326. /**
  39327. * Defines the camera the input is attached to.
  39328. */
  39329. camera: FollowCamera;
  39330. /**
  39331. * Defines the list of key codes associated with the up action (increase heightOffset)
  39332. */
  39333. keysHeightOffsetIncr: number[];
  39334. /**
  39335. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39336. */
  39337. keysHeightOffsetDecr: number[];
  39338. /**
  39339. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39340. */
  39341. keysHeightOffsetModifierAlt: boolean;
  39342. /**
  39343. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39344. */
  39345. keysHeightOffsetModifierCtrl: boolean;
  39346. /**
  39347. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39348. */
  39349. keysHeightOffsetModifierShift: boolean;
  39350. /**
  39351. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39352. */
  39353. keysRotationOffsetIncr: number[];
  39354. /**
  39355. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39356. */
  39357. keysRotationOffsetDecr: number[];
  39358. /**
  39359. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39360. */
  39361. keysRotationOffsetModifierAlt: boolean;
  39362. /**
  39363. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39364. */
  39365. keysRotationOffsetModifierCtrl: boolean;
  39366. /**
  39367. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39368. */
  39369. keysRotationOffsetModifierShift: boolean;
  39370. /**
  39371. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39372. */
  39373. keysRadiusIncr: number[];
  39374. /**
  39375. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39376. */
  39377. keysRadiusDecr: number[];
  39378. /**
  39379. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39380. */
  39381. keysRadiusModifierAlt: boolean;
  39382. /**
  39383. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39384. */
  39385. keysRadiusModifierCtrl: boolean;
  39386. /**
  39387. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39388. */
  39389. keysRadiusModifierShift: boolean;
  39390. /**
  39391. * Defines the rate of change of heightOffset.
  39392. */
  39393. heightSensibility: number;
  39394. /**
  39395. * Defines the rate of change of rotationOffset.
  39396. */
  39397. rotationSensibility: number;
  39398. /**
  39399. * Defines the rate of change of radius.
  39400. */
  39401. radiusSensibility: number;
  39402. private _keys;
  39403. private _ctrlPressed;
  39404. private _altPressed;
  39405. private _shiftPressed;
  39406. private _onCanvasBlurObserver;
  39407. private _onKeyboardObserver;
  39408. private _engine;
  39409. private _scene;
  39410. /**
  39411. * Attach the input controls to a specific dom element to get the input from.
  39412. * @param element Defines the element the controls should be listened from
  39413. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39414. */
  39415. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39416. /**
  39417. * Detach the current controls from the specified dom element.
  39418. * @param element Defines the element to stop listening the inputs from
  39419. */
  39420. detachControl(element: Nullable<HTMLElement>): void;
  39421. /**
  39422. * Update the current camera state depending on the inputs that have been used this frame.
  39423. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39424. */
  39425. checkInputs(): void;
  39426. /**
  39427. * Gets the class name of the current input.
  39428. * @returns the class name
  39429. */
  39430. getClassName(): string;
  39431. /**
  39432. * Get the friendly name associated with the input class.
  39433. * @returns the input friendly name
  39434. */
  39435. getSimpleName(): string;
  39436. /**
  39437. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39438. * allow modification of the heightOffset value.
  39439. */
  39440. private _modifierHeightOffset;
  39441. /**
  39442. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39443. * allow modification of the rotationOffset value.
  39444. */
  39445. private _modifierRotationOffset;
  39446. /**
  39447. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39448. * allow modification of the radius value.
  39449. */
  39450. private _modifierRadius;
  39451. }
  39452. }
  39453. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39454. import { Nullable } from "babylonjs/types";
  39455. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39456. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39457. import { Observable } from "babylonjs/Misc/observable";
  39458. module "babylonjs/Cameras/freeCameraInputsManager" {
  39459. interface FreeCameraInputsManager {
  39460. /**
  39461. * @hidden
  39462. */
  39463. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39464. /**
  39465. * Add orientation input support to the input manager.
  39466. * @returns the current input manager
  39467. */
  39468. addDeviceOrientation(): FreeCameraInputsManager;
  39469. }
  39470. }
  39471. /**
  39472. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39473. * Screen rotation is taken into account.
  39474. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39475. */
  39476. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39477. private _camera;
  39478. private _screenOrientationAngle;
  39479. private _constantTranform;
  39480. private _screenQuaternion;
  39481. private _alpha;
  39482. private _beta;
  39483. private _gamma;
  39484. /**
  39485. * Can be used to detect if a device orientation sensor is availible on a device
  39486. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39487. * @returns a promise that will resolve on orientation change
  39488. */
  39489. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39490. /**
  39491. * @hidden
  39492. */
  39493. _onDeviceOrientationChangedObservable: Observable<void>;
  39494. /**
  39495. * Instantiates a new input
  39496. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39497. */
  39498. constructor();
  39499. /**
  39500. * Define the camera controlled by the input.
  39501. */
  39502. camera: FreeCamera;
  39503. /**
  39504. * Attach the input controls to a specific dom element to get the input from.
  39505. * @param element Defines the element the controls should be listened from
  39506. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39507. */
  39508. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39509. private _orientationChanged;
  39510. private _deviceOrientation;
  39511. /**
  39512. * Detach the current controls from the specified dom element.
  39513. * @param element Defines the element to stop listening the inputs from
  39514. */
  39515. detachControl(element: Nullable<HTMLElement>): void;
  39516. /**
  39517. * Update the current camera state depending on the inputs that have been used this frame.
  39518. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39519. */
  39520. checkInputs(): void;
  39521. /**
  39522. * Gets the class name of the current intput.
  39523. * @returns the class name
  39524. */
  39525. getClassName(): string;
  39526. /**
  39527. * Get the friendly name associated with the input class.
  39528. * @returns the input friendly name
  39529. */
  39530. getSimpleName(): string;
  39531. }
  39532. }
  39533. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39534. import { Nullable } from "babylonjs/types";
  39535. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39536. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39537. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39538. /**
  39539. * Manage the gamepad inputs to control a free camera.
  39540. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39541. */
  39542. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39543. /**
  39544. * Define the camera the input is attached to.
  39545. */
  39546. camera: FreeCamera;
  39547. /**
  39548. * Define the Gamepad controlling the input
  39549. */
  39550. gamepad: Nullable<Gamepad>;
  39551. /**
  39552. * Defines the gamepad rotation sensiblity.
  39553. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39554. */
  39555. gamepadAngularSensibility: number;
  39556. /**
  39557. * Defines the gamepad move sensiblity.
  39558. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39559. */
  39560. gamepadMoveSensibility: number;
  39561. private _yAxisScale;
  39562. /**
  39563. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  39564. */
  39565. invertYAxis: boolean;
  39566. private _onGamepadConnectedObserver;
  39567. private _onGamepadDisconnectedObserver;
  39568. private _cameraTransform;
  39569. private _deltaTransform;
  39570. private _vector3;
  39571. private _vector2;
  39572. /**
  39573. * Attach the input controls to a specific dom element to get the input from.
  39574. * @param element Defines the element the controls should be listened from
  39575. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39576. */
  39577. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39578. /**
  39579. * Detach the current controls from the specified dom element.
  39580. * @param element Defines the element to stop listening the inputs from
  39581. */
  39582. detachControl(element: Nullable<HTMLElement>): void;
  39583. /**
  39584. * Update the current camera state depending on the inputs that have been used this frame.
  39585. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39586. */
  39587. checkInputs(): void;
  39588. /**
  39589. * Gets the class name of the current intput.
  39590. * @returns the class name
  39591. */
  39592. getClassName(): string;
  39593. /**
  39594. * Get the friendly name associated with the input class.
  39595. * @returns the input friendly name
  39596. */
  39597. getSimpleName(): string;
  39598. }
  39599. }
  39600. declare module "babylonjs/Misc/virtualJoystick" {
  39601. import { Nullable } from "babylonjs/types";
  39602. import { Vector3 } from "babylonjs/Maths/math.vector";
  39603. /**
  39604. * Defines the potential axis of a Joystick
  39605. */
  39606. export enum JoystickAxis {
  39607. /** X axis */
  39608. X = 0,
  39609. /** Y axis */
  39610. Y = 1,
  39611. /** Z axis */
  39612. Z = 2
  39613. }
  39614. /**
  39615. * Class used to define virtual joystick (used in touch mode)
  39616. */
  39617. export class VirtualJoystick {
  39618. /**
  39619. * Gets or sets a boolean indicating that left and right values must be inverted
  39620. */
  39621. reverseLeftRight: boolean;
  39622. /**
  39623. * Gets or sets a boolean indicating that up and down values must be inverted
  39624. */
  39625. reverseUpDown: boolean;
  39626. /**
  39627. * Gets the offset value for the position (ie. the change of the position value)
  39628. */
  39629. deltaPosition: Vector3;
  39630. /**
  39631. * Gets a boolean indicating if the virtual joystick was pressed
  39632. */
  39633. pressed: boolean;
  39634. /**
  39635. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39636. */
  39637. static Canvas: Nullable<HTMLCanvasElement>;
  39638. private static _globalJoystickIndex;
  39639. private static vjCanvasContext;
  39640. private static vjCanvasWidth;
  39641. private static vjCanvasHeight;
  39642. private static halfWidth;
  39643. private _action;
  39644. private _axisTargetedByLeftAndRight;
  39645. private _axisTargetedByUpAndDown;
  39646. private _joystickSensibility;
  39647. private _inversedSensibility;
  39648. private _joystickPointerID;
  39649. private _joystickColor;
  39650. private _joystickPointerPos;
  39651. private _joystickPreviousPointerPos;
  39652. private _joystickPointerStartPos;
  39653. private _deltaJoystickVector;
  39654. private _leftJoystick;
  39655. private _touches;
  39656. private _onPointerDownHandlerRef;
  39657. private _onPointerMoveHandlerRef;
  39658. private _onPointerUpHandlerRef;
  39659. private _onResize;
  39660. /**
  39661. * Creates a new virtual joystick
  39662. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39663. */
  39664. constructor(leftJoystick?: boolean);
  39665. /**
  39666. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39667. * @param newJoystickSensibility defines the new sensibility
  39668. */
  39669. setJoystickSensibility(newJoystickSensibility: number): void;
  39670. private _onPointerDown;
  39671. private _onPointerMove;
  39672. private _onPointerUp;
  39673. /**
  39674. * Change the color of the virtual joystick
  39675. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39676. */
  39677. setJoystickColor(newColor: string): void;
  39678. /**
  39679. * Defines a callback to call when the joystick is touched
  39680. * @param action defines the callback
  39681. */
  39682. setActionOnTouch(action: () => any): void;
  39683. /**
  39684. * Defines which axis you'd like to control for left & right
  39685. * @param axis defines the axis to use
  39686. */
  39687. setAxisForLeftRight(axis: JoystickAxis): void;
  39688. /**
  39689. * Defines which axis you'd like to control for up & down
  39690. * @param axis defines the axis to use
  39691. */
  39692. setAxisForUpDown(axis: JoystickAxis): void;
  39693. private _drawVirtualJoystick;
  39694. /**
  39695. * Release internal HTML canvas
  39696. */
  39697. releaseCanvas(): void;
  39698. }
  39699. }
  39700. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39701. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39702. import { Nullable } from "babylonjs/types";
  39703. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39704. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39705. module "babylonjs/Cameras/freeCameraInputsManager" {
  39706. interface FreeCameraInputsManager {
  39707. /**
  39708. * Add virtual joystick input support to the input manager.
  39709. * @returns the current input manager
  39710. */
  39711. addVirtualJoystick(): FreeCameraInputsManager;
  39712. }
  39713. }
  39714. /**
  39715. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39716. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39717. */
  39718. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39719. /**
  39720. * Defines the camera the input is attached to.
  39721. */
  39722. camera: FreeCamera;
  39723. private _leftjoystick;
  39724. private _rightjoystick;
  39725. /**
  39726. * Gets the left stick of the virtual joystick.
  39727. * @returns The virtual Joystick
  39728. */
  39729. getLeftJoystick(): VirtualJoystick;
  39730. /**
  39731. * Gets the right stick of the virtual joystick.
  39732. * @returns The virtual Joystick
  39733. */
  39734. getRightJoystick(): VirtualJoystick;
  39735. /**
  39736. * Update the current camera state depending on the inputs that have been used this frame.
  39737. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39738. */
  39739. checkInputs(): void;
  39740. /**
  39741. * Attach the input controls to a specific dom element to get the input from.
  39742. * @param element Defines the element the controls should be listened from
  39743. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39744. */
  39745. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39746. /**
  39747. * Detach the current controls from the specified dom element.
  39748. * @param element Defines the element to stop listening the inputs from
  39749. */
  39750. detachControl(element: Nullable<HTMLElement>): void;
  39751. /**
  39752. * Gets the class name of the current intput.
  39753. * @returns the class name
  39754. */
  39755. getClassName(): string;
  39756. /**
  39757. * Get the friendly name associated with the input class.
  39758. * @returns the input friendly name
  39759. */
  39760. getSimpleName(): string;
  39761. }
  39762. }
  39763. declare module "babylonjs/Cameras/Inputs/index" {
  39764. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39765. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39766. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39767. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39768. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39769. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39770. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39771. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39772. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39773. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39774. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39775. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39776. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39777. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39778. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39779. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39780. }
  39781. declare module "babylonjs/Cameras/touchCamera" {
  39782. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39783. import { Scene } from "babylonjs/scene";
  39784. import { Vector3 } from "babylonjs/Maths/math.vector";
  39785. /**
  39786. * This represents a FPS type of camera controlled by touch.
  39787. * This is like a universal camera minus the Gamepad controls.
  39788. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39789. */
  39790. export class TouchCamera extends FreeCamera {
  39791. /**
  39792. * Defines the touch sensibility for rotation.
  39793. * The higher the faster.
  39794. */
  39795. touchAngularSensibility: number;
  39796. /**
  39797. * Defines the touch sensibility for move.
  39798. * The higher the faster.
  39799. */
  39800. touchMoveSensibility: number;
  39801. /**
  39802. * Instantiates a new touch camera.
  39803. * This represents a FPS type of camera controlled by touch.
  39804. * This is like a universal camera minus the Gamepad controls.
  39805. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39806. * @param name Define the name of the camera in the scene
  39807. * @param position Define the start position of the camera in the scene
  39808. * @param scene Define the scene the camera belongs to
  39809. */
  39810. constructor(name: string, position: Vector3, scene: Scene);
  39811. /**
  39812. * Gets the current object class name.
  39813. * @return the class name
  39814. */
  39815. getClassName(): string;
  39816. /** @hidden */
  39817. _setupInputs(): void;
  39818. }
  39819. }
  39820. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39821. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39822. import { Scene } from "babylonjs/scene";
  39823. import { Vector3 } from "babylonjs/Maths/math.vector";
  39824. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39825. import { Axis } from "babylonjs/Maths/math.axis";
  39826. /**
  39827. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39828. * being tilted forward or back and left or right.
  39829. */
  39830. export class DeviceOrientationCamera extends FreeCamera {
  39831. private _initialQuaternion;
  39832. private _quaternionCache;
  39833. private _tmpDragQuaternion;
  39834. private _disablePointerInputWhenUsingDeviceOrientation;
  39835. /**
  39836. * Creates a new device orientation camera
  39837. * @param name The name of the camera
  39838. * @param position The start position camera
  39839. * @param scene The scene the camera belongs to
  39840. */
  39841. constructor(name: string, position: Vector3, scene: Scene);
  39842. /**
  39843. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39844. */
  39845. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39846. private _dragFactor;
  39847. /**
  39848. * Enabled turning on the y axis when the orientation sensor is active
  39849. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39850. */
  39851. enableHorizontalDragging(dragFactor?: number): void;
  39852. /**
  39853. * Gets the current instance class name ("DeviceOrientationCamera").
  39854. * This helps avoiding instanceof at run time.
  39855. * @returns the class name
  39856. */
  39857. getClassName(): string;
  39858. /**
  39859. * @hidden
  39860. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39861. */
  39862. _checkInputs(): void;
  39863. /**
  39864. * Reset the camera to its default orientation on the specified axis only.
  39865. * @param axis The axis to reset
  39866. */
  39867. resetToCurrentRotation(axis?: Axis): void;
  39868. }
  39869. }
  39870. declare module "babylonjs/Gamepads/xboxGamepad" {
  39871. import { Observable } from "babylonjs/Misc/observable";
  39872. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39873. /**
  39874. * Defines supported buttons for XBox360 compatible gamepads
  39875. */
  39876. export enum Xbox360Button {
  39877. /** A */
  39878. A = 0,
  39879. /** B */
  39880. B = 1,
  39881. /** X */
  39882. X = 2,
  39883. /** Y */
  39884. Y = 3,
  39885. /** Start */
  39886. Start = 4,
  39887. /** Back */
  39888. Back = 5,
  39889. /** Left button */
  39890. LB = 6,
  39891. /** Right button */
  39892. RB = 7,
  39893. /** Left stick */
  39894. LeftStick = 8,
  39895. /** Right stick */
  39896. RightStick = 9
  39897. }
  39898. /** Defines values for XBox360 DPad */
  39899. export enum Xbox360Dpad {
  39900. /** Up */
  39901. Up = 0,
  39902. /** Down */
  39903. Down = 1,
  39904. /** Left */
  39905. Left = 2,
  39906. /** Right */
  39907. Right = 3
  39908. }
  39909. /**
  39910. * Defines a XBox360 gamepad
  39911. */
  39912. export class Xbox360Pad extends Gamepad {
  39913. private _leftTrigger;
  39914. private _rightTrigger;
  39915. private _onlefttriggerchanged;
  39916. private _onrighttriggerchanged;
  39917. private _onbuttondown;
  39918. private _onbuttonup;
  39919. private _ondpaddown;
  39920. private _ondpadup;
  39921. /** Observable raised when a button is pressed */
  39922. onButtonDownObservable: Observable<Xbox360Button>;
  39923. /** Observable raised when a button is released */
  39924. onButtonUpObservable: Observable<Xbox360Button>;
  39925. /** Observable raised when a pad is pressed */
  39926. onPadDownObservable: Observable<Xbox360Dpad>;
  39927. /** Observable raised when a pad is released */
  39928. onPadUpObservable: Observable<Xbox360Dpad>;
  39929. private _buttonA;
  39930. private _buttonB;
  39931. private _buttonX;
  39932. private _buttonY;
  39933. private _buttonBack;
  39934. private _buttonStart;
  39935. private _buttonLB;
  39936. private _buttonRB;
  39937. private _buttonLeftStick;
  39938. private _buttonRightStick;
  39939. private _dPadUp;
  39940. private _dPadDown;
  39941. private _dPadLeft;
  39942. private _dPadRight;
  39943. private _isXboxOnePad;
  39944. /**
  39945. * Creates a new XBox360 gamepad object
  39946. * @param id defines the id of this gamepad
  39947. * @param index defines its index
  39948. * @param gamepad defines the internal HTML gamepad object
  39949. * @param xboxOne defines if it is a XBox One gamepad
  39950. */
  39951. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39952. /**
  39953. * Defines the callback to call when left trigger is pressed
  39954. * @param callback defines the callback to use
  39955. */
  39956. onlefttriggerchanged(callback: (value: number) => void): void;
  39957. /**
  39958. * Defines the callback to call when right trigger is pressed
  39959. * @param callback defines the callback to use
  39960. */
  39961. onrighttriggerchanged(callback: (value: number) => void): void;
  39962. /**
  39963. * Gets the left trigger value
  39964. */
  39965. /**
  39966. * Sets the left trigger value
  39967. */
  39968. leftTrigger: number;
  39969. /**
  39970. * Gets the right trigger value
  39971. */
  39972. /**
  39973. * Sets the right trigger value
  39974. */
  39975. rightTrigger: number;
  39976. /**
  39977. * Defines the callback to call when a button is pressed
  39978. * @param callback defines the callback to use
  39979. */
  39980. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39981. /**
  39982. * Defines the callback to call when a button is released
  39983. * @param callback defines the callback to use
  39984. */
  39985. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39986. /**
  39987. * Defines the callback to call when a pad is pressed
  39988. * @param callback defines the callback to use
  39989. */
  39990. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39991. /**
  39992. * Defines the callback to call when a pad is released
  39993. * @param callback defines the callback to use
  39994. */
  39995. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39996. private _setButtonValue;
  39997. private _setDPadValue;
  39998. /**
  39999. * Gets the value of the `A` button
  40000. */
  40001. /**
  40002. * Sets the value of the `A` button
  40003. */
  40004. buttonA: number;
  40005. /**
  40006. * Gets the value of the `B` button
  40007. */
  40008. /**
  40009. * Sets the value of the `B` button
  40010. */
  40011. buttonB: number;
  40012. /**
  40013. * Gets the value of the `X` button
  40014. */
  40015. /**
  40016. * Sets the value of the `X` button
  40017. */
  40018. buttonX: number;
  40019. /**
  40020. * Gets the value of the `Y` button
  40021. */
  40022. /**
  40023. * Sets the value of the `Y` button
  40024. */
  40025. buttonY: number;
  40026. /**
  40027. * Gets the value of the `Start` button
  40028. */
  40029. /**
  40030. * Sets the value of the `Start` button
  40031. */
  40032. buttonStart: number;
  40033. /**
  40034. * Gets the value of the `Back` button
  40035. */
  40036. /**
  40037. * Sets the value of the `Back` button
  40038. */
  40039. buttonBack: number;
  40040. /**
  40041. * Gets the value of the `Left` button
  40042. */
  40043. /**
  40044. * Sets the value of the `Left` button
  40045. */
  40046. buttonLB: number;
  40047. /**
  40048. * Gets the value of the `Right` button
  40049. */
  40050. /**
  40051. * Sets the value of the `Right` button
  40052. */
  40053. buttonRB: number;
  40054. /**
  40055. * Gets the value of the Left joystick
  40056. */
  40057. /**
  40058. * Sets the value of the Left joystick
  40059. */
  40060. buttonLeftStick: number;
  40061. /**
  40062. * Gets the value of the Right joystick
  40063. */
  40064. /**
  40065. * Sets the value of the Right joystick
  40066. */
  40067. buttonRightStick: number;
  40068. /**
  40069. * Gets the value of D-pad up
  40070. */
  40071. /**
  40072. * Sets the value of D-pad up
  40073. */
  40074. dPadUp: number;
  40075. /**
  40076. * Gets the value of D-pad down
  40077. */
  40078. /**
  40079. * Sets the value of D-pad down
  40080. */
  40081. dPadDown: number;
  40082. /**
  40083. * Gets the value of D-pad left
  40084. */
  40085. /**
  40086. * Sets the value of D-pad left
  40087. */
  40088. dPadLeft: number;
  40089. /**
  40090. * Gets the value of D-pad right
  40091. */
  40092. /**
  40093. * Sets the value of D-pad right
  40094. */
  40095. dPadRight: number;
  40096. /**
  40097. * Force the gamepad to synchronize with device values
  40098. */
  40099. update(): void;
  40100. /**
  40101. * Disposes the gamepad
  40102. */
  40103. dispose(): void;
  40104. }
  40105. }
  40106. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40107. import { Observable } from "babylonjs/Misc/observable";
  40108. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40109. /**
  40110. * Defines supported buttons for DualShock compatible gamepads
  40111. */
  40112. export enum DualShockButton {
  40113. /** Cross */
  40114. Cross = 0,
  40115. /** Circle */
  40116. Circle = 1,
  40117. /** Square */
  40118. Square = 2,
  40119. /** Triangle */
  40120. Triangle = 3,
  40121. /** Options */
  40122. Options = 4,
  40123. /** Share */
  40124. Share = 5,
  40125. /** L1 */
  40126. L1 = 6,
  40127. /** R1 */
  40128. R1 = 7,
  40129. /** Left stick */
  40130. LeftStick = 8,
  40131. /** Right stick */
  40132. RightStick = 9
  40133. }
  40134. /** Defines values for DualShock DPad */
  40135. export enum DualShockDpad {
  40136. /** Up */
  40137. Up = 0,
  40138. /** Down */
  40139. Down = 1,
  40140. /** Left */
  40141. Left = 2,
  40142. /** Right */
  40143. Right = 3
  40144. }
  40145. /**
  40146. * Defines a DualShock gamepad
  40147. */
  40148. export class DualShockPad extends Gamepad {
  40149. private _leftTrigger;
  40150. private _rightTrigger;
  40151. private _onlefttriggerchanged;
  40152. private _onrighttriggerchanged;
  40153. private _onbuttondown;
  40154. private _onbuttonup;
  40155. private _ondpaddown;
  40156. private _ondpadup;
  40157. /** Observable raised when a button is pressed */
  40158. onButtonDownObservable: Observable<DualShockButton>;
  40159. /** Observable raised when a button is released */
  40160. onButtonUpObservable: Observable<DualShockButton>;
  40161. /** Observable raised when a pad is pressed */
  40162. onPadDownObservable: Observable<DualShockDpad>;
  40163. /** Observable raised when a pad is released */
  40164. onPadUpObservable: Observable<DualShockDpad>;
  40165. private _buttonCross;
  40166. private _buttonCircle;
  40167. private _buttonSquare;
  40168. private _buttonTriangle;
  40169. private _buttonShare;
  40170. private _buttonOptions;
  40171. private _buttonL1;
  40172. private _buttonR1;
  40173. private _buttonLeftStick;
  40174. private _buttonRightStick;
  40175. private _dPadUp;
  40176. private _dPadDown;
  40177. private _dPadLeft;
  40178. private _dPadRight;
  40179. /**
  40180. * Creates a new DualShock gamepad object
  40181. * @param id defines the id of this gamepad
  40182. * @param index defines its index
  40183. * @param gamepad defines the internal HTML gamepad object
  40184. */
  40185. constructor(id: string, index: number, gamepad: any);
  40186. /**
  40187. * Defines the callback to call when left trigger is pressed
  40188. * @param callback defines the callback to use
  40189. */
  40190. onlefttriggerchanged(callback: (value: number) => void): void;
  40191. /**
  40192. * Defines the callback to call when right trigger is pressed
  40193. * @param callback defines the callback to use
  40194. */
  40195. onrighttriggerchanged(callback: (value: number) => void): void;
  40196. /**
  40197. * Gets the left trigger value
  40198. */
  40199. /**
  40200. * Sets the left trigger value
  40201. */
  40202. leftTrigger: number;
  40203. /**
  40204. * Gets the right trigger value
  40205. */
  40206. /**
  40207. * Sets the right trigger value
  40208. */
  40209. rightTrigger: number;
  40210. /**
  40211. * Defines the callback to call when a button is pressed
  40212. * @param callback defines the callback to use
  40213. */
  40214. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40215. /**
  40216. * Defines the callback to call when a button is released
  40217. * @param callback defines the callback to use
  40218. */
  40219. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40220. /**
  40221. * Defines the callback to call when a pad is pressed
  40222. * @param callback defines the callback to use
  40223. */
  40224. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40225. /**
  40226. * Defines the callback to call when a pad is released
  40227. * @param callback defines the callback to use
  40228. */
  40229. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40230. private _setButtonValue;
  40231. private _setDPadValue;
  40232. /**
  40233. * Gets the value of the `Cross` button
  40234. */
  40235. /**
  40236. * Sets the value of the `Cross` button
  40237. */
  40238. buttonCross: number;
  40239. /**
  40240. * Gets the value of the `Circle` button
  40241. */
  40242. /**
  40243. * Sets the value of the `Circle` button
  40244. */
  40245. buttonCircle: number;
  40246. /**
  40247. * Gets the value of the `Square` button
  40248. */
  40249. /**
  40250. * Sets the value of the `Square` button
  40251. */
  40252. buttonSquare: number;
  40253. /**
  40254. * Gets the value of the `Triangle` button
  40255. */
  40256. /**
  40257. * Sets the value of the `Triangle` button
  40258. */
  40259. buttonTriangle: number;
  40260. /**
  40261. * Gets the value of the `Options` button
  40262. */
  40263. /**
  40264. * Sets the value of the `Options` button
  40265. */
  40266. buttonOptions: number;
  40267. /**
  40268. * Gets the value of the `Share` button
  40269. */
  40270. /**
  40271. * Sets the value of the `Share` button
  40272. */
  40273. buttonShare: number;
  40274. /**
  40275. * Gets the value of the `L1` button
  40276. */
  40277. /**
  40278. * Sets the value of the `L1` button
  40279. */
  40280. buttonL1: number;
  40281. /**
  40282. * Gets the value of the `R1` button
  40283. */
  40284. /**
  40285. * Sets the value of the `R1` button
  40286. */
  40287. buttonR1: number;
  40288. /**
  40289. * Gets the value of the Left joystick
  40290. */
  40291. /**
  40292. * Sets the value of the Left joystick
  40293. */
  40294. buttonLeftStick: number;
  40295. /**
  40296. * Gets the value of the Right joystick
  40297. */
  40298. /**
  40299. * Sets the value of the Right joystick
  40300. */
  40301. buttonRightStick: number;
  40302. /**
  40303. * Gets the value of D-pad up
  40304. */
  40305. /**
  40306. * Sets the value of D-pad up
  40307. */
  40308. dPadUp: number;
  40309. /**
  40310. * Gets the value of D-pad down
  40311. */
  40312. /**
  40313. * Sets the value of D-pad down
  40314. */
  40315. dPadDown: number;
  40316. /**
  40317. * Gets the value of D-pad left
  40318. */
  40319. /**
  40320. * Sets the value of D-pad left
  40321. */
  40322. dPadLeft: number;
  40323. /**
  40324. * Gets the value of D-pad right
  40325. */
  40326. /**
  40327. * Sets the value of D-pad right
  40328. */
  40329. dPadRight: number;
  40330. /**
  40331. * Force the gamepad to synchronize with device values
  40332. */
  40333. update(): void;
  40334. /**
  40335. * Disposes the gamepad
  40336. */
  40337. dispose(): void;
  40338. }
  40339. }
  40340. declare module "babylonjs/Gamepads/gamepadManager" {
  40341. import { Observable } from "babylonjs/Misc/observable";
  40342. import { Nullable } from "babylonjs/types";
  40343. import { Scene } from "babylonjs/scene";
  40344. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40345. /**
  40346. * Manager for handling gamepads
  40347. */
  40348. export class GamepadManager {
  40349. private _scene?;
  40350. private _babylonGamepads;
  40351. private _oneGamepadConnected;
  40352. /** @hidden */
  40353. _isMonitoring: boolean;
  40354. private _gamepadEventSupported;
  40355. private _gamepadSupport;
  40356. /**
  40357. * observable to be triggered when the gamepad controller has been connected
  40358. */
  40359. onGamepadConnectedObservable: Observable<Gamepad>;
  40360. /**
  40361. * observable to be triggered when the gamepad controller has been disconnected
  40362. */
  40363. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40364. private _onGamepadConnectedEvent;
  40365. private _onGamepadDisconnectedEvent;
  40366. /**
  40367. * Initializes the gamepad manager
  40368. * @param _scene BabylonJS scene
  40369. */
  40370. constructor(_scene?: Scene | undefined);
  40371. /**
  40372. * The gamepads in the game pad manager
  40373. */
  40374. readonly gamepads: Gamepad[];
  40375. /**
  40376. * Get the gamepad controllers based on type
  40377. * @param type The type of gamepad controller
  40378. * @returns Nullable gamepad
  40379. */
  40380. getGamepadByType(type?: number): Nullable<Gamepad>;
  40381. /**
  40382. * Disposes the gamepad manager
  40383. */
  40384. dispose(): void;
  40385. private _addNewGamepad;
  40386. private _startMonitoringGamepads;
  40387. private _stopMonitoringGamepads;
  40388. /** @hidden */
  40389. _checkGamepadsStatus(): void;
  40390. private _updateGamepadObjects;
  40391. }
  40392. }
  40393. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40394. import { Nullable } from "babylonjs/types";
  40395. import { Scene } from "babylonjs/scene";
  40396. import { ISceneComponent } from "babylonjs/sceneComponent";
  40397. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40398. module "babylonjs/scene" {
  40399. interface Scene {
  40400. /** @hidden */
  40401. _gamepadManager: Nullable<GamepadManager>;
  40402. /**
  40403. * Gets the gamepad manager associated with the scene
  40404. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40405. */
  40406. gamepadManager: GamepadManager;
  40407. }
  40408. }
  40409. module "babylonjs/Cameras/freeCameraInputsManager" {
  40410. /**
  40411. * Interface representing a free camera inputs manager
  40412. */
  40413. interface FreeCameraInputsManager {
  40414. /**
  40415. * Adds gamepad input support to the FreeCameraInputsManager.
  40416. * @returns the FreeCameraInputsManager
  40417. */
  40418. addGamepad(): FreeCameraInputsManager;
  40419. }
  40420. }
  40421. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40422. /**
  40423. * Interface representing an arc rotate camera inputs manager
  40424. */
  40425. interface ArcRotateCameraInputsManager {
  40426. /**
  40427. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40428. * @returns the camera inputs manager
  40429. */
  40430. addGamepad(): ArcRotateCameraInputsManager;
  40431. }
  40432. }
  40433. /**
  40434. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40435. */
  40436. export class GamepadSystemSceneComponent implements ISceneComponent {
  40437. /**
  40438. * The component name helpfull to identify the component in the list of scene components.
  40439. */
  40440. readonly name: string;
  40441. /**
  40442. * The scene the component belongs to.
  40443. */
  40444. scene: Scene;
  40445. /**
  40446. * Creates a new instance of the component for the given scene
  40447. * @param scene Defines the scene to register the component in
  40448. */
  40449. constructor(scene: Scene);
  40450. /**
  40451. * Registers the component in a given scene
  40452. */
  40453. register(): void;
  40454. /**
  40455. * Rebuilds the elements related to this component in case of
  40456. * context lost for instance.
  40457. */
  40458. rebuild(): void;
  40459. /**
  40460. * Disposes the component and the associated ressources
  40461. */
  40462. dispose(): void;
  40463. private _beforeCameraUpdate;
  40464. }
  40465. }
  40466. declare module "babylonjs/Cameras/universalCamera" {
  40467. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40468. import { Scene } from "babylonjs/scene";
  40469. import { Vector3 } from "babylonjs/Maths/math.vector";
  40470. import "babylonjs/Gamepads/gamepadSceneComponent";
  40471. /**
  40472. * 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,
  40473. * which still works and will still be found in many Playgrounds.
  40474. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40475. */
  40476. export class UniversalCamera extends TouchCamera {
  40477. /**
  40478. * Defines the gamepad rotation sensiblity.
  40479. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40480. */
  40481. gamepadAngularSensibility: number;
  40482. /**
  40483. * Defines the gamepad move sensiblity.
  40484. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40485. */
  40486. gamepadMoveSensibility: number;
  40487. /**
  40488. * 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,
  40489. * which still works and will still be found in many Playgrounds.
  40490. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40491. * @param name Define the name of the camera in the scene
  40492. * @param position Define the start position of the camera in the scene
  40493. * @param scene Define the scene the camera belongs to
  40494. */
  40495. constructor(name: string, position: Vector3, scene: Scene);
  40496. /**
  40497. * Gets the current object class name.
  40498. * @return the class name
  40499. */
  40500. getClassName(): string;
  40501. }
  40502. }
  40503. declare module "babylonjs/Cameras/gamepadCamera" {
  40504. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40505. import { Scene } from "babylonjs/scene";
  40506. import { Vector3 } from "babylonjs/Maths/math.vector";
  40507. /**
  40508. * This represents a FPS type of camera. This is only here for back compat purpose.
  40509. * Please use the UniversalCamera instead as both are identical.
  40510. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40511. */
  40512. export class GamepadCamera extends UniversalCamera {
  40513. /**
  40514. * Instantiates a new Gamepad Camera
  40515. * This represents a FPS type of camera. This is only here for back compat purpose.
  40516. * Please use the UniversalCamera instead as both are identical.
  40517. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40518. * @param name Define the name of the camera in the scene
  40519. * @param position Define the start position of the camera in the scene
  40520. * @param scene Define the scene the camera belongs to
  40521. */
  40522. constructor(name: string, position: Vector3, scene: Scene);
  40523. /**
  40524. * Gets the current object class name.
  40525. * @return the class name
  40526. */
  40527. getClassName(): string;
  40528. }
  40529. }
  40530. declare module "babylonjs/Shaders/pass.fragment" {
  40531. /** @hidden */
  40532. export var passPixelShader: {
  40533. name: string;
  40534. shader: string;
  40535. };
  40536. }
  40537. declare module "babylonjs/Shaders/passCube.fragment" {
  40538. /** @hidden */
  40539. export var passCubePixelShader: {
  40540. name: string;
  40541. shader: string;
  40542. };
  40543. }
  40544. declare module "babylonjs/PostProcesses/passPostProcess" {
  40545. import { Nullable } from "babylonjs/types";
  40546. import { Camera } from "babylonjs/Cameras/camera";
  40547. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40548. import { Engine } from "babylonjs/Engines/engine";
  40549. import "babylonjs/Shaders/pass.fragment";
  40550. import "babylonjs/Shaders/passCube.fragment";
  40551. /**
  40552. * PassPostProcess which produces an output the same as it's input
  40553. */
  40554. export class PassPostProcess extends PostProcess {
  40555. /**
  40556. * Creates the PassPostProcess
  40557. * @param name The name of the effect.
  40558. * @param options The required width/height ratio to downsize to before computing the render pass.
  40559. * @param camera The camera to apply the render pass to.
  40560. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40561. * @param engine The engine which the post process will be applied. (default: current engine)
  40562. * @param reusable If the post process can be reused on the same frame. (default: false)
  40563. * @param textureType The type of texture to be used when performing the post processing.
  40564. * @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)
  40565. */
  40566. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40567. }
  40568. /**
  40569. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40570. */
  40571. export class PassCubePostProcess extends PostProcess {
  40572. private _face;
  40573. /**
  40574. * Gets or sets the cube face to display.
  40575. * * 0 is +X
  40576. * * 1 is -X
  40577. * * 2 is +Y
  40578. * * 3 is -Y
  40579. * * 4 is +Z
  40580. * * 5 is -Z
  40581. */
  40582. face: number;
  40583. /**
  40584. * Creates the PassCubePostProcess
  40585. * @param name The name of the effect.
  40586. * @param options The required width/height ratio to downsize to before computing the render pass.
  40587. * @param camera The camera to apply the render pass to.
  40588. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40589. * @param engine The engine which the post process will be applied. (default: current engine)
  40590. * @param reusable If the post process can be reused on the same frame. (default: false)
  40591. * @param textureType The type of texture to be used when performing the post processing.
  40592. * @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)
  40593. */
  40594. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40595. }
  40596. }
  40597. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40598. /** @hidden */
  40599. export var anaglyphPixelShader: {
  40600. name: string;
  40601. shader: string;
  40602. };
  40603. }
  40604. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40605. import { Engine } from "babylonjs/Engines/engine";
  40606. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40607. import { Camera } from "babylonjs/Cameras/camera";
  40608. import "babylonjs/Shaders/anaglyph.fragment";
  40609. /**
  40610. * Postprocess used to generate anaglyphic rendering
  40611. */
  40612. export class AnaglyphPostProcess extends PostProcess {
  40613. private _passedProcess;
  40614. /**
  40615. * Creates a new AnaglyphPostProcess
  40616. * @param name defines postprocess name
  40617. * @param options defines creation options or target ratio scale
  40618. * @param rigCameras defines cameras using this postprocess
  40619. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40620. * @param engine defines hosting engine
  40621. * @param reusable defines if the postprocess will be reused multiple times per frame
  40622. */
  40623. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40624. }
  40625. }
  40626. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40627. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40628. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40629. import { Scene } from "babylonjs/scene";
  40630. import { Vector3 } from "babylonjs/Maths/math.vector";
  40631. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40632. /**
  40633. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40634. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40635. */
  40636. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40637. /**
  40638. * Creates a new AnaglyphArcRotateCamera
  40639. * @param name defines camera name
  40640. * @param alpha defines alpha angle (in radians)
  40641. * @param beta defines beta angle (in radians)
  40642. * @param radius defines radius
  40643. * @param target defines camera target
  40644. * @param interaxialDistance defines distance between each color axis
  40645. * @param scene defines the hosting scene
  40646. */
  40647. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40648. /**
  40649. * Gets camera class name
  40650. * @returns AnaglyphArcRotateCamera
  40651. */
  40652. getClassName(): string;
  40653. }
  40654. }
  40655. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40656. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40657. import { Scene } from "babylonjs/scene";
  40658. import { Vector3 } from "babylonjs/Maths/math.vector";
  40659. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40660. /**
  40661. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40662. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40663. */
  40664. export class AnaglyphFreeCamera extends FreeCamera {
  40665. /**
  40666. * Creates a new AnaglyphFreeCamera
  40667. * @param name defines camera name
  40668. * @param position defines initial position
  40669. * @param interaxialDistance defines distance between each color axis
  40670. * @param scene defines the hosting scene
  40671. */
  40672. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40673. /**
  40674. * Gets camera class name
  40675. * @returns AnaglyphFreeCamera
  40676. */
  40677. getClassName(): string;
  40678. }
  40679. }
  40680. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40681. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40682. import { Scene } from "babylonjs/scene";
  40683. import { Vector3 } from "babylonjs/Maths/math.vector";
  40684. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40685. /**
  40686. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40687. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40688. */
  40689. export class AnaglyphGamepadCamera extends GamepadCamera {
  40690. /**
  40691. * Creates a new AnaglyphGamepadCamera
  40692. * @param name defines camera name
  40693. * @param position defines initial position
  40694. * @param interaxialDistance defines distance between each color axis
  40695. * @param scene defines the hosting scene
  40696. */
  40697. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40698. /**
  40699. * Gets camera class name
  40700. * @returns AnaglyphGamepadCamera
  40701. */
  40702. getClassName(): string;
  40703. }
  40704. }
  40705. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40706. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40707. import { Scene } from "babylonjs/scene";
  40708. import { Vector3 } from "babylonjs/Maths/math.vector";
  40709. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40710. /**
  40711. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40712. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40713. */
  40714. export class AnaglyphUniversalCamera extends UniversalCamera {
  40715. /**
  40716. * Creates a new AnaglyphUniversalCamera
  40717. * @param name defines camera name
  40718. * @param position defines initial position
  40719. * @param interaxialDistance defines distance between each color axis
  40720. * @param scene defines the hosting scene
  40721. */
  40722. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40723. /**
  40724. * Gets camera class name
  40725. * @returns AnaglyphUniversalCamera
  40726. */
  40727. getClassName(): string;
  40728. }
  40729. }
  40730. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40731. /** @hidden */
  40732. export var stereoscopicInterlacePixelShader: {
  40733. name: string;
  40734. shader: string;
  40735. };
  40736. }
  40737. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40738. import { Camera } from "babylonjs/Cameras/camera";
  40739. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40740. import { Engine } from "babylonjs/Engines/engine";
  40741. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40742. /**
  40743. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40744. */
  40745. export class StereoscopicInterlacePostProcess extends PostProcess {
  40746. private _stepSize;
  40747. private _passedProcess;
  40748. /**
  40749. * Initializes a StereoscopicInterlacePostProcess
  40750. * @param name The name of the effect.
  40751. * @param rigCameras The rig cameras to be appled to the post process
  40752. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40753. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40754. * @param engine The engine which the post process will be applied. (default: current engine)
  40755. * @param reusable If the post process can be reused on the same frame. (default: false)
  40756. */
  40757. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40758. }
  40759. }
  40760. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40761. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40762. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40763. import { Scene } from "babylonjs/scene";
  40764. import { Vector3 } from "babylonjs/Maths/math.vector";
  40765. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40766. /**
  40767. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40768. * @see http://doc.babylonjs.com/features/cameras
  40769. */
  40770. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40771. /**
  40772. * Creates a new StereoscopicArcRotateCamera
  40773. * @param name defines camera name
  40774. * @param alpha defines alpha angle (in radians)
  40775. * @param beta defines beta angle (in radians)
  40776. * @param radius defines radius
  40777. * @param target defines camera target
  40778. * @param interaxialDistance defines distance between each color axis
  40779. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40780. * @param scene defines the hosting scene
  40781. */
  40782. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40783. /**
  40784. * Gets camera class name
  40785. * @returns StereoscopicArcRotateCamera
  40786. */
  40787. getClassName(): string;
  40788. }
  40789. }
  40790. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40791. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40792. import { Scene } from "babylonjs/scene";
  40793. import { Vector3 } from "babylonjs/Maths/math.vector";
  40794. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40795. /**
  40796. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40797. * @see http://doc.babylonjs.com/features/cameras
  40798. */
  40799. export class StereoscopicFreeCamera extends FreeCamera {
  40800. /**
  40801. * Creates a new StereoscopicFreeCamera
  40802. * @param name defines camera name
  40803. * @param position defines initial position
  40804. * @param interaxialDistance defines distance between each color axis
  40805. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40806. * @param scene defines the hosting scene
  40807. */
  40808. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40809. /**
  40810. * Gets camera class name
  40811. * @returns StereoscopicFreeCamera
  40812. */
  40813. getClassName(): string;
  40814. }
  40815. }
  40816. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40817. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40818. import { Scene } from "babylonjs/scene";
  40819. import { Vector3 } from "babylonjs/Maths/math.vector";
  40820. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40821. /**
  40822. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40823. * @see http://doc.babylonjs.com/features/cameras
  40824. */
  40825. export class StereoscopicGamepadCamera extends GamepadCamera {
  40826. /**
  40827. * Creates a new StereoscopicGamepadCamera
  40828. * @param name defines camera name
  40829. * @param position defines initial position
  40830. * @param interaxialDistance defines distance between each color axis
  40831. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40832. * @param scene defines the hosting scene
  40833. */
  40834. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40835. /**
  40836. * Gets camera class name
  40837. * @returns StereoscopicGamepadCamera
  40838. */
  40839. getClassName(): string;
  40840. }
  40841. }
  40842. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40843. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40844. import { Scene } from "babylonjs/scene";
  40845. import { Vector3 } from "babylonjs/Maths/math.vector";
  40846. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40847. /**
  40848. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40849. * @see http://doc.babylonjs.com/features/cameras
  40850. */
  40851. export class StereoscopicUniversalCamera extends UniversalCamera {
  40852. /**
  40853. * Creates a new StereoscopicUniversalCamera
  40854. * @param name defines camera name
  40855. * @param position defines initial position
  40856. * @param interaxialDistance defines distance between each color axis
  40857. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40858. * @param scene defines the hosting scene
  40859. */
  40860. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40861. /**
  40862. * Gets camera class name
  40863. * @returns StereoscopicUniversalCamera
  40864. */
  40865. getClassName(): string;
  40866. }
  40867. }
  40868. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40869. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40870. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40871. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40872. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40873. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40874. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40875. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40876. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40877. }
  40878. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40879. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40880. import { Scene } from "babylonjs/scene";
  40881. import { Vector3 } from "babylonjs/Maths/math.vector";
  40882. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40883. /**
  40884. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40885. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40886. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40887. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40888. */
  40889. export class VirtualJoysticksCamera extends FreeCamera {
  40890. /**
  40891. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40892. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40893. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40894. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40895. * @param name Define the name of the camera in the scene
  40896. * @param position Define the start position of the camera in the scene
  40897. * @param scene Define the scene the camera belongs to
  40898. */
  40899. constructor(name: string, position: Vector3, scene: Scene);
  40900. /**
  40901. * Gets the current object class name.
  40902. * @return the class name
  40903. */
  40904. getClassName(): string;
  40905. }
  40906. }
  40907. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40908. import { Matrix } from "babylonjs/Maths/math.vector";
  40909. /**
  40910. * This represents all the required metrics to create a VR camera.
  40911. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40912. */
  40913. export class VRCameraMetrics {
  40914. /**
  40915. * Define the horizontal resolution off the screen.
  40916. */
  40917. hResolution: number;
  40918. /**
  40919. * Define the vertical resolution off the screen.
  40920. */
  40921. vResolution: number;
  40922. /**
  40923. * Define the horizontal screen size.
  40924. */
  40925. hScreenSize: number;
  40926. /**
  40927. * Define the vertical screen size.
  40928. */
  40929. vScreenSize: number;
  40930. /**
  40931. * Define the vertical screen center position.
  40932. */
  40933. vScreenCenter: number;
  40934. /**
  40935. * Define the distance of the eyes to the screen.
  40936. */
  40937. eyeToScreenDistance: number;
  40938. /**
  40939. * Define the distance between both lenses
  40940. */
  40941. lensSeparationDistance: number;
  40942. /**
  40943. * Define the distance between both viewer's eyes.
  40944. */
  40945. interpupillaryDistance: number;
  40946. /**
  40947. * Define the distortion factor of the VR postprocess.
  40948. * Please, touch with care.
  40949. */
  40950. distortionK: number[];
  40951. /**
  40952. * Define the chromatic aberration correction factors for the VR post process.
  40953. */
  40954. chromaAbCorrection: number[];
  40955. /**
  40956. * Define the scale factor of the post process.
  40957. * The smaller the better but the slower.
  40958. */
  40959. postProcessScaleFactor: number;
  40960. /**
  40961. * Define an offset for the lens center.
  40962. */
  40963. lensCenterOffset: number;
  40964. /**
  40965. * Define if the current vr camera should compensate the distortion of the lense or not.
  40966. */
  40967. compensateDistortion: boolean;
  40968. /**
  40969. * Defines if multiview should be enabled when rendering (Default: false)
  40970. */
  40971. multiviewEnabled: boolean;
  40972. /**
  40973. * Gets the rendering aspect ratio based on the provided resolutions.
  40974. */
  40975. readonly aspectRatio: number;
  40976. /**
  40977. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  40978. */
  40979. readonly aspectRatioFov: number;
  40980. /**
  40981. * @hidden
  40982. */
  40983. readonly leftHMatrix: Matrix;
  40984. /**
  40985. * @hidden
  40986. */
  40987. readonly rightHMatrix: Matrix;
  40988. /**
  40989. * @hidden
  40990. */
  40991. readonly leftPreViewMatrix: Matrix;
  40992. /**
  40993. * @hidden
  40994. */
  40995. readonly rightPreViewMatrix: Matrix;
  40996. /**
  40997. * Get the default VRMetrics based on the most generic setup.
  40998. * @returns the default vr metrics
  40999. */
  41000. static GetDefault(): VRCameraMetrics;
  41001. }
  41002. }
  41003. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41004. /** @hidden */
  41005. export var vrDistortionCorrectionPixelShader: {
  41006. name: string;
  41007. shader: string;
  41008. };
  41009. }
  41010. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41011. import { Camera } from "babylonjs/Cameras/camera";
  41012. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41013. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41014. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41015. /**
  41016. * VRDistortionCorrectionPostProcess used for mobile VR
  41017. */
  41018. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41019. private _isRightEye;
  41020. private _distortionFactors;
  41021. private _postProcessScaleFactor;
  41022. private _lensCenterOffset;
  41023. private _scaleIn;
  41024. private _scaleFactor;
  41025. private _lensCenter;
  41026. /**
  41027. * Initializes the VRDistortionCorrectionPostProcess
  41028. * @param name The name of the effect.
  41029. * @param camera The camera to apply the render pass to.
  41030. * @param isRightEye If this is for the right eye distortion
  41031. * @param vrMetrics All the required metrics for the VR camera
  41032. */
  41033. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41034. }
  41035. }
  41036. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41037. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41038. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41039. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41040. import { Scene } from "babylonjs/scene";
  41041. import { Vector3 } from "babylonjs/Maths/math.vector";
  41042. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41043. import "babylonjs/Cameras/RigModes/vrRigMode";
  41044. /**
  41045. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41046. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41047. */
  41048. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41049. /**
  41050. * Creates a new VRDeviceOrientationArcRotateCamera
  41051. * @param name defines camera name
  41052. * @param alpha defines the camera rotation along the logitudinal axis
  41053. * @param beta defines the camera rotation along the latitudinal axis
  41054. * @param radius defines the camera distance from its target
  41055. * @param target defines the camera target
  41056. * @param scene defines the scene the camera belongs to
  41057. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41058. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41059. */
  41060. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41061. /**
  41062. * Gets camera class name
  41063. * @returns VRDeviceOrientationArcRotateCamera
  41064. */
  41065. getClassName(): string;
  41066. }
  41067. }
  41068. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41069. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41070. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41071. import { Scene } from "babylonjs/scene";
  41072. import { Vector3 } from "babylonjs/Maths/math.vector";
  41073. import "babylonjs/Cameras/RigModes/vrRigMode";
  41074. /**
  41075. * Camera used to simulate VR rendering (based on FreeCamera)
  41076. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41077. */
  41078. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41079. /**
  41080. * Creates a new VRDeviceOrientationFreeCamera
  41081. * @param name defines camera name
  41082. * @param position defines the start position of the camera
  41083. * @param scene defines the scene the camera belongs to
  41084. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41085. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41086. */
  41087. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41088. /**
  41089. * Gets camera class name
  41090. * @returns VRDeviceOrientationFreeCamera
  41091. */
  41092. getClassName(): string;
  41093. }
  41094. }
  41095. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41096. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41097. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41098. import { Scene } from "babylonjs/scene";
  41099. import { Vector3 } from "babylonjs/Maths/math.vector";
  41100. import "babylonjs/Gamepads/gamepadSceneComponent";
  41101. /**
  41102. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41103. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41104. */
  41105. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41106. /**
  41107. * Creates a new VRDeviceOrientationGamepadCamera
  41108. * @param name defines camera name
  41109. * @param position defines the start position of the camera
  41110. * @param scene defines the scene the camera belongs to
  41111. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41112. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41113. */
  41114. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41115. /**
  41116. * Gets camera class name
  41117. * @returns VRDeviceOrientationGamepadCamera
  41118. */
  41119. getClassName(): string;
  41120. }
  41121. }
  41122. declare module "babylonjs/Materials/pushMaterial" {
  41123. import { Nullable } from "babylonjs/types";
  41124. import { Scene } from "babylonjs/scene";
  41125. import { Matrix } from "babylonjs/Maths/math.vector";
  41126. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41127. import { Mesh } from "babylonjs/Meshes/mesh";
  41128. import { Material } from "babylonjs/Materials/material";
  41129. import { Effect } from "babylonjs/Materials/effect";
  41130. /**
  41131. * Base class of materials working in push mode in babylon JS
  41132. * @hidden
  41133. */
  41134. export class PushMaterial extends Material {
  41135. protected _activeEffect: Effect;
  41136. protected _normalMatrix: Matrix;
  41137. /**
  41138. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41139. * This means that the material can keep using a previous shader while a new one is being compiled.
  41140. * This is mostly used when shader parallel compilation is supported (true by default)
  41141. */
  41142. allowShaderHotSwapping: boolean;
  41143. constructor(name: string, scene: Scene);
  41144. getEffect(): Effect;
  41145. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41146. /**
  41147. * Binds the given world matrix to the active effect
  41148. *
  41149. * @param world the matrix to bind
  41150. */
  41151. bindOnlyWorldMatrix(world: Matrix): void;
  41152. /**
  41153. * Binds the given normal matrix to the active effect
  41154. *
  41155. * @param normalMatrix the matrix to bind
  41156. */
  41157. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41158. bind(world: Matrix, mesh?: Mesh): void;
  41159. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41160. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41161. }
  41162. }
  41163. declare module "babylonjs/Materials/materialFlags" {
  41164. /**
  41165. * This groups all the flags used to control the materials channel.
  41166. */
  41167. export class MaterialFlags {
  41168. private static _DiffuseTextureEnabled;
  41169. /**
  41170. * Are diffuse textures enabled in the application.
  41171. */
  41172. static DiffuseTextureEnabled: boolean;
  41173. private static _AmbientTextureEnabled;
  41174. /**
  41175. * Are ambient textures enabled in the application.
  41176. */
  41177. static AmbientTextureEnabled: boolean;
  41178. private static _OpacityTextureEnabled;
  41179. /**
  41180. * Are opacity textures enabled in the application.
  41181. */
  41182. static OpacityTextureEnabled: boolean;
  41183. private static _ReflectionTextureEnabled;
  41184. /**
  41185. * Are reflection textures enabled in the application.
  41186. */
  41187. static ReflectionTextureEnabled: boolean;
  41188. private static _EmissiveTextureEnabled;
  41189. /**
  41190. * Are emissive textures enabled in the application.
  41191. */
  41192. static EmissiveTextureEnabled: boolean;
  41193. private static _SpecularTextureEnabled;
  41194. /**
  41195. * Are specular textures enabled in the application.
  41196. */
  41197. static SpecularTextureEnabled: boolean;
  41198. private static _BumpTextureEnabled;
  41199. /**
  41200. * Are bump textures enabled in the application.
  41201. */
  41202. static BumpTextureEnabled: boolean;
  41203. private static _LightmapTextureEnabled;
  41204. /**
  41205. * Are lightmap textures enabled in the application.
  41206. */
  41207. static LightmapTextureEnabled: boolean;
  41208. private static _RefractionTextureEnabled;
  41209. /**
  41210. * Are refraction textures enabled in the application.
  41211. */
  41212. static RefractionTextureEnabled: boolean;
  41213. private static _ColorGradingTextureEnabled;
  41214. /**
  41215. * Are color grading textures enabled in the application.
  41216. */
  41217. static ColorGradingTextureEnabled: boolean;
  41218. private static _FresnelEnabled;
  41219. /**
  41220. * Are fresnels enabled in the application.
  41221. */
  41222. static FresnelEnabled: boolean;
  41223. private static _ClearCoatTextureEnabled;
  41224. /**
  41225. * Are clear coat textures enabled in the application.
  41226. */
  41227. static ClearCoatTextureEnabled: boolean;
  41228. private static _ClearCoatBumpTextureEnabled;
  41229. /**
  41230. * Are clear coat bump textures enabled in the application.
  41231. */
  41232. static ClearCoatBumpTextureEnabled: boolean;
  41233. private static _ClearCoatTintTextureEnabled;
  41234. /**
  41235. * Are clear coat tint textures enabled in the application.
  41236. */
  41237. static ClearCoatTintTextureEnabled: boolean;
  41238. private static _SheenTextureEnabled;
  41239. /**
  41240. * Are sheen textures enabled in the application.
  41241. */
  41242. static SheenTextureEnabled: boolean;
  41243. private static _AnisotropicTextureEnabled;
  41244. /**
  41245. * Are anisotropic textures enabled in the application.
  41246. */
  41247. static AnisotropicTextureEnabled: boolean;
  41248. private static _ThicknessTextureEnabled;
  41249. /**
  41250. * Are thickness textures enabled in the application.
  41251. */
  41252. static ThicknessTextureEnabled: boolean;
  41253. }
  41254. }
  41255. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41256. /** @hidden */
  41257. export var defaultFragmentDeclaration: {
  41258. name: string;
  41259. shader: string;
  41260. };
  41261. }
  41262. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41263. /** @hidden */
  41264. export var defaultUboDeclaration: {
  41265. name: string;
  41266. shader: string;
  41267. };
  41268. }
  41269. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41270. /** @hidden */
  41271. export var lightFragmentDeclaration: {
  41272. name: string;
  41273. shader: string;
  41274. };
  41275. }
  41276. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41277. /** @hidden */
  41278. export var lightUboDeclaration: {
  41279. name: string;
  41280. shader: string;
  41281. };
  41282. }
  41283. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41284. /** @hidden */
  41285. export var lightsFragmentFunctions: {
  41286. name: string;
  41287. shader: string;
  41288. };
  41289. }
  41290. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41291. /** @hidden */
  41292. export var shadowsFragmentFunctions: {
  41293. name: string;
  41294. shader: string;
  41295. };
  41296. }
  41297. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41298. /** @hidden */
  41299. export var fresnelFunction: {
  41300. name: string;
  41301. shader: string;
  41302. };
  41303. }
  41304. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41305. /** @hidden */
  41306. export var reflectionFunction: {
  41307. name: string;
  41308. shader: string;
  41309. };
  41310. }
  41311. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41312. /** @hidden */
  41313. export var bumpFragmentFunctions: {
  41314. name: string;
  41315. shader: string;
  41316. };
  41317. }
  41318. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41319. /** @hidden */
  41320. export var logDepthDeclaration: {
  41321. name: string;
  41322. shader: string;
  41323. };
  41324. }
  41325. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41326. /** @hidden */
  41327. export var bumpFragment: {
  41328. name: string;
  41329. shader: string;
  41330. };
  41331. }
  41332. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41333. /** @hidden */
  41334. export var depthPrePass: {
  41335. name: string;
  41336. shader: string;
  41337. };
  41338. }
  41339. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41340. /** @hidden */
  41341. export var lightFragment: {
  41342. name: string;
  41343. shader: string;
  41344. };
  41345. }
  41346. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41347. /** @hidden */
  41348. export var logDepthFragment: {
  41349. name: string;
  41350. shader: string;
  41351. };
  41352. }
  41353. declare module "babylonjs/Shaders/default.fragment" {
  41354. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41355. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41356. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41357. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41358. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41359. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41360. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41361. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41362. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41363. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41364. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41365. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41366. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41367. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41368. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41369. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41370. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41371. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41372. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41373. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41374. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41375. /** @hidden */
  41376. export var defaultPixelShader: {
  41377. name: string;
  41378. shader: string;
  41379. };
  41380. }
  41381. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41382. /** @hidden */
  41383. export var defaultVertexDeclaration: {
  41384. name: string;
  41385. shader: string;
  41386. };
  41387. }
  41388. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41389. /** @hidden */
  41390. export var bumpVertexDeclaration: {
  41391. name: string;
  41392. shader: string;
  41393. };
  41394. }
  41395. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41396. /** @hidden */
  41397. export var bumpVertex: {
  41398. name: string;
  41399. shader: string;
  41400. };
  41401. }
  41402. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41403. /** @hidden */
  41404. export var fogVertex: {
  41405. name: string;
  41406. shader: string;
  41407. };
  41408. }
  41409. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41410. /** @hidden */
  41411. export var shadowsVertex: {
  41412. name: string;
  41413. shader: string;
  41414. };
  41415. }
  41416. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41417. /** @hidden */
  41418. export var pointCloudVertex: {
  41419. name: string;
  41420. shader: string;
  41421. };
  41422. }
  41423. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41424. /** @hidden */
  41425. export var logDepthVertex: {
  41426. name: string;
  41427. shader: string;
  41428. };
  41429. }
  41430. declare module "babylonjs/Shaders/default.vertex" {
  41431. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41432. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41433. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41434. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41435. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41436. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41437. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41438. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41439. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41440. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41441. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41442. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41443. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41444. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41445. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41446. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41447. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41448. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41449. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41450. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41451. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41452. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41453. /** @hidden */
  41454. export var defaultVertexShader: {
  41455. name: string;
  41456. shader: string;
  41457. };
  41458. }
  41459. declare module "babylonjs/Materials/standardMaterial" {
  41460. import { SmartArray } from "babylonjs/Misc/smartArray";
  41461. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41462. import { Nullable } from "babylonjs/types";
  41463. import { Scene } from "babylonjs/scene";
  41464. import { Matrix } from "babylonjs/Maths/math.vector";
  41465. import { Color3 } from "babylonjs/Maths/math.color";
  41466. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41468. import { Mesh } from "babylonjs/Meshes/mesh";
  41469. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41470. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41471. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41472. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41473. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41474. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41475. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41476. import "babylonjs/Shaders/default.fragment";
  41477. import "babylonjs/Shaders/default.vertex";
  41478. /** @hidden */
  41479. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41480. MAINUV1: boolean;
  41481. MAINUV2: boolean;
  41482. DIFFUSE: boolean;
  41483. DIFFUSEDIRECTUV: number;
  41484. AMBIENT: boolean;
  41485. AMBIENTDIRECTUV: number;
  41486. OPACITY: boolean;
  41487. OPACITYDIRECTUV: number;
  41488. OPACITYRGB: boolean;
  41489. REFLECTION: boolean;
  41490. EMISSIVE: boolean;
  41491. EMISSIVEDIRECTUV: number;
  41492. SPECULAR: boolean;
  41493. SPECULARDIRECTUV: number;
  41494. BUMP: boolean;
  41495. BUMPDIRECTUV: number;
  41496. PARALLAX: boolean;
  41497. PARALLAXOCCLUSION: boolean;
  41498. SPECULAROVERALPHA: boolean;
  41499. CLIPPLANE: boolean;
  41500. CLIPPLANE2: boolean;
  41501. CLIPPLANE3: boolean;
  41502. CLIPPLANE4: boolean;
  41503. ALPHATEST: boolean;
  41504. DEPTHPREPASS: boolean;
  41505. ALPHAFROMDIFFUSE: boolean;
  41506. POINTSIZE: boolean;
  41507. FOG: boolean;
  41508. SPECULARTERM: boolean;
  41509. DIFFUSEFRESNEL: boolean;
  41510. OPACITYFRESNEL: boolean;
  41511. REFLECTIONFRESNEL: boolean;
  41512. REFRACTIONFRESNEL: boolean;
  41513. EMISSIVEFRESNEL: boolean;
  41514. FRESNEL: boolean;
  41515. NORMAL: boolean;
  41516. UV1: boolean;
  41517. UV2: boolean;
  41518. VERTEXCOLOR: boolean;
  41519. VERTEXALPHA: boolean;
  41520. NUM_BONE_INFLUENCERS: number;
  41521. BonesPerMesh: number;
  41522. BONETEXTURE: boolean;
  41523. INSTANCES: boolean;
  41524. GLOSSINESS: boolean;
  41525. ROUGHNESS: boolean;
  41526. EMISSIVEASILLUMINATION: boolean;
  41527. LINKEMISSIVEWITHDIFFUSE: boolean;
  41528. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41529. LIGHTMAP: boolean;
  41530. LIGHTMAPDIRECTUV: number;
  41531. OBJECTSPACE_NORMALMAP: boolean;
  41532. USELIGHTMAPASSHADOWMAP: boolean;
  41533. REFLECTIONMAP_3D: boolean;
  41534. REFLECTIONMAP_SPHERICAL: boolean;
  41535. REFLECTIONMAP_PLANAR: boolean;
  41536. REFLECTIONMAP_CUBIC: boolean;
  41537. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41538. REFLECTIONMAP_PROJECTION: boolean;
  41539. REFLECTIONMAP_SKYBOX: boolean;
  41540. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41541. REFLECTIONMAP_EXPLICIT: boolean;
  41542. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41543. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41544. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41545. INVERTCUBICMAP: boolean;
  41546. LOGARITHMICDEPTH: boolean;
  41547. REFRACTION: boolean;
  41548. REFRACTIONMAP_3D: boolean;
  41549. REFLECTIONOVERALPHA: boolean;
  41550. TWOSIDEDLIGHTING: boolean;
  41551. SHADOWFLOAT: boolean;
  41552. MORPHTARGETS: boolean;
  41553. MORPHTARGETS_NORMAL: boolean;
  41554. MORPHTARGETS_TANGENT: boolean;
  41555. MORPHTARGETS_UV: boolean;
  41556. NUM_MORPH_INFLUENCERS: number;
  41557. NONUNIFORMSCALING: boolean;
  41558. PREMULTIPLYALPHA: boolean;
  41559. IMAGEPROCESSING: boolean;
  41560. VIGNETTE: boolean;
  41561. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41562. VIGNETTEBLENDMODEOPAQUE: boolean;
  41563. TONEMAPPING: boolean;
  41564. TONEMAPPING_ACES: boolean;
  41565. CONTRAST: boolean;
  41566. COLORCURVES: boolean;
  41567. COLORGRADING: boolean;
  41568. COLORGRADING3D: boolean;
  41569. SAMPLER3DGREENDEPTH: boolean;
  41570. SAMPLER3DBGRMAP: boolean;
  41571. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41572. MULTIVIEW: boolean;
  41573. /**
  41574. * If the reflection texture on this material is in linear color space
  41575. * @hidden
  41576. */
  41577. IS_REFLECTION_LINEAR: boolean;
  41578. /**
  41579. * If the refraction texture on this material is in linear color space
  41580. * @hidden
  41581. */
  41582. IS_REFRACTION_LINEAR: boolean;
  41583. EXPOSURE: boolean;
  41584. constructor();
  41585. setReflectionMode(modeToEnable: string): void;
  41586. }
  41587. /**
  41588. * This is the default material used in Babylon. It is the best trade off between quality
  41589. * and performances.
  41590. * @see http://doc.babylonjs.com/babylon101/materials
  41591. */
  41592. export class StandardMaterial extends PushMaterial {
  41593. private _diffuseTexture;
  41594. /**
  41595. * The basic texture of the material as viewed under a light.
  41596. */
  41597. diffuseTexture: Nullable<BaseTexture>;
  41598. private _ambientTexture;
  41599. /**
  41600. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41601. */
  41602. ambientTexture: Nullable<BaseTexture>;
  41603. private _opacityTexture;
  41604. /**
  41605. * Define the transparency of the material from a texture.
  41606. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41607. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41608. */
  41609. opacityTexture: Nullable<BaseTexture>;
  41610. private _reflectionTexture;
  41611. /**
  41612. * Define the texture used to display the reflection.
  41613. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41614. */
  41615. reflectionTexture: Nullable<BaseTexture>;
  41616. private _emissiveTexture;
  41617. /**
  41618. * Define texture of the material as if self lit.
  41619. * This will be mixed in the final result even in the absence of light.
  41620. */
  41621. emissiveTexture: Nullable<BaseTexture>;
  41622. private _specularTexture;
  41623. /**
  41624. * Define how the color and intensity of the highlight given by the light in the material.
  41625. */
  41626. specularTexture: Nullable<BaseTexture>;
  41627. private _bumpTexture;
  41628. /**
  41629. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41630. * 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.
  41631. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41632. */
  41633. bumpTexture: Nullable<BaseTexture>;
  41634. private _lightmapTexture;
  41635. /**
  41636. * Complex lighting can be computationally expensive to compute at runtime.
  41637. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41638. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41639. */
  41640. lightmapTexture: Nullable<BaseTexture>;
  41641. private _refractionTexture;
  41642. /**
  41643. * Define the texture used to display the refraction.
  41644. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41645. */
  41646. refractionTexture: Nullable<BaseTexture>;
  41647. /**
  41648. * The color of the material lit by the environmental background lighting.
  41649. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41650. */
  41651. ambientColor: Color3;
  41652. /**
  41653. * The basic color of the material as viewed under a light.
  41654. */
  41655. diffuseColor: Color3;
  41656. /**
  41657. * Define how the color and intensity of the highlight given by the light in the material.
  41658. */
  41659. specularColor: Color3;
  41660. /**
  41661. * Define the color of the material as if self lit.
  41662. * This will be mixed in the final result even in the absence of light.
  41663. */
  41664. emissiveColor: Color3;
  41665. /**
  41666. * Defines how sharp are the highlights in the material.
  41667. * The bigger the value the sharper giving a more glossy feeling to the result.
  41668. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41669. */
  41670. specularPower: number;
  41671. private _useAlphaFromDiffuseTexture;
  41672. /**
  41673. * Does the transparency come from the diffuse texture alpha channel.
  41674. */
  41675. useAlphaFromDiffuseTexture: boolean;
  41676. private _useEmissiveAsIllumination;
  41677. /**
  41678. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41679. */
  41680. useEmissiveAsIllumination: boolean;
  41681. private _linkEmissiveWithDiffuse;
  41682. /**
  41683. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41684. * the emissive level when the final color is close to one.
  41685. */
  41686. linkEmissiveWithDiffuse: boolean;
  41687. private _useSpecularOverAlpha;
  41688. /**
  41689. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41690. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41691. */
  41692. useSpecularOverAlpha: boolean;
  41693. private _useReflectionOverAlpha;
  41694. /**
  41695. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41696. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41697. */
  41698. useReflectionOverAlpha: boolean;
  41699. private _disableLighting;
  41700. /**
  41701. * Does lights from the scene impacts this material.
  41702. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41703. */
  41704. disableLighting: boolean;
  41705. private _useObjectSpaceNormalMap;
  41706. /**
  41707. * Allows using an object space normal map (instead of tangent space).
  41708. */
  41709. useObjectSpaceNormalMap: boolean;
  41710. private _useParallax;
  41711. /**
  41712. * Is parallax enabled or not.
  41713. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41714. */
  41715. useParallax: boolean;
  41716. private _useParallaxOcclusion;
  41717. /**
  41718. * Is parallax occlusion enabled or not.
  41719. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41720. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41721. */
  41722. useParallaxOcclusion: boolean;
  41723. /**
  41724. * 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.
  41725. */
  41726. parallaxScaleBias: number;
  41727. private _roughness;
  41728. /**
  41729. * Helps to define how blurry the reflections should appears in the material.
  41730. */
  41731. roughness: number;
  41732. /**
  41733. * In case of refraction, define the value of the index of refraction.
  41734. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41735. */
  41736. indexOfRefraction: number;
  41737. /**
  41738. * Invert the refraction texture alongside the y axis.
  41739. * It can be useful with procedural textures or probe for instance.
  41740. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41741. */
  41742. invertRefractionY: boolean;
  41743. /**
  41744. * Defines the alpha limits in alpha test mode.
  41745. */
  41746. alphaCutOff: number;
  41747. private _useLightmapAsShadowmap;
  41748. /**
  41749. * In case of light mapping, define whether the map contains light or shadow informations.
  41750. */
  41751. useLightmapAsShadowmap: boolean;
  41752. private _diffuseFresnelParameters;
  41753. /**
  41754. * Define the diffuse fresnel parameters of the material.
  41755. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41756. */
  41757. diffuseFresnelParameters: FresnelParameters;
  41758. private _opacityFresnelParameters;
  41759. /**
  41760. * Define the opacity fresnel parameters of the material.
  41761. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41762. */
  41763. opacityFresnelParameters: FresnelParameters;
  41764. private _reflectionFresnelParameters;
  41765. /**
  41766. * Define the reflection fresnel parameters of the material.
  41767. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41768. */
  41769. reflectionFresnelParameters: FresnelParameters;
  41770. private _refractionFresnelParameters;
  41771. /**
  41772. * Define the refraction fresnel parameters of the material.
  41773. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41774. */
  41775. refractionFresnelParameters: FresnelParameters;
  41776. private _emissiveFresnelParameters;
  41777. /**
  41778. * Define the emissive fresnel parameters of the material.
  41779. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41780. */
  41781. emissiveFresnelParameters: FresnelParameters;
  41782. private _useReflectionFresnelFromSpecular;
  41783. /**
  41784. * If true automatically deducts the fresnels values from the material specularity.
  41785. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41786. */
  41787. useReflectionFresnelFromSpecular: boolean;
  41788. private _useGlossinessFromSpecularMapAlpha;
  41789. /**
  41790. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41791. */
  41792. useGlossinessFromSpecularMapAlpha: boolean;
  41793. private _maxSimultaneousLights;
  41794. /**
  41795. * Defines the maximum number of lights that can be used in the material
  41796. */
  41797. maxSimultaneousLights: number;
  41798. private _invertNormalMapX;
  41799. /**
  41800. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41801. */
  41802. invertNormalMapX: boolean;
  41803. private _invertNormalMapY;
  41804. /**
  41805. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41806. */
  41807. invertNormalMapY: boolean;
  41808. private _twoSidedLighting;
  41809. /**
  41810. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41811. */
  41812. twoSidedLighting: boolean;
  41813. /**
  41814. * Default configuration related to image processing available in the standard Material.
  41815. */
  41816. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41817. /**
  41818. * Gets the image processing configuration used either in this material.
  41819. */
  41820. /**
  41821. * Sets the Default image processing configuration used either in the this material.
  41822. *
  41823. * If sets to null, the scene one is in use.
  41824. */
  41825. imageProcessingConfiguration: ImageProcessingConfiguration;
  41826. /**
  41827. * Keep track of the image processing observer to allow dispose and replace.
  41828. */
  41829. private _imageProcessingObserver;
  41830. /**
  41831. * Attaches a new image processing configuration to the Standard Material.
  41832. * @param configuration
  41833. */
  41834. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41835. /**
  41836. * Gets wether the color curves effect is enabled.
  41837. */
  41838. /**
  41839. * Sets wether the color curves effect is enabled.
  41840. */
  41841. cameraColorCurvesEnabled: boolean;
  41842. /**
  41843. * Gets wether the color grading effect is enabled.
  41844. */
  41845. /**
  41846. * Gets wether the color grading effect is enabled.
  41847. */
  41848. cameraColorGradingEnabled: boolean;
  41849. /**
  41850. * Gets wether tonemapping is enabled or not.
  41851. */
  41852. /**
  41853. * Sets wether tonemapping is enabled or not
  41854. */
  41855. cameraToneMappingEnabled: boolean;
  41856. /**
  41857. * The camera exposure used on this material.
  41858. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41859. * This corresponds to a photographic exposure.
  41860. */
  41861. /**
  41862. * The camera exposure used on this material.
  41863. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41864. * This corresponds to a photographic exposure.
  41865. */
  41866. cameraExposure: number;
  41867. /**
  41868. * Gets The camera contrast used on this material.
  41869. */
  41870. /**
  41871. * Sets The camera contrast used on this material.
  41872. */
  41873. cameraContrast: number;
  41874. /**
  41875. * Gets the Color Grading 2D Lookup Texture.
  41876. */
  41877. /**
  41878. * Sets the Color Grading 2D Lookup Texture.
  41879. */
  41880. cameraColorGradingTexture: Nullable<BaseTexture>;
  41881. /**
  41882. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41883. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41884. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  41885. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41886. */
  41887. /**
  41888. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41889. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41890. * 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;
  41891. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41892. */
  41893. cameraColorCurves: Nullable<ColorCurves>;
  41894. /**
  41895. * Custom callback helping to override the default shader used in the material.
  41896. */
  41897. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41898. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41899. protected _worldViewProjectionMatrix: Matrix;
  41900. protected _globalAmbientColor: Color3;
  41901. protected _useLogarithmicDepth: boolean;
  41902. protected _rebuildInParallel: boolean;
  41903. /**
  41904. * Instantiates a new standard material.
  41905. * This is the default material used in Babylon. It is the best trade off between quality
  41906. * and performances.
  41907. * @see http://doc.babylonjs.com/babylon101/materials
  41908. * @param name Define the name of the material in the scene
  41909. * @param scene Define the scene the material belong to
  41910. */
  41911. constructor(name: string, scene: Scene);
  41912. /**
  41913. * Gets a boolean indicating that current material needs to register RTT
  41914. */
  41915. readonly hasRenderTargetTextures: boolean;
  41916. /**
  41917. * Gets the current class name of the material e.g. "StandardMaterial"
  41918. * Mainly use in serialization.
  41919. * @returns the class name
  41920. */
  41921. getClassName(): string;
  41922. /**
  41923. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  41924. * You can try switching to logarithmic depth.
  41925. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  41926. */
  41927. useLogarithmicDepth: boolean;
  41928. /**
  41929. * Specifies if the material will require alpha blending
  41930. * @returns a boolean specifying if alpha blending is needed
  41931. */
  41932. needAlphaBlending(): boolean;
  41933. /**
  41934. * Specifies if this material should be rendered in alpha test mode
  41935. * @returns a boolean specifying if an alpha test is needed.
  41936. */
  41937. needAlphaTesting(): boolean;
  41938. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  41939. /**
  41940. * Get the texture used for alpha test purpose.
  41941. * @returns the diffuse texture in case of the standard material.
  41942. */
  41943. getAlphaTestTexture(): Nullable<BaseTexture>;
  41944. /**
  41945. * Get if the submesh is ready to be used and all its information available.
  41946. * Child classes can use it to update shaders
  41947. * @param mesh defines the mesh to check
  41948. * @param subMesh defines which submesh to check
  41949. * @param useInstances specifies that instances should be used
  41950. * @returns a boolean indicating that the submesh is ready or not
  41951. */
  41952. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  41953. /**
  41954. * Builds the material UBO layouts.
  41955. * Used internally during the effect preparation.
  41956. */
  41957. buildUniformLayout(): void;
  41958. /**
  41959. * Unbinds the material from the mesh
  41960. */
  41961. unbind(): void;
  41962. /**
  41963. * Binds the submesh to this material by preparing the effect and shader to draw
  41964. * @param world defines the world transformation matrix
  41965. * @param mesh defines the mesh containing the submesh
  41966. * @param subMesh defines the submesh to bind the material to
  41967. */
  41968. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  41969. /**
  41970. * Get the list of animatables in the material.
  41971. * @returns the list of animatables object used in the material
  41972. */
  41973. getAnimatables(): IAnimatable[];
  41974. /**
  41975. * Gets the active textures from the material
  41976. * @returns an array of textures
  41977. */
  41978. getActiveTextures(): BaseTexture[];
  41979. /**
  41980. * Specifies if the material uses a texture
  41981. * @param texture defines the texture to check against the material
  41982. * @returns a boolean specifying if the material uses the texture
  41983. */
  41984. hasTexture(texture: BaseTexture): boolean;
  41985. /**
  41986. * Disposes the material
  41987. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  41988. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  41989. */
  41990. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  41991. /**
  41992. * Makes a duplicate of the material, and gives it a new name
  41993. * @param name defines the new name for the duplicated material
  41994. * @returns the cloned material
  41995. */
  41996. clone(name: string): StandardMaterial;
  41997. /**
  41998. * Serializes this material in a JSON representation
  41999. * @returns the serialized material object
  42000. */
  42001. serialize(): any;
  42002. /**
  42003. * Creates a standard material from parsed material data
  42004. * @param source defines the JSON representation of the material
  42005. * @param scene defines the hosting scene
  42006. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42007. * @returns a new standard material
  42008. */
  42009. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42010. /**
  42011. * Are diffuse textures enabled in the application.
  42012. */
  42013. static DiffuseTextureEnabled: boolean;
  42014. /**
  42015. * Are ambient textures enabled in the application.
  42016. */
  42017. static AmbientTextureEnabled: boolean;
  42018. /**
  42019. * Are opacity textures enabled in the application.
  42020. */
  42021. static OpacityTextureEnabled: boolean;
  42022. /**
  42023. * Are reflection textures enabled in the application.
  42024. */
  42025. static ReflectionTextureEnabled: boolean;
  42026. /**
  42027. * Are emissive textures enabled in the application.
  42028. */
  42029. static EmissiveTextureEnabled: boolean;
  42030. /**
  42031. * Are specular textures enabled in the application.
  42032. */
  42033. static SpecularTextureEnabled: boolean;
  42034. /**
  42035. * Are bump textures enabled in the application.
  42036. */
  42037. static BumpTextureEnabled: boolean;
  42038. /**
  42039. * Are lightmap textures enabled in the application.
  42040. */
  42041. static LightmapTextureEnabled: boolean;
  42042. /**
  42043. * Are refraction textures enabled in the application.
  42044. */
  42045. static RefractionTextureEnabled: boolean;
  42046. /**
  42047. * Are color grading textures enabled in the application.
  42048. */
  42049. static ColorGradingTextureEnabled: boolean;
  42050. /**
  42051. * Are fresnels enabled in the application.
  42052. */
  42053. static FresnelEnabled: boolean;
  42054. }
  42055. }
  42056. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42057. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42058. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42059. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42060. /** @hidden */
  42061. export var imageProcessingPixelShader: {
  42062. name: string;
  42063. shader: string;
  42064. };
  42065. }
  42066. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42067. import { Nullable } from "babylonjs/types";
  42068. import { Color4 } from "babylonjs/Maths/math.color";
  42069. import { Camera } from "babylonjs/Cameras/camera";
  42070. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42071. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42072. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42073. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42074. import { Engine } from "babylonjs/Engines/engine";
  42075. import "babylonjs/Shaders/imageProcessing.fragment";
  42076. import "babylonjs/Shaders/postprocess.vertex";
  42077. /**
  42078. * ImageProcessingPostProcess
  42079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42080. */
  42081. export class ImageProcessingPostProcess extends PostProcess {
  42082. /**
  42083. * Default configuration related to image processing available in the PBR Material.
  42084. */
  42085. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42086. /**
  42087. * Gets the image processing configuration used either in this material.
  42088. */
  42089. /**
  42090. * Sets the Default image processing configuration used either in the this material.
  42091. *
  42092. * If sets to null, the scene one is in use.
  42093. */
  42094. imageProcessingConfiguration: ImageProcessingConfiguration;
  42095. /**
  42096. * Keep track of the image processing observer to allow dispose and replace.
  42097. */
  42098. private _imageProcessingObserver;
  42099. /**
  42100. * Attaches a new image processing configuration to the PBR Material.
  42101. * @param configuration
  42102. */
  42103. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42104. /**
  42105. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42106. */
  42107. /**
  42108. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42109. */
  42110. colorCurves: Nullable<ColorCurves>;
  42111. /**
  42112. * Gets wether the color curves effect is enabled.
  42113. */
  42114. /**
  42115. * Sets wether the color curves effect is enabled.
  42116. */
  42117. colorCurvesEnabled: boolean;
  42118. /**
  42119. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42120. */
  42121. /**
  42122. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42123. */
  42124. colorGradingTexture: Nullable<BaseTexture>;
  42125. /**
  42126. * Gets wether the color grading effect is enabled.
  42127. */
  42128. /**
  42129. * Gets wether the color grading effect is enabled.
  42130. */
  42131. colorGradingEnabled: boolean;
  42132. /**
  42133. * Gets exposure used in the effect.
  42134. */
  42135. /**
  42136. * Sets exposure used in the effect.
  42137. */
  42138. exposure: number;
  42139. /**
  42140. * Gets wether tonemapping is enabled or not.
  42141. */
  42142. /**
  42143. * Sets wether tonemapping is enabled or not
  42144. */
  42145. toneMappingEnabled: boolean;
  42146. /**
  42147. * Gets the type of tone mapping effect.
  42148. */
  42149. /**
  42150. * Sets the type of tone mapping effect.
  42151. */
  42152. toneMappingType: number;
  42153. /**
  42154. * Gets contrast used in the effect.
  42155. */
  42156. /**
  42157. * Sets contrast used in the effect.
  42158. */
  42159. contrast: number;
  42160. /**
  42161. * Gets Vignette stretch size.
  42162. */
  42163. /**
  42164. * Sets Vignette stretch size.
  42165. */
  42166. vignetteStretch: number;
  42167. /**
  42168. * Gets Vignette centre X Offset.
  42169. */
  42170. /**
  42171. * Sets Vignette centre X Offset.
  42172. */
  42173. vignetteCentreX: number;
  42174. /**
  42175. * Gets Vignette centre Y Offset.
  42176. */
  42177. /**
  42178. * Sets Vignette centre Y Offset.
  42179. */
  42180. vignetteCentreY: number;
  42181. /**
  42182. * Gets Vignette weight or intensity of the vignette effect.
  42183. */
  42184. /**
  42185. * Sets Vignette weight or intensity of the vignette effect.
  42186. */
  42187. vignetteWeight: number;
  42188. /**
  42189. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42190. * if vignetteEnabled is set to true.
  42191. */
  42192. /**
  42193. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42194. * if vignetteEnabled is set to true.
  42195. */
  42196. vignetteColor: Color4;
  42197. /**
  42198. * Gets Camera field of view used by the Vignette effect.
  42199. */
  42200. /**
  42201. * Sets Camera field of view used by the Vignette effect.
  42202. */
  42203. vignetteCameraFov: number;
  42204. /**
  42205. * Gets the vignette blend mode allowing different kind of effect.
  42206. */
  42207. /**
  42208. * Sets the vignette blend mode allowing different kind of effect.
  42209. */
  42210. vignetteBlendMode: number;
  42211. /**
  42212. * Gets wether the vignette effect is enabled.
  42213. */
  42214. /**
  42215. * Sets wether the vignette effect is enabled.
  42216. */
  42217. vignetteEnabled: boolean;
  42218. private _fromLinearSpace;
  42219. /**
  42220. * Gets wether the input of the processing is in Gamma or Linear Space.
  42221. */
  42222. /**
  42223. * Sets wether the input of the processing is in Gamma or Linear Space.
  42224. */
  42225. fromLinearSpace: boolean;
  42226. /**
  42227. * Defines cache preventing GC.
  42228. */
  42229. private _defines;
  42230. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42231. /**
  42232. * "ImageProcessingPostProcess"
  42233. * @returns "ImageProcessingPostProcess"
  42234. */
  42235. getClassName(): string;
  42236. protected _updateParameters(): void;
  42237. dispose(camera?: Camera): void;
  42238. }
  42239. }
  42240. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42241. import { Scene } from "babylonjs/scene";
  42242. import { Color3 } from "babylonjs/Maths/math.color";
  42243. import { Mesh } from "babylonjs/Meshes/mesh";
  42244. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42245. import { Nullable } from "babylonjs/types";
  42246. /**
  42247. * Class containing static functions to help procedurally build meshes
  42248. */
  42249. export class GroundBuilder {
  42250. /**
  42251. * Creates a ground mesh
  42252. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42253. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42255. * @param name defines the name of the mesh
  42256. * @param options defines the options used to create the mesh
  42257. * @param scene defines the hosting scene
  42258. * @returns the ground mesh
  42259. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42260. */
  42261. static CreateGround(name: string, options: {
  42262. width?: number;
  42263. height?: number;
  42264. subdivisions?: number;
  42265. subdivisionsX?: number;
  42266. subdivisionsY?: number;
  42267. updatable?: boolean;
  42268. }, scene: any): Mesh;
  42269. /**
  42270. * Creates a tiled ground mesh
  42271. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42272. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42273. * * 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
  42274. * * 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
  42275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42276. * @param name defines the name of the mesh
  42277. * @param options defines the options used to create the mesh
  42278. * @param scene defines the hosting scene
  42279. * @returns the tiled ground mesh
  42280. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42281. */
  42282. static CreateTiledGround(name: string, options: {
  42283. xmin: number;
  42284. zmin: number;
  42285. xmax: number;
  42286. zmax: number;
  42287. subdivisions?: {
  42288. w: number;
  42289. h: number;
  42290. };
  42291. precision?: {
  42292. w: number;
  42293. h: number;
  42294. };
  42295. updatable?: boolean;
  42296. }, scene?: Nullable<Scene>): Mesh;
  42297. /**
  42298. * Creates a ground mesh from a height map
  42299. * * The parameter `url` sets the URL of the height map image resource.
  42300. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42301. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42302. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42303. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42304. * * 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.
  42305. * * 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).
  42306. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42308. * @param name defines the name of the mesh
  42309. * @param url defines the url to the height map
  42310. * @param options defines the options used to create the mesh
  42311. * @param scene defines the hosting scene
  42312. * @returns the ground mesh
  42313. * @see https://doc.babylonjs.com/babylon101/height_map
  42314. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42315. */
  42316. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42317. width?: number;
  42318. height?: number;
  42319. subdivisions?: number;
  42320. minHeight?: number;
  42321. maxHeight?: number;
  42322. colorFilter?: Color3;
  42323. alphaFilter?: number;
  42324. updatable?: boolean;
  42325. onReady?: (mesh: GroundMesh) => void;
  42326. }, scene?: Nullable<Scene>): GroundMesh;
  42327. }
  42328. }
  42329. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42330. import { Vector4 } from "babylonjs/Maths/math.vector";
  42331. import { Mesh } from "babylonjs/Meshes/mesh";
  42332. /**
  42333. * Class containing static functions to help procedurally build meshes
  42334. */
  42335. export class TorusBuilder {
  42336. /**
  42337. * Creates a torus mesh
  42338. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42339. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42340. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42342. * * 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
  42343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42344. * @param name defines the name of the mesh
  42345. * @param options defines the options used to create the mesh
  42346. * @param scene defines the hosting scene
  42347. * @returns the torus mesh
  42348. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42349. */
  42350. static CreateTorus(name: string, options: {
  42351. diameter?: number;
  42352. thickness?: number;
  42353. tessellation?: number;
  42354. updatable?: boolean;
  42355. sideOrientation?: number;
  42356. frontUVs?: Vector4;
  42357. backUVs?: Vector4;
  42358. }, scene: any): Mesh;
  42359. }
  42360. }
  42361. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42362. import { Vector4 } from "babylonjs/Maths/math.vector";
  42363. import { Color4 } from "babylonjs/Maths/math.color";
  42364. import { Mesh } from "babylonjs/Meshes/mesh";
  42365. /**
  42366. * Class containing static functions to help procedurally build meshes
  42367. */
  42368. export class CylinderBuilder {
  42369. /**
  42370. * Creates a cylinder or a cone mesh
  42371. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42372. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42373. * * 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.
  42374. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42375. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42376. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42377. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42378. * * 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).
  42379. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42380. * * 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).
  42381. * * 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
  42382. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42383. * * 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
  42384. * * 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.
  42385. * * If `enclose` is false, a ring surface is one element.
  42386. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42387. * * 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
  42388. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42389. * * 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
  42390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42391. * @param name defines the name of the mesh
  42392. * @param options defines the options used to create the mesh
  42393. * @param scene defines the hosting scene
  42394. * @returns the cylinder mesh
  42395. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42396. */
  42397. static CreateCylinder(name: string, options: {
  42398. height?: number;
  42399. diameterTop?: number;
  42400. diameterBottom?: number;
  42401. diameter?: number;
  42402. tessellation?: number;
  42403. subdivisions?: number;
  42404. arc?: number;
  42405. faceColors?: Color4[];
  42406. faceUV?: Vector4[];
  42407. updatable?: boolean;
  42408. hasRings?: boolean;
  42409. enclose?: boolean;
  42410. cap?: number;
  42411. sideOrientation?: number;
  42412. frontUVs?: Vector4;
  42413. backUVs?: Vector4;
  42414. }, scene: any): Mesh;
  42415. }
  42416. }
  42417. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42418. import { Observable } from "babylonjs/Misc/observable";
  42419. import { Nullable } from "babylonjs/types";
  42420. import { Camera } from "babylonjs/Cameras/camera";
  42421. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42422. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42423. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42424. import { Scene } from "babylonjs/scene";
  42425. import { Vector3 } from "babylonjs/Maths/math.vector";
  42426. import { Color3 } from "babylonjs/Maths/math.color";
  42427. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42429. import { Mesh } from "babylonjs/Meshes/mesh";
  42430. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42431. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42432. import "babylonjs/Meshes/Builders/groundBuilder";
  42433. import "babylonjs/Meshes/Builders/torusBuilder";
  42434. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42435. import "babylonjs/Gamepads/gamepadSceneComponent";
  42436. import "babylonjs/Animations/animatable";
  42437. /**
  42438. * Options to modify the vr teleportation behavior.
  42439. */
  42440. export interface VRTeleportationOptions {
  42441. /**
  42442. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42443. */
  42444. floorMeshName?: string;
  42445. /**
  42446. * A list of meshes to be used as the teleportation floor. (default: empty)
  42447. */
  42448. floorMeshes?: Mesh[];
  42449. }
  42450. /**
  42451. * Options to modify the vr experience helper's behavior.
  42452. */
  42453. export interface VRExperienceHelperOptions extends WebVROptions {
  42454. /**
  42455. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42456. */
  42457. createDeviceOrientationCamera?: boolean;
  42458. /**
  42459. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42460. */
  42461. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42462. /**
  42463. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42464. */
  42465. laserToggle?: boolean;
  42466. /**
  42467. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42468. */
  42469. floorMeshes?: Mesh[];
  42470. /**
  42471. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42472. */
  42473. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42474. }
  42475. /**
  42476. * Event containing information after VR has been entered
  42477. */
  42478. export class OnAfterEnteringVRObservableEvent {
  42479. /**
  42480. * If entering vr was successful
  42481. */
  42482. success: boolean;
  42483. }
  42484. /**
  42485. * Helps to quickly add VR support to an existing scene.
  42486. * See http://doc.babylonjs.com/how_to/webvr_helper
  42487. */
  42488. export class VRExperienceHelper {
  42489. /** Options to modify the vr experience helper's behavior. */
  42490. webVROptions: VRExperienceHelperOptions;
  42491. private _scene;
  42492. private _position;
  42493. private _btnVR;
  42494. private _btnVRDisplayed;
  42495. private _webVRsupported;
  42496. private _webVRready;
  42497. private _webVRrequesting;
  42498. private _webVRpresenting;
  42499. private _hasEnteredVR;
  42500. private _fullscreenVRpresenting;
  42501. private _canvas;
  42502. private _webVRCamera;
  42503. private _vrDeviceOrientationCamera;
  42504. private _deviceOrientationCamera;
  42505. private _existingCamera;
  42506. private _onKeyDown;
  42507. private _onVrDisplayPresentChange;
  42508. private _onVRDisplayChanged;
  42509. private _onVRRequestPresentStart;
  42510. private _onVRRequestPresentComplete;
  42511. /**
  42512. * 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)
  42513. */
  42514. enableGazeEvenWhenNoPointerLock: boolean;
  42515. /**
  42516. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42517. */
  42518. exitVROnDoubleTap: boolean;
  42519. /**
  42520. * Observable raised right before entering VR.
  42521. */
  42522. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42523. /**
  42524. * Observable raised when entering VR has completed.
  42525. */
  42526. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42527. /**
  42528. * Observable raised when exiting VR.
  42529. */
  42530. onExitingVRObservable: Observable<VRExperienceHelper>;
  42531. /**
  42532. * Observable raised when controller mesh is loaded.
  42533. */
  42534. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42535. /** Return this.onEnteringVRObservable
  42536. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42537. */
  42538. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42539. /** Return this.onExitingVRObservable
  42540. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42541. */
  42542. readonly onExitingVR: Observable<VRExperienceHelper>;
  42543. /** Return this.onControllerMeshLoadedObservable
  42544. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42545. */
  42546. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42547. private _rayLength;
  42548. private _useCustomVRButton;
  42549. private _teleportationRequested;
  42550. private _teleportActive;
  42551. private _floorMeshName;
  42552. private _floorMeshesCollection;
  42553. private _rotationAllowed;
  42554. private _teleportBackwardsVector;
  42555. private _teleportationTarget;
  42556. private _isDefaultTeleportationTarget;
  42557. private _postProcessMove;
  42558. private _teleportationFillColor;
  42559. private _teleportationBorderColor;
  42560. private _rotationAngle;
  42561. private _haloCenter;
  42562. private _cameraGazer;
  42563. private _padSensibilityUp;
  42564. private _padSensibilityDown;
  42565. private _leftController;
  42566. private _rightController;
  42567. /**
  42568. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42569. */
  42570. onNewMeshSelected: Observable<AbstractMesh>;
  42571. /**
  42572. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42573. * This observable will provide the mesh and the controller used to select the mesh
  42574. */
  42575. onMeshSelectedWithController: Observable<{
  42576. mesh: AbstractMesh;
  42577. controller: WebVRController;
  42578. }>;
  42579. /**
  42580. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42581. */
  42582. onNewMeshPicked: Observable<PickingInfo>;
  42583. private _circleEase;
  42584. /**
  42585. * Observable raised before camera teleportation
  42586. */
  42587. onBeforeCameraTeleport: Observable<Vector3>;
  42588. /**
  42589. * Observable raised after camera teleportation
  42590. */
  42591. onAfterCameraTeleport: Observable<Vector3>;
  42592. /**
  42593. * Observable raised when current selected mesh gets unselected
  42594. */
  42595. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42596. private _raySelectionPredicate;
  42597. /**
  42598. * To be optionaly changed by user to define custom ray selection
  42599. */
  42600. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42601. /**
  42602. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42603. */
  42604. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42605. /**
  42606. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42607. */
  42608. teleportationEnabled: boolean;
  42609. private _defaultHeight;
  42610. private _teleportationInitialized;
  42611. private _interactionsEnabled;
  42612. private _interactionsRequested;
  42613. private _displayGaze;
  42614. private _displayLaserPointer;
  42615. /**
  42616. * The mesh used to display where the user is going to teleport.
  42617. */
  42618. /**
  42619. * Sets the mesh to be used to display where the user is going to teleport.
  42620. */
  42621. teleportationTarget: Mesh;
  42622. /**
  42623. * 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
  42624. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42625. * See http://doc.babylonjs.com/resources/baking_transformations
  42626. */
  42627. gazeTrackerMesh: Mesh;
  42628. /**
  42629. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42630. */
  42631. updateGazeTrackerScale: boolean;
  42632. /**
  42633. * If the gaze trackers color should be updated when selecting meshes
  42634. */
  42635. updateGazeTrackerColor: boolean;
  42636. /**
  42637. * If the controller laser color should be updated when selecting meshes
  42638. */
  42639. updateControllerLaserColor: boolean;
  42640. /**
  42641. * The gaze tracking mesh corresponding to the left controller
  42642. */
  42643. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42644. /**
  42645. * The gaze tracking mesh corresponding to the right controller
  42646. */
  42647. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42648. /**
  42649. * If the ray of the gaze should be displayed.
  42650. */
  42651. /**
  42652. * Sets if the ray of the gaze should be displayed.
  42653. */
  42654. displayGaze: boolean;
  42655. /**
  42656. * If the ray of the LaserPointer should be displayed.
  42657. */
  42658. /**
  42659. * Sets if the ray of the LaserPointer should be displayed.
  42660. */
  42661. displayLaserPointer: boolean;
  42662. /**
  42663. * The deviceOrientationCamera used as the camera when not in VR.
  42664. */
  42665. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42666. /**
  42667. * Based on the current WebVR support, returns the current VR camera used.
  42668. */
  42669. readonly currentVRCamera: Nullable<Camera>;
  42670. /**
  42671. * The webVRCamera which is used when in VR.
  42672. */
  42673. readonly webVRCamera: WebVRFreeCamera;
  42674. /**
  42675. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42676. */
  42677. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42678. /**
  42679. * The html button that is used to trigger entering into VR.
  42680. */
  42681. readonly vrButton: Nullable<HTMLButtonElement>;
  42682. private readonly _teleportationRequestInitiated;
  42683. /**
  42684. * Defines wether or not Pointer lock should be requested when switching to
  42685. * full screen.
  42686. */
  42687. requestPointerLockOnFullScreen: boolean;
  42688. /**
  42689. * Instantiates a VRExperienceHelper.
  42690. * Helps to quickly add VR support to an existing scene.
  42691. * @param scene The scene the VRExperienceHelper belongs to.
  42692. * @param webVROptions Options to modify the vr experience helper's behavior.
  42693. */
  42694. constructor(scene: Scene,
  42695. /** Options to modify the vr experience helper's behavior. */
  42696. webVROptions?: VRExperienceHelperOptions);
  42697. private _onDefaultMeshLoaded;
  42698. private _onResize;
  42699. private _onFullscreenChange;
  42700. /**
  42701. * Gets a value indicating if we are currently in VR mode.
  42702. */
  42703. readonly isInVRMode: boolean;
  42704. private onVrDisplayPresentChange;
  42705. private onVRDisplayChanged;
  42706. private moveButtonToBottomRight;
  42707. private displayVRButton;
  42708. private updateButtonVisibility;
  42709. private _cachedAngularSensibility;
  42710. /**
  42711. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42712. * Otherwise, will use the fullscreen API.
  42713. */
  42714. enterVR(): void;
  42715. /**
  42716. * Attempt to exit VR, or fullscreen.
  42717. */
  42718. exitVR(): void;
  42719. /**
  42720. * The position of the vr experience helper.
  42721. */
  42722. /**
  42723. * Sets the position of the vr experience helper.
  42724. */
  42725. position: Vector3;
  42726. /**
  42727. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42728. */
  42729. enableInteractions(): void;
  42730. private readonly _noControllerIsActive;
  42731. private beforeRender;
  42732. private _isTeleportationFloor;
  42733. /**
  42734. * Adds a floor mesh to be used for teleportation.
  42735. * @param floorMesh the mesh to be used for teleportation.
  42736. */
  42737. addFloorMesh(floorMesh: Mesh): void;
  42738. /**
  42739. * Removes a floor mesh from being used for teleportation.
  42740. * @param floorMesh the mesh to be removed.
  42741. */
  42742. removeFloorMesh(floorMesh: Mesh): void;
  42743. /**
  42744. * Enables interactions and teleportation using the VR controllers and gaze.
  42745. * @param vrTeleportationOptions options to modify teleportation behavior.
  42746. */
  42747. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42748. private _onNewGamepadConnected;
  42749. private _tryEnableInteractionOnController;
  42750. private _onNewGamepadDisconnected;
  42751. private _enableInteractionOnController;
  42752. private _checkTeleportWithRay;
  42753. private _checkRotate;
  42754. private _checkTeleportBackwards;
  42755. private _enableTeleportationOnController;
  42756. private _createTeleportationCircles;
  42757. private _displayTeleportationTarget;
  42758. private _hideTeleportationTarget;
  42759. private _rotateCamera;
  42760. private _moveTeleportationSelectorTo;
  42761. private _workingVector;
  42762. private _workingQuaternion;
  42763. private _workingMatrix;
  42764. /**
  42765. * Teleports the users feet to the desired location
  42766. * @param location The location where the user's feet should be placed
  42767. */
  42768. teleportCamera(location: Vector3): void;
  42769. private _convertNormalToDirectionOfRay;
  42770. private _castRayAndSelectObject;
  42771. private _notifySelectedMeshUnselected;
  42772. /**
  42773. * Sets the color of the laser ray from the vr controllers.
  42774. * @param color new color for the ray.
  42775. */
  42776. changeLaserColor(color: Color3): void;
  42777. /**
  42778. * Sets the color of the ray from the vr headsets gaze.
  42779. * @param color new color for the ray.
  42780. */
  42781. changeGazeColor(color: Color3): void;
  42782. /**
  42783. * Exits VR and disposes of the vr experience helper
  42784. */
  42785. dispose(): void;
  42786. /**
  42787. * Gets the name of the VRExperienceHelper class
  42788. * @returns "VRExperienceHelper"
  42789. */
  42790. getClassName(): string;
  42791. }
  42792. }
  42793. declare module "babylonjs/Cameras/VR/index" {
  42794. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42795. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42796. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42797. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42798. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42799. export * from "babylonjs/Cameras/VR/webVRCamera";
  42800. }
  42801. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42802. import { Observable } from "babylonjs/Misc/observable";
  42803. import { Nullable } from "babylonjs/types";
  42804. import { IDisposable, Scene } from "babylonjs/scene";
  42805. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42806. /**
  42807. * Manages an XRSession to work with Babylon's engine
  42808. * @see https://doc.babylonjs.com/how_to/webxr
  42809. */
  42810. export class WebXRSessionManager implements IDisposable {
  42811. private scene;
  42812. /**
  42813. * Fires every time a new xrFrame arrives which can be used to update the camera
  42814. */
  42815. onXRFrameObservable: Observable<any>;
  42816. /**
  42817. * Fires when the xr session is ended either by the device or manually done
  42818. */
  42819. onXRSessionEnded: Observable<any>;
  42820. /**
  42821. * Underlying xr session
  42822. */
  42823. session: XRSession;
  42824. /**
  42825. * Type of reference space used when creating the session
  42826. */
  42827. referenceSpace: XRReferenceSpace;
  42828. /** @hidden */
  42829. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42830. /**
  42831. * Current XR frame
  42832. */
  42833. currentFrame: Nullable<XRFrame>;
  42834. private _xrNavigator;
  42835. private baseLayer;
  42836. /**
  42837. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42838. * @param scene The scene which the session should be created for
  42839. */
  42840. constructor(scene: Scene);
  42841. /**
  42842. * Initializes the manager
  42843. * After initialization enterXR can be called to start an XR session
  42844. * @returns Promise which resolves after it is initialized
  42845. */
  42846. initializeAsync(): Promise<void>;
  42847. /**
  42848. * Initializes an xr session
  42849. * @param xrSessionMode mode to initialize
  42850. * @returns a promise which will resolve once the session has been initialized
  42851. */
  42852. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42853. /**
  42854. * Sets the reference space on the xr session
  42855. * @param referenceSpace space to set
  42856. * @returns a promise that will resolve once the reference space has been set
  42857. */
  42858. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42859. /**
  42860. * Updates the render state of the session
  42861. * @param state state to set
  42862. * @returns a promise that resolves once the render state has been updated
  42863. */
  42864. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42865. /**
  42866. * Starts rendering to the xr layer
  42867. * @returns a promise that will resolve once rendering has started
  42868. */
  42869. startRenderingToXRAsync(): Promise<void>;
  42870. /**
  42871. * Stops the xrSession and restores the renderloop
  42872. * @returns Promise which resolves after it exits XR
  42873. */
  42874. exitXRAsync(): Promise<unknown>;
  42875. /**
  42876. * Checks if a session would be supported for the creation options specified
  42877. * @param sessionMode session mode to check if supported eg. immersive-vr
  42878. * @returns true if supported
  42879. */
  42880. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42881. /**
  42882. * @hidden
  42883. * Converts the render layer of xrSession to a render target
  42884. * @param session session to create render target for
  42885. * @param scene scene the new render target should be created for
  42886. */
  42887. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42888. /**
  42889. * Disposes of the session manager
  42890. */
  42891. dispose(): void;
  42892. }
  42893. }
  42894. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42895. import { Scene } from "babylonjs/scene";
  42896. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42897. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42898. /**
  42899. * WebXR Camera which holds the views for the xrSession
  42900. * @see https://doc.babylonjs.com/how_to/webxr
  42901. */
  42902. export class WebXRCamera extends FreeCamera {
  42903. private static _TmpMatrix;
  42904. /**
  42905. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42906. * @param name the name of the camera
  42907. * @param scene the scene to add the camera to
  42908. */
  42909. constructor(name: string, scene: Scene);
  42910. private _updateNumberOfRigCameras;
  42911. /** @hidden */
  42912. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42913. /**
  42914. * Updates the cameras position from the current pose information of the XR session
  42915. * @param xrSessionManager the session containing pose information
  42916. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42917. */
  42918. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  42919. }
  42920. }
  42921. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  42922. import { Nullable } from "babylonjs/types";
  42923. import { IDisposable } from "babylonjs/scene";
  42924. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  42925. /**
  42926. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  42927. */
  42928. export class WebXRManagedOutputCanvas implements IDisposable {
  42929. private helper;
  42930. private _canvas;
  42931. /**
  42932. * xrpresent context of the canvas which can be used to display/mirror xr content
  42933. */
  42934. canvasContext: WebGLRenderingContext;
  42935. /**
  42936. * xr layer for the canvas
  42937. */
  42938. xrLayer: Nullable<XRWebGLLayer>;
  42939. /**
  42940. * Initializes the xr layer for the session
  42941. * @param xrSession xr session
  42942. * @returns a promise that will resolve once the XR Layer has been created
  42943. */
  42944. initializeXRLayerAsync(xrSession: any): any;
  42945. /**
  42946. * Initializes the canvas to be added/removed upon entering/exiting xr
  42947. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  42948. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  42949. */
  42950. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  42951. /**
  42952. * Disposes of the object
  42953. */
  42954. dispose(): void;
  42955. private _setManagedOutputCanvas;
  42956. private _addCanvas;
  42957. private _removeCanvas;
  42958. }
  42959. }
  42960. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  42961. import { Observable } from "babylonjs/Misc/observable";
  42962. import { IDisposable, Scene } from "babylonjs/scene";
  42963. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  42964. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42965. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42966. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  42967. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  42968. /**
  42969. * States of the webXR experience
  42970. */
  42971. export enum WebXRState {
  42972. /**
  42973. * Transitioning to being in XR mode
  42974. */
  42975. ENTERING_XR = 0,
  42976. /**
  42977. * Transitioning to non XR mode
  42978. */
  42979. EXITING_XR = 1,
  42980. /**
  42981. * In XR mode and presenting
  42982. */
  42983. IN_XR = 2,
  42984. /**
  42985. * Not entered XR mode
  42986. */
  42987. NOT_IN_XR = 3
  42988. }
  42989. /**
  42990. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  42991. * @see https://doc.babylonjs.com/how_to/webxr
  42992. */
  42993. export class WebXRExperienceHelper implements IDisposable {
  42994. private scene;
  42995. /**
  42996. * 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
  42997. */
  42998. container: AbstractMesh;
  42999. /**
  43000. * Camera used to render xr content
  43001. */
  43002. camera: WebXRCamera;
  43003. /**
  43004. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43005. */
  43006. state: WebXRState;
  43007. private _setState;
  43008. private static _TmpVector;
  43009. /**
  43010. * Fires when the state of the experience helper has changed
  43011. */
  43012. onStateChangedObservable: Observable<WebXRState>;
  43013. /** Session manager used to keep track of xr session */
  43014. sessionManager: WebXRSessionManager;
  43015. private _nonVRCamera;
  43016. private _originalSceneAutoClear;
  43017. private _supported;
  43018. /**
  43019. * Creates the experience helper
  43020. * @param scene the scene to attach the experience helper to
  43021. * @returns a promise for the experience helper
  43022. */
  43023. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43024. /**
  43025. * Creates a WebXRExperienceHelper
  43026. * @param scene The scene the helper should be created in
  43027. */
  43028. private constructor();
  43029. /**
  43030. * Exits XR mode and returns the scene to its original state
  43031. * @returns promise that resolves after xr mode has exited
  43032. */
  43033. exitXRAsync(): Promise<unknown>;
  43034. /**
  43035. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43036. * @param sessionCreationOptions options for the XR session
  43037. * @param referenceSpaceType frame of reference of the XR session
  43038. * @param outputCanvas the output canvas that will be used to enter XR mode
  43039. * @returns promise that resolves after xr mode has entered
  43040. */
  43041. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43042. /**
  43043. * Updates the global position of the camera by moving the camera's container
  43044. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43045. * @param position The desired global position of the camera
  43046. */
  43047. setPositionOfCameraUsingContainer(position: Vector3): void;
  43048. /**
  43049. * Rotates the xr camera by rotating the camera's container around the camera's position
  43050. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43051. * @param rotation the desired quaternion rotation to apply to the camera
  43052. */
  43053. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43054. /**
  43055. * Disposes of the experience helper
  43056. */
  43057. dispose(): void;
  43058. }
  43059. }
  43060. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43061. import { Nullable } from "babylonjs/types";
  43062. import { Observable } from "babylonjs/Misc/observable";
  43063. import { IDisposable, Scene } from "babylonjs/scene";
  43064. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43065. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43066. /**
  43067. * Button which can be used to enter a different mode of XR
  43068. */
  43069. export class WebXREnterExitUIButton {
  43070. /** button element */
  43071. element: HTMLElement;
  43072. /** XR initialization options for the button */
  43073. sessionMode: XRSessionMode;
  43074. /** Reference space type */
  43075. referenceSpaceType: XRReferenceSpaceType;
  43076. /**
  43077. * Creates a WebXREnterExitUIButton
  43078. * @param element button element
  43079. * @param sessionMode XR initialization session mode
  43080. * @param referenceSpaceType the type of reference space to be used
  43081. */
  43082. constructor(
  43083. /** button element */
  43084. element: HTMLElement,
  43085. /** XR initialization options for the button */
  43086. sessionMode: XRSessionMode,
  43087. /** Reference space type */
  43088. referenceSpaceType: XRReferenceSpaceType);
  43089. /**
  43090. * Overwritable function which can be used to update the button's visuals when the state changes
  43091. * @param activeButton the current active button in the UI
  43092. */
  43093. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43094. }
  43095. /**
  43096. * Options to create the webXR UI
  43097. */
  43098. export class WebXREnterExitUIOptions {
  43099. /**
  43100. * Context to enter xr with
  43101. */
  43102. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43103. /**
  43104. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43105. */
  43106. customButtons?: Array<WebXREnterExitUIButton>;
  43107. }
  43108. /**
  43109. * UI to allow the user to enter/exit XR mode
  43110. */
  43111. export class WebXREnterExitUI implements IDisposable {
  43112. private scene;
  43113. private _overlay;
  43114. private _buttons;
  43115. private _activeButton;
  43116. /**
  43117. * Fired every time the active button is changed.
  43118. *
  43119. * When xr is entered via a button that launches xr that button will be the callback parameter
  43120. *
  43121. * When exiting xr the callback parameter will be null)
  43122. */
  43123. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43124. /**
  43125. * Creates UI to allow the user to enter/exit XR mode
  43126. * @param scene the scene to add the ui to
  43127. * @param helper the xr experience helper to enter/exit xr with
  43128. * @param options options to configure the UI
  43129. * @returns the created ui
  43130. */
  43131. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43132. private constructor();
  43133. private _updateButtons;
  43134. /**
  43135. * Disposes of the object
  43136. */
  43137. dispose(): void;
  43138. }
  43139. }
  43140. declare module "babylonjs/Cameras/XR/webXRController" {
  43141. import { Nullable } from "babylonjs/types";
  43142. import { Observable } from "babylonjs/Misc/observable";
  43143. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43144. import { Ray } from "babylonjs/Culling/ray";
  43145. import { Scene } from "babylonjs/scene";
  43146. /**
  43147. * Represents an XR input
  43148. */
  43149. export class WebXRController {
  43150. private scene;
  43151. /** The underlying input source for the controller */
  43152. inputSource: XRInputSource;
  43153. private parentContainer;
  43154. /**
  43155. * 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
  43156. */
  43157. grip?: AbstractMesh;
  43158. /**
  43159. * Pointer which can be used to select objects or attach a visible laser to
  43160. */
  43161. pointer: AbstractMesh;
  43162. /**
  43163. * Event that fires when the controller is removed/disposed
  43164. */
  43165. onDisposeObservable: Observable<{}>;
  43166. private _tmpMatrix;
  43167. private _tmpQuaternion;
  43168. private _tmpVector;
  43169. /**
  43170. * Creates the controller
  43171. * @see https://doc.babylonjs.com/how_to/webxr
  43172. * @param scene the scene which the controller should be associated to
  43173. * @param inputSource the underlying input source for the controller
  43174. * @param parentContainer parent that the controller meshes should be children of
  43175. */
  43176. constructor(scene: Scene,
  43177. /** The underlying input source for the controller */
  43178. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43179. /**
  43180. * Updates the controller pose based on the given XRFrame
  43181. * @param xrFrame xr frame to update the pose with
  43182. * @param referenceSpace reference space to use
  43183. */
  43184. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43185. /**
  43186. * Gets a world space ray coming from the controller
  43187. * @param result the resulting ray
  43188. */
  43189. getWorldPointerRayToRef(result: Ray): void;
  43190. /**
  43191. * Disposes of the object
  43192. */
  43193. dispose(): void;
  43194. }
  43195. }
  43196. declare module "babylonjs/Cameras/XR/webXRInput" {
  43197. import { Observable } from "babylonjs/Misc/observable";
  43198. import { IDisposable } from "babylonjs/scene";
  43199. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43200. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43201. /**
  43202. * XR input used to track XR inputs such as controllers/rays
  43203. */
  43204. export class WebXRInput implements IDisposable {
  43205. /**
  43206. * Base experience the input listens to
  43207. */
  43208. baseExperience: WebXRExperienceHelper;
  43209. /**
  43210. * XR controllers being tracked
  43211. */
  43212. controllers: Array<WebXRController>;
  43213. private _frameObserver;
  43214. private _stateObserver;
  43215. /**
  43216. * Event when a controller has been connected/added
  43217. */
  43218. onControllerAddedObservable: Observable<WebXRController>;
  43219. /**
  43220. * Event when a controller has been removed/disconnected
  43221. */
  43222. onControllerRemovedObservable: Observable<WebXRController>;
  43223. /**
  43224. * Initializes the WebXRInput
  43225. * @param baseExperience experience helper which the input should be created for
  43226. */
  43227. constructor(
  43228. /**
  43229. * Base experience the input listens to
  43230. */
  43231. baseExperience: WebXRExperienceHelper);
  43232. private _onInputSourcesChange;
  43233. private _addAndRemoveControllers;
  43234. /**
  43235. * Disposes of the object
  43236. */
  43237. dispose(): void;
  43238. }
  43239. }
  43240. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43241. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43242. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43243. /**
  43244. * Enables teleportation
  43245. */
  43246. export class WebXRControllerTeleportation {
  43247. private _teleportationFillColor;
  43248. private _teleportationBorderColor;
  43249. private _tmpRay;
  43250. private _tmpVector;
  43251. /**
  43252. * Creates a WebXRControllerTeleportation
  43253. * @param input input manager to add teleportation to
  43254. * @param floorMeshes floormeshes which can be teleported to
  43255. */
  43256. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43257. }
  43258. }
  43259. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43260. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43261. /**
  43262. * Handles pointer input automatically for the pointer of XR controllers
  43263. */
  43264. export class WebXRControllerPointerSelection {
  43265. private static _idCounter;
  43266. private _tmpRay;
  43267. /**
  43268. * Creates a WebXRControllerPointerSelection
  43269. * @param input input manager to setup pointer selection
  43270. */
  43271. constructor(input: WebXRInput);
  43272. private _convertNormalToDirectionOfRay;
  43273. private _updatePointerDistance;
  43274. }
  43275. }
  43276. declare module "babylonjs/Loading/sceneLoader" {
  43277. import { Observable } from "babylonjs/Misc/observable";
  43278. import { Nullable } from "babylonjs/types";
  43279. import { Scene } from "babylonjs/scene";
  43280. import { Engine } from "babylonjs/Engines/engine";
  43281. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43282. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43283. import { AssetContainer } from "babylonjs/assetContainer";
  43284. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43285. import { Skeleton } from "babylonjs/Bones/skeleton";
  43286. /**
  43287. * Class used to represent data loading progression
  43288. */
  43289. export class SceneLoaderProgressEvent {
  43290. /** defines if data length to load can be evaluated */
  43291. readonly lengthComputable: boolean;
  43292. /** defines the loaded data length */
  43293. readonly loaded: number;
  43294. /** defines the data length to load */
  43295. readonly total: number;
  43296. /**
  43297. * Create a new progress event
  43298. * @param lengthComputable defines if data length to load can be evaluated
  43299. * @param loaded defines the loaded data length
  43300. * @param total defines the data length to load
  43301. */
  43302. constructor(
  43303. /** defines if data length to load can be evaluated */
  43304. lengthComputable: boolean,
  43305. /** defines the loaded data length */
  43306. loaded: number,
  43307. /** defines the data length to load */
  43308. total: number);
  43309. /**
  43310. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43311. * @param event defines the source event
  43312. * @returns a new SceneLoaderProgressEvent
  43313. */
  43314. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43315. }
  43316. /**
  43317. * Interface used by SceneLoader plugins to define supported file extensions
  43318. */
  43319. export interface ISceneLoaderPluginExtensions {
  43320. /**
  43321. * Defines the list of supported extensions
  43322. */
  43323. [extension: string]: {
  43324. isBinary: boolean;
  43325. };
  43326. }
  43327. /**
  43328. * Interface used by SceneLoader plugin factory
  43329. */
  43330. export interface ISceneLoaderPluginFactory {
  43331. /**
  43332. * Defines the name of the factory
  43333. */
  43334. name: string;
  43335. /**
  43336. * Function called to create a new plugin
  43337. * @return the new plugin
  43338. */
  43339. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43340. /**
  43341. * Boolean indicating if the plugin can direct load specific data
  43342. */
  43343. canDirectLoad?: (data: string) => boolean;
  43344. }
  43345. /**
  43346. * Interface used to define a SceneLoader plugin
  43347. */
  43348. export interface ISceneLoaderPlugin {
  43349. /**
  43350. * The friendly name of this plugin.
  43351. */
  43352. name: string;
  43353. /**
  43354. * The file extensions supported by this plugin.
  43355. */
  43356. extensions: string | ISceneLoaderPluginExtensions;
  43357. /**
  43358. * Import meshes into a scene.
  43359. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43360. * @param scene The scene to import into
  43361. * @param data The data to import
  43362. * @param rootUrl The root url for scene and resources
  43363. * @param meshes The meshes array to import into
  43364. * @param particleSystems The particle systems array to import into
  43365. * @param skeletons The skeletons array to import into
  43366. * @param onError The callback when import fails
  43367. * @returns True if successful or false otherwise
  43368. */
  43369. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43370. /**
  43371. * Load into a scene.
  43372. * @param scene The scene to load into
  43373. * @param data The data to import
  43374. * @param rootUrl The root url for scene and resources
  43375. * @param onError The callback when import fails
  43376. * @returns true if successful or false otherwise
  43377. */
  43378. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43379. /**
  43380. * The callback that returns true if the data can be directly loaded.
  43381. */
  43382. canDirectLoad?: (data: string) => boolean;
  43383. /**
  43384. * The callback that allows custom handling of the root url based on the response url.
  43385. */
  43386. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43387. /**
  43388. * Load into an asset container.
  43389. * @param scene The scene to load into
  43390. * @param data The data to import
  43391. * @param rootUrl The root url for scene and resources
  43392. * @param onError The callback when import fails
  43393. * @returns The loaded asset container
  43394. */
  43395. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43396. }
  43397. /**
  43398. * Interface used to define an async SceneLoader plugin
  43399. */
  43400. export interface ISceneLoaderPluginAsync {
  43401. /**
  43402. * The friendly name of this plugin.
  43403. */
  43404. name: string;
  43405. /**
  43406. * The file extensions supported by this plugin.
  43407. */
  43408. extensions: string | ISceneLoaderPluginExtensions;
  43409. /**
  43410. * Import meshes into a scene.
  43411. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43412. * @param scene The scene to import into
  43413. * @param data The data to import
  43414. * @param rootUrl The root url for scene and resources
  43415. * @param onProgress The callback when the load progresses
  43416. * @param fileName Defines the name of the file to load
  43417. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43418. */
  43419. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43420. meshes: AbstractMesh[];
  43421. particleSystems: IParticleSystem[];
  43422. skeletons: Skeleton[];
  43423. animationGroups: AnimationGroup[];
  43424. }>;
  43425. /**
  43426. * Load into a scene.
  43427. * @param scene The scene to load into
  43428. * @param data The data to import
  43429. * @param rootUrl The root url for scene and resources
  43430. * @param onProgress The callback when the load progresses
  43431. * @param fileName Defines the name of the file to load
  43432. * @returns Nothing
  43433. */
  43434. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43435. /**
  43436. * The callback that returns true if the data can be directly loaded.
  43437. */
  43438. canDirectLoad?: (data: string) => boolean;
  43439. /**
  43440. * The callback that allows custom handling of the root url based on the response url.
  43441. */
  43442. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43443. /**
  43444. * Load into an asset container.
  43445. * @param scene The scene to load into
  43446. * @param data The data to import
  43447. * @param rootUrl The root url for scene and resources
  43448. * @param onProgress The callback when the load progresses
  43449. * @param fileName Defines the name of the file to load
  43450. * @returns The loaded asset container
  43451. */
  43452. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43453. }
  43454. /**
  43455. * Class used to load scene from various file formats using registered plugins
  43456. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43457. */
  43458. export class SceneLoader {
  43459. /**
  43460. * No logging while loading
  43461. */
  43462. static readonly NO_LOGGING: number;
  43463. /**
  43464. * Minimal logging while loading
  43465. */
  43466. static readonly MINIMAL_LOGGING: number;
  43467. /**
  43468. * Summary logging while loading
  43469. */
  43470. static readonly SUMMARY_LOGGING: number;
  43471. /**
  43472. * Detailled logging while loading
  43473. */
  43474. static readonly DETAILED_LOGGING: number;
  43475. /**
  43476. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43477. */
  43478. static ForceFullSceneLoadingForIncremental: boolean;
  43479. /**
  43480. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43481. */
  43482. static ShowLoadingScreen: boolean;
  43483. /**
  43484. * Defines the current logging level (while loading the scene)
  43485. * @ignorenaming
  43486. */
  43487. static loggingLevel: number;
  43488. /**
  43489. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43490. */
  43491. static CleanBoneMatrixWeights: boolean;
  43492. /**
  43493. * Event raised when a plugin is used to load a scene
  43494. */
  43495. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43496. private static _registeredPlugins;
  43497. private static _getDefaultPlugin;
  43498. private static _getPluginForExtension;
  43499. private static _getPluginForDirectLoad;
  43500. private static _getPluginForFilename;
  43501. private static _getDirectLoad;
  43502. private static _loadData;
  43503. private static _getFileInfo;
  43504. /**
  43505. * Gets a plugin that can load the given extension
  43506. * @param extension defines the extension to load
  43507. * @returns a plugin or null if none works
  43508. */
  43509. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43510. /**
  43511. * Gets a boolean indicating that the given extension can be loaded
  43512. * @param extension defines the extension to load
  43513. * @returns true if the extension is supported
  43514. */
  43515. static IsPluginForExtensionAvailable(extension: string): boolean;
  43516. /**
  43517. * Adds a new plugin to the list of registered plugins
  43518. * @param plugin defines the plugin to add
  43519. */
  43520. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43521. /**
  43522. * Import meshes into a scene
  43523. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43524. * @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)
  43525. * @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)
  43526. * @param scene the instance of BABYLON.Scene to append to
  43527. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43528. * @param onProgress a callback with a progress event for each file being loaded
  43529. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43530. * @param pluginExtension the extension used to determine the plugin
  43531. * @returns The loaded plugin
  43532. */
  43533. 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>;
  43534. /**
  43535. * Import meshes into a scene
  43536. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43537. * @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)
  43538. * @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)
  43539. * @param scene the instance of BABYLON.Scene to append to
  43540. * @param onProgress a callback with a progress event for each file being loaded
  43541. * @param pluginExtension the extension used to determine the plugin
  43542. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43543. */
  43544. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43545. meshes: AbstractMesh[];
  43546. particleSystems: IParticleSystem[];
  43547. skeletons: Skeleton[];
  43548. animationGroups: AnimationGroup[];
  43549. }>;
  43550. /**
  43551. * Load a scene
  43552. * @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)
  43553. * @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)
  43554. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43555. * @param onSuccess a callback with the scene when import succeeds
  43556. * @param onProgress a callback with a progress event for each file being loaded
  43557. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43558. * @param pluginExtension the extension used to determine the plugin
  43559. * @returns The loaded plugin
  43560. */
  43561. 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>;
  43562. /**
  43563. * Load a scene
  43564. * @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)
  43565. * @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)
  43566. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43567. * @param onProgress a callback with a progress event for each file being loaded
  43568. * @param pluginExtension the extension used to determine the plugin
  43569. * @returns The loaded scene
  43570. */
  43571. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43572. /**
  43573. * Append a scene
  43574. * @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)
  43575. * @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)
  43576. * @param scene is the instance of BABYLON.Scene to append to
  43577. * @param onSuccess a callback with the scene when import succeeds
  43578. * @param onProgress a callback with a progress event for each file being loaded
  43579. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43580. * @param pluginExtension the extension used to determine the plugin
  43581. * @returns The loaded plugin
  43582. */
  43583. 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>;
  43584. /**
  43585. * Append a scene
  43586. * @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)
  43587. * @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)
  43588. * @param scene is the instance of BABYLON.Scene to append to
  43589. * @param onProgress a callback with a progress event for each file being loaded
  43590. * @param pluginExtension the extension used to determine the plugin
  43591. * @returns The given scene
  43592. */
  43593. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43594. /**
  43595. * Load a scene into an asset container
  43596. * @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)
  43597. * @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)
  43598. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43599. * @param onSuccess a callback with the scene when import succeeds
  43600. * @param onProgress a callback with a progress event for each file being loaded
  43601. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43602. * @param pluginExtension the extension used to determine the plugin
  43603. * @returns The loaded plugin
  43604. */
  43605. 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>;
  43606. /**
  43607. * Load a scene into an asset container
  43608. * @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)
  43609. * @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)
  43610. * @param scene is the instance of Scene to append to
  43611. * @param onProgress a callback with a progress event for each file being loaded
  43612. * @param pluginExtension the extension used to determine the plugin
  43613. * @returns The loaded asset container
  43614. */
  43615. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43616. }
  43617. }
  43618. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43619. import { Scene } from "babylonjs/scene";
  43620. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43621. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43622. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43623. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43624. /**
  43625. * Generic Controller
  43626. */
  43627. export class GenericController extends WebVRController {
  43628. /**
  43629. * Base Url for the controller model.
  43630. */
  43631. static readonly MODEL_BASE_URL: string;
  43632. /**
  43633. * File name for the controller model.
  43634. */
  43635. static readonly MODEL_FILENAME: string;
  43636. /**
  43637. * Creates a new GenericController from a gamepad
  43638. * @param vrGamepad the gamepad that the controller should be created from
  43639. */
  43640. constructor(vrGamepad: any);
  43641. /**
  43642. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43643. * @param scene scene in which to add meshes
  43644. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43645. */
  43646. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43647. /**
  43648. * Called once for each button that changed state since the last frame
  43649. * @param buttonIdx Which button index changed
  43650. * @param state New state of the button
  43651. * @param changes Which properties on the state changed since last frame
  43652. */
  43653. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43654. }
  43655. }
  43656. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43657. import { Observable } from "babylonjs/Misc/observable";
  43658. import { Scene } from "babylonjs/scene";
  43659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43660. import { Ray } from "babylonjs/Culling/ray";
  43661. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43662. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43663. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43664. /**
  43665. * Defines the WindowsMotionController object that the state of the windows motion controller
  43666. */
  43667. export class WindowsMotionController extends WebVRController {
  43668. /**
  43669. * The base url used to load the left and right controller models
  43670. */
  43671. static MODEL_BASE_URL: string;
  43672. /**
  43673. * The name of the left controller model file
  43674. */
  43675. static MODEL_LEFT_FILENAME: string;
  43676. /**
  43677. * The name of the right controller model file
  43678. */
  43679. static MODEL_RIGHT_FILENAME: string;
  43680. /**
  43681. * The controller name prefix for this controller type
  43682. */
  43683. static readonly GAMEPAD_ID_PREFIX: string;
  43684. /**
  43685. * The controller id pattern for this controller type
  43686. */
  43687. private static readonly GAMEPAD_ID_PATTERN;
  43688. private _loadedMeshInfo;
  43689. private readonly _mapping;
  43690. /**
  43691. * Fired when the trackpad on this controller is clicked
  43692. */
  43693. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43694. /**
  43695. * Fired when the trackpad on this controller is modified
  43696. */
  43697. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43698. /**
  43699. * The current x and y values of this controller's trackpad
  43700. */
  43701. trackpad: StickValues;
  43702. /**
  43703. * Creates a new WindowsMotionController from a gamepad
  43704. * @param vrGamepad the gamepad that the controller should be created from
  43705. */
  43706. constructor(vrGamepad: any);
  43707. /**
  43708. * Fired when the trigger on this controller is modified
  43709. */
  43710. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43711. /**
  43712. * Fired when the menu button on this controller is modified
  43713. */
  43714. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43715. /**
  43716. * Fired when the grip button on this controller is modified
  43717. */
  43718. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43719. /**
  43720. * Fired when the thumbstick button on this controller is modified
  43721. */
  43722. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43723. /**
  43724. * Fired when the touchpad button on this controller is modified
  43725. */
  43726. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43727. /**
  43728. * Fired when the touchpad values on this controller are modified
  43729. */
  43730. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43731. private _updateTrackpad;
  43732. /**
  43733. * Called once per frame by the engine.
  43734. */
  43735. update(): void;
  43736. /**
  43737. * Called once for each button that changed state since the last frame
  43738. * @param buttonIdx Which button index changed
  43739. * @param state New state of the button
  43740. * @param changes Which properties on the state changed since last frame
  43741. */
  43742. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43743. /**
  43744. * Moves the buttons on the controller mesh based on their current state
  43745. * @param buttonName the name of the button to move
  43746. * @param buttonValue the value of the button which determines the buttons new position
  43747. */
  43748. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43749. /**
  43750. * Moves the axis on the controller mesh based on its current state
  43751. * @param axis the index of the axis
  43752. * @param axisValue the value of the axis which determines the meshes new position
  43753. * @hidden
  43754. */
  43755. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43756. /**
  43757. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43758. * @param scene scene in which to add meshes
  43759. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43760. */
  43761. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43762. /**
  43763. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43764. * can be transformed by button presses and axes values, based on this._mapping.
  43765. *
  43766. * @param scene scene in which the meshes exist
  43767. * @param meshes list of meshes that make up the controller model to process
  43768. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43769. */
  43770. private processModel;
  43771. private createMeshInfo;
  43772. /**
  43773. * Gets the ray of the controller in the direction the controller is pointing
  43774. * @param length the length the resulting ray should be
  43775. * @returns a ray in the direction the controller is pointing
  43776. */
  43777. getForwardRay(length?: number): Ray;
  43778. /**
  43779. * Disposes of the controller
  43780. */
  43781. dispose(): void;
  43782. }
  43783. }
  43784. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43785. import { Observable } from "babylonjs/Misc/observable";
  43786. import { Scene } from "babylonjs/scene";
  43787. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43788. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43789. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43790. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43791. /**
  43792. * Oculus Touch Controller
  43793. */
  43794. export class OculusTouchController extends WebVRController {
  43795. /**
  43796. * Base Url for the controller model.
  43797. */
  43798. static MODEL_BASE_URL: string;
  43799. /**
  43800. * File name for the left controller model.
  43801. */
  43802. static MODEL_LEFT_FILENAME: string;
  43803. /**
  43804. * File name for the right controller model.
  43805. */
  43806. static MODEL_RIGHT_FILENAME: string;
  43807. /**
  43808. * Base Url for the Quest controller model.
  43809. */
  43810. static QUEST_MODEL_BASE_URL: string;
  43811. /**
  43812. * @hidden
  43813. * If the controllers are running on a device that needs the updated Quest controller models
  43814. */
  43815. static _IsQuest: boolean;
  43816. /**
  43817. * Fired when the secondary trigger on this controller is modified
  43818. */
  43819. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43820. /**
  43821. * Fired when the thumb rest on this controller is modified
  43822. */
  43823. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43824. /**
  43825. * Creates a new OculusTouchController from a gamepad
  43826. * @param vrGamepad the gamepad that the controller should be created from
  43827. */
  43828. constructor(vrGamepad: any);
  43829. /**
  43830. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43831. * @param scene scene in which to add meshes
  43832. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43833. */
  43834. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43835. /**
  43836. * Fired when the A button on this controller is modified
  43837. */
  43838. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43839. /**
  43840. * Fired when the B button on this controller is modified
  43841. */
  43842. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43843. /**
  43844. * Fired when the X button on this controller is modified
  43845. */
  43846. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43847. /**
  43848. * Fired when the Y button on this controller is modified
  43849. */
  43850. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43851. /**
  43852. * Called once for each button that changed state since the last frame
  43853. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43854. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43855. * 2) secondary trigger (same)
  43856. * 3) A (right) X (left), touch, pressed = value
  43857. * 4) B / Y
  43858. * 5) thumb rest
  43859. * @param buttonIdx Which button index changed
  43860. * @param state New state of the button
  43861. * @param changes Which properties on the state changed since last frame
  43862. */
  43863. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43864. }
  43865. }
  43866. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43867. import { Scene } from "babylonjs/scene";
  43868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43869. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43870. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43871. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43872. import { Observable } from "babylonjs/Misc/observable";
  43873. /**
  43874. * Vive Controller
  43875. */
  43876. export class ViveController extends WebVRController {
  43877. /**
  43878. * Base Url for the controller model.
  43879. */
  43880. static MODEL_BASE_URL: string;
  43881. /**
  43882. * File name for the controller model.
  43883. */
  43884. static MODEL_FILENAME: string;
  43885. /**
  43886. * Creates a new ViveController from a gamepad
  43887. * @param vrGamepad the gamepad that the controller should be created from
  43888. */
  43889. constructor(vrGamepad: any);
  43890. /**
  43891. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43892. * @param scene scene in which to add meshes
  43893. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43894. */
  43895. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43896. /**
  43897. * Fired when the left button on this controller is modified
  43898. */
  43899. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43900. /**
  43901. * Fired when the right button on this controller is modified
  43902. */
  43903. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43904. /**
  43905. * Fired when the menu button on this controller is modified
  43906. */
  43907. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43908. /**
  43909. * Called once for each button that changed state since the last frame
  43910. * Vive mapping:
  43911. * 0: touchpad
  43912. * 1: trigger
  43913. * 2: left AND right buttons
  43914. * 3: menu button
  43915. * @param buttonIdx Which button index changed
  43916. * @param state New state of the button
  43917. * @param changes Which properties on the state changed since last frame
  43918. */
  43919. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43920. }
  43921. }
  43922. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  43923. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43924. /**
  43925. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  43926. */
  43927. export class WebXRControllerModelLoader {
  43928. /**
  43929. * Creates the WebXRControllerModelLoader
  43930. * @param input xr input that creates the controllers
  43931. */
  43932. constructor(input: WebXRInput);
  43933. }
  43934. }
  43935. declare module "babylonjs/Cameras/XR/index" {
  43936. export * from "babylonjs/Cameras/XR/webXRCamera";
  43937. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  43938. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43939. export * from "babylonjs/Cameras/XR/webXRInput";
  43940. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  43941. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  43942. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  43943. export * from "babylonjs/Cameras/XR/webXRController";
  43944. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43945. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  43946. }
  43947. declare module "babylonjs/Cameras/RigModes/index" {
  43948. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43949. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43950. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  43951. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  43952. }
  43953. declare module "babylonjs/Cameras/index" {
  43954. export * from "babylonjs/Cameras/Inputs/index";
  43955. export * from "babylonjs/Cameras/cameraInputsManager";
  43956. export * from "babylonjs/Cameras/camera";
  43957. export * from "babylonjs/Cameras/targetCamera";
  43958. export * from "babylonjs/Cameras/freeCamera";
  43959. export * from "babylonjs/Cameras/freeCameraInputsManager";
  43960. export * from "babylonjs/Cameras/touchCamera";
  43961. export * from "babylonjs/Cameras/arcRotateCamera";
  43962. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  43963. export * from "babylonjs/Cameras/deviceOrientationCamera";
  43964. export * from "babylonjs/Cameras/flyCamera";
  43965. export * from "babylonjs/Cameras/flyCameraInputsManager";
  43966. export * from "babylonjs/Cameras/followCamera";
  43967. export * from "babylonjs/Cameras/followCameraInputsManager";
  43968. export * from "babylonjs/Cameras/gamepadCamera";
  43969. export * from "babylonjs/Cameras/Stereoscopic/index";
  43970. export * from "babylonjs/Cameras/universalCamera";
  43971. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  43972. export * from "babylonjs/Cameras/VR/index";
  43973. export * from "babylonjs/Cameras/XR/index";
  43974. export * from "babylonjs/Cameras/RigModes/index";
  43975. }
  43976. declare module "babylonjs/Collisions/index" {
  43977. export * from "babylonjs/Collisions/collider";
  43978. export * from "babylonjs/Collisions/collisionCoordinator";
  43979. export * from "babylonjs/Collisions/pickingInfo";
  43980. export * from "babylonjs/Collisions/intersectionInfo";
  43981. export * from "babylonjs/Collisions/meshCollisionData";
  43982. }
  43983. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  43984. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  43985. import { Vector3 } from "babylonjs/Maths/math.vector";
  43986. import { Ray } from "babylonjs/Culling/ray";
  43987. import { Plane } from "babylonjs/Maths/math.plane";
  43988. /**
  43989. * Contains an array of blocks representing the octree
  43990. */
  43991. export interface IOctreeContainer<T> {
  43992. /**
  43993. * Blocks within the octree
  43994. */
  43995. blocks: Array<OctreeBlock<T>>;
  43996. }
  43997. /**
  43998. * Class used to store a cell in an octree
  43999. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44000. */
  44001. export class OctreeBlock<T> {
  44002. /**
  44003. * Gets the content of the current block
  44004. */
  44005. entries: T[];
  44006. /**
  44007. * Gets the list of block children
  44008. */
  44009. blocks: Array<OctreeBlock<T>>;
  44010. private _depth;
  44011. private _maxDepth;
  44012. private _capacity;
  44013. private _minPoint;
  44014. private _maxPoint;
  44015. private _boundingVectors;
  44016. private _creationFunc;
  44017. /**
  44018. * Creates a new block
  44019. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44020. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44021. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44022. * @param depth defines the current depth of this block in the octree
  44023. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44024. * @param creationFunc defines a callback to call when an element is added to the block
  44025. */
  44026. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44027. /**
  44028. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44029. */
  44030. readonly capacity: number;
  44031. /**
  44032. * Gets the minimum vector (in world space) of the block's bounding box
  44033. */
  44034. readonly minPoint: Vector3;
  44035. /**
  44036. * Gets the maximum vector (in world space) of the block's bounding box
  44037. */
  44038. readonly maxPoint: Vector3;
  44039. /**
  44040. * Add a new element to this block
  44041. * @param entry defines the element to add
  44042. */
  44043. addEntry(entry: T): void;
  44044. /**
  44045. * Remove an element from this block
  44046. * @param entry defines the element to remove
  44047. */
  44048. removeEntry(entry: T): void;
  44049. /**
  44050. * Add an array of elements to this block
  44051. * @param entries defines the array of elements to add
  44052. */
  44053. addEntries(entries: T[]): void;
  44054. /**
  44055. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44056. * @param frustumPlanes defines the frustum planes to test
  44057. * @param selection defines the array to store current content if selection is positive
  44058. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44059. */
  44060. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44061. /**
  44062. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44063. * @param sphereCenter defines the bounding sphere center
  44064. * @param sphereRadius defines the bounding sphere radius
  44065. * @param selection defines the array to store current content if selection is positive
  44066. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44067. */
  44068. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44069. /**
  44070. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44071. * @param ray defines the ray to test with
  44072. * @param selection defines the array to store current content if selection is positive
  44073. */
  44074. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44075. /**
  44076. * Subdivide the content into child blocks (this block will then be empty)
  44077. */
  44078. createInnerBlocks(): void;
  44079. /**
  44080. * @hidden
  44081. */
  44082. 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;
  44083. }
  44084. }
  44085. declare module "babylonjs/Culling/Octrees/octree" {
  44086. import { SmartArray } from "babylonjs/Misc/smartArray";
  44087. import { Vector3 } from "babylonjs/Maths/math.vector";
  44088. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44089. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44090. import { Ray } from "babylonjs/Culling/ray";
  44091. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44092. import { Plane } from "babylonjs/Maths/math.plane";
  44093. /**
  44094. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44095. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44096. */
  44097. export class Octree<T> {
  44098. /** 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.) */
  44099. maxDepth: number;
  44100. /**
  44101. * Blocks within the octree containing objects
  44102. */
  44103. blocks: Array<OctreeBlock<T>>;
  44104. /**
  44105. * Content stored in the octree
  44106. */
  44107. dynamicContent: T[];
  44108. private _maxBlockCapacity;
  44109. private _selectionContent;
  44110. private _creationFunc;
  44111. /**
  44112. * Creates a octree
  44113. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44114. * @param creationFunc function to be used to instatiate the octree
  44115. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44116. * @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.)
  44117. */
  44118. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44119. /** 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.) */
  44120. maxDepth?: number);
  44121. /**
  44122. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44123. * @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);
  44124. * @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);
  44125. * @param entries meshes to be added to the octree blocks
  44126. */
  44127. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44128. /**
  44129. * Adds a mesh to the octree
  44130. * @param entry Mesh to add to the octree
  44131. */
  44132. addMesh(entry: T): void;
  44133. /**
  44134. * Remove an element from the octree
  44135. * @param entry defines the element to remove
  44136. */
  44137. removeMesh(entry: T): void;
  44138. /**
  44139. * Selects an array of meshes within the frustum
  44140. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44141. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44142. * @returns array of meshes within the frustum
  44143. */
  44144. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44145. /**
  44146. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44147. * @param sphereCenter defines the bounding sphere center
  44148. * @param sphereRadius defines the bounding sphere radius
  44149. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44150. * @returns an array of objects that intersect the sphere
  44151. */
  44152. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44153. /**
  44154. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44155. * @param ray defines the ray to test with
  44156. * @returns array of intersected objects
  44157. */
  44158. intersectsRay(ray: Ray): SmartArray<T>;
  44159. /**
  44160. * Adds a mesh into the octree block if it intersects the block
  44161. */
  44162. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44163. /**
  44164. * Adds a submesh into the octree block if it intersects the block
  44165. */
  44166. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44167. }
  44168. }
  44169. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44170. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44171. import { Scene } from "babylonjs/scene";
  44172. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44173. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44174. import { Ray } from "babylonjs/Culling/ray";
  44175. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44176. import { Collider } from "babylonjs/Collisions/collider";
  44177. module "babylonjs/scene" {
  44178. interface Scene {
  44179. /**
  44180. * @hidden
  44181. * Backing Filed
  44182. */
  44183. _selectionOctree: Octree<AbstractMesh>;
  44184. /**
  44185. * Gets the octree used to boost mesh selection (picking)
  44186. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44187. */
  44188. selectionOctree: Octree<AbstractMesh>;
  44189. /**
  44190. * Creates or updates the octree used to boost selection (picking)
  44191. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44192. * @param maxCapacity defines the maximum capacity per leaf
  44193. * @param maxDepth defines the maximum depth of the octree
  44194. * @returns an octree of AbstractMesh
  44195. */
  44196. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44197. }
  44198. }
  44199. module "babylonjs/Meshes/abstractMesh" {
  44200. interface AbstractMesh {
  44201. /**
  44202. * @hidden
  44203. * Backing Field
  44204. */
  44205. _submeshesOctree: Octree<SubMesh>;
  44206. /**
  44207. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44208. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44209. * @param maxCapacity defines the maximum size of each block (64 by default)
  44210. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44211. * @returns the new octree
  44212. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44213. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44214. */
  44215. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44216. }
  44217. }
  44218. /**
  44219. * Defines the octree scene component responsible to manage any octrees
  44220. * in a given scene.
  44221. */
  44222. export class OctreeSceneComponent {
  44223. /**
  44224. * The component name help to identify the component in the list of scene components.
  44225. */
  44226. readonly name: string;
  44227. /**
  44228. * The scene the component belongs to.
  44229. */
  44230. scene: Scene;
  44231. /**
  44232. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44233. */
  44234. readonly checksIsEnabled: boolean;
  44235. /**
  44236. * Creates a new instance of the component for the given scene
  44237. * @param scene Defines the scene to register the component in
  44238. */
  44239. constructor(scene: Scene);
  44240. /**
  44241. * Registers the component in a given scene
  44242. */
  44243. register(): void;
  44244. /**
  44245. * Return the list of active meshes
  44246. * @returns the list of active meshes
  44247. */
  44248. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44249. /**
  44250. * Return the list of active sub meshes
  44251. * @param mesh The mesh to get the candidates sub meshes from
  44252. * @returns the list of active sub meshes
  44253. */
  44254. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44255. private _tempRay;
  44256. /**
  44257. * Return the list of sub meshes intersecting with a given local ray
  44258. * @param mesh defines the mesh to find the submesh for
  44259. * @param localRay defines the ray in local space
  44260. * @returns the list of intersecting sub meshes
  44261. */
  44262. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44263. /**
  44264. * Return the list of sub meshes colliding with a collider
  44265. * @param mesh defines the mesh to find the submesh for
  44266. * @param collider defines the collider to evaluate the collision against
  44267. * @returns the list of colliding sub meshes
  44268. */
  44269. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44270. /**
  44271. * Rebuilds the elements related to this component in case of
  44272. * context lost for instance.
  44273. */
  44274. rebuild(): void;
  44275. /**
  44276. * Disposes the component and the associated ressources.
  44277. */
  44278. dispose(): void;
  44279. }
  44280. }
  44281. declare module "babylonjs/Culling/Octrees/index" {
  44282. export * from "babylonjs/Culling/Octrees/octree";
  44283. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44284. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44285. }
  44286. declare module "babylonjs/Culling/index" {
  44287. export * from "babylonjs/Culling/boundingBox";
  44288. export * from "babylonjs/Culling/boundingInfo";
  44289. export * from "babylonjs/Culling/boundingSphere";
  44290. export * from "babylonjs/Culling/Octrees/index";
  44291. export * from "babylonjs/Culling/ray";
  44292. }
  44293. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44294. import { IDisposable, Scene } from "babylonjs/scene";
  44295. import { Nullable } from "babylonjs/types";
  44296. import { Observable } from "babylonjs/Misc/observable";
  44297. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44298. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44299. import { Camera } from "babylonjs/Cameras/camera";
  44300. /**
  44301. * Renders a layer on top of an existing scene
  44302. */
  44303. export class UtilityLayerRenderer implements IDisposable {
  44304. /** the original scene that will be rendered on top of */
  44305. originalScene: Scene;
  44306. private _pointerCaptures;
  44307. private _lastPointerEvents;
  44308. private static _DefaultUtilityLayer;
  44309. private static _DefaultKeepDepthUtilityLayer;
  44310. private _sharedGizmoLight;
  44311. private _renderCamera;
  44312. /**
  44313. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44314. * @returns the camera that is used when rendering the utility layer
  44315. */
  44316. getRenderCamera(): Nullable<Camera>;
  44317. /**
  44318. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44319. * @param cam the camera that should be used when rendering the utility layer
  44320. */
  44321. setRenderCamera(cam: Nullable<Camera>): void;
  44322. /**
  44323. * @hidden
  44324. * Light which used by gizmos to get light shading
  44325. */
  44326. _getSharedGizmoLight(): HemisphericLight;
  44327. /**
  44328. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44329. */
  44330. pickUtilitySceneFirst: boolean;
  44331. /**
  44332. * 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)
  44333. */
  44334. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44335. /**
  44336. * 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)
  44337. */
  44338. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44339. /**
  44340. * The scene that is rendered on top of the original scene
  44341. */
  44342. utilityLayerScene: Scene;
  44343. /**
  44344. * If the utility layer should automatically be rendered on top of existing scene
  44345. */
  44346. shouldRender: boolean;
  44347. /**
  44348. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44349. */
  44350. onlyCheckPointerDownEvents: boolean;
  44351. /**
  44352. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44353. */
  44354. processAllEvents: boolean;
  44355. /**
  44356. * Observable raised when the pointer move from the utility layer scene to the main scene
  44357. */
  44358. onPointerOutObservable: Observable<number>;
  44359. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44360. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44361. private _afterRenderObserver;
  44362. private _sceneDisposeObserver;
  44363. private _originalPointerObserver;
  44364. /**
  44365. * Instantiates a UtilityLayerRenderer
  44366. * @param originalScene the original scene that will be rendered on top of
  44367. * @param handleEvents boolean indicating if the utility layer should handle events
  44368. */
  44369. constructor(
  44370. /** the original scene that will be rendered on top of */
  44371. originalScene: Scene, handleEvents?: boolean);
  44372. private _notifyObservers;
  44373. /**
  44374. * Renders the utility layers scene on top of the original scene
  44375. */
  44376. render(): void;
  44377. /**
  44378. * Disposes of the renderer
  44379. */
  44380. dispose(): void;
  44381. private _updateCamera;
  44382. }
  44383. }
  44384. declare module "babylonjs/Gizmos/gizmo" {
  44385. import { Nullable } from "babylonjs/types";
  44386. import { IDisposable } from "babylonjs/scene";
  44387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44388. import { Mesh } from "babylonjs/Meshes/mesh";
  44389. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44390. /**
  44391. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44392. */
  44393. export class Gizmo implements IDisposable {
  44394. /** The utility layer the gizmo will be added to */
  44395. gizmoLayer: UtilityLayerRenderer;
  44396. /**
  44397. * The root mesh of the gizmo
  44398. */
  44399. _rootMesh: Mesh;
  44400. private _attachedMesh;
  44401. /**
  44402. * Ratio for the scale of the gizmo (Default: 1)
  44403. */
  44404. scaleRatio: number;
  44405. /**
  44406. * If a custom mesh has been set (Default: false)
  44407. */
  44408. protected _customMeshSet: boolean;
  44409. /**
  44410. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44411. * * When set, interactions will be enabled
  44412. */
  44413. attachedMesh: Nullable<AbstractMesh>;
  44414. /**
  44415. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44416. * @param mesh The mesh to replace the default mesh of the gizmo
  44417. */
  44418. setCustomMesh(mesh: Mesh): void;
  44419. /**
  44420. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44421. */
  44422. updateGizmoRotationToMatchAttachedMesh: boolean;
  44423. /**
  44424. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44425. */
  44426. updateGizmoPositionToMatchAttachedMesh: boolean;
  44427. /**
  44428. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44429. */
  44430. updateScale: boolean;
  44431. protected _interactionsEnabled: boolean;
  44432. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44433. private _beforeRenderObserver;
  44434. private _tempVector;
  44435. /**
  44436. * Creates a gizmo
  44437. * @param gizmoLayer The utility layer the gizmo will be added to
  44438. */
  44439. constructor(
  44440. /** The utility layer the gizmo will be added to */
  44441. gizmoLayer?: UtilityLayerRenderer);
  44442. /**
  44443. * Updates the gizmo to match the attached mesh's position/rotation
  44444. */
  44445. protected _update(): void;
  44446. /**
  44447. * Disposes of the gizmo
  44448. */
  44449. dispose(): void;
  44450. }
  44451. }
  44452. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44453. import { Observable } from "babylonjs/Misc/observable";
  44454. import { Nullable } from "babylonjs/types";
  44455. import { Vector3 } from "babylonjs/Maths/math.vector";
  44456. import { Color3 } from "babylonjs/Maths/math.color";
  44457. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44459. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44460. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44461. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44462. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44463. import { Scene } from "babylonjs/scene";
  44464. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44465. /**
  44466. * Single plane drag gizmo
  44467. */
  44468. export class PlaneDragGizmo extends Gizmo {
  44469. /**
  44470. * Drag behavior responsible for the gizmos dragging interactions
  44471. */
  44472. dragBehavior: PointerDragBehavior;
  44473. private _pointerObserver;
  44474. /**
  44475. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44476. */
  44477. snapDistance: number;
  44478. /**
  44479. * Event that fires each time the gizmo snaps to a new location.
  44480. * * snapDistance is the the change in distance
  44481. */
  44482. onSnapObservable: Observable<{
  44483. snapDistance: number;
  44484. }>;
  44485. private _plane;
  44486. private _coloredMaterial;
  44487. private _hoverMaterial;
  44488. private _isEnabled;
  44489. private _parent;
  44490. /** @hidden */
  44491. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44492. /** @hidden */
  44493. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44494. /**
  44495. * Creates a PlaneDragGizmo
  44496. * @param gizmoLayer The utility layer the gizmo will be added to
  44497. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44498. * @param color The color of the gizmo
  44499. */
  44500. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44501. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44502. /**
  44503. * If the gizmo is enabled
  44504. */
  44505. isEnabled: boolean;
  44506. /**
  44507. * Disposes of the gizmo
  44508. */
  44509. dispose(): void;
  44510. }
  44511. }
  44512. declare module "babylonjs/Gizmos/positionGizmo" {
  44513. import { Observable } from "babylonjs/Misc/observable";
  44514. import { Nullable } from "babylonjs/types";
  44515. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44516. import { Mesh } from "babylonjs/Meshes/mesh";
  44517. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44518. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44519. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44520. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44521. /**
  44522. * Gizmo that enables dragging a mesh along 3 axis
  44523. */
  44524. export class PositionGizmo extends Gizmo {
  44525. /**
  44526. * Internal gizmo used for interactions on the x axis
  44527. */
  44528. xGizmo: AxisDragGizmo;
  44529. /**
  44530. * Internal gizmo used for interactions on the y axis
  44531. */
  44532. yGizmo: AxisDragGizmo;
  44533. /**
  44534. * Internal gizmo used for interactions on the z axis
  44535. */
  44536. zGizmo: AxisDragGizmo;
  44537. /**
  44538. * Internal gizmo used for interactions on the yz plane
  44539. */
  44540. xPlaneGizmo: PlaneDragGizmo;
  44541. /**
  44542. * Internal gizmo used for interactions on the xz plane
  44543. */
  44544. yPlaneGizmo: PlaneDragGizmo;
  44545. /**
  44546. * Internal gizmo used for interactions on the xy plane
  44547. */
  44548. zPlaneGizmo: PlaneDragGizmo;
  44549. /**
  44550. * private variables
  44551. */
  44552. private _meshAttached;
  44553. private _updateGizmoRotationToMatchAttachedMesh;
  44554. private _snapDistance;
  44555. private _scaleRatio;
  44556. /** Fires an event when any of it's sub gizmos are dragged */
  44557. onDragStartObservable: Observable<unknown>;
  44558. /** Fires an event when any of it's sub gizmos are released from dragging */
  44559. onDragEndObservable: Observable<unknown>;
  44560. /**
  44561. * If set to true, planar drag is enabled
  44562. */
  44563. private _planarGizmoEnabled;
  44564. attachedMesh: Nullable<AbstractMesh>;
  44565. /**
  44566. * Creates a PositionGizmo
  44567. * @param gizmoLayer The utility layer the gizmo will be added to
  44568. */
  44569. constructor(gizmoLayer?: UtilityLayerRenderer);
  44570. /**
  44571. * If the planar drag gizmo is enabled
  44572. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44573. */
  44574. planarGizmoEnabled: boolean;
  44575. updateGizmoRotationToMatchAttachedMesh: boolean;
  44576. /**
  44577. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44578. */
  44579. snapDistance: number;
  44580. /**
  44581. * Ratio for the scale of the gizmo (Default: 1)
  44582. */
  44583. scaleRatio: number;
  44584. /**
  44585. * Disposes of the gizmo
  44586. */
  44587. dispose(): void;
  44588. /**
  44589. * CustomMeshes are not supported by this gizmo
  44590. * @param mesh The mesh to replace the default mesh of the gizmo
  44591. */
  44592. setCustomMesh(mesh: Mesh): void;
  44593. }
  44594. }
  44595. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44596. import { Observable } from "babylonjs/Misc/observable";
  44597. import { Nullable } from "babylonjs/types";
  44598. import { Vector3 } from "babylonjs/Maths/math.vector";
  44599. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44600. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44601. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44602. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44603. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44604. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44605. import { Scene } from "babylonjs/scene";
  44606. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44607. import { Color3 } from "babylonjs/Maths/math.color";
  44608. /**
  44609. * Single axis drag gizmo
  44610. */
  44611. export class AxisDragGizmo extends Gizmo {
  44612. /**
  44613. * Drag behavior responsible for the gizmos dragging interactions
  44614. */
  44615. dragBehavior: PointerDragBehavior;
  44616. private _pointerObserver;
  44617. /**
  44618. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44619. */
  44620. snapDistance: number;
  44621. /**
  44622. * Event that fires each time the gizmo snaps to a new location.
  44623. * * snapDistance is the the change in distance
  44624. */
  44625. onSnapObservable: Observable<{
  44626. snapDistance: number;
  44627. }>;
  44628. private _isEnabled;
  44629. private _parent;
  44630. private _arrow;
  44631. private _coloredMaterial;
  44632. private _hoverMaterial;
  44633. /** @hidden */
  44634. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44635. /** @hidden */
  44636. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44637. /**
  44638. * Creates an AxisDragGizmo
  44639. * @param gizmoLayer The utility layer the gizmo will be added to
  44640. * @param dragAxis The axis which the gizmo will be able to drag on
  44641. * @param color The color of the gizmo
  44642. */
  44643. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44644. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44645. /**
  44646. * If the gizmo is enabled
  44647. */
  44648. isEnabled: boolean;
  44649. /**
  44650. * Disposes of the gizmo
  44651. */
  44652. dispose(): void;
  44653. }
  44654. }
  44655. declare module "babylonjs/Debug/axesViewer" {
  44656. import { Vector3 } from "babylonjs/Maths/math.vector";
  44657. import { Nullable } from "babylonjs/types";
  44658. import { Scene } from "babylonjs/scene";
  44659. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44660. /**
  44661. * The Axes viewer will show 3 axes in a specific point in space
  44662. */
  44663. export class AxesViewer {
  44664. private _xAxis;
  44665. private _yAxis;
  44666. private _zAxis;
  44667. private _scaleLinesFactor;
  44668. private _instanced;
  44669. /**
  44670. * Gets the hosting scene
  44671. */
  44672. scene: Scene;
  44673. /**
  44674. * Gets or sets a number used to scale line length
  44675. */
  44676. scaleLines: number;
  44677. /** Gets the node hierarchy used to render x-axis */
  44678. readonly xAxis: TransformNode;
  44679. /** Gets the node hierarchy used to render y-axis */
  44680. readonly yAxis: TransformNode;
  44681. /** Gets the node hierarchy used to render z-axis */
  44682. readonly zAxis: TransformNode;
  44683. /**
  44684. * Creates a new AxesViewer
  44685. * @param scene defines the hosting scene
  44686. * @param scaleLines defines a number used to scale line length (1 by default)
  44687. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44688. * @param xAxis defines the node hierarchy used to render the x-axis
  44689. * @param yAxis defines the node hierarchy used to render the y-axis
  44690. * @param zAxis defines the node hierarchy used to render the z-axis
  44691. */
  44692. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44693. /**
  44694. * Force the viewer to update
  44695. * @param position defines the position of the viewer
  44696. * @param xaxis defines the x axis of the viewer
  44697. * @param yaxis defines the y axis of the viewer
  44698. * @param zaxis defines the z axis of the viewer
  44699. */
  44700. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44701. /**
  44702. * Creates an instance of this axes viewer.
  44703. * @returns a new axes viewer with instanced meshes
  44704. */
  44705. createInstance(): AxesViewer;
  44706. /** Releases resources */
  44707. dispose(): void;
  44708. private static _SetRenderingGroupId;
  44709. }
  44710. }
  44711. declare module "babylonjs/Debug/boneAxesViewer" {
  44712. import { Nullable } from "babylonjs/types";
  44713. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44714. import { Vector3 } from "babylonjs/Maths/math.vector";
  44715. import { Mesh } from "babylonjs/Meshes/mesh";
  44716. import { Bone } from "babylonjs/Bones/bone";
  44717. import { Scene } from "babylonjs/scene";
  44718. /**
  44719. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44720. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44721. */
  44722. export class BoneAxesViewer extends AxesViewer {
  44723. /**
  44724. * Gets or sets the target mesh where to display the axes viewer
  44725. */
  44726. mesh: Nullable<Mesh>;
  44727. /**
  44728. * Gets or sets the target bone where to display the axes viewer
  44729. */
  44730. bone: Nullable<Bone>;
  44731. /** Gets current position */
  44732. pos: Vector3;
  44733. /** Gets direction of X axis */
  44734. xaxis: Vector3;
  44735. /** Gets direction of Y axis */
  44736. yaxis: Vector3;
  44737. /** Gets direction of Z axis */
  44738. zaxis: Vector3;
  44739. /**
  44740. * Creates a new BoneAxesViewer
  44741. * @param scene defines the hosting scene
  44742. * @param bone defines the target bone
  44743. * @param mesh defines the target mesh
  44744. * @param scaleLines defines a scaling factor for line length (1 by default)
  44745. */
  44746. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44747. /**
  44748. * Force the viewer to update
  44749. */
  44750. update(): void;
  44751. /** Releases resources */
  44752. dispose(): void;
  44753. }
  44754. }
  44755. declare module "babylonjs/Debug/debugLayer" {
  44756. import { Scene } from "babylonjs/scene";
  44757. /**
  44758. * Interface used to define scene explorer extensibility option
  44759. */
  44760. export interface IExplorerExtensibilityOption {
  44761. /**
  44762. * Define the option label
  44763. */
  44764. label: string;
  44765. /**
  44766. * Defines the action to execute on click
  44767. */
  44768. action: (entity: any) => void;
  44769. }
  44770. /**
  44771. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44772. */
  44773. export interface IExplorerExtensibilityGroup {
  44774. /**
  44775. * Defines a predicate to test if a given type mut be extended
  44776. */
  44777. predicate: (entity: any) => boolean;
  44778. /**
  44779. * Gets the list of options added to a type
  44780. */
  44781. entries: IExplorerExtensibilityOption[];
  44782. }
  44783. /**
  44784. * Interface used to define the options to use to create the Inspector
  44785. */
  44786. export interface IInspectorOptions {
  44787. /**
  44788. * Display in overlay mode (default: false)
  44789. */
  44790. overlay?: boolean;
  44791. /**
  44792. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44793. */
  44794. globalRoot?: HTMLElement;
  44795. /**
  44796. * Display the Scene explorer
  44797. */
  44798. showExplorer?: boolean;
  44799. /**
  44800. * Display the property inspector
  44801. */
  44802. showInspector?: boolean;
  44803. /**
  44804. * Display in embed mode (both panes on the right)
  44805. */
  44806. embedMode?: boolean;
  44807. /**
  44808. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44809. */
  44810. handleResize?: boolean;
  44811. /**
  44812. * Allow the panes to popup (default: true)
  44813. */
  44814. enablePopup?: boolean;
  44815. /**
  44816. * Allow the panes to be closed by users (default: true)
  44817. */
  44818. enableClose?: boolean;
  44819. /**
  44820. * Optional list of extensibility entries
  44821. */
  44822. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44823. /**
  44824. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44825. */
  44826. inspectorURL?: string;
  44827. }
  44828. module "babylonjs/scene" {
  44829. interface Scene {
  44830. /**
  44831. * @hidden
  44832. * Backing field
  44833. */
  44834. _debugLayer: DebugLayer;
  44835. /**
  44836. * Gets the debug layer (aka Inspector) associated with the scene
  44837. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44838. */
  44839. debugLayer: DebugLayer;
  44840. }
  44841. }
  44842. /**
  44843. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44844. * what is happening in your scene
  44845. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44846. */
  44847. export class DebugLayer {
  44848. /**
  44849. * Define the url to get the inspector script from.
  44850. * By default it uses the babylonjs CDN.
  44851. * @ignoreNaming
  44852. */
  44853. static InspectorURL: string;
  44854. private _scene;
  44855. private BJSINSPECTOR;
  44856. private _onPropertyChangedObservable?;
  44857. /**
  44858. * Observable triggered when a property is changed through the inspector.
  44859. */
  44860. readonly onPropertyChangedObservable: any;
  44861. /**
  44862. * Instantiates a new debug layer.
  44863. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44864. * what is happening in your scene
  44865. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44866. * @param scene Defines the scene to inspect
  44867. */
  44868. constructor(scene: Scene);
  44869. /** Creates the inspector window. */
  44870. private _createInspector;
  44871. /**
  44872. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44873. * @param entity defines the entity to select
  44874. * @param lineContainerTitle defines the specific block to highlight
  44875. */
  44876. select(entity: any, lineContainerTitle?: string): void;
  44877. /** Get the inspector from bundle or global */
  44878. private _getGlobalInspector;
  44879. /**
  44880. * Get if the inspector is visible or not.
  44881. * @returns true if visible otherwise, false
  44882. */
  44883. isVisible(): boolean;
  44884. /**
  44885. * Hide the inspector and close its window.
  44886. */
  44887. hide(): void;
  44888. /**
  44889. * Launch the debugLayer.
  44890. * @param config Define the configuration of the inspector
  44891. * @return a promise fulfilled when the debug layer is visible
  44892. */
  44893. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44894. }
  44895. }
  44896. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44897. import { Nullable } from "babylonjs/types";
  44898. import { Scene } from "babylonjs/scene";
  44899. import { Vector4 } from "babylonjs/Maths/math.vector";
  44900. import { Color4 } from "babylonjs/Maths/math.color";
  44901. import { Mesh } from "babylonjs/Meshes/mesh";
  44902. /**
  44903. * Class containing static functions to help procedurally build meshes
  44904. */
  44905. export class BoxBuilder {
  44906. /**
  44907. * Creates a box mesh
  44908. * * The parameter `size` sets the size (float) of each box side (default 1)
  44909. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44910. * * 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)
  44911. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44912. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44913. * * 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
  44914. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44915. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44916. * @param name defines the name of the mesh
  44917. * @param options defines the options used to create the mesh
  44918. * @param scene defines the hosting scene
  44919. * @returns the box mesh
  44920. */
  44921. static CreateBox(name: string, options: {
  44922. size?: number;
  44923. width?: number;
  44924. height?: number;
  44925. depth?: number;
  44926. faceUV?: Vector4[];
  44927. faceColors?: Color4[];
  44928. sideOrientation?: number;
  44929. frontUVs?: Vector4;
  44930. backUVs?: Vector4;
  44931. wrap?: boolean;
  44932. topBaseAt?: number;
  44933. bottomBaseAt?: number;
  44934. updatable?: boolean;
  44935. }, scene?: Nullable<Scene>): Mesh;
  44936. }
  44937. }
  44938. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  44939. import { Vector4 } from "babylonjs/Maths/math.vector";
  44940. import { Mesh } from "babylonjs/Meshes/mesh";
  44941. import { Scene } from "babylonjs/scene";
  44942. import { Nullable } from "babylonjs/types";
  44943. /**
  44944. * Class containing static functions to help procedurally build meshes
  44945. */
  44946. export class SphereBuilder {
  44947. /**
  44948. * Creates a sphere mesh
  44949. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  44950. * * 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`)
  44951. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  44952. * * 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
  44953. * * 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)
  44954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44955. * * 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
  44956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44957. * @param name defines the name of the mesh
  44958. * @param options defines the options used to create the mesh
  44959. * @param scene defines the hosting scene
  44960. * @returns the sphere mesh
  44961. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  44962. */
  44963. static CreateSphere(name: string, options: {
  44964. segments?: number;
  44965. diameter?: number;
  44966. diameterX?: number;
  44967. diameterY?: number;
  44968. diameterZ?: number;
  44969. arc?: number;
  44970. slice?: number;
  44971. sideOrientation?: number;
  44972. frontUVs?: Vector4;
  44973. backUVs?: Vector4;
  44974. updatable?: boolean;
  44975. }, scene?: Nullable<Scene>): Mesh;
  44976. }
  44977. }
  44978. declare module "babylonjs/Debug/physicsViewer" {
  44979. import { Nullable } from "babylonjs/types";
  44980. import { Scene } from "babylonjs/scene";
  44981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44982. import { Mesh } from "babylonjs/Meshes/mesh";
  44983. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  44984. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  44985. /**
  44986. * Used to show the physics impostor around the specific mesh
  44987. */
  44988. export class PhysicsViewer {
  44989. /** @hidden */
  44990. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  44991. /** @hidden */
  44992. protected _meshes: Array<Nullable<AbstractMesh>>;
  44993. /** @hidden */
  44994. protected _scene: Nullable<Scene>;
  44995. /** @hidden */
  44996. protected _numMeshes: number;
  44997. /** @hidden */
  44998. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  44999. private _renderFunction;
  45000. private _utilityLayer;
  45001. private _debugBoxMesh;
  45002. private _debugSphereMesh;
  45003. private _debugCylinderMesh;
  45004. private _debugMaterial;
  45005. private _debugMeshMeshes;
  45006. /**
  45007. * Creates a new PhysicsViewer
  45008. * @param scene defines the hosting scene
  45009. */
  45010. constructor(scene: Scene);
  45011. /** @hidden */
  45012. protected _updateDebugMeshes(): void;
  45013. /**
  45014. * Renders a specified physic impostor
  45015. * @param impostor defines the impostor to render
  45016. * @param targetMesh defines the mesh represented by the impostor
  45017. * @returns the new debug mesh used to render the impostor
  45018. */
  45019. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45020. /**
  45021. * Hides a specified physic impostor
  45022. * @param impostor defines the impostor to hide
  45023. */
  45024. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45025. private _getDebugMaterial;
  45026. private _getDebugBoxMesh;
  45027. private _getDebugSphereMesh;
  45028. private _getDebugCylinderMesh;
  45029. private _getDebugMeshMesh;
  45030. private _getDebugMesh;
  45031. /** Releases all resources */
  45032. dispose(): void;
  45033. }
  45034. }
  45035. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45036. import { Vector3 } from "babylonjs/Maths/math.vector";
  45037. import { Color4 } from "babylonjs/Maths/math.color";
  45038. import { Nullable } from "babylonjs/types";
  45039. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45040. import { Scene } from "babylonjs/scene";
  45041. /**
  45042. * Class containing static functions to help procedurally build meshes
  45043. */
  45044. export class LinesBuilder {
  45045. /**
  45046. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45047. * * 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
  45048. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45049. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45050. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45051. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45052. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45053. * * 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
  45054. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45056. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45057. * @param name defines the name of the new line system
  45058. * @param options defines the options used to create the line system
  45059. * @param scene defines the hosting scene
  45060. * @returns a new line system mesh
  45061. */
  45062. static CreateLineSystem(name: string, options: {
  45063. lines: Vector3[][];
  45064. updatable?: boolean;
  45065. instance?: Nullable<LinesMesh>;
  45066. colors?: Nullable<Color4[][]>;
  45067. useVertexAlpha?: boolean;
  45068. }, scene: Nullable<Scene>): LinesMesh;
  45069. /**
  45070. * Creates a line mesh
  45071. * 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
  45072. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45073. * * The parameter `points` is an array successive Vector3
  45074. * * 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
  45075. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45076. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45077. * * When updating an instance, remember that only point positions can change, not the number of points
  45078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45079. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45080. * @param name defines the name of the new line system
  45081. * @param options defines the options used to create the line system
  45082. * @param scene defines the hosting scene
  45083. * @returns a new line mesh
  45084. */
  45085. static CreateLines(name: string, options: {
  45086. points: Vector3[];
  45087. updatable?: boolean;
  45088. instance?: Nullable<LinesMesh>;
  45089. colors?: Color4[];
  45090. useVertexAlpha?: boolean;
  45091. }, scene?: Nullable<Scene>): LinesMesh;
  45092. /**
  45093. * Creates a dashed line mesh
  45094. * * 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
  45095. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45096. * * The parameter `points` is an array successive Vector3
  45097. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45098. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45099. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45100. * * 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
  45101. * * When updating an instance, remember that only point positions can change, not the number of points
  45102. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45103. * @param name defines the name of the mesh
  45104. * @param options defines the options used to create the mesh
  45105. * @param scene defines the hosting scene
  45106. * @returns the dashed line mesh
  45107. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45108. */
  45109. static CreateDashedLines(name: string, options: {
  45110. points: Vector3[];
  45111. dashSize?: number;
  45112. gapSize?: number;
  45113. dashNb?: number;
  45114. updatable?: boolean;
  45115. instance?: LinesMesh;
  45116. }, scene?: Nullable<Scene>): LinesMesh;
  45117. }
  45118. }
  45119. declare module "babylonjs/Debug/rayHelper" {
  45120. import { Nullable } from "babylonjs/types";
  45121. import { Ray } from "babylonjs/Culling/ray";
  45122. import { Vector3 } from "babylonjs/Maths/math.vector";
  45123. import { Color3 } from "babylonjs/Maths/math.color";
  45124. import { Scene } from "babylonjs/scene";
  45125. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45126. import "babylonjs/Meshes/Builders/linesBuilder";
  45127. /**
  45128. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45129. * in order to better appreciate the issue one might have.
  45130. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45131. */
  45132. export class RayHelper {
  45133. /**
  45134. * Defines the ray we are currently tryin to visualize.
  45135. */
  45136. ray: Nullable<Ray>;
  45137. private _renderPoints;
  45138. private _renderLine;
  45139. private _renderFunction;
  45140. private _scene;
  45141. private _updateToMeshFunction;
  45142. private _attachedToMesh;
  45143. private _meshSpaceDirection;
  45144. private _meshSpaceOrigin;
  45145. /**
  45146. * Helper function to create a colored helper in a scene in one line.
  45147. * @param ray Defines the ray we are currently tryin to visualize
  45148. * @param scene Defines the scene the ray is used in
  45149. * @param color Defines the color we want to see the ray in
  45150. * @returns The newly created ray helper.
  45151. */
  45152. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45153. /**
  45154. * Instantiate a new ray helper.
  45155. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45156. * in order to better appreciate the issue one might have.
  45157. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45158. * @param ray Defines the ray we are currently tryin to visualize
  45159. */
  45160. constructor(ray: Ray);
  45161. /**
  45162. * Shows the ray we are willing to debug.
  45163. * @param scene Defines the scene the ray needs to be rendered in
  45164. * @param color Defines the color the ray needs to be rendered in
  45165. */
  45166. show(scene: Scene, color?: Color3): void;
  45167. /**
  45168. * Hides the ray we are debugging.
  45169. */
  45170. hide(): void;
  45171. private _render;
  45172. /**
  45173. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45174. * @param mesh Defines the mesh we want the helper attached to
  45175. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45176. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45177. * @param length Defines the length of the ray
  45178. */
  45179. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45180. /**
  45181. * Detach the ray helper from the mesh it has previously been attached to.
  45182. */
  45183. detachFromMesh(): void;
  45184. private _updateToMesh;
  45185. /**
  45186. * Dispose the helper and release its associated resources.
  45187. */
  45188. dispose(): void;
  45189. }
  45190. }
  45191. declare module "babylonjs/Debug/skeletonViewer" {
  45192. import { Color3 } from "babylonjs/Maths/math.color";
  45193. import { Scene } from "babylonjs/scene";
  45194. import { Nullable } from "babylonjs/types";
  45195. import { Skeleton } from "babylonjs/Bones/skeleton";
  45196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45197. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45198. /**
  45199. * Class used to render a debug view of a given skeleton
  45200. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45201. */
  45202. export class SkeletonViewer {
  45203. /** defines the skeleton to render */
  45204. skeleton: Skeleton;
  45205. /** defines the mesh attached to the skeleton */
  45206. mesh: AbstractMesh;
  45207. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45208. autoUpdateBonesMatrices: boolean;
  45209. /** defines the rendering group id to use with the viewer */
  45210. renderingGroupId: number;
  45211. /** Gets or sets the color used to render the skeleton */
  45212. color: Color3;
  45213. private _scene;
  45214. private _debugLines;
  45215. private _debugMesh;
  45216. private _isEnabled;
  45217. private _renderFunction;
  45218. private _utilityLayer;
  45219. /**
  45220. * Returns the mesh used to render the bones
  45221. */
  45222. readonly debugMesh: Nullable<LinesMesh>;
  45223. /**
  45224. * Creates a new SkeletonViewer
  45225. * @param skeleton defines the skeleton to render
  45226. * @param mesh defines the mesh attached to the skeleton
  45227. * @param scene defines the hosting scene
  45228. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45229. * @param renderingGroupId defines the rendering group id to use with the viewer
  45230. */
  45231. constructor(
  45232. /** defines the skeleton to render */
  45233. skeleton: Skeleton,
  45234. /** defines the mesh attached to the skeleton */
  45235. mesh: AbstractMesh, scene: Scene,
  45236. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45237. autoUpdateBonesMatrices?: boolean,
  45238. /** defines the rendering group id to use with the viewer */
  45239. renderingGroupId?: number);
  45240. /** Gets or sets a boolean indicating if the viewer is enabled */
  45241. isEnabled: boolean;
  45242. private _getBonePosition;
  45243. private _getLinesForBonesWithLength;
  45244. private _getLinesForBonesNoLength;
  45245. /** Update the viewer to sync with current skeleton state */
  45246. update(): void;
  45247. /** Release associated resources */
  45248. dispose(): void;
  45249. }
  45250. }
  45251. declare module "babylonjs/Debug/index" {
  45252. export * from "babylonjs/Debug/axesViewer";
  45253. export * from "babylonjs/Debug/boneAxesViewer";
  45254. export * from "babylonjs/Debug/debugLayer";
  45255. export * from "babylonjs/Debug/physicsViewer";
  45256. export * from "babylonjs/Debug/rayHelper";
  45257. export * from "babylonjs/Debug/skeletonViewer";
  45258. }
  45259. declare module "babylonjs/Engines/nullEngine" {
  45260. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45261. import { Scene } from "babylonjs/scene";
  45262. import { Engine } from "babylonjs/Engines/engine";
  45263. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45264. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45265. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45266. import { Effect } from "babylonjs/Materials/effect";
  45267. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45268. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45269. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45270. /**
  45271. * Options to create the null engine
  45272. */
  45273. export class NullEngineOptions {
  45274. /**
  45275. * Render width (Default: 512)
  45276. */
  45277. renderWidth: number;
  45278. /**
  45279. * Render height (Default: 256)
  45280. */
  45281. renderHeight: number;
  45282. /**
  45283. * Texture size (Default: 512)
  45284. */
  45285. textureSize: number;
  45286. /**
  45287. * If delta time between frames should be constant
  45288. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45289. */
  45290. deterministicLockstep: boolean;
  45291. /**
  45292. * Maximum about of steps between frames (Default: 4)
  45293. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45294. */
  45295. lockstepMaxSteps: number;
  45296. }
  45297. /**
  45298. * The null engine class provides support for headless version of babylon.js.
  45299. * This can be used in server side scenario or for testing purposes
  45300. */
  45301. export class NullEngine extends Engine {
  45302. private _options;
  45303. /**
  45304. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45305. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45306. * @returns true if engine is in deterministic lock step mode
  45307. */
  45308. isDeterministicLockStep(): boolean;
  45309. /**
  45310. * Gets the max steps when engine is running in deterministic lock step
  45311. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45312. * @returns the max steps
  45313. */
  45314. getLockstepMaxSteps(): number;
  45315. /**
  45316. * Gets the current hardware scaling level.
  45317. * By default the hardware scaling level is computed from the window device ratio.
  45318. * 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.
  45319. * @returns a number indicating the current hardware scaling level
  45320. */
  45321. getHardwareScalingLevel(): number;
  45322. constructor(options?: NullEngineOptions);
  45323. /**
  45324. * Creates a vertex buffer
  45325. * @param vertices the data for the vertex buffer
  45326. * @returns the new WebGL static buffer
  45327. */
  45328. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45329. /**
  45330. * Creates a new index buffer
  45331. * @param indices defines the content of the index buffer
  45332. * @param updatable defines if the index buffer must be updatable
  45333. * @returns a new webGL buffer
  45334. */
  45335. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45336. /**
  45337. * Clear the current render buffer or the current render target (if any is set up)
  45338. * @param color defines the color to use
  45339. * @param backBuffer defines if the back buffer must be cleared
  45340. * @param depth defines if the depth buffer must be cleared
  45341. * @param stencil defines if the stencil buffer must be cleared
  45342. */
  45343. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45344. /**
  45345. * Gets the current render width
  45346. * @param useScreen defines if screen size must be used (or the current render target if any)
  45347. * @returns a number defining the current render width
  45348. */
  45349. getRenderWidth(useScreen?: boolean): number;
  45350. /**
  45351. * Gets the current render height
  45352. * @param useScreen defines if screen size must be used (or the current render target if any)
  45353. * @returns a number defining the current render height
  45354. */
  45355. getRenderHeight(useScreen?: boolean): number;
  45356. /**
  45357. * Set the WebGL's viewport
  45358. * @param viewport defines the viewport element to be used
  45359. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45360. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45361. */
  45362. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45363. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45364. /**
  45365. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45366. * @param pipelineContext defines the pipeline context to use
  45367. * @param uniformsNames defines the list of uniform names
  45368. * @returns an array of webGL uniform locations
  45369. */
  45370. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45371. /**
  45372. * Gets the lsit of active attributes for a given webGL program
  45373. * @param pipelineContext defines the pipeline context to use
  45374. * @param attributesNames defines the list of attribute names to get
  45375. * @returns an array of indices indicating the offset of each attribute
  45376. */
  45377. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45378. /**
  45379. * Binds an effect to the webGL context
  45380. * @param effect defines the effect to bind
  45381. */
  45382. bindSamplers(effect: Effect): void;
  45383. /**
  45384. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45385. * @param effect defines the effect to activate
  45386. */
  45387. enableEffect(effect: Effect): void;
  45388. /**
  45389. * Set various states to the webGL context
  45390. * @param culling defines backface culling state
  45391. * @param zOffset defines the value to apply to zOffset (0 by default)
  45392. * @param force defines if states must be applied even if cache is up to date
  45393. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45394. */
  45395. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45396. /**
  45397. * Set the value of an uniform to an array of int32
  45398. * @param uniform defines the webGL uniform location where to store the value
  45399. * @param array defines the array of int32 to store
  45400. */
  45401. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45402. /**
  45403. * Set the value of an uniform to an array of int32 (stored as vec2)
  45404. * @param uniform defines the webGL uniform location where to store the value
  45405. * @param array defines the array of int32 to store
  45406. */
  45407. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45408. /**
  45409. * Set the value of an uniform to an array of int32 (stored as vec3)
  45410. * @param uniform defines the webGL uniform location where to store the value
  45411. * @param array defines the array of int32 to store
  45412. */
  45413. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45414. /**
  45415. * Set the value of an uniform to an array of int32 (stored as vec4)
  45416. * @param uniform defines the webGL uniform location where to store the value
  45417. * @param array defines the array of int32 to store
  45418. */
  45419. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45420. /**
  45421. * Set the value of an uniform to an array of float32
  45422. * @param uniform defines the webGL uniform location where to store the value
  45423. * @param array defines the array of float32 to store
  45424. */
  45425. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45426. /**
  45427. * Set the value of an uniform to an array of float32 (stored as vec2)
  45428. * @param uniform defines the webGL uniform location where to store the value
  45429. * @param array defines the array of float32 to store
  45430. */
  45431. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45432. /**
  45433. * Set the value of an uniform to an array of float32 (stored as vec3)
  45434. * @param uniform defines the webGL uniform location where to store the value
  45435. * @param array defines the array of float32 to store
  45436. */
  45437. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45438. /**
  45439. * Set the value of an uniform to an array of float32 (stored as vec4)
  45440. * @param uniform defines the webGL uniform location where to store the value
  45441. * @param array defines the array of float32 to store
  45442. */
  45443. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45444. /**
  45445. * Set the value of an uniform to an array of number
  45446. * @param uniform defines the webGL uniform location where to store the value
  45447. * @param array defines the array of number to store
  45448. */
  45449. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45450. /**
  45451. * Set the value of an uniform to an array of number (stored as vec2)
  45452. * @param uniform defines the webGL uniform location where to store the value
  45453. * @param array defines the array of number to store
  45454. */
  45455. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45456. /**
  45457. * Set the value of an uniform to an array of number (stored as vec3)
  45458. * @param uniform defines the webGL uniform location where to store the value
  45459. * @param array defines the array of number to store
  45460. */
  45461. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45462. /**
  45463. * Set the value of an uniform to an array of number (stored as vec4)
  45464. * @param uniform defines the webGL uniform location where to store the value
  45465. * @param array defines the array of number to store
  45466. */
  45467. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45468. /**
  45469. * Set the value of an uniform to an array of float32 (stored as matrices)
  45470. * @param uniform defines the webGL uniform location where to store the value
  45471. * @param matrices defines the array of float32 to store
  45472. */
  45473. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45474. /**
  45475. * Set the value of an uniform to a matrix (3x3)
  45476. * @param uniform defines the webGL uniform location where to store the value
  45477. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45478. */
  45479. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45480. /**
  45481. * Set the value of an uniform to a matrix (2x2)
  45482. * @param uniform defines the webGL uniform location where to store the value
  45483. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45484. */
  45485. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45486. /**
  45487. * Set the value of an uniform to a number (float)
  45488. * @param uniform defines the webGL uniform location where to store the value
  45489. * @param value defines the float number to store
  45490. */
  45491. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45492. /**
  45493. * Set the value of an uniform to a vec2
  45494. * @param uniform defines the webGL uniform location where to store the value
  45495. * @param x defines the 1st component of the value
  45496. * @param y defines the 2nd component of the value
  45497. */
  45498. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45499. /**
  45500. * Set the value of an uniform to a vec3
  45501. * @param uniform defines the webGL uniform location where to store the value
  45502. * @param x defines the 1st component of the value
  45503. * @param y defines the 2nd component of the value
  45504. * @param z defines the 3rd component of the value
  45505. */
  45506. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45507. /**
  45508. * Set the value of an uniform to a boolean
  45509. * @param uniform defines the webGL uniform location where to store the value
  45510. * @param bool defines the boolean to store
  45511. */
  45512. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45513. /**
  45514. * Set the value of an uniform to a vec4
  45515. * @param uniform defines the webGL uniform location where to store the value
  45516. * @param x defines the 1st component of the value
  45517. * @param y defines the 2nd component of the value
  45518. * @param z defines the 3rd component of the value
  45519. * @param w defines the 4th component of the value
  45520. */
  45521. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45522. /**
  45523. * Sets the current alpha mode
  45524. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45525. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45526. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45527. */
  45528. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45529. /**
  45530. * Bind webGl buffers directly to the webGL context
  45531. * @param vertexBuffers defines the vertex buffer to bind
  45532. * @param indexBuffer defines the index buffer to bind
  45533. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45534. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45535. * @param effect defines the effect associated with the vertex buffer
  45536. */
  45537. bindBuffers(vertexBuffers: {
  45538. [key: string]: VertexBuffer;
  45539. }, indexBuffer: DataBuffer, effect: Effect): void;
  45540. /**
  45541. * Force the entire cache to be cleared
  45542. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45543. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45544. */
  45545. wipeCaches(bruteForce?: boolean): void;
  45546. /**
  45547. * Send a draw order
  45548. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45549. * @param indexStart defines the starting index
  45550. * @param indexCount defines the number of index to draw
  45551. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45552. */
  45553. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45554. /**
  45555. * Draw a list of indexed primitives
  45556. * @param fillMode defines the primitive to use
  45557. * @param indexStart defines the starting index
  45558. * @param indexCount defines the number of index to draw
  45559. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45560. */
  45561. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45562. /**
  45563. * Draw a list of unindexed primitives
  45564. * @param fillMode defines the primitive to use
  45565. * @param verticesStart defines the index of first vertex to draw
  45566. * @param verticesCount defines the count of vertices to draw
  45567. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45568. */
  45569. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45570. /** @hidden */
  45571. _createTexture(): WebGLTexture;
  45572. /** @hidden */
  45573. _releaseTexture(texture: InternalTexture): void;
  45574. /**
  45575. * Usually called from Texture.ts.
  45576. * Passed information to create a WebGLTexture
  45577. * @param urlArg defines a value which contains one of the following:
  45578. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45579. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45580. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45581. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45582. * @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)
  45583. * @param scene needed for loading to the correct scene
  45584. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45585. * @param onLoad optional callback to be called upon successful completion
  45586. * @param onError optional callback to be called upon failure
  45587. * @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
  45588. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45589. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45590. * @param forcedExtension defines the extension to use to pick the right loader
  45591. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45592. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45593. */
  45594. 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;
  45595. /**
  45596. * Creates a new render target texture
  45597. * @param size defines the size of the texture
  45598. * @param options defines the options used to create the texture
  45599. * @returns a new render target texture stored in an InternalTexture
  45600. */
  45601. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45602. /**
  45603. * Update the sampling mode of a given texture
  45604. * @param samplingMode defines the required sampling mode
  45605. * @param texture defines the texture to update
  45606. */
  45607. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45608. /**
  45609. * Binds the frame buffer to the specified texture.
  45610. * @param texture The texture to render to or null for the default canvas
  45611. * @param faceIndex The face of the texture to render to in case of cube texture
  45612. * @param requiredWidth The width of the target to render to
  45613. * @param requiredHeight The height of the target to render to
  45614. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45615. * @param depthStencilTexture The depth stencil texture to use to render
  45616. * @param lodLevel defines le lod level to bind to the frame buffer
  45617. */
  45618. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45619. /**
  45620. * Unbind the current render target texture from the webGL context
  45621. * @param texture defines the render target texture to unbind
  45622. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45623. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45624. */
  45625. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45626. /**
  45627. * Creates a dynamic vertex buffer
  45628. * @param vertices the data for the dynamic vertex buffer
  45629. * @returns the new WebGL dynamic buffer
  45630. */
  45631. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45632. /**
  45633. * Update the content of a dynamic texture
  45634. * @param texture defines the texture to update
  45635. * @param canvas defines the canvas containing the source
  45636. * @param invertY defines if data must be stored with Y axis inverted
  45637. * @param premulAlpha defines if alpha is stored as premultiplied
  45638. * @param format defines the format of the data
  45639. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45640. */
  45641. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45642. /**
  45643. * Gets a boolean indicating if all created effects are ready
  45644. * @returns true if all effects are ready
  45645. */
  45646. areAllEffectsReady(): boolean;
  45647. /**
  45648. * @hidden
  45649. * Get the current error code of the webGL context
  45650. * @returns the error code
  45651. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45652. */
  45653. getError(): number;
  45654. /** @hidden */
  45655. _getUnpackAlignement(): number;
  45656. /** @hidden */
  45657. _unpackFlipY(value: boolean): void;
  45658. /**
  45659. * Update a dynamic index buffer
  45660. * @param indexBuffer defines the target index buffer
  45661. * @param indices defines the data to update
  45662. * @param offset defines the offset in the target index buffer where update should start
  45663. */
  45664. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45665. /**
  45666. * Updates a dynamic vertex buffer.
  45667. * @param vertexBuffer the vertex buffer to update
  45668. * @param vertices the data used to update the vertex buffer
  45669. * @param byteOffset the byte offset of the data (optional)
  45670. * @param byteLength the byte length of the data (optional)
  45671. */
  45672. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45673. /** @hidden */
  45674. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45675. /** @hidden */
  45676. _bindTexture(channel: number, texture: InternalTexture): void;
  45677. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45678. /**
  45679. * 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
  45680. */
  45681. releaseEffects(): void;
  45682. displayLoadingUI(): void;
  45683. hideLoadingUI(): void;
  45684. /** @hidden */
  45685. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45686. /** @hidden */
  45687. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45688. /** @hidden */
  45689. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45690. /** @hidden */
  45691. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45692. }
  45693. }
  45694. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45695. import { Nullable, int } from "babylonjs/types";
  45696. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45697. /** @hidden */
  45698. export class _OcclusionDataStorage {
  45699. /** @hidden */
  45700. occlusionInternalRetryCounter: number;
  45701. /** @hidden */
  45702. isOcclusionQueryInProgress: boolean;
  45703. /** @hidden */
  45704. isOccluded: boolean;
  45705. /** @hidden */
  45706. occlusionRetryCount: number;
  45707. /** @hidden */
  45708. occlusionType: number;
  45709. /** @hidden */
  45710. occlusionQueryAlgorithmType: number;
  45711. }
  45712. module "babylonjs/Engines/engine" {
  45713. interface Engine {
  45714. /**
  45715. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45716. * @return the new query
  45717. */
  45718. createQuery(): WebGLQuery;
  45719. /**
  45720. * Delete and release a webGL query
  45721. * @param query defines the query to delete
  45722. * @return the current engine
  45723. */
  45724. deleteQuery(query: WebGLQuery): Engine;
  45725. /**
  45726. * Check if a given query has resolved and got its value
  45727. * @param query defines the query to check
  45728. * @returns true if the query got its value
  45729. */
  45730. isQueryResultAvailable(query: WebGLQuery): boolean;
  45731. /**
  45732. * Gets the value of a given query
  45733. * @param query defines the query to check
  45734. * @returns the value of the query
  45735. */
  45736. getQueryResult(query: WebGLQuery): number;
  45737. /**
  45738. * Initiates an occlusion query
  45739. * @param algorithmType defines the algorithm to use
  45740. * @param query defines the query to use
  45741. * @returns the current engine
  45742. * @see http://doc.babylonjs.com/features/occlusionquery
  45743. */
  45744. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45745. /**
  45746. * Ends an occlusion query
  45747. * @see http://doc.babylonjs.com/features/occlusionquery
  45748. * @param algorithmType defines the algorithm to use
  45749. * @returns the current engine
  45750. */
  45751. endOcclusionQuery(algorithmType: number): Engine;
  45752. /**
  45753. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45754. * Please note that only one query can be issued at a time
  45755. * @returns a time token used to track the time span
  45756. */
  45757. startTimeQuery(): Nullable<_TimeToken>;
  45758. /**
  45759. * Ends a time query
  45760. * @param token defines the token used to measure the time span
  45761. * @returns the time spent (in ns)
  45762. */
  45763. endTimeQuery(token: _TimeToken): int;
  45764. /** @hidden */
  45765. _currentNonTimestampToken: Nullable<_TimeToken>;
  45766. /** @hidden */
  45767. _createTimeQuery(): WebGLQuery;
  45768. /** @hidden */
  45769. _deleteTimeQuery(query: WebGLQuery): void;
  45770. /** @hidden */
  45771. _getGlAlgorithmType(algorithmType: number): number;
  45772. /** @hidden */
  45773. _getTimeQueryResult(query: WebGLQuery): any;
  45774. /** @hidden */
  45775. _getTimeQueryAvailability(query: WebGLQuery): any;
  45776. }
  45777. }
  45778. module "babylonjs/Meshes/abstractMesh" {
  45779. interface AbstractMesh {
  45780. /**
  45781. * Backing filed
  45782. * @hidden
  45783. */
  45784. __occlusionDataStorage: _OcclusionDataStorage;
  45785. /**
  45786. * Access property
  45787. * @hidden
  45788. */
  45789. _occlusionDataStorage: _OcclusionDataStorage;
  45790. /**
  45791. * 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.
  45792. * The default value is -1 which means don't break the query and wait till the result
  45793. * @see http://doc.babylonjs.com/features/occlusionquery
  45794. */
  45795. occlusionRetryCount: number;
  45796. /**
  45797. * 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:
  45798. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45799. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45800. * * 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.
  45801. * @see http://doc.babylonjs.com/features/occlusionquery
  45802. */
  45803. occlusionType: number;
  45804. /**
  45805. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45806. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45807. * * 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.
  45808. * @see http://doc.babylonjs.com/features/occlusionquery
  45809. */
  45810. occlusionQueryAlgorithmType: number;
  45811. /**
  45812. * 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
  45813. * @see http://doc.babylonjs.com/features/occlusionquery
  45814. */
  45815. isOccluded: boolean;
  45816. /**
  45817. * Flag to check the progress status of the query
  45818. * @see http://doc.babylonjs.com/features/occlusionquery
  45819. */
  45820. isOcclusionQueryInProgress: boolean;
  45821. }
  45822. }
  45823. }
  45824. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45825. import { Nullable } from "babylonjs/types";
  45826. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45827. /** @hidden */
  45828. export var _forceTransformFeedbackToBundle: boolean;
  45829. module "babylonjs/Engines/engine" {
  45830. interface Engine {
  45831. /**
  45832. * Creates a webGL transform feedback object
  45833. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45834. * @returns the webGL transform feedback object
  45835. */
  45836. createTransformFeedback(): WebGLTransformFeedback;
  45837. /**
  45838. * Delete a webGL transform feedback object
  45839. * @param value defines the webGL transform feedback object to delete
  45840. */
  45841. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45842. /**
  45843. * Bind a webGL transform feedback object to the webgl context
  45844. * @param value defines the webGL transform feedback object to bind
  45845. */
  45846. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45847. /**
  45848. * Begins a transform feedback operation
  45849. * @param usePoints defines if points or triangles must be used
  45850. */
  45851. beginTransformFeedback(usePoints: boolean): void;
  45852. /**
  45853. * Ends a transform feedback operation
  45854. */
  45855. endTransformFeedback(): void;
  45856. /**
  45857. * Specify the varyings to use with transform feedback
  45858. * @param program defines the associated webGL program
  45859. * @param value defines the list of strings representing the varying names
  45860. */
  45861. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45862. /**
  45863. * Bind a webGL buffer for a transform feedback operation
  45864. * @param value defines the webGL buffer to bind
  45865. */
  45866. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45867. }
  45868. }
  45869. }
  45870. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45871. import { Scene } from "babylonjs/scene";
  45872. import { Engine } from "babylonjs/Engines/engine";
  45873. import { Texture } from "babylonjs/Materials/Textures/texture";
  45874. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45875. import "babylonjs/Engines/Extensions/engine.multiRender";
  45876. /**
  45877. * Creation options of the multi render target texture.
  45878. */
  45879. export interface IMultiRenderTargetOptions {
  45880. /**
  45881. * Define if the texture needs to create mip maps after render.
  45882. */
  45883. generateMipMaps?: boolean;
  45884. /**
  45885. * Define the types of all the draw buffers we want to create
  45886. */
  45887. types?: number[];
  45888. /**
  45889. * Define the sampling modes of all the draw buffers we want to create
  45890. */
  45891. samplingModes?: number[];
  45892. /**
  45893. * Define if a depth buffer is required
  45894. */
  45895. generateDepthBuffer?: boolean;
  45896. /**
  45897. * Define if a stencil buffer is required
  45898. */
  45899. generateStencilBuffer?: boolean;
  45900. /**
  45901. * Define if a depth texture is required instead of a depth buffer
  45902. */
  45903. generateDepthTexture?: boolean;
  45904. /**
  45905. * Define the number of desired draw buffers
  45906. */
  45907. textureCount?: number;
  45908. /**
  45909. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45910. */
  45911. doNotChangeAspectRatio?: boolean;
  45912. /**
  45913. * Define the default type of the buffers we are creating
  45914. */
  45915. defaultType?: number;
  45916. }
  45917. /**
  45918. * A multi render target, like a render target provides the ability to render to a texture.
  45919. * Unlike the render target, it can render to several draw buffers in one draw.
  45920. * This is specially interesting in deferred rendering or for any effects requiring more than
  45921. * just one color from a single pass.
  45922. */
  45923. export class MultiRenderTarget extends RenderTargetTexture {
  45924. private _internalTextures;
  45925. private _textures;
  45926. private _multiRenderTargetOptions;
  45927. /**
  45928. * Get if draw buffers are currently supported by the used hardware and browser.
  45929. */
  45930. readonly isSupported: boolean;
  45931. /**
  45932. * Get the list of textures generated by the multi render target.
  45933. */
  45934. readonly textures: Texture[];
  45935. /**
  45936. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  45937. */
  45938. readonly depthTexture: Texture;
  45939. /**
  45940. * Set the wrapping mode on U of all the textures we are rendering to.
  45941. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45942. */
  45943. wrapU: number;
  45944. /**
  45945. * Set the wrapping mode on V of all the textures we are rendering to.
  45946. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  45947. */
  45948. wrapV: number;
  45949. /**
  45950. * Instantiate a new multi render target texture.
  45951. * A multi render target, like a render target provides the ability to render to a texture.
  45952. * Unlike the render target, it can render to several draw buffers in one draw.
  45953. * This is specially interesting in deferred rendering or for any effects requiring more than
  45954. * just one color from a single pass.
  45955. * @param name Define the name of the texture
  45956. * @param size Define the size of the buffers to render to
  45957. * @param count Define the number of target we are rendering into
  45958. * @param scene Define the scene the texture belongs to
  45959. * @param options Define the options used to create the multi render target
  45960. */
  45961. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  45962. /** @hidden */
  45963. _rebuild(): void;
  45964. private _createInternalTextures;
  45965. private _createTextures;
  45966. /**
  45967. * Define the number of samples used if MSAA is enabled.
  45968. */
  45969. samples: number;
  45970. /**
  45971. * Resize all the textures in the multi render target.
  45972. * Be carrefull as it will recreate all the data in the new texture.
  45973. * @param size Define the new size
  45974. */
  45975. resize(size: any): void;
  45976. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  45977. /**
  45978. * Dispose the render targets and their associated resources
  45979. */
  45980. dispose(): void;
  45981. /**
  45982. * Release all the underlying texture used as draw buffers.
  45983. */
  45984. releaseInternalTextures(): void;
  45985. }
  45986. }
  45987. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  45988. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45989. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  45990. import { Nullable } from "babylonjs/types";
  45991. module "babylonjs/Engines/thinEngine" {
  45992. interface ThinEngine {
  45993. /**
  45994. * Unbind a list of render target textures from the webGL context
  45995. * This is used only when drawBuffer extension or webGL2 are active
  45996. * @param textures defines the render target textures to unbind
  45997. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45998. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45999. */
  46000. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46001. /**
  46002. * Create a multi render target texture
  46003. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46004. * @param size defines the size of the texture
  46005. * @param options defines the creation options
  46006. * @returns the cube texture as an InternalTexture
  46007. */
  46008. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46009. /**
  46010. * Update the sample count for a given multiple render target texture
  46011. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46012. * @param textures defines the textures to update
  46013. * @param samples defines the sample count to set
  46014. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46015. */
  46016. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46017. }
  46018. }
  46019. }
  46020. declare module "babylonjs/Engines/Extensions/index" {
  46021. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46022. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46023. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46024. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46025. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46026. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46027. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46028. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46029. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46030. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46031. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46032. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46033. }
  46034. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  46035. import { Nullable } from "babylonjs/types";
  46036. /**
  46037. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  46038. */
  46039. export interface CubeMapInfo {
  46040. /**
  46041. * The pixel array for the front face.
  46042. * This is stored in format, left to right, up to down format.
  46043. */
  46044. front: Nullable<ArrayBufferView>;
  46045. /**
  46046. * The pixel array for the back face.
  46047. * This is stored in format, left to right, up to down format.
  46048. */
  46049. back: Nullable<ArrayBufferView>;
  46050. /**
  46051. * The pixel array for the left face.
  46052. * This is stored in format, left to right, up to down format.
  46053. */
  46054. left: Nullable<ArrayBufferView>;
  46055. /**
  46056. * The pixel array for the right face.
  46057. * This is stored in format, left to right, up to down format.
  46058. */
  46059. right: Nullable<ArrayBufferView>;
  46060. /**
  46061. * The pixel array for the up face.
  46062. * This is stored in format, left to right, up to down format.
  46063. */
  46064. up: Nullable<ArrayBufferView>;
  46065. /**
  46066. * The pixel array for the down face.
  46067. * This is stored in format, left to right, up to down format.
  46068. */
  46069. down: Nullable<ArrayBufferView>;
  46070. /**
  46071. * The size of the cubemap stored.
  46072. *
  46073. * Each faces will be size * size pixels.
  46074. */
  46075. size: number;
  46076. /**
  46077. * The format of the texture.
  46078. *
  46079. * RGBA, RGB.
  46080. */
  46081. format: number;
  46082. /**
  46083. * The type of the texture data.
  46084. *
  46085. * UNSIGNED_INT, FLOAT.
  46086. */
  46087. type: number;
  46088. /**
  46089. * Specifies whether the texture is in gamma space.
  46090. */
  46091. gammaSpace: boolean;
  46092. }
  46093. /**
  46094. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  46095. */
  46096. export class PanoramaToCubeMapTools {
  46097. private static FACE_FRONT;
  46098. private static FACE_BACK;
  46099. private static FACE_RIGHT;
  46100. private static FACE_LEFT;
  46101. private static FACE_DOWN;
  46102. private static FACE_UP;
  46103. /**
  46104. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  46105. *
  46106. * @param float32Array The source data.
  46107. * @param inputWidth The width of the input panorama.
  46108. * @param inputHeight The height of the input panorama.
  46109. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  46110. * @return The cubemap data
  46111. */
  46112. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  46113. private static CreateCubemapTexture;
  46114. private static CalcProjectionSpherical;
  46115. }
  46116. }
  46117. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  46118. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46119. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46120. import { Nullable } from "babylonjs/types";
  46121. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  46122. /**
  46123. * Helper class dealing with the extraction of spherical polynomial dataArray
  46124. * from a cube map.
  46125. */
  46126. export class CubeMapToSphericalPolynomialTools {
  46127. private static FileFaces;
  46128. /**
  46129. * Converts a texture to the according Spherical Polynomial data.
  46130. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46131. *
  46132. * @param texture The texture to extract the information from.
  46133. * @return The Spherical Polynomial data.
  46134. */
  46135. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  46136. /**
  46137. * Converts a cubemap to the according Spherical Polynomial data.
  46138. * This extracts the first 3 orders only as they are the only one used in the lighting.
  46139. *
  46140. * @param cubeInfo The Cube map to extract the information from.
  46141. * @return The Spherical Polynomial data.
  46142. */
  46143. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  46144. }
  46145. }
  46146. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  46147. import { Nullable } from "babylonjs/types";
  46148. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46149. module "babylonjs/Materials/Textures/baseTexture" {
  46150. interface BaseTexture {
  46151. /**
  46152. * Get the polynomial representation of the texture data.
  46153. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  46154. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  46155. */
  46156. sphericalPolynomial: Nullable<SphericalPolynomial>;
  46157. }
  46158. }
  46159. }
  46160. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46161. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46162. /** @hidden */
  46163. export var rgbdEncodePixelShader: {
  46164. name: string;
  46165. shader: string;
  46166. };
  46167. }
  46168. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46169. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46170. /** @hidden */
  46171. export var rgbdDecodePixelShader: {
  46172. name: string;
  46173. shader: string;
  46174. };
  46175. }
  46176. declare module "babylonjs/Misc/environmentTextureTools" {
  46177. import { Nullable } from "babylonjs/types";
  46178. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46179. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46180. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46181. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  46182. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  46183. import "babylonjs/Shaders/rgbdEncode.fragment";
  46184. import "babylonjs/Shaders/rgbdDecode.fragment";
  46185. /**
  46186. * Raw texture data and descriptor sufficient for WebGL texture upload
  46187. */
  46188. export interface EnvironmentTextureInfo {
  46189. /**
  46190. * Version of the environment map
  46191. */
  46192. version: number;
  46193. /**
  46194. * Width of image
  46195. */
  46196. width: number;
  46197. /**
  46198. * Irradiance information stored in the file.
  46199. */
  46200. irradiance: any;
  46201. /**
  46202. * Specular information stored in the file.
  46203. */
  46204. specular: any;
  46205. }
  46206. /**
  46207. * Defines One Image in the file. It requires only the position in the file
  46208. * as well as the length.
  46209. */
  46210. interface BufferImageData {
  46211. /**
  46212. * Length of the image data.
  46213. */
  46214. length: number;
  46215. /**
  46216. * Position of the data from the null terminator delimiting the end of the JSON.
  46217. */
  46218. position: number;
  46219. }
  46220. /**
  46221. * Defines the specular data enclosed in the file.
  46222. * This corresponds to the version 1 of the data.
  46223. */
  46224. export interface EnvironmentTextureSpecularInfoV1 {
  46225. /**
  46226. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46227. */
  46228. specularDataPosition?: number;
  46229. /**
  46230. * This contains all the images data needed to reconstruct the cubemap.
  46231. */
  46232. mipmaps: Array<BufferImageData>;
  46233. /**
  46234. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46235. */
  46236. lodGenerationScale: number;
  46237. }
  46238. /**
  46239. * Sets of helpers addressing the serialization and deserialization of environment texture
  46240. * stored in a BabylonJS env file.
  46241. * Those files are usually stored as .env files.
  46242. */
  46243. export class EnvironmentTextureTools {
  46244. /**
  46245. * Magic number identifying the env file.
  46246. */
  46247. private static _MagicBytes;
  46248. /**
  46249. * Gets the environment info from an env file.
  46250. * @param data The array buffer containing the .env bytes.
  46251. * @returns the environment file info (the json header) if successfully parsed.
  46252. */
  46253. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46254. /**
  46255. * Creates an environment texture from a loaded cube texture.
  46256. * @param texture defines the cube texture to convert in env file
  46257. * @return a promise containing the environment data if succesfull.
  46258. */
  46259. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46260. /**
  46261. * Creates a JSON representation of the spherical data.
  46262. * @param texture defines the texture containing the polynomials
  46263. * @return the JSON representation of the spherical info
  46264. */
  46265. private static _CreateEnvTextureIrradiance;
  46266. /**
  46267. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46268. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46269. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46270. * @return the views described by info providing access to the underlying buffer
  46271. */
  46272. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46273. /**
  46274. * Uploads the texture info contained in the env file to the GPU.
  46275. * @param texture defines the internal texture to upload to
  46276. * @param arrayBuffer defines the buffer cotaining the data to load
  46277. * @param info defines the texture info retrieved through the GetEnvInfo method
  46278. * @returns a promise
  46279. */
  46280. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46281. /**
  46282. * Uploads the levels of image data to the GPU.
  46283. * @param texture defines the internal texture to upload to
  46284. * @param imageData defines the array buffer views of image data [mipmap][face]
  46285. * @returns a promise
  46286. */
  46287. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46288. /**
  46289. * Uploads spherical polynomials information to the texture.
  46290. * @param texture defines the texture we are trying to upload the information to
  46291. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46292. */
  46293. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46294. /** @hidden */
  46295. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46296. }
  46297. }
  46298. declare module "babylonjs/Maths/math.vertexFormat" {
  46299. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46300. /**
  46301. * Contains position and normal vectors for a vertex
  46302. */
  46303. export class PositionNormalVertex {
  46304. /** the position of the vertex (defaut: 0,0,0) */
  46305. position: Vector3;
  46306. /** the normal of the vertex (defaut: 0,1,0) */
  46307. normal: Vector3;
  46308. /**
  46309. * Creates a PositionNormalVertex
  46310. * @param position the position of the vertex (defaut: 0,0,0)
  46311. * @param normal the normal of the vertex (defaut: 0,1,0)
  46312. */
  46313. constructor(
  46314. /** the position of the vertex (defaut: 0,0,0) */
  46315. position?: Vector3,
  46316. /** the normal of the vertex (defaut: 0,1,0) */
  46317. normal?: Vector3);
  46318. /**
  46319. * Clones the PositionNormalVertex
  46320. * @returns the cloned PositionNormalVertex
  46321. */
  46322. clone(): PositionNormalVertex;
  46323. }
  46324. /**
  46325. * Contains position, normal and uv vectors for a vertex
  46326. */
  46327. export class PositionNormalTextureVertex {
  46328. /** the position of the vertex (defaut: 0,0,0) */
  46329. position: Vector3;
  46330. /** the normal of the vertex (defaut: 0,1,0) */
  46331. normal: Vector3;
  46332. /** the uv of the vertex (default: 0,0) */
  46333. uv: Vector2;
  46334. /**
  46335. * Creates a PositionNormalTextureVertex
  46336. * @param position the position of the vertex (defaut: 0,0,0)
  46337. * @param normal the normal of the vertex (defaut: 0,1,0)
  46338. * @param uv the uv of the vertex (default: 0,0)
  46339. */
  46340. constructor(
  46341. /** the position of the vertex (defaut: 0,0,0) */
  46342. position?: Vector3,
  46343. /** the normal of the vertex (defaut: 0,1,0) */
  46344. normal?: Vector3,
  46345. /** the uv of the vertex (default: 0,0) */
  46346. uv?: Vector2);
  46347. /**
  46348. * Clones the PositionNormalTextureVertex
  46349. * @returns the cloned PositionNormalTextureVertex
  46350. */
  46351. clone(): PositionNormalTextureVertex;
  46352. }
  46353. }
  46354. declare module "babylonjs/Maths/math" {
  46355. export * from "babylonjs/Maths/math.axis";
  46356. export * from "babylonjs/Maths/math.color";
  46357. export * from "babylonjs/Maths/math.constants";
  46358. export * from "babylonjs/Maths/math.frustum";
  46359. export * from "babylonjs/Maths/math.path";
  46360. export * from "babylonjs/Maths/math.plane";
  46361. export * from "babylonjs/Maths/math.size";
  46362. export * from "babylonjs/Maths/math.vector";
  46363. export * from "babylonjs/Maths/math.vertexFormat";
  46364. export * from "babylonjs/Maths/math.viewport";
  46365. }
  46366. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46367. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46368. /** @hidden */
  46369. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46370. private _genericAttributeLocation;
  46371. private _varyingLocationCount;
  46372. private _varyingLocationMap;
  46373. private _replacements;
  46374. private _textureCount;
  46375. private _uniforms;
  46376. lineProcessor(line: string): string;
  46377. attributeProcessor(attribute: string): string;
  46378. varyingProcessor(varying: string, isFragment: boolean): string;
  46379. uniformProcessor(uniform: string): string;
  46380. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46381. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46382. }
  46383. }
  46384. declare module "babylonjs/Engines/nativeEngine" {
  46385. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46386. import { Engine } from "babylonjs/Engines/engine";
  46387. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46388. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46390. import { Effect } from "babylonjs/Materials/effect";
  46391. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46392. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46393. import { Scene } from "babylonjs/scene";
  46394. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46395. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46396. /**
  46397. * Container for accessors for natively-stored mesh data buffers.
  46398. */
  46399. class NativeDataBuffer extends DataBuffer {
  46400. /**
  46401. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46402. */
  46403. nativeIndexBuffer?: any;
  46404. /**
  46405. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46406. */
  46407. nativeVertexBuffer?: any;
  46408. }
  46409. /** @hidden */
  46410. export class NativeEngine extends Engine {
  46411. private readonly _native;
  46412. getHardwareScalingLevel(): number;
  46413. constructor();
  46414. /**
  46415. * Can be used to override the current requestAnimationFrame requester.
  46416. * @hidden
  46417. */
  46418. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46419. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46420. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46421. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46422. recordVertexArrayObject(vertexBuffers: {
  46423. [key: string]: VertexBuffer;
  46424. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46425. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46426. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46427. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46428. /**
  46429. * Draw a list of indexed primitives
  46430. * @param fillMode defines the primitive to use
  46431. * @param indexStart defines the starting index
  46432. * @param indexCount defines the number of index to draw
  46433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46434. */
  46435. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46436. /**
  46437. * Draw a list of unindexed primitives
  46438. * @param fillMode defines the primitive to use
  46439. * @param verticesStart defines the index of first vertex to draw
  46440. * @param verticesCount defines the count of vertices to draw
  46441. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46442. */
  46443. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46444. createPipelineContext(): IPipelineContext;
  46445. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46446. /** @hidden */
  46447. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46448. /** @hidden */
  46449. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46450. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46451. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46452. protected _setProgram(program: WebGLProgram): void;
  46453. _releaseEffect(effect: Effect): void;
  46454. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46455. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46456. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46457. bindSamplers(effect: Effect): void;
  46458. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46459. getRenderWidth(useScreen?: boolean): number;
  46460. getRenderHeight(useScreen?: boolean): number;
  46461. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46462. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46463. /**
  46464. * Set the z offset to apply to current rendering
  46465. * @param value defines the offset to apply
  46466. */
  46467. setZOffset(value: number): void;
  46468. /**
  46469. * Gets the current value of the zOffset
  46470. * @returns the current zOffset state
  46471. */
  46472. getZOffset(): number;
  46473. /**
  46474. * Enable or disable depth buffering
  46475. * @param enable defines the state to set
  46476. */
  46477. setDepthBuffer(enable: boolean): void;
  46478. /**
  46479. * Gets a boolean indicating if depth writing is enabled
  46480. * @returns the current depth writing state
  46481. */
  46482. getDepthWrite(): boolean;
  46483. /**
  46484. * Enable or disable depth writing
  46485. * @param enable defines the state to set
  46486. */
  46487. setDepthWrite(enable: boolean): void;
  46488. /**
  46489. * Enable or disable color writing
  46490. * @param enable defines the state to set
  46491. */
  46492. setColorWrite(enable: boolean): void;
  46493. /**
  46494. * Gets a boolean indicating if color writing is enabled
  46495. * @returns the current color writing state
  46496. */
  46497. getColorWrite(): boolean;
  46498. /**
  46499. * Sets alpha constants used by some alpha blending modes
  46500. * @param r defines the red component
  46501. * @param g defines the green component
  46502. * @param b defines the blue component
  46503. * @param a defines the alpha component
  46504. */
  46505. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46506. /**
  46507. * Sets the current alpha mode
  46508. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46509. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46510. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46511. */
  46512. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46513. /**
  46514. * Gets the current alpha mode
  46515. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46516. * @returns the current alpha mode
  46517. */
  46518. getAlphaMode(): number;
  46519. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46520. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46521. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46522. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46523. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46524. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46525. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46526. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46527. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46528. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46529. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46530. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46531. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46532. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46533. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46534. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46535. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46536. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46537. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46538. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46539. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46540. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46541. wipeCaches(bruteForce?: boolean): void;
  46542. _createTexture(): WebGLTexture;
  46543. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46544. /**
  46545. * Usually called from BABYLON.Texture.ts.
  46546. * Passed information to create a WebGLTexture
  46547. * @param urlArg defines a value which contains one of the following:
  46548. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46549. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46550. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46551. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46552. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46553. * @param scene needed for loading to the correct scene
  46554. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46555. * @param onLoad optional callback to be called upon successful completion
  46556. * @param onError optional callback to be called upon failure
  46557. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46558. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46559. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46560. * @param forcedExtension defines the extension to use to pick the right loader
  46561. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46562. */
  46563. 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;
  46564. /**
  46565. * Creates a cube texture
  46566. * @param rootUrl defines the url where the files to load is located
  46567. * @param scene defines the current scene
  46568. * @param files defines the list of files to load (1 per face)
  46569. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46570. * @param onLoad defines an optional callback raised when the texture is loaded
  46571. * @param onError defines an optional callback raised if there is an issue to load the texture
  46572. * @param format defines the format of the data
  46573. * @param forcedExtension defines the extension to use to pick the right loader
  46574. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46575. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46576. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46577. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46578. * @returns the cube texture as an InternalTexture
  46579. */
  46580. 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;
  46581. private _getSamplingFilter;
  46582. private static _GetNativeTextureFormat;
  46583. createRenderTargetTexture(size: number | {
  46584. width: number;
  46585. height: number;
  46586. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46587. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46588. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46589. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46590. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46591. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46592. /**
  46593. * Updates a dynamic vertex buffer.
  46594. * @param vertexBuffer the vertex buffer to update
  46595. * @param data the data used to update the vertex buffer
  46596. * @param byteOffset the byte offset of the data (optional)
  46597. * @param byteLength the byte length of the data (optional)
  46598. */
  46599. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46600. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46601. private _updateAnisotropicLevel;
  46602. private _getAddressMode;
  46603. /** @hidden */
  46604. _bindTexture(channel: number, texture: InternalTexture): void;
  46605. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46606. releaseEffects(): void;
  46607. /** @hidden */
  46608. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46609. /** @hidden */
  46610. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46611. /** @hidden */
  46612. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46613. /** @hidden */
  46614. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46615. }
  46616. }
  46617. declare module "babylonjs/Engines/index" {
  46618. export * from "babylonjs/Engines/constants";
  46619. export * from "babylonjs/Engines/engineCapabilities";
  46620. export * from "babylonjs/Engines/instancingAttributeInfo";
  46621. export * from "babylonjs/Engines/thinEngine";
  46622. export * from "babylonjs/Engines/engine";
  46623. export * from "babylonjs/Engines/engineStore";
  46624. export * from "babylonjs/Engines/nullEngine";
  46625. export * from "babylonjs/Engines/Extensions/index";
  46626. export * from "babylonjs/Engines/IPipelineContext";
  46627. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46628. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46629. export * from "babylonjs/Engines/nativeEngine";
  46630. }
  46631. declare module "babylonjs/Events/clipboardEvents" {
  46632. /**
  46633. * Gather the list of clipboard event types as constants.
  46634. */
  46635. export class ClipboardEventTypes {
  46636. /**
  46637. * The clipboard event is fired when a copy command is active (pressed).
  46638. */
  46639. static readonly COPY: number;
  46640. /**
  46641. * The clipboard event is fired when a cut command is active (pressed).
  46642. */
  46643. static readonly CUT: number;
  46644. /**
  46645. * The clipboard event is fired when a paste command is active (pressed).
  46646. */
  46647. static readonly PASTE: number;
  46648. }
  46649. /**
  46650. * This class is used to store clipboard related info for the onClipboardObservable event.
  46651. */
  46652. export class ClipboardInfo {
  46653. /**
  46654. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46655. */
  46656. type: number;
  46657. /**
  46658. * Defines the related dom event
  46659. */
  46660. event: ClipboardEvent;
  46661. /**
  46662. *Creates an instance of ClipboardInfo.
  46663. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46664. * @param event Defines the related dom event
  46665. */
  46666. constructor(
  46667. /**
  46668. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46669. */
  46670. type: number,
  46671. /**
  46672. * Defines the related dom event
  46673. */
  46674. event: ClipboardEvent);
  46675. /**
  46676. * Get the clipboard event's type from the keycode.
  46677. * @param keyCode Defines the keyCode for the current keyboard event.
  46678. * @return {number}
  46679. */
  46680. static GetTypeFromCharacter(keyCode: number): number;
  46681. }
  46682. }
  46683. declare module "babylonjs/Events/index" {
  46684. export * from "babylonjs/Events/keyboardEvents";
  46685. export * from "babylonjs/Events/pointerEvents";
  46686. export * from "babylonjs/Events/clipboardEvents";
  46687. }
  46688. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46689. import { Scene } from "babylonjs/scene";
  46690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46691. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46692. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46693. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46694. /**
  46695. * Google Daydream controller
  46696. */
  46697. export class DaydreamController extends WebVRController {
  46698. /**
  46699. * Base Url for the controller model.
  46700. */
  46701. static MODEL_BASE_URL: string;
  46702. /**
  46703. * File name for the controller model.
  46704. */
  46705. static MODEL_FILENAME: string;
  46706. /**
  46707. * Gamepad Id prefix used to identify Daydream Controller.
  46708. */
  46709. static readonly GAMEPAD_ID_PREFIX: string;
  46710. /**
  46711. * Creates a new DaydreamController from a gamepad
  46712. * @param vrGamepad the gamepad that the controller should be created from
  46713. */
  46714. constructor(vrGamepad: any);
  46715. /**
  46716. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46717. * @param scene scene in which to add meshes
  46718. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46719. */
  46720. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46721. /**
  46722. * Called once for each button that changed state since the last frame
  46723. * @param buttonIdx Which button index changed
  46724. * @param state New state of the button
  46725. * @param changes Which properties on the state changed since last frame
  46726. */
  46727. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46728. }
  46729. }
  46730. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46731. import { Scene } from "babylonjs/scene";
  46732. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46733. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46734. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46735. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46736. /**
  46737. * Gear VR Controller
  46738. */
  46739. export class GearVRController extends WebVRController {
  46740. /**
  46741. * Base Url for the controller model.
  46742. */
  46743. static MODEL_BASE_URL: string;
  46744. /**
  46745. * File name for the controller model.
  46746. */
  46747. static MODEL_FILENAME: string;
  46748. /**
  46749. * Gamepad Id prefix used to identify this controller.
  46750. */
  46751. static readonly GAMEPAD_ID_PREFIX: string;
  46752. private readonly _buttonIndexToObservableNameMap;
  46753. /**
  46754. * Creates a new GearVRController from a gamepad
  46755. * @param vrGamepad the gamepad that the controller should be created from
  46756. */
  46757. constructor(vrGamepad: any);
  46758. /**
  46759. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46760. * @param scene scene in which to add meshes
  46761. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46762. */
  46763. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46764. /**
  46765. * Called once for each button that changed state since the last frame
  46766. * @param buttonIdx Which button index changed
  46767. * @param state New state of the button
  46768. * @param changes Which properties on the state changed since last frame
  46769. */
  46770. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46771. }
  46772. }
  46773. declare module "babylonjs/Gamepads/Controllers/index" {
  46774. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46775. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46776. export * from "babylonjs/Gamepads/Controllers/genericController";
  46777. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46778. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46779. export * from "babylonjs/Gamepads/Controllers/viveController";
  46780. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46781. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46782. }
  46783. declare module "babylonjs/Gamepads/index" {
  46784. export * from "babylonjs/Gamepads/Controllers/index";
  46785. export * from "babylonjs/Gamepads/gamepad";
  46786. export * from "babylonjs/Gamepads/gamepadManager";
  46787. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46788. export * from "babylonjs/Gamepads/xboxGamepad";
  46789. export * from "babylonjs/Gamepads/dualShockGamepad";
  46790. }
  46791. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46792. import { Scene } from "babylonjs/scene";
  46793. import { Vector4 } from "babylonjs/Maths/math.vector";
  46794. import { Color4 } from "babylonjs/Maths/math.color";
  46795. import { Mesh } from "babylonjs/Meshes/mesh";
  46796. import { Nullable } from "babylonjs/types";
  46797. /**
  46798. * Class containing static functions to help procedurally build meshes
  46799. */
  46800. export class PolyhedronBuilder {
  46801. /**
  46802. * Creates a polyhedron mesh
  46803. * * 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
  46804. * * The parameter `size` (positive float, default 1) sets the polygon size
  46805. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46806. * * 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`
  46807. * * 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
  46808. * * 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)`)
  46809. * * 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
  46810. * * 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
  46811. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46812. * * 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
  46813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46814. * @param name defines the name of the mesh
  46815. * @param options defines the options used to create the mesh
  46816. * @param scene defines the hosting scene
  46817. * @returns the polyhedron mesh
  46818. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46819. */
  46820. static CreatePolyhedron(name: string, options: {
  46821. type?: number;
  46822. size?: number;
  46823. sizeX?: number;
  46824. sizeY?: number;
  46825. sizeZ?: number;
  46826. custom?: any;
  46827. faceUV?: Vector4[];
  46828. faceColors?: Color4[];
  46829. flat?: boolean;
  46830. updatable?: boolean;
  46831. sideOrientation?: number;
  46832. frontUVs?: Vector4;
  46833. backUVs?: Vector4;
  46834. }, scene?: Nullable<Scene>): Mesh;
  46835. }
  46836. }
  46837. declare module "babylonjs/Gizmos/scaleGizmo" {
  46838. import { Observable } from "babylonjs/Misc/observable";
  46839. import { Nullable } from "babylonjs/types";
  46840. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46841. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46842. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46843. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46844. /**
  46845. * Gizmo that enables scaling a mesh along 3 axis
  46846. */
  46847. export class ScaleGizmo extends Gizmo {
  46848. /**
  46849. * Internal gizmo used for interactions on the x axis
  46850. */
  46851. xGizmo: AxisScaleGizmo;
  46852. /**
  46853. * Internal gizmo used for interactions on the y axis
  46854. */
  46855. yGizmo: AxisScaleGizmo;
  46856. /**
  46857. * Internal gizmo used for interactions on the z axis
  46858. */
  46859. zGizmo: AxisScaleGizmo;
  46860. /**
  46861. * Internal gizmo used to scale all axis equally
  46862. */
  46863. uniformScaleGizmo: AxisScaleGizmo;
  46864. private _meshAttached;
  46865. private _updateGizmoRotationToMatchAttachedMesh;
  46866. private _snapDistance;
  46867. private _scaleRatio;
  46868. private _uniformScalingMesh;
  46869. private _octahedron;
  46870. /** Fires an event when any of it's sub gizmos are dragged */
  46871. onDragStartObservable: Observable<unknown>;
  46872. /** Fires an event when any of it's sub gizmos are released from dragging */
  46873. onDragEndObservable: Observable<unknown>;
  46874. attachedMesh: Nullable<AbstractMesh>;
  46875. /**
  46876. * Creates a ScaleGizmo
  46877. * @param gizmoLayer The utility layer the gizmo will be added to
  46878. */
  46879. constructor(gizmoLayer?: UtilityLayerRenderer);
  46880. updateGizmoRotationToMatchAttachedMesh: boolean;
  46881. /**
  46882. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46883. */
  46884. snapDistance: number;
  46885. /**
  46886. * Ratio for the scale of the gizmo (Default: 1)
  46887. */
  46888. scaleRatio: number;
  46889. /**
  46890. * Disposes of the gizmo
  46891. */
  46892. dispose(): void;
  46893. }
  46894. }
  46895. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46896. import { Observable } from "babylonjs/Misc/observable";
  46897. import { Nullable } from "babylonjs/types";
  46898. import { Vector3 } from "babylonjs/Maths/math.vector";
  46899. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46900. import { Mesh } from "babylonjs/Meshes/mesh";
  46901. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46902. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46903. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46904. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46905. import { Color3 } from "babylonjs/Maths/math.color";
  46906. /**
  46907. * Single axis scale gizmo
  46908. */
  46909. export class AxisScaleGizmo extends Gizmo {
  46910. /**
  46911. * Drag behavior responsible for the gizmos dragging interactions
  46912. */
  46913. dragBehavior: PointerDragBehavior;
  46914. private _pointerObserver;
  46915. /**
  46916. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46917. */
  46918. snapDistance: number;
  46919. /**
  46920. * Event that fires each time the gizmo snaps to a new location.
  46921. * * snapDistance is the the change in distance
  46922. */
  46923. onSnapObservable: Observable<{
  46924. snapDistance: number;
  46925. }>;
  46926. /**
  46927. * If the scaling operation should be done on all axis (default: false)
  46928. */
  46929. uniformScaling: boolean;
  46930. private _isEnabled;
  46931. private _parent;
  46932. private _arrow;
  46933. private _coloredMaterial;
  46934. private _hoverMaterial;
  46935. /**
  46936. * Creates an AxisScaleGizmo
  46937. * @param gizmoLayer The utility layer the gizmo will be added to
  46938. * @param dragAxis The axis which the gizmo will be able to scale on
  46939. * @param color The color of the gizmo
  46940. */
  46941. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46942. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46943. /**
  46944. * If the gizmo is enabled
  46945. */
  46946. isEnabled: boolean;
  46947. /**
  46948. * Disposes of the gizmo
  46949. */
  46950. dispose(): void;
  46951. /**
  46952. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46953. * @param mesh The mesh to replace the default mesh of the gizmo
  46954. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46955. */
  46956. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46957. }
  46958. }
  46959. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46960. import { Observable } from "babylonjs/Misc/observable";
  46961. import { Nullable } from "babylonjs/types";
  46962. import { Vector3 } from "babylonjs/Maths/math.vector";
  46963. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46964. import { Mesh } from "babylonjs/Meshes/mesh";
  46965. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46966. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46967. import { Color3 } from "babylonjs/Maths/math.color";
  46968. import "babylonjs/Meshes/Builders/boxBuilder";
  46969. /**
  46970. * Bounding box gizmo
  46971. */
  46972. export class BoundingBoxGizmo extends Gizmo {
  46973. private _lineBoundingBox;
  46974. private _rotateSpheresParent;
  46975. private _scaleBoxesParent;
  46976. private _boundingDimensions;
  46977. private _renderObserver;
  46978. private _pointerObserver;
  46979. private _scaleDragSpeed;
  46980. private _tmpQuaternion;
  46981. private _tmpVector;
  46982. private _tmpRotationMatrix;
  46983. /**
  46984. * 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)
  46985. */
  46986. ignoreChildren: boolean;
  46987. /**
  46988. * 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)
  46989. */
  46990. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46991. /**
  46992. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46993. */
  46994. rotationSphereSize: number;
  46995. /**
  46996. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46997. */
  46998. scaleBoxSize: number;
  46999. /**
  47000. * 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)
  47001. */
  47002. fixedDragMeshScreenSize: boolean;
  47003. /**
  47004. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  47005. */
  47006. fixedDragMeshScreenSizeDistanceFactor: number;
  47007. /**
  47008. * Fired when a rotation sphere or scale box is dragged
  47009. */
  47010. onDragStartObservable: Observable<{}>;
  47011. /**
  47012. * Fired when a scale box is dragged
  47013. */
  47014. onScaleBoxDragObservable: Observable<{}>;
  47015. /**
  47016. * Fired when a scale box drag is ended
  47017. */
  47018. onScaleBoxDragEndObservable: Observable<{}>;
  47019. /**
  47020. * Fired when a rotation sphere is dragged
  47021. */
  47022. onRotationSphereDragObservable: Observable<{}>;
  47023. /**
  47024. * Fired when a rotation sphere drag is ended
  47025. */
  47026. onRotationSphereDragEndObservable: Observable<{}>;
  47027. /**
  47028. * 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)
  47029. */
  47030. scalePivot: Nullable<Vector3>;
  47031. /**
  47032. * Mesh used as a pivot to rotate the attached mesh
  47033. */
  47034. private _anchorMesh;
  47035. private _existingMeshScale;
  47036. private _dragMesh;
  47037. private pointerDragBehavior;
  47038. private coloredMaterial;
  47039. private hoverColoredMaterial;
  47040. /**
  47041. * Sets the color of the bounding box gizmo
  47042. * @param color the color to set
  47043. */
  47044. setColor(color: Color3): void;
  47045. /**
  47046. * Creates an BoundingBoxGizmo
  47047. * @param gizmoLayer The utility layer the gizmo will be added to
  47048. * @param color The color of the gizmo
  47049. */
  47050. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47051. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47052. private _selectNode;
  47053. /**
  47054. * Updates the bounding box information for the Gizmo
  47055. */
  47056. updateBoundingBox(): void;
  47057. private _updateRotationSpheres;
  47058. private _updateScaleBoxes;
  47059. /**
  47060. * Enables rotation on the specified axis and disables rotation on the others
  47061. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47062. */
  47063. setEnabledRotationAxis(axis: string): void;
  47064. /**
  47065. * Enables/disables scaling
  47066. * @param enable if scaling should be enabled
  47067. */
  47068. setEnabledScaling(enable: boolean): void;
  47069. private _updateDummy;
  47070. /**
  47071. * Enables a pointer drag behavior on the bounding box of the gizmo
  47072. */
  47073. enableDragBehavior(): void;
  47074. /**
  47075. * Disposes of the gizmo
  47076. */
  47077. dispose(): void;
  47078. /**
  47079. * 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)
  47080. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47081. * @returns the bounding box mesh with the passed in mesh as a child
  47082. */
  47083. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47084. /**
  47085. * CustomMeshes are not supported by this gizmo
  47086. * @param mesh The mesh to replace the default mesh of the gizmo
  47087. */
  47088. setCustomMesh(mesh: Mesh): void;
  47089. }
  47090. }
  47091. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47092. import { Observable } from "babylonjs/Misc/observable";
  47093. import { Nullable } from "babylonjs/types";
  47094. import { Vector3 } from "babylonjs/Maths/math.vector";
  47095. import { Color3 } from "babylonjs/Maths/math.color";
  47096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47097. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47098. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47099. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47100. import "babylonjs/Meshes/Builders/linesBuilder";
  47101. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47102. /**
  47103. * Single plane rotation gizmo
  47104. */
  47105. export class PlaneRotationGizmo extends Gizmo {
  47106. /**
  47107. * Drag behavior responsible for the gizmos dragging interactions
  47108. */
  47109. dragBehavior: PointerDragBehavior;
  47110. private _pointerObserver;
  47111. /**
  47112. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47113. */
  47114. snapDistance: number;
  47115. /**
  47116. * Event that fires each time the gizmo snaps to a new location.
  47117. * * snapDistance is the the change in distance
  47118. */
  47119. onSnapObservable: Observable<{
  47120. snapDistance: number;
  47121. }>;
  47122. private _isEnabled;
  47123. private _parent;
  47124. /**
  47125. * Creates a PlaneRotationGizmo
  47126. * @param gizmoLayer The utility layer the gizmo will be added to
  47127. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47128. * @param color The color of the gizmo
  47129. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47130. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47131. */
  47132. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47133. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47134. /**
  47135. * If the gizmo is enabled
  47136. */
  47137. isEnabled: boolean;
  47138. /**
  47139. * Disposes of the gizmo
  47140. */
  47141. dispose(): void;
  47142. }
  47143. }
  47144. declare module "babylonjs/Gizmos/rotationGizmo" {
  47145. import { Observable } from "babylonjs/Misc/observable";
  47146. import { Nullable } from "babylonjs/types";
  47147. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47148. import { Mesh } from "babylonjs/Meshes/mesh";
  47149. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47150. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47151. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47152. /**
  47153. * Gizmo that enables rotating a mesh along 3 axis
  47154. */
  47155. export class RotationGizmo extends Gizmo {
  47156. /**
  47157. * Internal gizmo used for interactions on the x axis
  47158. */
  47159. xGizmo: PlaneRotationGizmo;
  47160. /**
  47161. * Internal gizmo used for interactions on the y axis
  47162. */
  47163. yGizmo: PlaneRotationGizmo;
  47164. /**
  47165. * Internal gizmo used for interactions on the z axis
  47166. */
  47167. zGizmo: PlaneRotationGizmo;
  47168. /** Fires an event when any of it's sub gizmos are dragged */
  47169. onDragStartObservable: Observable<unknown>;
  47170. /** Fires an event when any of it's sub gizmos are released from dragging */
  47171. onDragEndObservable: Observable<unknown>;
  47172. private _meshAttached;
  47173. attachedMesh: Nullable<AbstractMesh>;
  47174. /**
  47175. * Creates a RotationGizmo
  47176. * @param gizmoLayer The utility layer the gizmo will be added to
  47177. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47178. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47179. */
  47180. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47181. updateGizmoRotationToMatchAttachedMesh: boolean;
  47182. /**
  47183. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47184. */
  47185. snapDistance: number;
  47186. /**
  47187. * Ratio for the scale of the gizmo (Default: 1)
  47188. */
  47189. scaleRatio: number;
  47190. /**
  47191. * Disposes of the gizmo
  47192. */
  47193. dispose(): void;
  47194. /**
  47195. * CustomMeshes are not supported by this gizmo
  47196. * @param mesh The mesh to replace the default mesh of the gizmo
  47197. */
  47198. setCustomMesh(mesh: Mesh): void;
  47199. }
  47200. }
  47201. declare module "babylonjs/Gizmos/gizmoManager" {
  47202. import { Observable } from "babylonjs/Misc/observable";
  47203. import { Nullable } from "babylonjs/types";
  47204. import { Scene, IDisposable } from "babylonjs/scene";
  47205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47206. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47207. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47208. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47209. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47210. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47211. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47212. /**
  47213. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47214. */
  47215. export class GizmoManager implements IDisposable {
  47216. private scene;
  47217. /**
  47218. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47219. */
  47220. gizmos: {
  47221. positionGizmo: Nullable<PositionGizmo>;
  47222. rotationGizmo: Nullable<RotationGizmo>;
  47223. scaleGizmo: Nullable<ScaleGizmo>;
  47224. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47225. };
  47226. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47227. clearGizmoOnEmptyPointerEvent: boolean;
  47228. /** Fires an event when the manager is attached to a mesh */
  47229. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47230. private _gizmosEnabled;
  47231. private _pointerObserver;
  47232. private _attachedMesh;
  47233. private _boundingBoxColor;
  47234. private _defaultUtilityLayer;
  47235. private _defaultKeepDepthUtilityLayer;
  47236. /**
  47237. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47238. */
  47239. boundingBoxDragBehavior: SixDofDragBehavior;
  47240. /**
  47241. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47242. */
  47243. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47244. /**
  47245. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47246. */
  47247. usePointerToAttachGizmos: boolean;
  47248. /**
  47249. * Utility layer that the bounding box gizmo belongs to
  47250. */
  47251. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47252. /**
  47253. * Utility layer that all gizmos besides bounding box belong to
  47254. */
  47255. readonly utilityLayer: UtilityLayerRenderer;
  47256. /**
  47257. * Instatiates a gizmo manager
  47258. * @param scene the scene to overlay the gizmos on top of
  47259. */
  47260. constructor(scene: Scene);
  47261. /**
  47262. * Attaches a set of gizmos to the specified mesh
  47263. * @param mesh The mesh the gizmo's should be attached to
  47264. */
  47265. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47266. /**
  47267. * If the position gizmo is enabled
  47268. */
  47269. positionGizmoEnabled: boolean;
  47270. /**
  47271. * If the rotation gizmo is enabled
  47272. */
  47273. rotationGizmoEnabled: boolean;
  47274. /**
  47275. * If the scale gizmo is enabled
  47276. */
  47277. scaleGizmoEnabled: boolean;
  47278. /**
  47279. * If the boundingBox gizmo is enabled
  47280. */
  47281. boundingBoxGizmoEnabled: boolean;
  47282. /**
  47283. * Disposes of the gizmo manager
  47284. */
  47285. dispose(): void;
  47286. }
  47287. }
  47288. declare module "babylonjs/Lights/directionalLight" {
  47289. import { Camera } from "babylonjs/Cameras/camera";
  47290. import { Scene } from "babylonjs/scene";
  47291. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47293. import { Light } from "babylonjs/Lights/light";
  47294. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47295. import { Effect } from "babylonjs/Materials/effect";
  47296. /**
  47297. * A directional light is defined by a direction (what a surprise!).
  47298. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47299. * 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.
  47300. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47301. */
  47302. export class DirectionalLight extends ShadowLight {
  47303. private _shadowFrustumSize;
  47304. /**
  47305. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47306. */
  47307. /**
  47308. * Specifies a fix frustum size for the shadow generation.
  47309. */
  47310. shadowFrustumSize: number;
  47311. private _shadowOrthoScale;
  47312. /**
  47313. * Gets the shadow projection scale against the optimal computed one.
  47314. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47315. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47316. */
  47317. /**
  47318. * Sets the shadow projection scale against the optimal computed one.
  47319. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47320. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47321. */
  47322. shadowOrthoScale: number;
  47323. /**
  47324. * Automatically compute the projection matrix to best fit (including all the casters)
  47325. * on each frame.
  47326. */
  47327. autoUpdateExtends: boolean;
  47328. private _orthoLeft;
  47329. private _orthoRight;
  47330. private _orthoTop;
  47331. private _orthoBottom;
  47332. /**
  47333. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47334. * The directional light is emitted from everywhere in the given direction.
  47335. * It can cast shadows.
  47336. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47337. * @param name The friendly name of the light
  47338. * @param direction The direction of the light
  47339. * @param scene The scene the light belongs to
  47340. */
  47341. constructor(name: string, direction: Vector3, scene: Scene);
  47342. /**
  47343. * Returns the string "DirectionalLight".
  47344. * @return The class name
  47345. */
  47346. getClassName(): string;
  47347. /**
  47348. * Returns the integer 1.
  47349. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47350. */
  47351. getTypeID(): number;
  47352. /**
  47353. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47354. * Returns the DirectionalLight Shadow projection matrix.
  47355. */
  47356. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47357. /**
  47358. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47359. * Returns the DirectionalLight Shadow projection matrix.
  47360. */
  47361. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47362. /**
  47363. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47364. * Returns the DirectionalLight Shadow projection matrix.
  47365. */
  47366. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47367. protected _buildUniformLayout(): void;
  47368. /**
  47369. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47370. * @param effect The effect to update
  47371. * @param lightIndex The index of the light in the effect to update
  47372. * @returns The directional light
  47373. */
  47374. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47375. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47376. /**
  47377. * Gets the minZ used for shadow according to both the scene and the light.
  47378. *
  47379. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47380. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47381. * @param activeCamera The camera we are returning the min for
  47382. * @returns the depth min z
  47383. */
  47384. getDepthMinZ(activeCamera: Camera): number;
  47385. /**
  47386. * Gets the maxZ used for shadow according to both the scene and the light.
  47387. *
  47388. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47389. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47390. * @param activeCamera The camera we are returning the max for
  47391. * @returns the depth max z
  47392. */
  47393. getDepthMaxZ(activeCamera: Camera): number;
  47394. /**
  47395. * Prepares the list of defines specific to the light type.
  47396. * @param defines the list of defines
  47397. * @param lightIndex defines the index of the light for the effect
  47398. */
  47399. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47400. }
  47401. }
  47402. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47403. import { Mesh } from "babylonjs/Meshes/mesh";
  47404. /**
  47405. * Class containing static functions to help procedurally build meshes
  47406. */
  47407. export class HemisphereBuilder {
  47408. /**
  47409. * Creates a hemisphere mesh
  47410. * @param name defines the name of the mesh
  47411. * @param options defines the options used to create the mesh
  47412. * @param scene defines the hosting scene
  47413. * @returns the hemisphere mesh
  47414. */
  47415. static CreateHemisphere(name: string, options: {
  47416. segments?: number;
  47417. diameter?: number;
  47418. sideOrientation?: number;
  47419. }, scene: any): Mesh;
  47420. }
  47421. }
  47422. declare module "babylonjs/Lights/spotLight" {
  47423. import { Nullable } from "babylonjs/types";
  47424. import { Scene } from "babylonjs/scene";
  47425. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47427. import { Effect } from "babylonjs/Materials/effect";
  47428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47429. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47430. /**
  47431. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47432. * These values define a cone of light starting from the position, emitting toward the direction.
  47433. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47434. * and the exponent defines the speed of the decay of the light with distance (reach).
  47435. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47436. */
  47437. export class SpotLight extends ShadowLight {
  47438. private _angle;
  47439. private _innerAngle;
  47440. private _cosHalfAngle;
  47441. private _lightAngleScale;
  47442. private _lightAngleOffset;
  47443. /**
  47444. * Gets the cone angle of the spot light in Radians.
  47445. */
  47446. /**
  47447. * Sets the cone angle of the spot light in Radians.
  47448. */
  47449. angle: number;
  47450. /**
  47451. * Only used in gltf falloff mode, this defines the angle where
  47452. * the directional falloff will start before cutting at angle which could be seen
  47453. * as outer angle.
  47454. */
  47455. /**
  47456. * Only used in gltf falloff mode, this defines the angle where
  47457. * the directional falloff will start before cutting at angle which could be seen
  47458. * as outer angle.
  47459. */
  47460. innerAngle: number;
  47461. private _shadowAngleScale;
  47462. /**
  47463. * Allows scaling the angle of the light for shadow generation only.
  47464. */
  47465. /**
  47466. * Allows scaling the angle of the light for shadow generation only.
  47467. */
  47468. shadowAngleScale: number;
  47469. /**
  47470. * The light decay speed with the distance from the emission spot.
  47471. */
  47472. exponent: number;
  47473. private _projectionTextureMatrix;
  47474. /**
  47475. * Allows reading the projecton texture
  47476. */
  47477. readonly projectionTextureMatrix: Matrix;
  47478. protected _projectionTextureLightNear: number;
  47479. /**
  47480. * Gets the near clip of the Spotlight for texture projection.
  47481. */
  47482. /**
  47483. * Sets the near clip of the Spotlight for texture projection.
  47484. */
  47485. projectionTextureLightNear: number;
  47486. protected _projectionTextureLightFar: number;
  47487. /**
  47488. * Gets the far clip of the Spotlight for texture projection.
  47489. */
  47490. /**
  47491. * Sets the far clip of the Spotlight for texture projection.
  47492. */
  47493. projectionTextureLightFar: number;
  47494. protected _projectionTextureUpDirection: Vector3;
  47495. /**
  47496. * Gets the Up vector of the Spotlight for texture projection.
  47497. */
  47498. /**
  47499. * Sets the Up vector of the Spotlight for texture projection.
  47500. */
  47501. projectionTextureUpDirection: Vector3;
  47502. private _projectionTexture;
  47503. /**
  47504. * Gets the projection texture of the light.
  47505. */
  47506. /**
  47507. * Sets the projection texture of the light.
  47508. */
  47509. projectionTexture: Nullable<BaseTexture>;
  47510. private _projectionTextureViewLightDirty;
  47511. private _projectionTextureProjectionLightDirty;
  47512. private _projectionTextureDirty;
  47513. private _projectionTextureViewTargetVector;
  47514. private _projectionTextureViewLightMatrix;
  47515. private _projectionTextureProjectionLightMatrix;
  47516. private _projectionTextureScalingMatrix;
  47517. /**
  47518. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47519. * It can cast shadows.
  47520. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47521. * @param name The light friendly name
  47522. * @param position The position of the spot light in the scene
  47523. * @param direction The direction of the light in the scene
  47524. * @param angle The cone angle of the light in Radians
  47525. * @param exponent The light decay speed with the distance from the emission spot
  47526. * @param scene The scene the lights belongs to
  47527. */
  47528. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47529. /**
  47530. * Returns the string "SpotLight".
  47531. * @returns the class name
  47532. */
  47533. getClassName(): string;
  47534. /**
  47535. * Returns the integer 2.
  47536. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47537. */
  47538. getTypeID(): number;
  47539. /**
  47540. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47541. */
  47542. protected _setDirection(value: Vector3): void;
  47543. /**
  47544. * Overrides the position setter to recompute the projection texture view light Matrix.
  47545. */
  47546. protected _setPosition(value: Vector3): void;
  47547. /**
  47548. * 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.
  47549. * Returns the SpotLight.
  47550. */
  47551. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47552. protected _computeProjectionTextureViewLightMatrix(): void;
  47553. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47554. /**
  47555. * Main function for light texture projection matrix computing.
  47556. */
  47557. protected _computeProjectionTextureMatrix(): void;
  47558. protected _buildUniformLayout(): void;
  47559. private _computeAngleValues;
  47560. /**
  47561. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47562. * @param effect The effect to update
  47563. * @param lightIndex The index of the light in the effect to update
  47564. * @returns The spot light
  47565. */
  47566. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47567. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47568. /**
  47569. * Disposes the light and the associated resources.
  47570. */
  47571. dispose(): void;
  47572. /**
  47573. * Prepares the list of defines specific to the light type.
  47574. * @param defines the list of defines
  47575. * @param lightIndex defines the index of the light for the effect
  47576. */
  47577. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47578. }
  47579. }
  47580. declare module "babylonjs/Gizmos/lightGizmo" {
  47581. import { Nullable } from "babylonjs/types";
  47582. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47583. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47584. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47585. import { Light } from "babylonjs/Lights/light";
  47586. /**
  47587. * Gizmo that enables viewing a light
  47588. */
  47589. export class LightGizmo extends Gizmo {
  47590. private _lightMesh;
  47591. private _material;
  47592. private cachedPosition;
  47593. private cachedForward;
  47594. /**
  47595. * Creates a LightGizmo
  47596. * @param gizmoLayer The utility layer the gizmo will be added to
  47597. */
  47598. constructor(gizmoLayer?: UtilityLayerRenderer);
  47599. private _light;
  47600. /**
  47601. * The light that the gizmo is attached to
  47602. */
  47603. light: Nullable<Light>;
  47604. /**
  47605. * Gets the material used to render the light gizmo
  47606. */
  47607. readonly material: StandardMaterial;
  47608. /**
  47609. * @hidden
  47610. * Updates the gizmo to match the attached mesh's position/rotation
  47611. */
  47612. protected _update(): void;
  47613. private static _Scale;
  47614. /**
  47615. * Creates the lines for a light mesh
  47616. */
  47617. private static _createLightLines;
  47618. /**
  47619. * Disposes of the light gizmo
  47620. */
  47621. dispose(): void;
  47622. private static _CreateHemisphericLightMesh;
  47623. private static _CreatePointLightMesh;
  47624. private static _CreateSpotLightMesh;
  47625. private static _CreateDirectionalLightMesh;
  47626. }
  47627. }
  47628. declare module "babylonjs/Gizmos/index" {
  47629. export * from "babylonjs/Gizmos/axisDragGizmo";
  47630. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47631. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47632. export * from "babylonjs/Gizmos/gizmo";
  47633. export * from "babylonjs/Gizmos/gizmoManager";
  47634. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47635. export * from "babylonjs/Gizmos/positionGizmo";
  47636. export * from "babylonjs/Gizmos/rotationGizmo";
  47637. export * from "babylonjs/Gizmos/scaleGizmo";
  47638. export * from "babylonjs/Gizmos/lightGizmo";
  47639. export * from "babylonjs/Gizmos/planeDragGizmo";
  47640. }
  47641. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47642. /** @hidden */
  47643. export var backgroundFragmentDeclaration: {
  47644. name: string;
  47645. shader: string;
  47646. };
  47647. }
  47648. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47649. /** @hidden */
  47650. export var backgroundUboDeclaration: {
  47651. name: string;
  47652. shader: string;
  47653. };
  47654. }
  47655. declare module "babylonjs/Shaders/background.fragment" {
  47656. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47657. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47658. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47659. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47660. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47661. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47662. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47663. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47664. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47665. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47666. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47667. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47668. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47669. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47670. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47671. /** @hidden */
  47672. export var backgroundPixelShader: {
  47673. name: string;
  47674. shader: string;
  47675. };
  47676. }
  47677. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47678. /** @hidden */
  47679. export var backgroundVertexDeclaration: {
  47680. name: string;
  47681. shader: string;
  47682. };
  47683. }
  47684. declare module "babylonjs/Shaders/background.vertex" {
  47685. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47686. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47687. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47688. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47689. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47690. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47691. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47692. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47693. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47694. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47695. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47696. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47697. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47698. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47699. /** @hidden */
  47700. export var backgroundVertexShader: {
  47701. name: string;
  47702. shader: string;
  47703. };
  47704. }
  47705. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47706. import { Nullable, int, float } from "babylonjs/types";
  47707. import { Scene } from "babylonjs/scene";
  47708. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47709. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47710. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47711. import { Mesh } from "babylonjs/Meshes/mesh";
  47712. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47713. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47714. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47715. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47716. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47717. import { Color3 } from "babylonjs/Maths/math.color";
  47718. import "babylonjs/Shaders/background.fragment";
  47719. import "babylonjs/Shaders/background.vertex";
  47720. /**
  47721. * Background material used to create an efficient environement around your scene.
  47722. */
  47723. export class BackgroundMaterial extends PushMaterial {
  47724. /**
  47725. * Standard reflectance value at parallel view angle.
  47726. */
  47727. static StandardReflectance0: number;
  47728. /**
  47729. * Standard reflectance value at grazing angle.
  47730. */
  47731. static StandardReflectance90: number;
  47732. protected _primaryColor: Color3;
  47733. /**
  47734. * Key light Color (multiply against the environement texture)
  47735. */
  47736. primaryColor: Color3;
  47737. protected __perceptualColor: Nullable<Color3>;
  47738. /**
  47739. * Experimental Internal Use Only.
  47740. *
  47741. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47742. * This acts as a helper to set the primary color to a more "human friendly" value.
  47743. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47744. * output color as close as possible from the chosen value.
  47745. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47746. * part of lighting setup.)
  47747. */
  47748. _perceptualColor: Nullable<Color3>;
  47749. protected _primaryColorShadowLevel: float;
  47750. /**
  47751. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47752. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47753. */
  47754. primaryColorShadowLevel: float;
  47755. protected _primaryColorHighlightLevel: float;
  47756. /**
  47757. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47758. * The primary color is used at the level chosen to define what the white area would look.
  47759. */
  47760. primaryColorHighlightLevel: float;
  47761. protected _reflectionTexture: Nullable<BaseTexture>;
  47762. /**
  47763. * Reflection Texture used in the material.
  47764. * Should be author in a specific way for the best result (refer to the documentation).
  47765. */
  47766. reflectionTexture: Nullable<BaseTexture>;
  47767. protected _reflectionBlur: float;
  47768. /**
  47769. * Reflection Texture level of blur.
  47770. *
  47771. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47772. * texture twice.
  47773. */
  47774. reflectionBlur: float;
  47775. protected _diffuseTexture: Nullable<BaseTexture>;
  47776. /**
  47777. * Diffuse Texture used in the material.
  47778. * Should be author in a specific way for the best result (refer to the documentation).
  47779. */
  47780. diffuseTexture: Nullable<BaseTexture>;
  47781. protected _shadowLights: Nullable<IShadowLight[]>;
  47782. /**
  47783. * Specify the list of lights casting shadow on the material.
  47784. * All scene shadow lights will be included if null.
  47785. */
  47786. shadowLights: Nullable<IShadowLight[]>;
  47787. protected _shadowLevel: float;
  47788. /**
  47789. * Helps adjusting the shadow to a softer level if required.
  47790. * 0 means black shadows and 1 means no shadows.
  47791. */
  47792. shadowLevel: float;
  47793. protected _sceneCenter: Vector3;
  47794. /**
  47795. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47796. * It is usually zero but might be interesting to modify according to your setup.
  47797. */
  47798. sceneCenter: Vector3;
  47799. protected _opacityFresnel: boolean;
  47800. /**
  47801. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47802. * This helps ensuring a nice transition when the camera goes under the ground.
  47803. */
  47804. opacityFresnel: boolean;
  47805. protected _reflectionFresnel: boolean;
  47806. /**
  47807. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47808. * This helps adding a mirror texture on the ground.
  47809. */
  47810. reflectionFresnel: boolean;
  47811. protected _reflectionFalloffDistance: number;
  47812. /**
  47813. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47814. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47815. */
  47816. reflectionFalloffDistance: number;
  47817. protected _reflectionAmount: number;
  47818. /**
  47819. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47820. */
  47821. reflectionAmount: number;
  47822. protected _reflectionReflectance0: number;
  47823. /**
  47824. * This specifies the weight of the reflection at grazing angle.
  47825. */
  47826. reflectionReflectance0: number;
  47827. protected _reflectionReflectance90: number;
  47828. /**
  47829. * This specifies the weight of the reflection at a perpendicular point of view.
  47830. */
  47831. reflectionReflectance90: number;
  47832. /**
  47833. * Sets the reflection reflectance fresnel values according to the default standard
  47834. * empirically know to work well :-)
  47835. */
  47836. reflectionStandardFresnelWeight: number;
  47837. protected _useRGBColor: boolean;
  47838. /**
  47839. * Helps to directly use the maps channels instead of their level.
  47840. */
  47841. useRGBColor: boolean;
  47842. protected _enableNoise: boolean;
  47843. /**
  47844. * This helps reducing the banding effect that could occur on the background.
  47845. */
  47846. enableNoise: boolean;
  47847. /**
  47848. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47849. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47850. * Recommended to be keep at 1.0 except for special cases.
  47851. */
  47852. fovMultiplier: number;
  47853. private _fovMultiplier;
  47854. /**
  47855. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47856. */
  47857. useEquirectangularFOV: boolean;
  47858. private _maxSimultaneousLights;
  47859. /**
  47860. * Number of Simultaneous lights allowed on the material.
  47861. */
  47862. maxSimultaneousLights: int;
  47863. /**
  47864. * Default configuration related to image processing available in the Background Material.
  47865. */
  47866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47867. /**
  47868. * Keep track of the image processing observer to allow dispose and replace.
  47869. */
  47870. private _imageProcessingObserver;
  47871. /**
  47872. * Attaches a new image processing configuration to the PBR Material.
  47873. * @param configuration (if null the scene configuration will be use)
  47874. */
  47875. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47876. /**
  47877. * Gets the image processing configuration used either in this material.
  47878. */
  47879. /**
  47880. * Sets the Default image processing configuration used either in the this material.
  47881. *
  47882. * If sets to null, the scene one is in use.
  47883. */
  47884. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47885. /**
  47886. * Gets wether the color curves effect is enabled.
  47887. */
  47888. /**
  47889. * Sets wether the color curves effect is enabled.
  47890. */
  47891. cameraColorCurvesEnabled: boolean;
  47892. /**
  47893. * Gets wether the color grading effect is enabled.
  47894. */
  47895. /**
  47896. * Gets wether the color grading effect is enabled.
  47897. */
  47898. cameraColorGradingEnabled: boolean;
  47899. /**
  47900. * Gets wether tonemapping is enabled or not.
  47901. */
  47902. /**
  47903. * Sets wether tonemapping is enabled or not
  47904. */
  47905. cameraToneMappingEnabled: boolean;
  47906. /**
  47907. * The camera exposure used on this material.
  47908. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47909. * This corresponds to a photographic exposure.
  47910. */
  47911. /**
  47912. * The camera exposure used on this material.
  47913. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47914. * This corresponds to a photographic exposure.
  47915. */
  47916. cameraExposure: float;
  47917. /**
  47918. * Gets The camera contrast used on this material.
  47919. */
  47920. /**
  47921. * Sets The camera contrast used on this material.
  47922. */
  47923. cameraContrast: float;
  47924. /**
  47925. * Gets the Color Grading 2D Lookup Texture.
  47926. */
  47927. /**
  47928. * Sets the Color Grading 2D Lookup Texture.
  47929. */
  47930. cameraColorGradingTexture: Nullable<BaseTexture>;
  47931. /**
  47932. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47933. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47934. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  47935. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47936. */
  47937. /**
  47938. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47939. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47940. * 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;
  47941. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47942. */
  47943. cameraColorCurves: Nullable<ColorCurves>;
  47944. /**
  47945. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47946. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47947. */
  47948. switchToBGR: boolean;
  47949. private _renderTargets;
  47950. private _reflectionControls;
  47951. private _white;
  47952. private _primaryShadowColor;
  47953. private _primaryHighlightColor;
  47954. /**
  47955. * Instantiates a Background Material in the given scene
  47956. * @param name The friendly name of the material
  47957. * @param scene The scene to add the material to
  47958. */
  47959. constructor(name: string, scene: Scene);
  47960. /**
  47961. * Gets a boolean indicating that current material needs to register RTT
  47962. */
  47963. readonly hasRenderTargetTextures: boolean;
  47964. /**
  47965. * The entire material has been created in order to prevent overdraw.
  47966. * @returns false
  47967. */
  47968. needAlphaTesting(): boolean;
  47969. /**
  47970. * The entire material has been created in order to prevent overdraw.
  47971. * @returns true if blending is enable
  47972. */
  47973. needAlphaBlending(): boolean;
  47974. /**
  47975. * Checks wether the material is ready to be rendered for a given mesh.
  47976. * @param mesh The mesh to render
  47977. * @param subMesh The submesh to check against
  47978. * @param useInstances Specify wether or not the material is used with instances
  47979. * @returns true if all the dependencies are ready (Textures, Effects...)
  47980. */
  47981. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47982. /**
  47983. * Compute the primary color according to the chosen perceptual color.
  47984. */
  47985. private _computePrimaryColorFromPerceptualColor;
  47986. /**
  47987. * Compute the highlights and shadow colors according to their chosen levels.
  47988. */
  47989. private _computePrimaryColors;
  47990. /**
  47991. * Build the uniform buffer used in the material.
  47992. */
  47993. buildUniformLayout(): void;
  47994. /**
  47995. * Unbind the material.
  47996. */
  47997. unbind(): void;
  47998. /**
  47999. * Bind only the world matrix to the material.
  48000. * @param world The world matrix to bind.
  48001. */
  48002. bindOnlyWorldMatrix(world: Matrix): void;
  48003. /**
  48004. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  48005. * @param world The world matrix to bind.
  48006. * @param subMesh The submesh to bind for.
  48007. */
  48008. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  48009. /**
  48010. * Checks to see if a texture is used in the material.
  48011. * @param texture - Base texture to use.
  48012. * @returns - Boolean specifying if a texture is used in the material.
  48013. */
  48014. hasTexture(texture: BaseTexture): boolean;
  48015. /**
  48016. * Dispose the material.
  48017. * @param forceDisposeEffect Force disposal of the associated effect.
  48018. * @param forceDisposeTextures Force disposal of the associated textures.
  48019. */
  48020. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  48021. /**
  48022. * Clones the material.
  48023. * @param name The cloned name.
  48024. * @returns The cloned material.
  48025. */
  48026. clone(name: string): BackgroundMaterial;
  48027. /**
  48028. * Serializes the current material to its JSON representation.
  48029. * @returns The JSON representation.
  48030. */
  48031. serialize(): any;
  48032. /**
  48033. * Gets the class name of the material
  48034. * @returns "BackgroundMaterial"
  48035. */
  48036. getClassName(): string;
  48037. /**
  48038. * Parse a JSON input to create back a background material.
  48039. * @param source The JSON data to parse
  48040. * @param scene The scene to create the parsed material in
  48041. * @param rootUrl The root url of the assets the material depends upon
  48042. * @returns the instantiated BackgroundMaterial.
  48043. */
  48044. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  48045. }
  48046. }
  48047. declare module "babylonjs/Helpers/environmentHelper" {
  48048. import { Observable } from "babylonjs/Misc/observable";
  48049. import { Nullable } from "babylonjs/types";
  48050. import { Scene } from "babylonjs/scene";
  48051. import { Vector3 } from "babylonjs/Maths/math.vector";
  48052. import { Color3 } from "babylonjs/Maths/math.color";
  48053. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48054. import { Mesh } from "babylonjs/Meshes/mesh";
  48055. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48056. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48057. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48058. import "babylonjs/Meshes/Builders/planeBuilder";
  48059. import "babylonjs/Meshes/Builders/boxBuilder";
  48060. /**
  48061. * Represents the different options available during the creation of
  48062. * a Environment helper.
  48063. *
  48064. * This can control the default ground, skybox and image processing setup of your scene.
  48065. */
  48066. export interface IEnvironmentHelperOptions {
  48067. /**
  48068. * Specifies wether or not to create a ground.
  48069. * True by default.
  48070. */
  48071. createGround: boolean;
  48072. /**
  48073. * Specifies the ground size.
  48074. * 15 by default.
  48075. */
  48076. groundSize: number;
  48077. /**
  48078. * The texture used on the ground for the main color.
  48079. * Comes from the BabylonJS CDN by default.
  48080. *
  48081. * Remarks: Can be either a texture or a url.
  48082. */
  48083. groundTexture: string | BaseTexture;
  48084. /**
  48085. * The color mixed in the ground texture by default.
  48086. * BabylonJS clearColor by default.
  48087. */
  48088. groundColor: Color3;
  48089. /**
  48090. * Specifies the ground opacity.
  48091. * 1 by default.
  48092. */
  48093. groundOpacity: number;
  48094. /**
  48095. * Enables the ground to receive shadows.
  48096. * True by default.
  48097. */
  48098. enableGroundShadow: boolean;
  48099. /**
  48100. * Helps preventing the shadow to be fully black on the ground.
  48101. * 0.5 by default.
  48102. */
  48103. groundShadowLevel: number;
  48104. /**
  48105. * Creates a mirror texture attach to the ground.
  48106. * false by default.
  48107. */
  48108. enableGroundMirror: boolean;
  48109. /**
  48110. * Specifies the ground mirror size ratio.
  48111. * 0.3 by default as the default kernel is 64.
  48112. */
  48113. groundMirrorSizeRatio: number;
  48114. /**
  48115. * Specifies the ground mirror blur kernel size.
  48116. * 64 by default.
  48117. */
  48118. groundMirrorBlurKernel: number;
  48119. /**
  48120. * Specifies the ground mirror visibility amount.
  48121. * 1 by default
  48122. */
  48123. groundMirrorAmount: number;
  48124. /**
  48125. * Specifies the ground mirror reflectance weight.
  48126. * This uses the standard weight of the background material to setup the fresnel effect
  48127. * of the mirror.
  48128. * 1 by default.
  48129. */
  48130. groundMirrorFresnelWeight: number;
  48131. /**
  48132. * Specifies the ground mirror Falloff distance.
  48133. * This can helps reducing the size of the reflection.
  48134. * 0 by Default.
  48135. */
  48136. groundMirrorFallOffDistance: number;
  48137. /**
  48138. * Specifies the ground mirror texture type.
  48139. * Unsigned Int by Default.
  48140. */
  48141. groundMirrorTextureType: number;
  48142. /**
  48143. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48144. * the shown objects.
  48145. */
  48146. groundYBias: number;
  48147. /**
  48148. * Specifies wether or not to create a skybox.
  48149. * True by default.
  48150. */
  48151. createSkybox: boolean;
  48152. /**
  48153. * Specifies the skybox size.
  48154. * 20 by default.
  48155. */
  48156. skyboxSize: number;
  48157. /**
  48158. * The texture used on the skybox for the main color.
  48159. * Comes from the BabylonJS CDN by default.
  48160. *
  48161. * Remarks: Can be either a texture or a url.
  48162. */
  48163. skyboxTexture: string | BaseTexture;
  48164. /**
  48165. * The color mixed in the skybox texture by default.
  48166. * BabylonJS clearColor by default.
  48167. */
  48168. skyboxColor: Color3;
  48169. /**
  48170. * The background rotation around the Y axis of the scene.
  48171. * This helps aligning the key lights of your scene with the background.
  48172. * 0 by default.
  48173. */
  48174. backgroundYRotation: number;
  48175. /**
  48176. * Compute automatically the size of the elements to best fit with the scene.
  48177. */
  48178. sizeAuto: boolean;
  48179. /**
  48180. * Default position of the rootMesh if autoSize is not true.
  48181. */
  48182. rootPosition: Vector3;
  48183. /**
  48184. * Sets up the image processing in the scene.
  48185. * true by default.
  48186. */
  48187. setupImageProcessing: boolean;
  48188. /**
  48189. * The texture used as your environment texture in the scene.
  48190. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48191. *
  48192. * Remarks: Can be either a texture or a url.
  48193. */
  48194. environmentTexture: string | BaseTexture;
  48195. /**
  48196. * The value of the exposure to apply to the scene.
  48197. * 0.6 by default if setupImageProcessing is true.
  48198. */
  48199. cameraExposure: number;
  48200. /**
  48201. * The value of the contrast to apply to the scene.
  48202. * 1.6 by default if setupImageProcessing is true.
  48203. */
  48204. cameraContrast: number;
  48205. /**
  48206. * Specifies wether or not tonemapping should be enabled in the scene.
  48207. * true by default if setupImageProcessing is true.
  48208. */
  48209. toneMappingEnabled: boolean;
  48210. }
  48211. /**
  48212. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48213. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48214. * It also helps with the default setup of your imageProcessing configuration.
  48215. */
  48216. export class EnvironmentHelper {
  48217. /**
  48218. * Default ground texture URL.
  48219. */
  48220. private static _groundTextureCDNUrl;
  48221. /**
  48222. * Default skybox texture URL.
  48223. */
  48224. private static _skyboxTextureCDNUrl;
  48225. /**
  48226. * Default environment texture URL.
  48227. */
  48228. private static _environmentTextureCDNUrl;
  48229. /**
  48230. * Creates the default options for the helper.
  48231. */
  48232. private static _getDefaultOptions;
  48233. private _rootMesh;
  48234. /**
  48235. * Gets the root mesh created by the helper.
  48236. */
  48237. readonly rootMesh: Mesh;
  48238. private _skybox;
  48239. /**
  48240. * Gets the skybox created by the helper.
  48241. */
  48242. readonly skybox: Nullable<Mesh>;
  48243. private _skyboxTexture;
  48244. /**
  48245. * Gets the skybox texture created by the helper.
  48246. */
  48247. readonly skyboxTexture: Nullable<BaseTexture>;
  48248. private _skyboxMaterial;
  48249. /**
  48250. * Gets the skybox material created by the helper.
  48251. */
  48252. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48253. private _ground;
  48254. /**
  48255. * Gets the ground mesh created by the helper.
  48256. */
  48257. readonly ground: Nullable<Mesh>;
  48258. private _groundTexture;
  48259. /**
  48260. * Gets the ground texture created by the helper.
  48261. */
  48262. readonly groundTexture: Nullable<BaseTexture>;
  48263. private _groundMirror;
  48264. /**
  48265. * Gets the ground mirror created by the helper.
  48266. */
  48267. readonly groundMirror: Nullable<MirrorTexture>;
  48268. /**
  48269. * Gets the ground mirror render list to helps pushing the meshes
  48270. * you wish in the ground reflection.
  48271. */
  48272. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48273. private _groundMaterial;
  48274. /**
  48275. * Gets the ground material created by the helper.
  48276. */
  48277. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48278. /**
  48279. * Stores the creation options.
  48280. */
  48281. private readonly _scene;
  48282. private _options;
  48283. /**
  48284. * This observable will be notified with any error during the creation of the environment,
  48285. * mainly texture creation errors.
  48286. */
  48287. onErrorObservable: Observable<{
  48288. message?: string;
  48289. exception?: any;
  48290. }>;
  48291. /**
  48292. * constructor
  48293. * @param options Defines the options we want to customize the helper
  48294. * @param scene The scene to add the material to
  48295. */
  48296. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48297. /**
  48298. * Updates the background according to the new options
  48299. * @param options
  48300. */
  48301. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48302. /**
  48303. * Sets the primary color of all the available elements.
  48304. * @param color the main color to affect to the ground and the background
  48305. */
  48306. setMainColor(color: Color3): void;
  48307. /**
  48308. * Setup the image processing according to the specified options.
  48309. */
  48310. private _setupImageProcessing;
  48311. /**
  48312. * Setup the environment texture according to the specified options.
  48313. */
  48314. private _setupEnvironmentTexture;
  48315. /**
  48316. * Setup the background according to the specified options.
  48317. */
  48318. private _setupBackground;
  48319. /**
  48320. * Get the scene sizes according to the setup.
  48321. */
  48322. private _getSceneSize;
  48323. /**
  48324. * Setup the ground according to the specified options.
  48325. */
  48326. private _setupGround;
  48327. /**
  48328. * Setup the ground material according to the specified options.
  48329. */
  48330. private _setupGroundMaterial;
  48331. /**
  48332. * Setup the ground diffuse texture according to the specified options.
  48333. */
  48334. private _setupGroundDiffuseTexture;
  48335. /**
  48336. * Setup the ground mirror texture according to the specified options.
  48337. */
  48338. private _setupGroundMirrorTexture;
  48339. /**
  48340. * Setup the ground to receive the mirror texture.
  48341. */
  48342. private _setupMirrorInGroundMaterial;
  48343. /**
  48344. * Setup the skybox according to the specified options.
  48345. */
  48346. private _setupSkybox;
  48347. /**
  48348. * Setup the skybox material according to the specified options.
  48349. */
  48350. private _setupSkyboxMaterial;
  48351. /**
  48352. * Setup the skybox reflection texture according to the specified options.
  48353. */
  48354. private _setupSkyboxReflectionTexture;
  48355. private _errorHandler;
  48356. /**
  48357. * Dispose all the elements created by the Helper.
  48358. */
  48359. dispose(): void;
  48360. }
  48361. }
  48362. declare module "babylonjs/Helpers/photoDome" {
  48363. import { Observable } from "babylonjs/Misc/observable";
  48364. import { Nullable } from "babylonjs/types";
  48365. import { Scene } from "babylonjs/scene";
  48366. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48367. import { Mesh } from "babylonjs/Meshes/mesh";
  48368. import { Texture } from "babylonjs/Materials/Textures/texture";
  48369. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48370. import "babylonjs/Meshes/Builders/sphereBuilder";
  48371. /**
  48372. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48373. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48374. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48375. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48376. */
  48377. export class PhotoDome extends TransformNode {
  48378. /**
  48379. * Define the image as a Monoscopic panoramic 360 image.
  48380. */
  48381. static readonly MODE_MONOSCOPIC: number;
  48382. /**
  48383. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48384. */
  48385. static readonly MODE_TOPBOTTOM: number;
  48386. /**
  48387. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48388. */
  48389. static readonly MODE_SIDEBYSIDE: number;
  48390. private _useDirectMapping;
  48391. /**
  48392. * The texture being displayed on the sphere
  48393. */
  48394. protected _photoTexture: Texture;
  48395. /**
  48396. * Gets or sets the texture being displayed on the sphere
  48397. */
  48398. photoTexture: Texture;
  48399. /**
  48400. * Observable raised when an error occured while loading the 360 image
  48401. */
  48402. onLoadErrorObservable: Observable<string>;
  48403. /**
  48404. * The skybox material
  48405. */
  48406. protected _material: BackgroundMaterial;
  48407. /**
  48408. * The surface used for the skybox
  48409. */
  48410. protected _mesh: Mesh;
  48411. /**
  48412. * Gets the mesh used for the skybox.
  48413. */
  48414. readonly mesh: Mesh;
  48415. /**
  48416. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48417. * Also see the options.resolution property.
  48418. */
  48419. fovMultiplier: number;
  48420. private _imageMode;
  48421. /**
  48422. * Gets or set the current video mode for the video. It can be:
  48423. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48424. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48425. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48426. */
  48427. imageMode: number;
  48428. /**
  48429. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48430. * @param name Element's name, child elements will append suffixes for their own names.
  48431. * @param urlsOfPhoto defines the url of the photo to display
  48432. * @param options defines an object containing optional or exposed sub element properties
  48433. * @param onError defines a callback called when an error occured while loading the texture
  48434. */
  48435. constructor(name: string, urlOfPhoto: string, options: {
  48436. resolution?: number;
  48437. size?: number;
  48438. useDirectMapping?: boolean;
  48439. faceForward?: boolean;
  48440. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48441. private _onBeforeCameraRenderObserver;
  48442. private _changeImageMode;
  48443. /**
  48444. * Releases resources associated with this node.
  48445. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48446. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48447. */
  48448. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48449. }
  48450. }
  48451. declare module "babylonjs/Misc/rgbdTextureTools" {
  48452. import "babylonjs/Shaders/rgbdDecode.fragment";
  48453. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48454. import { Texture } from "babylonjs/Materials/Textures/texture";
  48455. /**
  48456. * Class used to host RGBD texture specific utilities
  48457. */
  48458. export class RGBDTextureTools {
  48459. /**
  48460. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48461. * @param texture the texture to expand.
  48462. */
  48463. static ExpandRGBDTexture(texture: Texture): void;
  48464. }
  48465. }
  48466. declare module "babylonjs/Misc/brdfTextureTools" {
  48467. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48468. import { Scene } from "babylonjs/scene";
  48469. /**
  48470. * Class used to host texture specific utilities
  48471. */
  48472. export class BRDFTextureTools {
  48473. /**
  48474. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48475. * @param scene defines the hosting scene
  48476. * @returns the environment BRDF texture
  48477. */
  48478. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48479. private static _environmentBRDFBase64Texture;
  48480. }
  48481. }
  48482. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48483. import { Nullable } from "babylonjs/types";
  48484. import { Color3 } from "babylonjs/Maths/math.color";
  48485. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48486. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48488. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48489. import { Engine } from "babylonjs/Engines/engine";
  48490. import { Scene } from "babylonjs/scene";
  48491. /**
  48492. * @hidden
  48493. */
  48494. export interface IMaterialClearCoatDefines {
  48495. CLEARCOAT: boolean;
  48496. CLEARCOAT_DEFAULTIOR: boolean;
  48497. CLEARCOAT_TEXTURE: boolean;
  48498. CLEARCOAT_TEXTUREDIRECTUV: number;
  48499. CLEARCOAT_BUMP: boolean;
  48500. CLEARCOAT_BUMPDIRECTUV: number;
  48501. CLEARCOAT_TINT: boolean;
  48502. CLEARCOAT_TINT_TEXTURE: boolean;
  48503. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48504. /** @hidden */
  48505. _areTexturesDirty: boolean;
  48506. }
  48507. /**
  48508. * Define the code related to the clear coat parameters of the pbr material.
  48509. */
  48510. export class PBRClearCoatConfiguration {
  48511. /**
  48512. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48513. * The default fits with a polyurethane material.
  48514. */
  48515. private static readonly _DefaultIndexOfRefraction;
  48516. private _isEnabled;
  48517. /**
  48518. * Defines if the clear coat is enabled in the material.
  48519. */
  48520. isEnabled: boolean;
  48521. /**
  48522. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48523. */
  48524. intensity: number;
  48525. /**
  48526. * Defines the clear coat layer roughness.
  48527. */
  48528. roughness: number;
  48529. private _indexOfRefraction;
  48530. /**
  48531. * Defines the index of refraction of the clear coat.
  48532. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48533. * The default fits with a polyurethane material.
  48534. * Changing the default value is more performance intensive.
  48535. */
  48536. indexOfRefraction: number;
  48537. private _texture;
  48538. /**
  48539. * Stores the clear coat values in a texture.
  48540. */
  48541. texture: Nullable<BaseTexture>;
  48542. private _bumpTexture;
  48543. /**
  48544. * Define the clear coat specific bump texture.
  48545. */
  48546. bumpTexture: Nullable<BaseTexture>;
  48547. private _isTintEnabled;
  48548. /**
  48549. * Defines if the clear coat tint is enabled in the material.
  48550. */
  48551. isTintEnabled: boolean;
  48552. /**
  48553. * Defines the clear coat tint of the material.
  48554. * This is only use if tint is enabled
  48555. */
  48556. tintColor: Color3;
  48557. /**
  48558. * Defines the distance at which the tint color should be found in the
  48559. * clear coat media.
  48560. * This is only use if tint is enabled
  48561. */
  48562. tintColorAtDistance: number;
  48563. /**
  48564. * Defines the clear coat layer thickness.
  48565. * This is only use if tint is enabled
  48566. */
  48567. tintThickness: number;
  48568. private _tintTexture;
  48569. /**
  48570. * Stores the clear tint values in a texture.
  48571. * rgb is tint
  48572. * a is a thickness factor
  48573. */
  48574. tintTexture: Nullable<BaseTexture>;
  48575. /** @hidden */
  48576. private _internalMarkAllSubMeshesAsTexturesDirty;
  48577. /** @hidden */
  48578. _markAllSubMeshesAsTexturesDirty(): void;
  48579. /**
  48580. * Instantiate a new istance of clear coat configuration.
  48581. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48582. */
  48583. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48584. /**
  48585. * Gets wehter the submesh is ready to be used or not.
  48586. * @param defines the list of "defines" to update.
  48587. * @param scene defines the scene the material belongs to.
  48588. * @param engine defines the engine the material belongs to.
  48589. * @param disableBumpMap defines wether the material disables bump or not.
  48590. * @returns - boolean indicating that the submesh is ready or not.
  48591. */
  48592. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48593. /**
  48594. * Checks to see if a texture is used in the material.
  48595. * @param defines the list of "defines" to update.
  48596. * @param scene defines the scene to the material belongs to.
  48597. */
  48598. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48599. /**
  48600. * Binds the material data.
  48601. * @param uniformBuffer defines the Uniform buffer to fill in.
  48602. * @param scene defines the scene the material belongs to.
  48603. * @param engine defines the engine the material belongs to.
  48604. * @param disableBumpMap defines wether the material disables bump or not.
  48605. * @param isFrozen defines wether the material is frozen or not.
  48606. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48607. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48608. */
  48609. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48610. /**
  48611. * Checks to see if a texture is used in the material.
  48612. * @param texture - Base texture to use.
  48613. * @returns - Boolean specifying if a texture is used in the material.
  48614. */
  48615. hasTexture(texture: BaseTexture): boolean;
  48616. /**
  48617. * Returns an array of the actively used textures.
  48618. * @param activeTextures Array of BaseTextures
  48619. */
  48620. getActiveTextures(activeTextures: BaseTexture[]): void;
  48621. /**
  48622. * Returns the animatable textures.
  48623. * @param animatables Array of animatable textures.
  48624. */
  48625. getAnimatables(animatables: IAnimatable[]): void;
  48626. /**
  48627. * Disposes the resources of the material.
  48628. * @param forceDisposeTextures - Forces the disposal of all textures.
  48629. */
  48630. dispose(forceDisposeTextures?: boolean): void;
  48631. /**
  48632. * Get the current class name of the texture useful for serialization or dynamic coding.
  48633. * @returns "PBRClearCoatConfiguration"
  48634. */
  48635. getClassName(): string;
  48636. /**
  48637. * Add fallbacks to the effect fallbacks list.
  48638. * @param defines defines the Base texture to use.
  48639. * @param fallbacks defines the current fallback list.
  48640. * @param currentRank defines the current fallback rank.
  48641. * @returns the new fallback rank.
  48642. */
  48643. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48644. /**
  48645. * Add the required uniforms to the current list.
  48646. * @param uniforms defines the current uniform list.
  48647. */
  48648. static AddUniforms(uniforms: string[]): void;
  48649. /**
  48650. * Add the required samplers to the current list.
  48651. * @param samplers defines the current sampler list.
  48652. */
  48653. static AddSamplers(samplers: string[]): void;
  48654. /**
  48655. * Add the required uniforms to the current buffer.
  48656. * @param uniformBuffer defines the current uniform buffer.
  48657. */
  48658. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48659. /**
  48660. * Makes a duplicate of the current configuration into another one.
  48661. * @param clearCoatConfiguration define the config where to copy the info
  48662. */
  48663. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48664. /**
  48665. * Serializes this clear coat configuration.
  48666. * @returns - An object with the serialized config.
  48667. */
  48668. serialize(): any;
  48669. /**
  48670. * Parses a anisotropy Configuration from a serialized object.
  48671. * @param source - Serialized object.
  48672. * @param scene Defines the scene we are parsing for
  48673. * @param rootUrl Defines the rootUrl to load from
  48674. */
  48675. parse(source: any, scene: Scene, rootUrl: string): void;
  48676. }
  48677. }
  48678. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48679. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48681. import { Vector2 } from "babylonjs/Maths/math.vector";
  48682. import { Scene } from "babylonjs/scene";
  48683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48684. import { Nullable } from "babylonjs/types";
  48685. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48686. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48687. /**
  48688. * @hidden
  48689. */
  48690. export interface IMaterialAnisotropicDefines {
  48691. ANISOTROPIC: boolean;
  48692. ANISOTROPIC_TEXTURE: boolean;
  48693. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48694. MAINUV1: boolean;
  48695. _areTexturesDirty: boolean;
  48696. _needUVs: boolean;
  48697. }
  48698. /**
  48699. * Define the code related to the anisotropic parameters of the pbr material.
  48700. */
  48701. export class PBRAnisotropicConfiguration {
  48702. private _isEnabled;
  48703. /**
  48704. * Defines if the anisotropy is enabled in the material.
  48705. */
  48706. isEnabled: boolean;
  48707. /**
  48708. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48709. */
  48710. intensity: number;
  48711. /**
  48712. * Defines if the effect is along the tangents, bitangents or in between.
  48713. * By default, the effect is "strectching" the highlights along the tangents.
  48714. */
  48715. direction: Vector2;
  48716. private _texture;
  48717. /**
  48718. * Stores the anisotropy values in a texture.
  48719. * rg is direction (like normal from -1 to 1)
  48720. * b is a intensity
  48721. */
  48722. texture: Nullable<BaseTexture>;
  48723. /** @hidden */
  48724. private _internalMarkAllSubMeshesAsTexturesDirty;
  48725. /** @hidden */
  48726. _markAllSubMeshesAsTexturesDirty(): void;
  48727. /**
  48728. * Instantiate a new istance of anisotropy configuration.
  48729. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48730. */
  48731. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48732. /**
  48733. * Specifies that the submesh is ready to be used.
  48734. * @param defines the list of "defines" to update.
  48735. * @param scene defines the scene the material belongs to.
  48736. * @returns - boolean indicating that the submesh is ready or not.
  48737. */
  48738. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48739. /**
  48740. * Checks to see if a texture is used in the material.
  48741. * @param defines the list of "defines" to update.
  48742. * @param mesh the mesh we are preparing the defines for.
  48743. * @param scene defines the scene the material belongs to.
  48744. */
  48745. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48746. /**
  48747. * Binds the material data.
  48748. * @param uniformBuffer defines the Uniform buffer to fill in.
  48749. * @param scene defines the scene the material belongs to.
  48750. * @param isFrozen defines wether the material is frozen or not.
  48751. */
  48752. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48753. /**
  48754. * Checks to see if a texture is used in the material.
  48755. * @param texture - Base texture to use.
  48756. * @returns - Boolean specifying if a texture is used in the material.
  48757. */
  48758. hasTexture(texture: BaseTexture): boolean;
  48759. /**
  48760. * Returns an array of the actively used textures.
  48761. * @param activeTextures Array of BaseTextures
  48762. */
  48763. getActiveTextures(activeTextures: BaseTexture[]): void;
  48764. /**
  48765. * Returns the animatable textures.
  48766. * @param animatables Array of animatable textures.
  48767. */
  48768. getAnimatables(animatables: IAnimatable[]): void;
  48769. /**
  48770. * Disposes the resources of the material.
  48771. * @param forceDisposeTextures - Forces the disposal of all textures.
  48772. */
  48773. dispose(forceDisposeTextures?: boolean): void;
  48774. /**
  48775. * Get the current class name of the texture useful for serialization or dynamic coding.
  48776. * @returns "PBRAnisotropicConfiguration"
  48777. */
  48778. getClassName(): string;
  48779. /**
  48780. * Add fallbacks to the effect fallbacks list.
  48781. * @param defines defines the Base texture to use.
  48782. * @param fallbacks defines the current fallback list.
  48783. * @param currentRank defines the current fallback rank.
  48784. * @returns the new fallback rank.
  48785. */
  48786. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48787. /**
  48788. * Add the required uniforms to the current list.
  48789. * @param uniforms defines the current uniform list.
  48790. */
  48791. static AddUniforms(uniforms: string[]): void;
  48792. /**
  48793. * Add the required uniforms to the current buffer.
  48794. * @param uniformBuffer defines the current uniform buffer.
  48795. */
  48796. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48797. /**
  48798. * Add the required samplers to the current list.
  48799. * @param samplers defines the current sampler list.
  48800. */
  48801. static AddSamplers(samplers: string[]): void;
  48802. /**
  48803. * Makes a duplicate of the current configuration into another one.
  48804. * @param anisotropicConfiguration define the config where to copy the info
  48805. */
  48806. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48807. /**
  48808. * Serializes this anisotropy configuration.
  48809. * @returns - An object with the serialized config.
  48810. */
  48811. serialize(): any;
  48812. /**
  48813. * Parses a anisotropy Configuration from a serialized object.
  48814. * @param source - Serialized object.
  48815. * @param scene Defines the scene we are parsing for
  48816. * @param rootUrl Defines the rootUrl to load from
  48817. */
  48818. parse(source: any, scene: Scene, rootUrl: string): void;
  48819. }
  48820. }
  48821. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48822. import { Scene } from "babylonjs/scene";
  48823. /**
  48824. * @hidden
  48825. */
  48826. export interface IMaterialBRDFDefines {
  48827. BRDF_V_HEIGHT_CORRELATED: boolean;
  48828. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48829. SPHERICAL_HARMONICS: boolean;
  48830. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48831. /** @hidden */
  48832. _areMiscDirty: boolean;
  48833. }
  48834. /**
  48835. * Define the code related to the BRDF parameters of the pbr material.
  48836. */
  48837. export class PBRBRDFConfiguration {
  48838. /**
  48839. * Default value used for the energy conservation.
  48840. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48841. */
  48842. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48843. /**
  48844. * Default value used for the Smith Visibility Height Correlated mode.
  48845. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48846. */
  48847. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48848. /**
  48849. * Default value used for the IBL diffuse part.
  48850. * This can help switching back to the polynomials mode globally which is a tiny bit
  48851. * less GPU intensive at the drawback of a lower quality.
  48852. */
  48853. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48854. /**
  48855. * Default value used for activating energy conservation for the specular workflow.
  48856. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48857. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48858. */
  48859. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48860. private _useEnergyConservation;
  48861. /**
  48862. * Defines if the material uses energy conservation.
  48863. */
  48864. useEnergyConservation: boolean;
  48865. private _useSmithVisibilityHeightCorrelated;
  48866. /**
  48867. * LEGACY Mode set to false
  48868. * Defines if the material uses height smith correlated visibility term.
  48869. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48870. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48871. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48872. * Not relying on height correlated will also disable energy conservation.
  48873. */
  48874. useSmithVisibilityHeightCorrelated: boolean;
  48875. private _useSphericalHarmonics;
  48876. /**
  48877. * LEGACY Mode set to false
  48878. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48879. * diffuse part of the IBL.
  48880. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48881. * to the ground truth.
  48882. */
  48883. useSphericalHarmonics: boolean;
  48884. private _useSpecularGlossinessInputEnergyConservation;
  48885. /**
  48886. * Defines if the material uses energy conservation, when the specular workflow is active.
  48887. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48888. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48889. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48890. */
  48891. useSpecularGlossinessInputEnergyConservation: boolean;
  48892. /** @hidden */
  48893. private _internalMarkAllSubMeshesAsMiscDirty;
  48894. /** @hidden */
  48895. _markAllSubMeshesAsMiscDirty(): void;
  48896. /**
  48897. * Instantiate a new istance of clear coat configuration.
  48898. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48899. */
  48900. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48901. /**
  48902. * Checks to see if a texture is used in the material.
  48903. * @param defines the list of "defines" to update.
  48904. */
  48905. prepareDefines(defines: IMaterialBRDFDefines): void;
  48906. /**
  48907. * Get the current class name of the texture useful for serialization or dynamic coding.
  48908. * @returns "PBRClearCoatConfiguration"
  48909. */
  48910. getClassName(): string;
  48911. /**
  48912. * Makes a duplicate of the current configuration into another one.
  48913. * @param brdfConfiguration define the config where to copy the info
  48914. */
  48915. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48916. /**
  48917. * Serializes this BRDF configuration.
  48918. * @returns - An object with the serialized config.
  48919. */
  48920. serialize(): any;
  48921. /**
  48922. * Parses a anisotropy Configuration from a serialized object.
  48923. * @param source - Serialized object.
  48924. * @param scene Defines the scene we are parsing for
  48925. * @param rootUrl Defines the rootUrl to load from
  48926. */
  48927. parse(source: any, scene: Scene, rootUrl: string): void;
  48928. }
  48929. }
  48930. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48931. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48932. import { Color3 } from "babylonjs/Maths/math.color";
  48933. import { Scene } from "babylonjs/scene";
  48934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48935. import { Nullable } from "babylonjs/types";
  48936. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48937. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48938. /**
  48939. * @hidden
  48940. */
  48941. export interface IMaterialSheenDefines {
  48942. SHEEN: boolean;
  48943. SHEEN_TEXTURE: boolean;
  48944. SHEEN_TEXTUREDIRECTUV: number;
  48945. SHEEN_LINKWITHALBEDO: boolean;
  48946. /** @hidden */
  48947. _areTexturesDirty: boolean;
  48948. }
  48949. /**
  48950. * Define the code related to the Sheen parameters of the pbr material.
  48951. */
  48952. export class PBRSheenConfiguration {
  48953. private _isEnabled;
  48954. /**
  48955. * Defines if the material uses sheen.
  48956. */
  48957. isEnabled: boolean;
  48958. private _linkSheenWithAlbedo;
  48959. /**
  48960. * Defines if the sheen is linked to the sheen color.
  48961. */
  48962. linkSheenWithAlbedo: boolean;
  48963. /**
  48964. * Defines the sheen intensity.
  48965. */
  48966. intensity: number;
  48967. /**
  48968. * Defines the sheen color.
  48969. */
  48970. color: Color3;
  48971. private _texture;
  48972. /**
  48973. * Stores the sheen tint values in a texture.
  48974. * rgb is tint
  48975. * a is a intensity
  48976. */
  48977. texture: Nullable<BaseTexture>;
  48978. /** @hidden */
  48979. private _internalMarkAllSubMeshesAsTexturesDirty;
  48980. /** @hidden */
  48981. _markAllSubMeshesAsTexturesDirty(): void;
  48982. /**
  48983. * Instantiate a new istance of clear coat configuration.
  48984. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48985. */
  48986. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48987. /**
  48988. * Specifies that the submesh is ready to be used.
  48989. * @param defines the list of "defines" to update.
  48990. * @param scene defines the scene the material belongs to.
  48991. * @returns - boolean indicating that the submesh is ready or not.
  48992. */
  48993. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48994. /**
  48995. * Checks to see if a texture is used in the material.
  48996. * @param defines the list of "defines" to update.
  48997. * @param scene defines the scene the material belongs to.
  48998. */
  48999. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  49000. /**
  49001. * Binds the material data.
  49002. * @param uniformBuffer defines the Uniform buffer to fill in.
  49003. * @param scene defines the scene the material belongs to.
  49004. * @param isFrozen defines wether the material is frozen or not.
  49005. */
  49006. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  49007. /**
  49008. * Checks to see if a texture is used in the material.
  49009. * @param texture - Base texture to use.
  49010. * @returns - Boolean specifying if a texture is used in the material.
  49011. */
  49012. hasTexture(texture: BaseTexture): boolean;
  49013. /**
  49014. * Returns an array of the actively used textures.
  49015. * @param activeTextures Array of BaseTextures
  49016. */
  49017. getActiveTextures(activeTextures: BaseTexture[]): void;
  49018. /**
  49019. * Returns the animatable textures.
  49020. * @param animatables Array of animatable textures.
  49021. */
  49022. getAnimatables(animatables: IAnimatable[]): void;
  49023. /**
  49024. * Disposes the resources of the material.
  49025. * @param forceDisposeTextures - Forces the disposal of all textures.
  49026. */
  49027. dispose(forceDisposeTextures?: boolean): void;
  49028. /**
  49029. * Get the current class name of the texture useful for serialization or dynamic coding.
  49030. * @returns "PBRSheenConfiguration"
  49031. */
  49032. getClassName(): string;
  49033. /**
  49034. * Add fallbacks to the effect fallbacks list.
  49035. * @param defines defines the Base texture to use.
  49036. * @param fallbacks defines the current fallback list.
  49037. * @param currentRank defines the current fallback rank.
  49038. * @returns the new fallback rank.
  49039. */
  49040. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49041. /**
  49042. * Add the required uniforms to the current list.
  49043. * @param uniforms defines the current uniform list.
  49044. */
  49045. static AddUniforms(uniforms: string[]): void;
  49046. /**
  49047. * Add the required uniforms to the current buffer.
  49048. * @param uniformBuffer defines the current uniform buffer.
  49049. */
  49050. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49051. /**
  49052. * Add the required samplers to the current list.
  49053. * @param samplers defines the current sampler list.
  49054. */
  49055. static AddSamplers(samplers: string[]): void;
  49056. /**
  49057. * Makes a duplicate of the current configuration into another one.
  49058. * @param sheenConfiguration define the config where to copy the info
  49059. */
  49060. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49061. /**
  49062. * Serializes this BRDF configuration.
  49063. * @returns - An object with the serialized config.
  49064. */
  49065. serialize(): any;
  49066. /**
  49067. * Parses a anisotropy Configuration from a serialized object.
  49068. * @param source - Serialized object.
  49069. * @param scene Defines the scene we are parsing for
  49070. * @param rootUrl Defines the rootUrl to load from
  49071. */
  49072. parse(source: any, scene: Scene, rootUrl: string): void;
  49073. }
  49074. }
  49075. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49076. import { Nullable } from "babylonjs/types";
  49077. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49078. import { Color3 } from "babylonjs/Maths/math.color";
  49079. import { SmartArray } from "babylonjs/Misc/smartArray";
  49080. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49081. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49082. import { Effect } from "babylonjs/Materials/effect";
  49083. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49084. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49085. import { Engine } from "babylonjs/Engines/engine";
  49086. import { Scene } from "babylonjs/scene";
  49087. /**
  49088. * @hidden
  49089. */
  49090. export interface IMaterialSubSurfaceDefines {
  49091. SUBSURFACE: boolean;
  49092. SS_REFRACTION: boolean;
  49093. SS_TRANSLUCENCY: boolean;
  49094. SS_SCATERRING: boolean;
  49095. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49096. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49097. SS_REFRACTIONMAP_3D: boolean;
  49098. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49099. SS_LODINREFRACTIONALPHA: boolean;
  49100. SS_GAMMAREFRACTION: boolean;
  49101. SS_RGBDREFRACTION: boolean;
  49102. SS_LINEARSPECULARREFRACTION: boolean;
  49103. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49104. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49105. /** @hidden */
  49106. _areTexturesDirty: boolean;
  49107. }
  49108. /**
  49109. * Define the code related to the sub surface parameters of the pbr material.
  49110. */
  49111. export class PBRSubSurfaceConfiguration {
  49112. private _isRefractionEnabled;
  49113. /**
  49114. * Defines if the refraction is enabled in the material.
  49115. */
  49116. isRefractionEnabled: boolean;
  49117. private _isTranslucencyEnabled;
  49118. /**
  49119. * Defines if the translucency is enabled in the material.
  49120. */
  49121. isTranslucencyEnabled: boolean;
  49122. private _isScatteringEnabled;
  49123. /**
  49124. * Defines the refraction intensity of the material.
  49125. * The refraction when enabled replaces the Diffuse part of the material.
  49126. * The intensity helps transitionning between diffuse and refraction.
  49127. */
  49128. refractionIntensity: number;
  49129. /**
  49130. * Defines the translucency intensity of the material.
  49131. * When translucency has been enabled, this defines how much of the "translucency"
  49132. * is addded to the diffuse part of the material.
  49133. */
  49134. translucencyIntensity: number;
  49135. /**
  49136. * Defines the scattering intensity of the material.
  49137. * When scattering has been enabled, this defines how much of the "scattered light"
  49138. * is addded to the diffuse part of the material.
  49139. */
  49140. scatteringIntensity: number;
  49141. private _thicknessTexture;
  49142. /**
  49143. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49144. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49145. * 0 would mean minimumThickness
  49146. * 1 would mean maximumThickness
  49147. * The other channels might be use as a mask to vary the different effects intensity.
  49148. */
  49149. thicknessTexture: Nullable<BaseTexture>;
  49150. private _refractionTexture;
  49151. /**
  49152. * Defines the texture to use for refraction.
  49153. */
  49154. refractionTexture: Nullable<BaseTexture>;
  49155. private _indexOfRefraction;
  49156. /**
  49157. * Defines the index of refraction used in the material.
  49158. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49159. */
  49160. indexOfRefraction: number;
  49161. private _invertRefractionY;
  49162. /**
  49163. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49164. */
  49165. invertRefractionY: boolean;
  49166. private _linkRefractionWithTransparency;
  49167. /**
  49168. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49169. * Materials half opaque for instance using refraction could benefit from this control.
  49170. */
  49171. linkRefractionWithTransparency: boolean;
  49172. /**
  49173. * Defines the minimum thickness stored in the thickness map.
  49174. * If no thickness map is defined, this value will be used to simulate thickness.
  49175. */
  49176. minimumThickness: number;
  49177. /**
  49178. * Defines the maximum thickness stored in the thickness map.
  49179. */
  49180. maximumThickness: number;
  49181. /**
  49182. * Defines the volume tint of the material.
  49183. * This is used for both translucency and scattering.
  49184. */
  49185. tintColor: Color3;
  49186. /**
  49187. * Defines the distance at which the tint color should be found in the media.
  49188. * This is used for refraction only.
  49189. */
  49190. tintColorAtDistance: number;
  49191. /**
  49192. * Defines how far each channel transmit through the media.
  49193. * It is defined as a color to simplify it selection.
  49194. */
  49195. diffusionDistance: Color3;
  49196. private _useMaskFromThicknessTexture;
  49197. /**
  49198. * Stores the intensity of the different subsurface effects in the thickness texture.
  49199. * * the green channel is the translucency intensity.
  49200. * * the blue channel is the scattering intensity.
  49201. * * the alpha channel is the refraction intensity.
  49202. */
  49203. useMaskFromThicknessTexture: boolean;
  49204. /** @hidden */
  49205. private _internalMarkAllSubMeshesAsTexturesDirty;
  49206. /** @hidden */
  49207. _markAllSubMeshesAsTexturesDirty(): void;
  49208. /**
  49209. * Instantiate a new istance of sub surface configuration.
  49210. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49211. */
  49212. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49213. /**
  49214. * Gets wehter the submesh is ready to be used or not.
  49215. * @param defines the list of "defines" to update.
  49216. * @param scene defines the scene the material belongs to.
  49217. * @returns - boolean indicating that the submesh is ready or not.
  49218. */
  49219. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49220. /**
  49221. * Checks to see if a texture is used in the material.
  49222. * @param defines the list of "defines" to update.
  49223. * @param scene defines the scene to the material belongs to.
  49224. */
  49225. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49226. /**
  49227. * Binds the material data.
  49228. * @param uniformBuffer defines the Uniform buffer to fill in.
  49229. * @param scene defines the scene the material belongs to.
  49230. * @param engine defines the engine the material belongs to.
  49231. * @param isFrozen defines wether the material is frozen or not.
  49232. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49233. */
  49234. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49235. /**
  49236. * Unbinds the material from the mesh.
  49237. * @param activeEffect defines the effect that should be unbound from.
  49238. * @returns true if unbound, otherwise false
  49239. */
  49240. unbind(activeEffect: Effect): boolean;
  49241. /**
  49242. * Returns the texture used for refraction or null if none is used.
  49243. * @param scene defines the scene the material belongs to.
  49244. * @returns - Refraction texture if present. If no refraction texture and refraction
  49245. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49246. */
  49247. private _getRefractionTexture;
  49248. /**
  49249. * Returns true if alpha blending should be disabled.
  49250. */
  49251. readonly disableAlphaBlending: boolean;
  49252. /**
  49253. * Fills the list of render target textures.
  49254. * @param renderTargets the list of render targets to update
  49255. */
  49256. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49257. /**
  49258. * Checks to see if a texture is used in the material.
  49259. * @param texture - Base texture to use.
  49260. * @returns - Boolean specifying if a texture is used in the material.
  49261. */
  49262. hasTexture(texture: BaseTexture): boolean;
  49263. /**
  49264. * Gets a boolean indicating that current material needs to register RTT
  49265. * @returns true if this uses a render target otherwise false.
  49266. */
  49267. hasRenderTargetTextures(): boolean;
  49268. /**
  49269. * Returns an array of the actively used textures.
  49270. * @param activeTextures Array of BaseTextures
  49271. */
  49272. getActiveTextures(activeTextures: BaseTexture[]): void;
  49273. /**
  49274. * Returns the animatable textures.
  49275. * @param animatables Array of animatable textures.
  49276. */
  49277. getAnimatables(animatables: IAnimatable[]): void;
  49278. /**
  49279. * Disposes the resources of the material.
  49280. * @param forceDisposeTextures - Forces the disposal of all textures.
  49281. */
  49282. dispose(forceDisposeTextures?: boolean): void;
  49283. /**
  49284. * Get the current class name of the texture useful for serialization or dynamic coding.
  49285. * @returns "PBRSubSurfaceConfiguration"
  49286. */
  49287. getClassName(): string;
  49288. /**
  49289. * Add fallbacks to the effect fallbacks list.
  49290. * @param defines defines the Base texture to use.
  49291. * @param fallbacks defines the current fallback list.
  49292. * @param currentRank defines the current fallback rank.
  49293. * @returns the new fallback rank.
  49294. */
  49295. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49296. /**
  49297. * Add the required uniforms to the current list.
  49298. * @param uniforms defines the current uniform list.
  49299. */
  49300. static AddUniforms(uniforms: string[]): void;
  49301. /**
  49302. * Add the required samplers to the current list.
  49303. * @param samplers defines the current sampler list.
  49304. */
  49305. static AddSamplers(samplers: string[]): void;
  49306. /**
  49307. * Add the required uniforms to the current buffer.
  49308. * @param uniformBuffer defines the current uniform buffer.
  49309. */
  49310. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49311. /**
  49312. * Makes a duplicate of the current configuration into another one.
  49313. * @param configuration define the config where to copy the info
  49314. */
  49315. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49316. /**
  49317. * Serializes this Sub Surface configuration.
  49318. * @returns - An object with the serialized config.
  49319. */
  49320. serialize(): any;
  49321. /**
  49322. * Parses a anisotropy Configuration from a serialized object.
  49323. * @param source - Serialized object.
  49324. * @param scene Defines the scene we are parsing for
  49325. * @param rootUrl Defines the rootUrl to load from
  49326. */
  49327. parse(source: any, scene: Scene, rootUrl: string): void;
  49328. }
  49329. }
  49330. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49331. /** @hidden */
  49332. export var pbrFragmentDeclaration: {
  49333. name: string;
  49334. shader: string;
  49335. };
  49336. }
  49337. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49338. /** @hidden */
  49339. export var pbrUboDeclaration: {
  49340. name: string;
  49341. shader: string;
  49342. };
  49343. }
  49344. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49345. /** @hidden */
  49346. export var pbrFragmentExtraDeclaration: {
  49347. name: string;
  49348. shader: string;
  49349. };
  49350. }
  49351. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49352. /** @hidden */
  49353. export var pbrFragmentSamplersDeclaration: {
  49354. name: string;
  49355. shader: string;
  49356. };
  49357. }
  49358. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49359. /** @hidden */
  49360. export var pbrHelperFunctions: {
  49361. name: string;
  49362. shader: string;
  49363. };
  49364. }
  49365. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49366. /** @hidden */
  49367. export var harmonicsFunctions: {
  49368. name: string;
  49369. shader: string;
  49370. };
  49371. }
  49372. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49373. /** @hidden */
  49374. export var pbrDirectLightingSetupFunctions: {
  49375. name: string;
  49376. shader: string;
  49377. };
  49378. }
  49379. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49380. /** @hidden */
  49381. export var pbrDirectLightingFalloffFunctions: {
  49382. name: string;
  49383. shader: string;
  49384. };
  49385. }
  49386. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49387. /** @hidden */
  49388. export var pbrBRDFFunctions: {
  49389. name: string;
  49390. shader: string;
  49391. };
  49392. }
  49393. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49394. /** @hidden */
  49395. export var pbrDirectLightingFunctions: {
  49396. name: string;
  49397. shader: string;
  49398. };
  49399. }
  49400. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49401. /** @hidden */
  49402. export var pbrIBLFunctions: {
  49403. name: string;
  49404. shader: string;
  49405. };
  49406. }
  49407. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49408. /** @hidden */
  49409. export var pbrDebug: {
  49410. name: string;
  49411. shader: string;
  49412. };
  49413. }
  49414. declare module "babylonjs/Shaders/pbr.fragment" {
  49415. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49416. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49417. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49418. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49419. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49420. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49421. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49422. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49423. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49424. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49425. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49426. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49427. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49428. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49429. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49430. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49431. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49432. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49433. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49434. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49435. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49436. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49437. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49438. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49439. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49440. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49441. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49442. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49443. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49444. /** @hidden */
  49445. export var pbrPixelShader: {
  49446. name: string;
  49447. shader: string;
  49448. };
  49449. }
  49450. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49451. /** @hidden */
  49452. export var pbrVertexDeclaration: {
  49453. name: string;
  49454. shader: string;
  49455. };
  49456. }
  49457. declare module "babylonjs/Shaders/pbr.vertex" {
  49458. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49459. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49460. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49461. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49462. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49463. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49464. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49465. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49466. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49467. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49468. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49469. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49470. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49471. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49472. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49473. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49474. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49475. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49476. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49477. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49478. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49479. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49480. /** @hidden */
  49481. export var pbrVertexShader: {
  49482. name: string;
  49483. shader: string;
  49484. };
  49485. }
  49486. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49487. import { Nullable } from "babylonjs/types";
  49488. import { Scene } from "babylonjs/scene";
  49489. import { Matrix } from "babylonjs/Maths/math.vector";
  49490. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49492. import { Mesh } from "babylonjs/Meshes/mesh";
  49493. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49494. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49495. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49496. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49497. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49498. import { Color3 } from "babylonjs/Maths/math.color";
  49499. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49500. import { Material } from "babylonjs/Materials/material";
  49501. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49502. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49503. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49504. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49505. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49506. import "babylonjs/Shaders/pbr.fragment";
  49507. import "babylonjs/Shaders/pbr.vertex";
  49508. /**
  49509. * Manages the defines for the PBR Material.
  49510. * @hidden
  49511. */
  49512. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49513. PBR: boolean;
  49514. MAINUV1: boolean;
  49515. MAINUV2: boolean;
  49516. UV1: boolean;
  49517. UV2: boolean;
  49518. ALBEDO: boolean;
  49519. ALBEDODIRECTUV: number;
  49520. VERTEXCOLOR: boolean;
  49521. AMBIENT: boolean;
  49522. AMBIENTDIRECTUV: number;
  49523. AMBIENTINGRAYSCALE: boolean;
  49524. OPACITY: boolean;
  49525. VERTEXALPHA: boolean;
  49526. OPACITYDIRECTUV: number;
  49527. OPACITYRGB: boolean;
  49528. ALPHATEST: boolean;
  49529. DEPTHPREPASS: boolean;
  49530. ALPHABLEND: boolean;
  49531. ALPHAFROMALBEDO: boolean;
  49532. ALPHATESTVALUE: string;
  49533. SPECULAROVERALPHA: boolean;
  49534. RADIANCEOVERALPHA: boolean;
  49535. ALPHAFRESNEL: boolean;
  49536. LINEARALPHAFRESNEL: boolean;
  49537. PREMULTIPLYALPHA: boolean;
  49538. EMISSIVE: boolean;
  49539. EMISSIVEDIRECTUV: number;
  49540. REFLECTIVITY: boolean;
  49541. REFLECTIVITYDIRECTUV: number;
  49542. SPECULARTERM: boolean;
  49543. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49544. MICROSURFACEAUTOMATIC: boolean;
  49545. LODBASEDMICROSFURACE: boolean;
  49546. MICROSURFACEMAP: boolean;
  49547. MICROSURFACEMAPDIRECTUV: number;
  49548. METALLICWORKFLOW: boolean;
  49549. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49550. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49551. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49552. AOSTOREINMETALMAPRED: boolean;
  49553. ENVIRONMENTBRDF: boolean;
  49554. ENVIRONMENTBRDF_RGBD: boolean;
  49555. NORMAL: boolean;
  49556. TANGENT: boolean;
  49557. BUMP: boolean;
  49558. BUMPDIRECTUV: number;
  49559. OBJECTSPACE_NORMALMAP: boolean;
  49560. PARALLAX: boolean;
  49561. PARALLAXOCCLUSION: boolean;
  49562. NORMALXYSCALE: boolean;
  49563. LIGHTMAP: boolean;
  49564. LIGHTMAPDIRECTUV: number;
  49565. USELIGHTMAPASSHADOWMAP: boolean;
  49566. GAMMALIGHTMAP: boolean;
  49567. RGBDLIGHTMAP: boolean;
  49568. REFLECTION: boolean;
  49569. REFLECTIONMAP_3D: boolean;
  49570. REFLECTIONMAP_SPHERICAL: boolean;
  49571. REFLECTIONMAP_PLANAR: boolean;
  49572. REFLECTIONMAP_CUBIC: boolean;
  49573. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49574. REFLECTIONMAP_PROJECTION: boolean;
  49575. REFLECTIONMAP_SKYBOX: boolean;
  49576. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49577. REFLECTIONMAP_EXPLICIT: boolean;
  49578. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49579. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49580. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49581. INVERTCUBICMAP: boolean;
  49582. USESPHERICALFROMREFLECTIONMAP: boolean;
  49583. USEIRRADIANCEMAP: boolean;
  49584. SPHERICAL_HARMONICS: boolean;
  49585. USESPHERICALINVERTEX: boolean;
  49586. REFLECTIONMAP_OPPOSITEZ: boolean;
  49587. LODINREFLECTIONALPHA: boolean;
  49588. GAMMAREFLECTION: boolean;
  49589. RGBDREFLECTION: boolean;
  49590. LINEARSPECULARREFLECTION: boolean;
  49591. RADIANCEOCCLUSION: boolean;
  49592. HORIZONOCCLUSION: boolean;
  49593. INSTANCES: boolean;
  49594. NUM_BONE_INFLUENCERS: number;
  49595. BonesPerMesh: number;
  49596. BONETEXTURE: boolean;
  49597. NONUNIFORMSCALING: boolean;
  49598. MORPHTARGETS: boolean;
  49599. MORPHTARGETS_NORMAL: boolean;
  49600. MORPHTARGETS_TANGENT: boolean;
  49601. MORPHTARGETS_UV: boolean;
  49602. NUM_MORPH_INFLUENCERS: number;
  49603. IMAGEPROCESSING: boolean;
  49604. VIGNETTE: boolean;
  49605. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49606. VIGNETTEBLENDMODEOPAQUE: boolean;
  49607. TONEMAPPING: boolean;
  49608. TONEMAPPING_ACES: boolean;
  49609. CONTRAST: boolean;
  49610. COLORCURVES: boolean;
  49611. COLORGRADING: boolean;
  49612. COLORGRADING3D: boolean;
  49613. SAMPLER3DGREENDEPTH: boolean;
  49614. SAMPLER3DBGRMAP: boolean;
  49615. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49616. EXPOSURE: boolean;
  49617. MULTIVIEW: boolean;
  49618. USEPHYSICALLIGHTFALLOFF: boolean;
  49619. USEGLTFLIGHTFALLOFF: boolean;
  49620. TWOSIDEDLIGHTING: boolean;
  49621. SHADOWFLOAT: boolean;
  49622. CLIPPLANE: boolean;
  49623. CLIPPLANE2: boolean;
  49624. CLIPPLANE3: boolean;
  49625. CLIPPLANE4: boolean;
  49626. POINTSIZE: boolean;
  49627. FOG: boolean;
  49628. LOGARITHMICDEPTH: boolean;
  49629. FORCENORMALFORWARD: boolean;
  49630. SPECULARAA: boolean;
  49631. CLEARCOAT: boolean;
  49632. CLEARCOAT_DEFAULTIOR: boolean;
  49633. CLEARCOAT_TEXTURE: boolean;
  49634. CLEARCOAT_TEXTUREDIRECTUV: number;
  49635. CLEARCOAT_BUMP: boolean;
  49636. CLEARCOAT_BUMPDIRECTUV: number;
  49637. CLEARCOAT_TINT: boolean;
  49638. CLEARCOAT_TINT_TEXTURE: boolean;
  49639. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49640. ANISOTROPIC: boolean;
  49641. ANISOTROPIC_TEXTURE: boolean;
  49642. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49643. BRDF_V_HEIGHT_CORRELATED: boolean;
  49644. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49645. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49646. SHEEN: boolean;
  49647. SHEEN_TEXTURE: boolean;
  49648. SHEEN_TEXTUREDIRECTUV: number;
  49649. SHEEN_LINKWITHALBEDO: boolean;
  49650. SUBSURFACE: boolean;
  49651. SS_REFRACTION: boolean;
  49652. SS_TRANSLUCENCY: boolean;
  49653. SS_SCATERRING: boolean;
  49654. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49655. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49656. SS_REFRACTIONMAP_3D: boolean;
  49657. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49658. SS_LODINREFRACTIONALPHA: boolean;
  49659. SS_GAMMAREFRACTION: boolean;
  49660. SS_RGBDREFRACTION: boolean;
  49661. SS_LINEARSPECULARREFRACTION: boolean;
  49662. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49663. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49664. UNLIT: boolean;
  49665. DEBUGMODE: number;
  49666. /**
  49667. * Initializes the PBR Material defines.
  49668. */
  49669. constructor();
  49670. /**
  49671. * Resets the PBR Material defines.
  49672. */
  49673. reset(): void;
  49674. }
  49675. /**
  49676. * The Physically based material base class of BJS.
  49677. *
  49678. * This offers the main features of a standard PBR material.
  49679. * For more information, please refer to the documentation :
  49680. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49681. */
  49682. export abstract class PBRBaseMaterial extends PushMaterial {
  49683. /**
  49684. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49685. */
  49686. static readonly PBRMATERIAL_OPAQUE: number;
  49687. /**
  49688. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49689. */
  49690. static readonly PBRMATERIAL_ALPHATEST: number;
  49691. /**
  49692. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49693. */
  49694. static readonly PBRMATERIAL_ALPHABLEND: number;
  49695. /**
  49696. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49697. * They are also discarded below the alpha cutoff threshold to improve performances.
  49698. */
  49699. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49700. /**
  49701. * Defines the default value of how much AO map is occluding the analytical lights
  49702. * (point spot...).
  49703. */
  49704. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49705. /**
  49706. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49707. */
  49708. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49709. /**
  49710. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49711. * to enhance interoperability with other engines.
  49712. */
  49713. static readonly LIGHTFALLOFF_GLTF: number;
  49714. /**
  49715. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49716. * to enhance interoperability with other materials.
  49717. */
  49718. static readonly LIGHTFALLOFF_STANDARD: number;
  49719. /**
  49720. * Intensity of the direct lights e.g. the four lights available in your scene.
  49721. * This impacts both the direct diffuse and specular highlights.
  49722. */
  49723. protected _directIntensity: number;
  49724. /**
  49725. * Intensity of the emissive part of the material.
  49726. * This helps controlling the emissive effect without modifying the emissive color.
  49727. */
  49728. protected _emissiveIntensity: number;
  49729. /**
  49730. * Intensity of the environment e.g. how much the environment will light the object
  49731. * either through harmonics for rough material or through the refelction for shiny ones.
  49732. */
  49733. protected _environmentIntensity: number;
  49734. /**
  49735. * This is a special control allowing the reduction of the specular highlights coming from the
  49736. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49737. */
  49738. protected _specularIntensity: number;
  49739. /**
  49740. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49741. */
  49742. private _lightingInfos;
  49743. /**
  49744. * Debug Control allowing disabling the bump map on this material.
  49745. */
  49746. protected _disableBumpMap: boolean;
  49747. /**
  49748. * AKA Diffuse Texture in standard nomenclature.
  49749. */
  49750. protected _albedoTexture: Nullable<BaseTexture>;
  49751. /**
  49752. * AKA Occlusion Texture in other nomenclature.
  49753. */
  49754. protected _ambientTexture: Nullable<BaseTexture>;
  49755. /**
  49756. * AKA Occlusion Texture Intensity in other nomenclature.
  49757. */
  49758. protected _ambientTextureStrength: number;
  49759. /**
  49760. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49761. * 1 means it completely occludes it
  49762. * 0 mean it has no impact
  49763. */
  49764. protected _ambientTextureImpactOnAnalyticalLights: number;
  49765. /**
  49766. * Stores the alpha values in a texture.
  49767. */
  49768. protected _opacityTexture: Nullable<BaseTexture>;
  49769. /**
  49770. * Stores the reflection values in a texture.
  49771. */
  49772. protected _reflectionTexture: Nullable<BaseTexture>;
  49773. /**
  49774. * Stores the emissive values in a texture.
  49775. */
  49776. protected _emissiveTexture: Nullable<BaseTexture>;
  49777. /**
  49778. * AKA Specular texture in other nomenclature.
  49779. */
  49780. protected _reflectivityTexture: Nullable<BaseTexture>;
  49781. /**
  49782. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49783. */
  49784. protected _metallicTexture: Nullable<BaseTexture>;
  49785. /**
  49786. * Specifies the metallic scalar of the metallic/roughness workflow.
  49787. * Can also be used to scale the metalness values of the metallic texture.
  49788. */
  49789. protected _metallic: Nullable<number>;
  49790. /**
  49791. * Specifies the roughness scalar of the metallic/roughness workflow.
  49792. * Can also be used to scale the roughness values of the metallic texture.
  49793. */
  49794. protected _roughness: Nullable<number>;
  49795. /**
  49796. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49797. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49798. */
  49799. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49800. /**
  49801. * Stores surface normal data used to displace a mesh in a texture.
  49802. */
  49803. protected _bumpTexture: Nullable<BaseTexture>;
  49804. /**
  49805. * Stores the pre-calculated light information of a mesh in a texture.
  49806. */
  49807. protected _lightmapTexture: Nullable<BaseTexture>;
  49808. /**
  49809. * The color of a material in ambient lighting.
  49810. */
  49811. protected _ambientColor: Color3;
  49812. /**
  49813. * AKA Diffuse Color in other nomenclature.
  49814. */
  49815. protected _albedoColor: Color3;
  49816. /**
  49817. * AKA Specular Color in other nomenclature.
  49818. */
  49819. protected _reflectivityColor: Color3;
  49820. /**
  49821. * The color applied when light is reflected from a material.
  49822. */
  49823. protected _reflectionColor: Color3;
  49824. /**
  49825. * The color applied when light is emitted from a material.
  49826. */
  49827. protected _emissiveColor: Color3;
  49828. /**
  49829. * AKA Glossiness in other nomenclature.
  49830. */
  49831. protected _microSurface: number;
  49832. /**
  49833. * Specifies that the material will use the light map as a show map.
  49834. */
  49835. protected _useLightmapAsShadowmap: boolean;
  49836. /**
  49837. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49838. * makes the reflect vector face the model (under horizon).
  49839. */
  49840. protected _useHorizonOcclusion: boolean;
  49841. /**
  49842. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49843. * too much the area relying on ambient texture to define their ambient occlusion.
  49844. */
  49845. protected _useRadianceOcclusion: boolean;
  49846. /**
  49847. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49848. */
  49849. protected _useAlphaFromAlbedoTexture: boolean;
  49850. /**
  49851. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49852. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49853. */
  49854. protected _useSpecularOverAlpha: boolean;
  49855. /**
  49856. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49857. */
  49858. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49859. /**
  49860. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49861. */
  49862. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49863. /**
  49864. * Specifies if the metallic texture contains the roughness information in its green channel.
  49865. */
  49866. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49867. /**
  49868. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49869. */
  49870. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49871. /**
  49872. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49873. */
  49874. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49875. /**
  49876. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49877. */
  49878. protected _useAmbientInGrayScale: boolean;
  49879. /**
  49880. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49881. * The material will try to infer what glossiness each pixel should be.
  49882. */
  49883. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49884. /**
  49885. * Defines the falloff type used in this material.
  49886. * It by default is Physical.
  49887. */
  49888. protected _lightFalloff: number;
  49889. /**
  49890. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49891. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49892. */
  49893. protected _useRadianceOverAlpha: boolean;
  49894. /**
  49895. * Allows using an object space normal map (instead of tangent space).
  49896. */
  49897. protected _useObjectSpaceNormalMap: boolean;
  49898. /**
  49899. * Allows using the bump map in parallax mode.
  49900. */
  49901. protected _useParallax: boolean;
  49902. /**
  49903. * Allows using the bump map in parallax occlusion mode.
  49904. */
  49905. protected _useParallaxOcclusion: boolean;
  49906. /**
  49907. * Controls the scale bias of the parallax mode.
  49908. */
  49909. protected _parallaxScaleBias: number;
  49910. /**
  49911. * If sets to true, disables all the lights affecting the material.
  49912. */
  49913. protected _disableLighting: boolean;
  49914. /**
  49915. * Number of Simultaneous lights allowed on the material.
  49916. */
  49917. protected _maxSimultaneousLights: number;
  49918. /**
  49919. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49920. */
  49921. protected _invertNormalMapX: boolean;
  49922. /**
  49923. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49924. */
  49925. protected _invertNormalMapY: boolean;
  49926. /**
  49927. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49928. */
  49929. protected _twoSidedLighting: boolean;
  49930. /**
  49931. * Defines the alpha limits in alpha test mode.
  49932. */
  49933. protected _alphaCutOff: number;
  49934. /**
  49935. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49936. */
  49937. protected _forceAlphaTest: boolean;
  49938. /**
  49939. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49940. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49941. */
  49942. protected _useAlphaFresnel: boolean;
  49943. /**
  49944. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49945. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49946. */
  49947. protected _useLinearAlphaFresnel: boolean;
  49948. /**
  49949. * The transparency mode of the material.
  49950. */
  49951. protected _transparencyMode: Nullable<number>;
  49952. /**
  49953. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49954. * from cos thetav and roughness:
  49955. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49956. */
  49957. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49958. /**
  49959. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49960. */
  49961. protected _forceIrradianceInFragment: boolean;
  49962. /**
  49963. * Force normal to face away from face.
  49964. */
  49965. protected _forceNormalForward: boolean;
  49966. /**
  49967. * Enables specular anti aliasing in the PBR shader.
  49968. * It will both interacts on the Geometry for analytical and IBL lighting.
  49969. * It also prefilter the roughness map based on the bump values.
  49970. */
  49971. protected _enableSpecularAntiAliasing: boolean;
  49972. /**
  49973. * Default configuration related to image processing available in the PBR Material.
  49974. */
  49975. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49976. /**
  49977. * Keep track of the image processing observer to allow dispose and replace.
  49978. */
  49979. private _imageProcessingObserver;
  49980. /**
  49981. * Attaches a new image processing configuration to the PBR Material.
  49982. * @param configuration
  49983. */
  49984. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49985. /**
  49986. * Stores the available render targets.
  49987. */
  49988. private _renderTargets;
  49989. /**
  49990. * Sets the global ambient color for the material used in lighting calculations.
  49991. */
  49992. private _globalAmbientColor;
  49993. /**
  49994. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49995. */
  49996. private _useLogarithmicDepth;
  49997. /**
  49998. * If set to true, no lighting calculations will be applied.
  49999. */
  50000. private _unlit;
  50001. private _debugMode;
  50002. /**
  50003. * @hidden
  50004. * This is reserved for the inspector.
  50005. * Defines the material debug mode.
  50006. * It helps seeing only some components of the material while troubleshooting.
  50007. */
  50008. debugMode: number;
  50009. /**
  50010. * @hidden
  50011. * This is reserved for the inspector.
  50012. * Specify from where on screen the debug mode should start.
  50013. * The value goes from -1 (full screen) to 1 (not visible)
  50014. * It helps with side by side comparison against the final render
  50015. * This defaults to -1
  50016. */
  50017. private debugLimit;
  50018. /**
  50019. * @hidden
  50020. * This is reserved for the inspector.
  50021. * As the default viewing range might not be enough (if the ambient is really small for instance)
  50022. * You can use the factor to better multiply the final value.
  50023. */
  50024. private debugFactor;
  50025. /**
  50026. * Defines the clear coat layer parameters for the material.
  50027. */
  50028. readonly clearCoat: PBRClearCoatConfiguration;
  50029. /**
  50030. * Defines the anisotropic parameters for the material.
  50031. */
  50032. readonly anisotropy: PBRAnisotropicConfiguration;
  50033. /**
  50034. * Defines the BRDF parameters for the material.
  50035. */
  50036. readonly brdf: PBRBRDFConfiguration;
  50037. /**
  50038. * Defines the Sheen parameters for the material.
  50039. */
  50040. readonly sheen: PBRSheenConfiguration;
  50041. /**
  50042. * Defines the SubSurface parameters for the material.
  50043. */
  50044. readonly subSurface: PBRSubSurfaceConfiguration;
  50045. /**
  50046. * Custom callback helping to override the default shader used in the material.
  50047. */
  50048. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50049. protected _rebuildInParallel: boolean;
  50050. /**
  50051. * Instantiates a new PBRMaterial instance.
  50052. *
  50053. * @param name The material name
  50054. * @param scene The scene the material will be use in.
  50055. */
  50056. constructor(name: string, scene: Scene);
  50057. /**
  50058. * Gets a boolean indicating that current material needs to register RTT
  50059. */
  50060. readonly hasRenderTargetTextures: boolean;
  50061. /**
  50062. * Gets the name of the material class.
  50063. */
  50064. getClassName(): string;
  50065. /**
  50066. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50067. */
  50068. /**
  50069. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50070. */
  50071. useLogarithmicDepth: boolean;
  50072. /**
  50073. * Gets the current transparency mode.
  50074. */
  50075. /**
  50076. * Sets the transparency mode of the material.
  50077. *
  50078. * | Value | Type | Description |
  50079. * | ----- | ----------------------------------- | ----------- |
  50080. * | 0 | OPAQUE | |
  50081. * | 1 | ALPHATEST | |
  50082. * | 2 | ALPHABLEND | |
  50083. * | 3 | ALPHATESTANDBLEND | |
  50084. *
  50085. */
  50086. transparencyMode: Nullable<number>;
  50087. /**
  50088. * Returns true if alpha blending should be disabled.
  50089. */
  50090. private readonly _disableAlphaBlending;
  50091. /**
  50092. * Specifies whether or not this material should be rendered in alpha blend mode.
  50093. */
  50094. needAlphaBlending(): boolean;
  50095. /**
  50096. * Specifies if the mesh will require alpha blending.
  50097. * @param mesh - BJS mesh.
  50098. */
  50099. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50100. /**
  50101. * Specifies whether or not this material should be rendered in alpha test mode.
  50102. */
  50103. needAlphaTesting(): boolean;
  50104. /**
  50105. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50106. */
  50107. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50108. /**
  50109. * Gets the texture used for the alpha test.
  50110. */
  50111. getAlphaTestTexture(): Nullable<BaseTexture>;
  50112. /**
  50113. * Specifies that the submesh is ready to be used.
  50114. * @param mesh - BJS mesh.
  50115. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50116. * @param useInstances - Specifies that instances should be used.
  50117. * @returns - boolean indicating that the submesh is ready or not.
  50118. */
  50119. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50120. /**
  50121. * Specifies if the material uses metallic roughness workflow.
  50122. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50123. */
  50124. isMetallicWorkflow(): boolean;
  50125. private _prepareEffect;
  50126. private _prepareDefines;
  50127. /**
  50128. * Force shader compilation
  50129. */
  50130. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50131. clipPlane: boolean;
  50132. }>): void;
  50133. /**
  50134. * Initializes the uniform buffer layout for the shader.
  50135. */
  50136. buildUniformLayout(): void;
  50137. /**
  50138. * Unbinds the material from the mesh
  50139. */
  50140. unbind(): void;
  50141. /**
  50142. * Binds the submesh data.
  50143. * @param world - The world matrix.
  50144. * @param mesh - The BJS mesh.
  50145. * @param subMesh - A submesh of the BJS mesh.
  50146. */
  50147. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50148. /**
  50149. * Returns the animatable textures.
  50150. * @returns - Array of animatable textures.
  50151. */
  50152. getAnimatables(): IAnimatable[];
  50153. /**
  50154. * Returns the texture used for reflections.
  50155. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50156. */
  50157. private _getReflectionTexture;
  50158. /**
  50159. * Returns an array of the actively used textures.
  50160. * @returns - Array of BaseTextures
  50161. */
  50162. getActiveTextures(): BaseTexture[];
  50163. /**
  50164. * Checks to see if a texture is used in the material.
  50165. * @param texture - Base texture to use.
  50166. * @returns - Boolean specifying if a texture is used in the material.
  50167. */
  50168. hasTexture(texture: BaseTexture): boolean;
  50169. /**
  50170. * Disposes the resources of the material.
  50171. * @param forceDisposeEffect - Forces the disposal of effects.
  50172. * @param forceDisposeTextures - Forces the disposal of all textures.
  50173. */
  50174. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50175. }
  50176. }
  50177. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50178. import { Nullable } from "babylonjs/types";
  50179. import { Scene } from "babylonjs/scene";
  50180. import { Color3 } from "babylonjs/Maths/math.color";
  50181. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50182. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50184. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50185. /**
  50186. * The Physically based material of BJS.
  50187. *
  50188. * This offers the main features of a standard PBR material.
  50189. * For more information, please refer to the documentation :
  50190. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50191. */
  50192. export class PBRMaterial extends PBRBaseMaterial {
  50193. /**
  50194. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50195. */
  50196. static readonly PBRMATERIAL_OPAQUE: number;
  50197. /**
  50198. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50199. */
  50200. static readonly PBRMATERIAL_ALPHATEST: number;
  50201. /**
  50202. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50203. */
  50204. static readonly PBRMATERIAL_ALPHABLEND: number;
  50205. /**
  50206. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50207. * They are also discarded below the alpha cutoff threshold to improve performances.
  50208. */
  50209. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50210. /**
  50211. * Defines the default value of how much AO map is occluding the analytical lights
  50212. * (point spot...).
  50213. */
  50214. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50215. /**
  50216. * Intensity of the direct lights e.g. the four lights available in your scene.
  50217. * This impacts both the direct diffuse and specular highlights.
  50218. */
  50219. directIntensity: number;
  50220. /**
  50221. * Intensity of the emissive part of the material.
  50222. * This helps controlling the emissive effect without modifying the emissive color.
  50223. */
  50224. emissiveIntensity: number;
  50225. /**
  50226. * Intensity of the environment e.g. how much the environment will light the object
  50227. * either through harmonics for rough material or through the refelction for shiny ones.
  50228. */
  50229. environmentIntensity: number;
  50230. /**
  50231. * This is a special control allowing the reduction of the specular highlights coming from the
  50232. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50233. */
  50234. specularIntensity: number;
  50235. /**
  50236. * Debug Control allowing disabling the bump map on this material.
  50237. */
  50238. disableBumpMap: boolean;
  50239. /**
  50240. * AKA Diffuse Texture in standard nomenclature.
  50241. */
  50242. albedoTexture: BaseTexture;
  50243. /**
  50244. * AKA Occlusion Texture in other nomenclature.
  50245. */
  50246. ambientTexture: BaseTexture;
  50247. /**
  50248. * AKA Occlusion Texture Intensity in other nomenclature.
  50249. */
  50250. ambientTextureStrength: number;
  50251. /**
  50252. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50253. * 1 means it completely occludes it
  50254. * 0 mean it has no impact
  50255. */
  50256. ambientTextureImpactOnAnalyticalLights: number;
  50257. /**
  50258. * Stores the alpha values in a texture.
  50259. */
  50260. opacityTexture: BaseTexture;
  50261. /**
  50262. * Stores the reflection values in a texture.
  50263. */
  50264. reflectionTexture: Nullable<BaseTexture>;
  50265. /**
  50266. * Stores the emissive values in a texture.
  50267. */
  50268. emissiveTexture: BaseTexture;
  50269. /**
  50270. * AKA Specular texture in other nomenclature.
  50271. */
  50272. reflectivityTexture: BaseTexture;
  50273. /**
  50274. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50275. */
  50276. metallicTexture: BaseTexture;
  50277. /**
  50278. * Specifies the metallic scalar of the metallic/roughness workflow.
  50279. * Can also be used to scale the metalness values of the metallic texture.
  50280. */
  50281. metallic: Nullable<number>;
  50282. /**
  50283. * Specifies the roughness scalar of the metallic/roughness workflow.
  50284. * Can also be used to scale the roughness values of the metallic texture.
  50285. */
  50286. roughness: Nullable<number>;
  50287. /**
  50288. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50289. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50290. */
  50291. microSurfaceTexture: BaseTexture;
  50292. /**
  50293. * Stores surface normal data used to displace a mesh in a texture.
  50294. */
  50295. bumpTexture: BaseTexture;
  50296. /**
  50297. * Stores the pre-calculated light information of a mesh in a texture.
  50298. */
  50299. lightmapTexture: BaseTexture;
  50300. /**
  50301. * Stores the refracted light information in a texture.
  50302. */
  50303. refractionTexture: Nullable<BaseTexture>;
  50304. /**
  50305. * The color of a material in ambient lighting.
  50306. */
  50307. ambientColor: Color3;
  50308. /**
  50309. * AKA Diffuse Color in other nomenclature.
  50310. */
  50311. albedoColor: Color3;
  50312. /**
  50313. * AKA Specular Color in other nomenclature.
  50314. */
  50315. reflectivityColor: Color3;
  50316. /**
  50317. * The color reflected from the material.
  50318. */
  50319. reflectionColor: Color3;
  50320. /**
  50321. * The color emitted from the material.
  50322. */
  50323. emissiveColor: Color3;
  50324. /**
  50325. * AKA Glossiness in other nomenclature.
  50326. */
  50327. microSurface: number;
  50328. /**
  50329. * source material index of refraction (IOR)' / 'destination material IOR.
  50330. */
  50331. indexOfRefraction: number;
  50332. /**
  50333. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50334. */
  50335. invertRefractionY: boolean;
  50336. /**
  50337. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50338. * Materials half opaque for instance using refraction could benefit from this control.
  50339. */
  50340. linkRefractionWithTransparency: boolean;
  50341. /**
  50342. * If true, the light map contains occlusion information instead of lighting info.
  50343. */
  50344. useLightmapAsShadowmap: boolean;
  50345. /**
  50346. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50347. */
  50348. useAlphaFromAlbedoTexture: boolean;
  50349. /**
  50350. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50351. */
  50352. forceAlphaTest: boolean;
  50353. /**
  50354. * Defines the alpha limits in alpha test mode.
  50355. */
  50356. alphaCutOff: number;
  50357. /**
  50358. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50359. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50360. */
  50361. useSpecularOverAlpha: boolean;
  50362. /**
  50363. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50364. */
  50365. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50366. /**
  50367. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50368. */
  50369. useRoughnessFromMetallicTextureAlpha: boolean;
  50370. /**
  50371. * Specifies if the metallic texture contains the roughness information in its green channel.
  50372. */
  50373. useRoughnessFromMetallicTextureGreen: boolean;
  50374. /**
  50375. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50376. */
  50377. useMetallnessFromMetallicTextureBlue: boolean;
  50378. /**
  50379. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50380. */
  50381. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50382. /**
  50383. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50384. */
  50385. useAmbientInGrayScale: boolean;
  50386. /**
  50387. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50388. * The material will try to infer what glossiness each pixel should be.
  50389. */
  50390. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50391. /**
  50392. * BJS is using an harcoded light falloff based on a manually sets up range.
  50393. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50394. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50395. */
  50396. /**
  50397. * BJS is using an harcoded light falloff based on a manually sets up range.
  50398. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50399. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50400. */
  50401. usePhysicalLightFalloff: boolean;
  50402. /**
  50403. * In order to support the falloff compatibility with gltf, a special mode has been added
  50404. * to reproduce the gltf light falloff.
  50405. */
  50406. /**
  50407. * In order to support the falloff compatibility with gltf, a special mode has been added
  50408. * to reproduce the gltf light falloff.
  50409. */
  50410. useGLTFLightFalloff: boolean;
  50411. /**
  50412. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50413. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50414. */
  50415. useRadianceOverAlpha: boolean;
  50416. /**
  50417. * Allows using an object space normal map (instead of tangent space).
  50418. */
  50419. useObjectSpaceNormalMap: boolean;
  50420. /**
  50421. * Allows using the bump map in parallax mode.
  50422. */
  50423. useParallax: boolean;
  50424. /**
  50425. * Allows using the bump map in parallax occlusion mode.
  50426. */
  50427. useParallaxOcclusion: boolean;
  50428. /**
  50429. * Controls the scale bias of the parallax mode.
  50430. */
  50431. parallaxScaleBias: number;
  50432. /**
  50433. * If sets to true, disables all the lights affecting the material.
  50434. */
  50435. disableLighting: boolean;
  50436. /**
  50437. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50438. */
  50439. forceIrradianceInFragment: boolean;
  50440. /**
  50441. * Number of Simultaneous lights allowed on the material.
  50442. */
  50443. maxSimultaneousLights: number;
  50444. /**
  50445. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50446. */
  50447. invertNormalMapX: boolean;
  50448. /**
  50449. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50450. */
  50451. invertNormalMapY: boolean;
  50452. /**
  50453. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50454. */
  50455. twoSidedLighting: boolean;
  50456. /**
  50457. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50458. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50459. */
  50460. useAlphaFresnel: boolean;
  50461. /**
  50462. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50463. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50464. */
  50465. useLinearAlphaFresnel: boolean;
  50466. /**
  50467. * Let user defines the brdf lookup texture used for IBL.
  50468. * A default 8bit version is embedded but you could point at :
  50469. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50470. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50471. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50472. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50473. */
  50474. environmentBRDFTexture: Nullable<BaseTexture>;
  50475. /**
  50476. * Force normal to face away from face.
  50477. */
  50478. forceNormalForward: boolean;
  50479. /**
  50480. * Enables specular anti aliasing in the PBR shader.
  50481. * It will both interacts on the Geometry for analytical and IBL lighting.
  50482. * It also prefilter the roughness map based on the bump values.
  50483. */
  50484. enableSpecularAntiAliasing: boolean;
  50485. /**
  50486. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50487. * makes the reflect vector face the model (under horizon).
  50488. */
  50489. useHorizonOcclusion: boolean;
  50490. /**
  50491. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50492. * too much the area relying on ambient texture to define their ambient occlusion.
  50493. */
  50494. useRadianceOcclusion: boolean;
  50495. /**
  50496. * If set to true, no lighting calculations will be applied.
  50497. */
  50498. unlit: boolean;
  50499. /**
  50500. * Gets the image processing configuration used either in this material.
  50501. */
  50502. /**
  50503. * Sets the Default image processing configuration used either in the this material.
  50504. *
  50505. * If sets to null, the scene one is in use.
  50506. */
  50507. imageProcessingConfiguration: ImageProcessingConfiguration;
  50508. /**
  50509. * Gets wether the color curves effect is enabled.
  50510. */
  50511. /**
  50512. * Sets wether the color curves effect is enabled.
  50513. */
  50514. cameraColorCurvesEnabled: boolean;
  50515. /**
  50516. * Gets wether the color grading effect is enabled.
  50517. */
  50518. /**
  50519. * Gets wether the color grading effect is enabled.
  50520. */
  50521. cameraColorGradingEnabled: boolean;
  50522. /**
  50523. * Gets wether tonemapping is enabled or not.
  50524. */
  50525. /**
  50526. * Sets wether tonemapping is enabled or not
  50527. */
  50528. cameraToneMappingEnabled: boolean;
  50529. /**
  50530. * The camera exposure used on this material.
  50531. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50532. * This corresponds to a photographic exposure.
  50533. */
  50534. /**
  50535. * The camera exposure used on this material.
  50536. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50537. * This corresponds to a photographic exposure.
  50538. */
  50539. cameraExposure: number;
  50540. /**
  50541. * Gets The camera contrast used on this material.
  50542. */
  50543. /**
  50544. * Sets The camera contrast used on this material.
  50545. */
  50546. cameraContrast: number;
  50547. /**
  50548. * Gets the Color Grading 2D Lookup Texture.
  50549. */
  50550. /**
  50551. * Sets the Color Grading 2D Lookup Texture.
  50552. */
  50553. cameraColorGradingTexture: Nullable<BaseTexture>;
  50554. /**
  50555. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50556. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50557. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  50558. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50559. */
  50560. /**
  50561. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50562. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50563. * 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;
  50564. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50565. */
  50566. cameraColorCurves: Nullable<ColorCurves>;
  50567. /**
  50568. * Instantiates a new PBRMaterial instance.
  50569. *
  50570. * @param name The material name
  50571. * @param scene The scene the material will be use in.
  50572. */
  50573. constructor(name: string, scene: Scene);
  50574. /**
  50575. * Returns the name of this material class.
  50576. */
  50577. getClassName(): string;
  50578. /**
  50579. * Makes a duplicate of the current material.
  50580. * @param name - name to use for the new material.
  50581. */
  50582. clone(name: string): PBRMaterial;
  50583. /**
  50584. * Serializes this PBR Material.
  50585. * @returns - An object with the serialized material.
  50586. */
  50587. serialize(): any;
  50588. /**
  50589. * Parses a PBR Material from a serialized object.
  50590. * @param source - Serialized object.
  50591. * @param scene - BJS scene instance.
  50592. * @param rootUrl - url for the scene object
  50593. * @returns - PBRMaterial
  50594. */
  50595. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50596. }
  50597. }
  50598. declare module "babylonjs/Misc/dds" {
  50599. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50600. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50601. import { Nullable } from "babylonjs/types";
  50602. import { Scene } from "babylonjs/scene";
  50603. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50604. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50605. /**
  50606. * Direct draw surface info
  50607. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50608. */
  50609. export interface DDSInfo {
  50610. /**
  50611. * Width of the texture
  50612. */
  50613. width: number;
  50614. /**
  50615. * Width of the texture
  50616. */
  50617. height: number;
  50618. /**
  50619. * Number of Mipmaps for the texture
  50620. * @see https://en.wikipedia.org/wiki/Mipmap
  50621. */
  50622. mipmapCount: number;
  50623. /**
  50624. * If the textures format is a known fourCC format
  50625. * @see https://www.fourcc.org/
  50626. */
  50627. isFourCC: boolean;
  50628. /**
  50629. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50630. */
  50631. isRGB: boolean;
  50632. /**
  50633. * If the texture is a lumincance format
  50634. */
  50635. isLuminance: boolean;
  50636. /**
  50637. * If this is a cube texture
  50638. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50639. */
  50640. isCube: boolean;
  50641. /**
  50642. * If the texture is a compressed format eg. FOURCC_DXT1
  50643. */
  50644. isCompressed: boolean;
  50645. /**
  50646. * The dxgiFormat of the texture
  50647. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50648. */
  50649. dxgiFormat: number;
  50650. /**
  50651. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50652. */
  50653. textureType: number;
  50654. /**
  50655. * Sphericle polynomial created for the dds texture
  50656. */
  50657. sphericalPolynomial?: SphericalPolynomial;
  50658. }
  50659. /**
  50660. * Class used to provide DDS decompression tools
  50661. */
  50662. export class DDSTools {
  50663. /**
  50664. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50665. */
  50666. static StoreLODInAlphaChannel: boolean;
  50667. /**
  50668. * Gets DDS information from an array buffer
  50669. * @param arrayBuffer defines the array buffer to read data from
  50670. * @returns the DDS information
  50671. */
  50672. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50673. private static _FloatView;
  50674. private static _Int32View;
  50675. private static _ToHalfFloat;
  50676. private static _FromHalfFloat;
  50677. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50678. private static _GetHalfFloatRGBAArrayBuffer;
  50679. private static _GetFloatRGBAArrayBuffer;
  50680. private static _GetFloatAsUIntRGBAArrayBuffer;
  50681. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50682. private static _GetRGBAArrayBuffer;
  50683. private static _ExtractLongWordOrder;
  50684. private static _GetRGBArrayBuffer;
  50685. private static _GetLuminanceArrayBuffer;
  50686. /**
  50687. * Uploads DDS Levels to a Babylon Texture
  50688. * @hidden
  50689. */
  50690. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50691. }
  50692. module "babylonjs/Engines/thinEngine" {
  50693. interface ThinEngine {
  50694. /**
  50695. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50696. * @param rootUrl defines the url where the file to load is located
  50697. * @param scene defines the current scene
  50698. * @param lodScale defines scale to apply to the mip map selection
  50699. * @param lodOffset defines offset to apply to the mip map selection
  50700. * @param onLoad defines an optional callback raised when the texture is loaded
  50701. * @param onError defines an optional callback raised if there is an issue to load the texture
  50702. * @param format defines the format of the data
  50703. * @param forcedExtension defines the extension to use to pick the right loader
  50704. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50705. * @returns the cube texture as an InternalTexture
  50706. */
  50707. 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;
  50708. }
  50709. }
  50710. }
  50711. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50712. import { Nullable } from "babylonjs/types";
  50713. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50714. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50715. /**
  50716. * Implementation of the DDS Texture Loader.
  50717. * @hidden
  50718. */
  50719. export class _DDSTextureLoader implements IInternalTextureLoader {
  50720. /**
  50721. * Defines wether the loader supports cascade loading the different faces.
  50722. */
  50723. readonly supportCascades: boolean;
  50724. /**
  50725. * This returns if the loader support the current file information.
  50726. * @param extension defines the file extension of the file being loaded
  50727. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50728. * @param fallback defines the fallback internal texture if any
  50729. * @param isBase64 defines whether the texture is encoded as a base64
  50730. * @param isBuffer defines whether the texture data are stored as a buffer
  50731. * @returns true if the loader can load the specified file
  50732. */
  50733. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50734. /**
  50735. * Transform the url before loading if required.
  50736. * @param rootUrl the url of the texture
  50737. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50738. * @returns the transformed texture
  50739. */
  50740. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50741. /**
  50742. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50743. * @param rootUrl the url of the texture
  50744. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50745. * @returns the fallback texture
  50746. */
  50747. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50748. /**
  50749. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50750. * @param data contains the texture data
  50751. * @param texture defines the BabylonJS internal texture
  50752. * @param createPolynomials will be true if polynomials have been requested
  50753. * @param onLoad defines the callback to trigger once the texture is ready
  50754. * @param onError defines the callback to trigger in case of error
  50755. */
  50756. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50757. /**
  50758. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50759. * @param data contains the texture data
  50760. * @param texture defines the BabylonJS internal texture
  50761. * @param callback defines the method to call once ready to upload
  50762. */
  50763. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50764. }
  50765. }
  50766. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50767. import { Nullable } from "babylonjs/types";
  50768. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50769. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50770. /**
  50771. * Implementation of the ENV Texture Loader.
  50772. * @hidden
  50773. */
  50774. export class _ENVTextureLoader implements IInternalTextureLoader {
  50775. /**
  50776. * Defines wether the loader supports cascade loading the different faces.
  50777. */
  50778. readonly supportCascades: boolean;
  50779. /**
  50780. * This returns if the loader support the current file information.
  50781. * @param extension defines the file extension of the file being loaded
  50782. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50783. * @param fallback defines the fallback internal texture if any
  50784. * @param isBase64 defines whether the texture is encoded as a base64
  50785. * @param isBuffer defines whether the texture data are stored as a buffer
  50786. * @returns true if the loader can load the specified file
  50787. */
  50788. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50789. /**
  50790. * Transform the url before loading if required.
  50791. * @param rootUrl the url of the texture
  50792. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50793. * @returns the transformed texture
  50794. */
  50795. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50796. /**
  50797. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50798. * @param rootUrl the url of the texture
  50799. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50800. * @returns the fallback texture
  50801. */
  50802. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50803. /**
  50804. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50805. * @param data contains the texture data
  50806. * @param texture defines the BabylonJS internal texture
  50807. * @param createPolynomials will be true if polynomials have been requested
  50808. * @param onLoad defines the callback to trigger once the texture is ready
  50809. * @param onError defines the callback to trigger in case of error
  50810. */
  50811. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50812. /**
  50813. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50814. * @param data contains the texture data
  50815. * @param texture defines the BabylonJS internal texture
  50816. * @param callback defines the method to call once ready to upload
  50817. */
  50818. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50819. }
  50820. }
  50821. declare module "babylonjs/Misc/khronosTextureContainer" {
  50822. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50823. /**
  50824. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50825. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50826. */
  50827. export class KhronosTextureContainer {
  50828. /** contents of the KTX container file */
  50829. arrayBuffer: any;
  50830. private static HEADER_LEN;
  50831. private static COMPRESSED_2D;
  50832. private static COMPRESSED_3D;
  50833. private static TEX_2D;
  50834. private static TEX_3D;
  50835. /**
  50836. * Gets the openGL type
  50837. */
  50838. glType: number;
  50839. /**
  50840. * Gets the openGL type size
  50841. */
  50842. glTypeSize: number;
  50843. /**
  50844. * Gets the openGL format
  50845. */
  50846. glFormat: number;
  50847. /**
  50848. * Gets the openGL internal format
  50849. */
  50850. glInternalFormat: number;
  50851. /**
  50852. * Gets the base internal format
  50853. */
  50854. glBaseInternalFormat: number;
  50855. /**
  50856. * Gets image width in pixel
  50857. */
  50858. pixelWidth: number;
  50859. /**
  50860. * Gets image height in pixel
  50861. */
  50862. pixelHeight: number;
  50863. /**
  50864. * Gets image depth in pixels
  50865. */
  50866. pixelDepth: number;
  50867. /**
  50868. * Gets the number of array elements
  50869. */
  50870. numberOfArrayElements: number;
  50871. /**
  50872. * Gets the number of faces
  50873. */
  50874. numberOfFaces: number;
  50875. /**
  50876. * Gets the number of mipmap levels
  50877. */
  50878. numberOfMipmapLevels: number;
  50879. /**
  50880. * Gets the bytes of key value data
  50881. */
  50882. bytesOfKeyValueData: number;
  50883. /**
  50884. * Gets the load type
  50885. */
  50886. loadType: number;
  50887. /**
  50888. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50889. */
  50890. isInvalid: boolean;
  50891. /**
  50892. * Creates a new KhronosTextureContainer
  50893. * @param arrayBuffer contents of the KTX container file
  50894. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50895. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50896. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50897. */
  50898. constructor(
  50899. /** contents of the KTX container file */
  50900. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50901. /**
  50902. * Uploads KTX content to a Babylon Texture.
  50903. * It is assumed that the texture has already been created & is currently bound
  50904. * @hidden
  50905. */
  50906. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50907. private _upload2DCompressedLevels;
  50908. }
  50909. }
  50910. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50911. import { Nullable } from "babylonjs/types";
  50912. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50913. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50914. /**
  50915. * Implementation of the KTX Texture Loader.
  50916. * @hidden
  50917. */
  50918. export class _KTXTextureLoader implements IInternalTextureLoader {
  50919. /**
  50920. * Defines wether the loader supports cascade loading the different faces.
  50921. */
  50922. readonly supportCascades: boolean;
  50923. /**
  50924. * This returns if the loader support the current file information.
  50925. * @param extension defines the file extension of the file being loaded
  50926. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50927. * @param fallback defines the fallback internal texture if any
  50928. * @param isBase64 defines whether the texture is encoded as a base64
  50929. * @param isBuffer defines whether the texture data are stored as a buffer
  50930. * @returns true if the loader can load the specified file
  50931. */
  50932. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50933. /**
  50934. * Transform the url before loading if required.
  50935. * @param rootUrl the url of the texture
  50936. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50937. * @returns the transformed texture
  50938. */
  50939. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50940. /**
  50941. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50942. * @param rootUrl the url of the texture
  50943. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50944. * @returns the fallback texture
  50945. */
  50946. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50947. /**
  50948. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50949. * @param data contains the texture data
  50950. * @param texture defines the BabylonJS internal texture
  50951. * @param createPolynomials will be true if polynomials have been requested
  50952. * @param onLoad defines the callback to trigger once the texture is ready
  50953. * @param onError defines the callback to trigger in case of error
  50954. */
  50955. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50956. /**
  50957. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50958. * @param data contains the texture data
  50959. * @param texture defines the BabylonJS internal texture
  50960. * @param callback defines the method to call once ready to upload
  50961. */
  50962. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50963. }
  50964. }
  50965. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50966. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50967. import { Scene } from "babylonjs/scene";
  50968. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50969. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50970. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50971. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50972. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50973. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50974. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50975. /**
  50976. * Options for the default xr helper
  50977. */
  50978. export class WebXRDefaultExperienceOptions {
  50979. /**
  50980. * Floor meshes that should be used for teleporting
  50981. */
  50982. floorMeshes: Array<AbstractMesh>;
  50983. }
  50984. /**
  50985. * Default experience which provides a similar setup to the previous webVRExperience
  50986. */
  50987. export class WebXRDefaultExperience {
  50988. /**
  50989. * Base experience
  50990. */
  50991. baseExperience: WebXRExperienceHelper;
  50992. /**
  50993. * Input experience extension
  50994. */
  50995. input: WebXRInput;
  50996. /**
  50997. * Loads the controller models
  50998. */
  50999. controllerModelLoader: WebXRControllerModelLoader;
  51000. /**
  51001. * Enables laser pointer and selection
  51002. */
  51003. pointerSelection: WebXRControllerPointerSelection;
  51004. /**
  51005. * Enables teleportation
  51006. */
  51007. teleportation: WebXRControllerTeleportation;
  51008. /**
  51009. * Enables ui for enetering/exiting xr
  51010. */
  51011. enterExitUI: WebXREnterExitUI;
  51012. /**
  51013. * Default output canvas xr should render to
  51014. */
  51015. outputCanvas: WebXRManagedOutputCanvas;
  51016. /**
  51017. * Creates the default xr experience
  51018. * @param scene scene
  51019. * @param options options for basic configuration
  51020. * @returns resulting WebXRDefaultExperience
  51021. */
  51022. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51023. private constructor();
  51024. /**
  51025. * DIsposes of the experience helper
  51026. */
  51027. dispose(): void;
  51028. }
  51029. }
  51030. declare module "babylonjs/Helpers/sceneHelpers" {
  51031. import { Nullable } from "babylonjs/types";
  51032. import { Mesh } from "babylonjs/Meshes/mesh";
  51033. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51034. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  51035. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  51036. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51037. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51038. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51039. import "babylonjs/Meshes/Builders/boxBuilder";
  51040. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  51041. /** @hidden */
  51042. export var _forceSceneHelpersToBundle: boolean;
  51043. module "babylonjs/scene" {
  51044. interface Scene {
  51045. /**
  51046. * Creates a default light for the scene.
  51047. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  51048. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51049. */
  51050. createDefaultLight(replace?: boolean): void;
  51051. /**
  51052. * Creates a default camera for the scene.
  51053. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51054. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51055. * @param replace has default false, when true replaces the active camera in the scene
  51056. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51057. */
  51058. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51059. /**
  51060. * Creates a default camera and a default light.
  51061. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51062. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51063. * @param replace has the default false, when true replaces the active camera/light in the scene
  51064. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51065. */
  51066. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51067. /**
  51068. * Creates a new sky box
  51069. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51070. * @param environmentTexture defines the texture to use as environment texture
  51071. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51072. * @param scale defines the overall scale of the skybox
  51073. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51074. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51075. * @returns a new mesh holding the sky box
  51076. */
  51077. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51078. /**
  51079. * Creates a new environment
  51080. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51081. * @param options defines the options you can use to configure the environment
  51082. * @returns the new EnvironmentHelper
  51083. */
  51084. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51085. /**
  51086. * Creates a new VREXperienceHelper
  51087. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51088. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51089. * @returns a new VREXperienceHelper
  51090. */
  51091. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51092. /**
  51093. * Creates a new WebXRDefaultExperience
  51094. * @see http://doc.babylonjs.com/how_to/webxr
  51095. * @param options experience options
  51096. * @returns a promise for a new WebXRDefaultExperience
  51097. */
  51098. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51099. }
  51100. }
  51101. }
  51102. declare module "babylonjs/Helpers/videoDome" {
  51103. import { Scene } from "babylonjs/scene";
  51104. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51105. import { Mesh } from "babylonjs/Meshes/mesh";
  51106. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51107. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51108. import "babylonjs/Meshes/Builders/sphereBuilder";
  51109. /**
  51110. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51111. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51112. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51113. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51114. */
  51115. export class VideoDome extends TransformNode {
  51116. /**
  51117. * Define the video source as a Monoscopic panoramic 360 video.
  51118. */
  51119. static readonly MODE_MONOSCOPIC: number;
  51120. /**
  51121. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51122. */
  51123. static readonly MODE_TOPBOTTOM: number;
  51124. /**
  51125. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51126. */
  51127. static readonly MODE_SIDEBYSIDE: number;
  51128. private _halfDome;
  51129. private _useDirectMapping;
  51130. /**
  51131. * The video texture being displayed on the sphere
  51132. */
  51133. protected _videoTexture: VideoTexture;
  51134. /**
  51135. * Gets the video texture being displayed on the sphere
  51136. */
  51137. readonly videoTexture: VideoTexture;
  51138. /**
  51139. * The skybox material
  51140. */
  51141. protected _material: BackgroundMaterial;
  51142. /**
  51143. * The surface used for the skybox
  51144. */
  51145. protected _mesh: Mesh;
  51146. /**
  51147. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51148. */
  51149. private _halfDomeMask;
  51150. /**
  51151. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51152. * Also see the options.resolution property.
  51153. */
  51154. fovMultiplier: number;
  51155. private _videoMode;
  51156. /**
  51157. * Gets or set the current video mode for the video. It can be:
  51158. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51159. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51160. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51161. */
  51162. videoMode: number;
  51163. /**
  51164. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51165. *
  51166. */
  51167. /**
  51168. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51169. */
  51170. halfDome: boolean;
  51171. /**
  51172. * Oberserver used in Stereoscopic VR Mode.
  51173. */
  51174. private _onBeforeCameraRenderObserver;
  51175. /**
  51176. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51177. * @param name Element's name, child elements will append suffixes for their own names.
  51178. * @param urlsOrVideo defines the url(s) or the video element to use
  51179. * @param options An object containing optional or exposed sub element properties
  51180. */
  51181. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51182. resolution?: number;
  51183. clickToPlay?: boolean;
  51184. autoPlay?: boolean;
  51185. loop?: boolean;
  51186. size?: number;
  51187. poster?: string;
  51188. faceForward?: boolean;
  51189. useDirectMapping?: boolean;
  51190. halfDomeMode?: boolean;
  51191. }, scene: Scene);
  51192. private _changeVideoMode;
  51193. /**
  51194. * Releases resources associated with this node.
  51195. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51196. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51197. */
  51198. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51199. }
  51200. }
  51201. declare module "babylonjs/Helpers/index" {
  51202. export * from "babylonjs/Helpers/environmentHelper";
  51203. export * from "babylonjs/Helpers/photoDome";
  51204. export * from "babylonjs/Helpers/sceneHelpers";
  51205. export * from "babylonjs/Helpers/videoDome";
  51206. }
  51207. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51208. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51209. import { IDisposable } from "babylonjs/scene";
  51210. import { Engine } from "babylonjs/Engines/engine";
  51211. /**
  51212. * This class can be used to get instrumentation data from a Babylon engine
  51213. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51214. */
  51215. export class EngineInstrumentation implements IDisposable {
  51216. /**
  51217. * Define the instrumented engine.
  51218. */
  51219. engine: Engine;
  51220. private _captureGPUFrameTime;
  51221. private _gpuFrameTimeToken;
  51222. private _gpuFrameTime;
  51223. private _captureShaderCompilationTime;
  51224. private _shaderCompilationTime;
  51225. private _onBeginFrameObserver;
  51226. private _onEndFrameObserver;
  51227. private _onBeforeShaderCompilationObserver;
  51228. private _onAfterShaderCompilationObserver;
  51229. /**
  51230. * Gets the perf counter used for GPU frame time
  51231. */
  51232. readonly gpuFrameTimeCounter: PerfCounter;
  51233. /**
  51234. * Gets the GPU frame time capture status
  51235. */
  51236. /**
  51237. * Enable or disable the GPU frame time capture
  51238. */
  51239. captureGPUFrameTime: boolean;
  51240. /**
  51241. * Gets the perf counter used for shader compilation time
  51242. */
  51243. readonly shaderCompilationTimeCounter: PerfCounter;
  51244. /**
  51245. * Gets the shader compilation time capture status
  51246. */
  51247. /**
  51248. * Enable or disable the shader compilation time capture
  51249. */
  51250. captureShaderCompilationTime: boolean;
  51251. /**
  51252. * Instantiates a new engine instrumentation.
  51253. * This class can be used to get instrumentation data from a Babylon engine
  51254. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51255. * @param engine Defines the engine to instrument
  51256. */
  51257. constructor(
  51258. /**
  51259. * Define the instrumented engine.
  51260. */
  51261. engine: Engine);
  51262. /**
  51263. * Dispose and release associated resources.
  51264. */
  51265. dispose(): void;
  51266. }
  51267. }
  51268. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51269. import { Scene, IDisposable } from "babylonjs/scene";
  51270. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51271. /**
  51272. * This class can be used to get instrumentation data from a Babylon engine
  51273. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51274. */
  51275. export class SceneInstrumentation implements IDisposable {
  51276. /**
  51277. * Defines the scene to instrument
  51278. */
  51279. scene: Scene;
  51280. private _captureActiveMeshesEvaluationTime;
  51281. private _activeMeshesEvaluationTime;
  51282. private _captureRenderTargetsRenderTime;
  51283. private _renderTargetsRenderTime;
  51284. private _captureFrameTime;
  51285. private _frameTime;
  51286. private _captureRenderTime;
  51287. private _renderTime;
  51288. private _captureInterFrameTime;
  51289. private _interFrameTime;
  51290. private _captureParticlesRenderTime;
  51291. private _particlesRenderTime;
  51292. private _captureSpritesRenderTime;
  51293. private _spritesRenderTime;
  51294. private _capturePhysicsTime;
  51295. private _physicsTime;
  51296. private _captureAnimationsTime;
  51297. private _animationsTime;
  51298. private _captureCameraRenderTime;
  51299. private _cameraRenderTime;
  51300. private _onBeforeActiveMeshesEvaluationObserver;
  51301. private _onAfterActiveMeshesEvaluationObserver;
  51302. private _onBeforeRenderTargetsRenderObserver;
  51303. private _onAfterRenderTargetsRenderObserver;
  51304. private _onAfterRenderObserver;
  51305. private _onBeforeDrawPhaseObserver;
  51306. private _onAfterDrawPhaseObserver;
  51307. private _onBeforeAnimationsObserver;
  51308. private _onBeforeParticlesRenderingObserver;
  51309. private _onAfterParticlesRenderingObserver;
  51310. private _onBeforeSpritesRenderingObserver;
  51311. private _onAfterSpritesRenderingObserver;
  51312. private _onBeforePhysicsObserver;
  51313. private _onAfterPhysicsObserver;
  51314. private _onAfterAnimationsObserver;
  51315. private _onBeforeCameraRenderObserver;
  51316. private _onAfterCameraRenderObserver;
  51317. /**
  51318. * Gets the perf counter used for active meshes evaluation time
  51319. */
  51320. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51321. /**
  51322. * Gets the active meshes evaluation time capture status
  51323. */
  51324. /**
  51325. * Enable or disable the active meshes evaluation time capture
  51326. */
  51327. captureActiveMeshesEvaluationTime: boolean;
  51328. /**
  51329. * Gets the perf counter used for render targets render time
  51330. */
  51331. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51332. /**
  51333. * Gets the render targets render time capture status
  51334. */
  51335. /**
  51336. * Enable or disable the render targets render time capture
  51337. */
  51338. captureRenderTargetsRenderTime: boolean;
  51339. /**
  51340. * Gets the perf counter used for particles render time
  51341. */
  51342. readonly particlesRenderTimeCounter: PerfCounter;
  51343. /**
  51344. * Gets the particles render time capture status
  51345. */
  51346. /**
  51347. * Enable or disable the particles render time capture
  51348. */
  51349. captureParticlesRenderTime: boolean;
  51350. /**
  51351. * Gets the perf counter used for sprites render time
  51352. */
  51353. readonly spritesRenderTimeCounter: PerfCounter;
  51354. /**
  51355. * Gets the sprites render time capture status
  51356. */
  51357. /**
  51358. * Enable or disable the sprites render time capture
  51359. */
  51360. captureSpritesRenderTime: boolean;
  51361. /**
  51362. * Gets the perf counter used for physics time
  51363. */
  51364. readonly physicsTimeCounter: PerfCounter;
  51365. /**
  51366. * Gets the physics time capture status
  51367. */
  51368. /**
  51369. * Enable or disable the physics time capture
  51370. */
  51371. capturePhysicsTime: boolean;
  51372. /**
  51373. * Gets the perf counter used for animations time
  51374. */
  51375. readonly animationsTimeCounter: PerfCounter;
  51376. /**
  51377. * Gets the animations time capture status
  51378. */
  51379. /**
  51380. * Enable or disable the animations time capture
  51381. */
  51382. captureAnimationsTime: boolean;
  51383. /**
  51384. * Gets the perf counter used for frame time capture
  51385. */
  51386. readonly frameTimeCounter: PerfCounter;
  51387. /**
  51388. * Gets the frame time capture status
  51389. */
  51390. /**
  51391. * Enable or disable the frame time capture
  51392. */
  51393. captureFrameTime: boolean;
  51394. /**
  51395. * Gets the perf counter used for inter-frames time capture
  51396. */
  51397. readonly interFrameTimeCounter: PerfCounter;
  51398. /**
  51399. * Gets the inter-frames time capture status
  51400. */
  51401. /**
  51402. * Enable or disable the inter-frames time capture
  51403. */
  51404. captureInterFrameTime: boolean;
  51405. /**
  51406. * Gets the perf counter used for render time capture
  51407. */
  51408. readonly renderTimeCounter: PerfCounter;
  51409. /**
  51410. * Gets the render time capture status
  51411. */
  51412. /**
  51413. * Enable or disable the render time capture
  51414. */
  51415. captureRenderTime: boolean;
  51416. /**
  51417. * Gets the perf counter used for camera render time capture
  51418. */
  51419. readonly cameraRenderTimeCounter: PerfCounter;
  51420. /**
  51421. * Gets the camera render time capture status
  51422. */
  51423. /**
  51424. * Enable or disable the camera render time capture
  51425. */
  51426. captureCameraRenderTime: boolean;
  51427. /**
  51428. * Gets the perf counter used for draw calls
  51429. */
  51430. readonly drawCallsCounter: PerfCounter;
  51431. /**
  51432. * Instantiates a new scene instrumentation.
  51433. * This class can be used to get instrumentation data from a Babylon engine
  51434. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51435. * @param scene Defines the scene to instrument
  51436. */
  51437. constructor(
  51438. /**
  51439. * Defines the scene to instrument
  51440. */
  51441. scene: Scene);
  51442. /**
  51443. * Dispose and release associated resources.
  51444. */
  51445. dispose(): void;
  51446. }
  51447. }
  51448. declare module "babylonjs/Instrumentation/index" {
  51449. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51450. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51451. export * from "babylonjs/Instrumentation/timeToken";
  51452. }
  51453. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51454. /** @hidden */
  51455. export var glowMapGenerationPixelShader: {
  51456. name: string;
  51457. shader: string;
  51458. };
  51459. }
  51460. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51461. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51462. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51463. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51464. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51465. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51466. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51467. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51468. /** @hidden */
  51469. export var glowMapGenerationVertexShader: {
  51470. name: string;
  51471. shader: string;
  51472. };
  51473. }
  51474. declare module "babylonjs/Layers/effectLayer" {
  51475. import { Observable } from "babylonjs/Misc/observable";
  51476. import { Nullable } from "babylonjs/types";
  51477. import { Camera } from "babylonjs/Cameras/camera";
  51478. import { Scene } from "babylonjs/scene";
  51479. import { ISize } from "babylonjs/Maths/math.size";
  51480. import { Color4 } from "babylonjs/Maths/math.color";
  51481. import { Engine } from "babylonjs/Engines/engine";
  51482. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51484. import { Mesh } from "babylonjs/Meshes/mesh";
  51485. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51487. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51488. import { Effect } from "babylonjs/Materials/effect";
  51489. import { Material } from "babylonjs/Materials/material";
  51490. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51491. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51492. /**
  51493. * Effect layer options. This helps customizing the behaviour
  51494. * of the effect layer.
  51495. */
  51496. export interface IEffectLayerOptions {
  51497. /**
  51498. * Multiplication factor apply to the canvas size to compute the render target size
  51499. * used to generated the objects (the smaller the faster).
  51500. */
  51501. mainTextureRatio: number;
  51502. /**
  51503. * Enforces a fixed size texture to ensure effect stability across devices.
  51504. */
  51505. mainTextureFixedSize?: number;
  51506. /**
  51507. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51508. */
  51509. alphaBlendingMode: number;
  51510. /**
  51511. * The camera attached to the layer.
  51512. */
  51513. camera: Nullable<Camera>;
  51514. /**
  51515. * The rendering group to draw the layer in.
  51516. */
  51517. renderingGroupId: number;
  51518. }
  51519. /**
  51520. * The effect layer Helps adding post process effect blended with the main pass.
  51521. *
  51522. * This can be for instance use to generate glow or higlight effects on the scene.
  51523. *
  51524. * The effect layer class can not be used directly and is intented to inherited from to be
  51525. * customized per effects.
  51526. */
  51527. export abstract class EffectLayer {
  51528. private _vertexBuffers;
  51529. private _indexBuffer;
  51530. private _cachedDefines;
  51531. private _effectLayerMapGenerationEffect;
  51532. private _effectLayerOptions;
  51533. private _mergeEffect;
  51534. protected _scene: Scene;
  51535. protected _engine: Engine;
  51536. protected _maxSize: number;
  51537. protected _mainTextureDesiredSize: ISize;
  51538. protected _mainTexture: RenderTargetTexture;
  51539. protected _shouldRender: boolean;
  51540. protected _postProcesses: PostProcess[];
  51541. protected _textures: BaseTexture[];
  51542. protected _emissiveTextureAndColor: {
  51543. texture: Nullable<BaseTexture>;
  51544. color: Color4;
  51545. };
  51546. /**
  51547. * The name of the layer
  51548. */
  51549. name: string;
  51550. /**
  51551. * The clear color of the texture used to generate the glow map.
  51552. */
  51553. neutralColor: Color4;
  51554. /**
  51555. * Specifies wether the highlight layer is enabled or not.
  51556. */
  51557. isEnabled: boolean;
  51558. /**
  51559. * Gets the camera attached to the layer.
  51560. */
  51561. readonly camera: Nullable<Camera>;
  51562. /**
  51563. * Gets the rendering group id the layer should render in.
  51564. */
  51565. renderingGroupId: number;
  51566. /**
  51567. * An event triggered when the effect layer has been disposed.
  51568. */
  51569. onDisposeObservable: Observable<EffectLayer>;
  51570. /**
  51571. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51572. */
  51573. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51574. /**
  51575. * An event triggered when the generated texture is being merged in the scene.
  51576. */
  51577. onBeforeComposeObservable: Observable<EffectLayer>;
  51578. /**
  51579. * An event triggered when the generated texture has been merged in the scene.
  51580. */
  51581. onAfterComposeObservable: Observable<EffectLayer>;
  51582. /**
  51583. * An event triggered when the efffect layer changes its size.
  51584. */
  51585. onSizeChangedObservable: Observable<EffectLayer>;
  51586. /** @hidden */
  51587. static _SceneComponentInitialization: (scene: Scene) => void;
  51588. /**
  51589. * Instantiates a new effect Layer and references it in the scene.
  51590. * @param name The name of the layer
  51591. * @param scene The scene to use the layer in
  51592. */
  51593. constructor(
  51594. /** The Friendly of the effect in the scene */
  51595. name: string, scene: Scene);
  51596. /**
  51597. * Get the effect name of the layer.
  51598. * @return The effect name
  51599. */
  51600. abstract getEffectName(): string;
  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. * @return true if ready otherwise, false
  51606. */
  51607. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51608. /**
  51609. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51610. * @returns true if the effect requires stencil during the main canvas render pass.
  51611. */
  51612. abstract needStencil(): boolean;
  51613. /**
  51614. * Create the merge effect. This is the shader use to blit the information back
  51615. * to the main canvas at the end of the scene rendering.
  51616. * @returns The effect containing the shader used to merge the effect on the main canvas
  51617. */
  51618. protected abstract _createMergeEffect(): Effect;
  51619. /**
  51620. * Creates the render target textures and post processes used in the effect layer.
  51621. */
  51622. protected abstract _createTextureAndPostProcesses(): void;
  51623. /**
  51624. * Implementation specific of rendering the generating effect on the main canvas.
  51625. * @param effect The effect used to render through
  51626. */
  51627. protected abstract _internalRender(effect: Effect): void;
  51628. /**
  51629. * Sets the required values for both the emissive texture and and the main color.
  51630. */
  51631. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51632. /**
  51633. * Free any resources and references associated to a mesh.
  51634. * Internal use
  51635. * @param mesh The mesh to free.
  51636. */
  51637. abstract _disposeMesh(mesh: Mesh): void;
  51638. /**
  51639. * Serializes this layer (Glow or Highlight for example)
  51640. * @returns a serialized layer object
  51641. */
  51642. abstract serialize?(): any;
  51643. /**
  51644. * Initializes the effect layer with the required options.
  51645. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51646. */
  51647. protected _init(options: Partial<IEffectLayerOptions>): void;
  51648. /**
  51649. * Generates the index buffer of the full screen quad blending to the main canvas.
  51650. */
  51651. private _generateIndexBuffer;
  51652. /**
  51653. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51654. */
  51655. private _generateVertexBuffer;
  51656. /**
  51657. * Sets the main texture desired size which is the closest power of two
  51658. * of the engine canvas size.
  51659. */
  51660. private _setMainTextureSize;
  51661. /**
  51662. * Creates the main texture for the effect layer.
  51663. */
  51664. protected _createMainTexture(): void;
  51665. /**
  51666. * Adds specific effects defines.
  51667. * @param defines The defines to add specifics to.
  51668. */
  51669. protected _addCustomEffectDefines(defines: string[]): void;
  51670. /**
  51671. * Checks for the readiness of the element composing the layer.
  51672. * @param subMesh the mesh to check for
  51673. * @param useInstances specify wether or not to use instances to render the mesh
  51674. * @param emissiveTexture the associated emissive texture used to generate the glow
  51675. * @return true if ready otherwise, false
  51676. */
  51677. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51678. /**
  51679. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51680. */
  51681. render(): void;
  51682. /**
  51683. * Determine if a given mesh will be used in the current effect.
  51684. * @param mesh mesh to test
  51685. * @returns true if the mesh will be used
  51686. */
  51687. hasMesh(mesh: AbstractMesh): boolean;
  51688. /**
  51689. * Returns true if the layer contains information to display, otherwise false.
  51690. * @returns true if the glow layer should be rendered
  51691. */
  51692. shouldRender(): boolean;
  51693. /**
  51694. * Returns true if the mesh should render, otherwise false.
  51695. * @param mesh The mesh to render
  51696. * @returns true if it should render otherwise false
  51697. */
  51698. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51699. /**
  51700. * Returns true if the mesh can be rendered, otherwise false.
  51701. * @param mesh The mesh to render
  51702. * @param material The material used on the mesh
  51703. * @returns true if it can be rendered otherwise false
  51704. */
  51705. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51706. /**
  51707. * Returns true if the mesh should render, otherwise false.
  51708. * @param mesh The mesh to render
  51709. * @returns true if it should render otherwise false
  51710. */
  51711. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51712. /**
  51713. * Renders the submesh passed in parameter to the generation map.
  51714. */
  51715. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51716. /**
  51717. * Rebuild the required buffers.
  51718. * @hidden Internal use only.
  51719. */
  51720. _rebuild(): void;
  51721. /**
  51722. * Dispose only the render target textures and post process.
  51723. */
  51724. private _disposeTextureAndPostProcesses;
  51725. /**
  51726. * Dispose the highlight layer and free resources.
  51727. */
  51728. dispose(): void;
  51729. /**
  51730. * Gets the class name of the effect layer
  51731. * @returns the string with the class name of the effect layer
  51732. */
  51733. getClassName(): string;
  51734. /**
  51735. * Creates an effect layer from parsed effect layer data
  51736. * @param parsedEffectLayer defines effect layer data
  51737. * @param scene defines the current scene
  51738. * @param rootUrl defines the root URL containing the effect layer information
  51739. * @returns a parsed effect Layer
  51740. */
  51741. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51742. }
  51743. }
  51744. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51745. import { Scene } from "babylonjs/scene";
  51746. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51747. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51748. import { AbstractScene } from "babylonjs/abstractScene";
  51749. module "babylonjs/abstractScene" {
  51750. interface AbstractScene {
  51751. /**
  51752. * The list of effect layers (highlights/glow) added to the scene
  51753. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51754. * @see http://doc.babylonjs.com/how_to/glow_layer
  51755. */
  51756. effectLayers: Array<EffectLayer>;
  51757. /**
  51758. * Removes the given effect layer from this scene.
  51759. * @param toRemove defines the effect layer to remove
  51760. * @returns the index of the removed effect layer
  51761. */
  51762. removeEffectLayer(toRemove: EffectLayer): number;
  51763. /**
  51764. * Adds the given effect layer to this scene
  51765. * @param newEffectLayer defines the effect layer to add
  51766. */
  51767. addEffectLayer(newEffectLayer: EffectLayer): void;
  51768. }
  51769. }
  51770. /**
  51771. * Defines the layer scene component responsible to manage any effect layers
  51772. * in a given scene.
  51773. */
  51774. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51775. /**
  51776. * The component name helpfull to identify the component in the list of scene components.
  51777. */
  51778. readonly name: string;
  51779. /**
  51780. * The scene the component belongs to.
  51781. */
  51782. scene: Scene;
  51783. private _engine;
  51784. private _renderEffects;
  51785. private _needStencil;
  51786. private _previousStencilState;
  51787. /**
  51788. * Creates a new instance of the component for the given scene
  51789. * @param scene Defines the scene to register the component in
  51790. */
  51791. constructor(scene: Scene);
  51792. /**
  51793. * Registers the component in a given scene
  51794. */
  51795. register(): void;
  51796. /**
  51797. * Rebuilds the elements related to this component in case of
  51798. * context lost for instance.
  51799. */
  51800. rebuild(): void;
  51801. /**
  51802. * Serializes the component data to the specified json object
  51803. * @param serializationObject The object to serialize to
  51804. */
  51805. serialize(serializationObject: any): void;
  51806. /**
  51807. * Adds all the elements from the container to the scene
  51808. * @param container the container holding the elements
  51809. */
  51810. addFromContainer(container: AbstractScene): void;
  51811. /**
  51812. * Removes all the elements in the container from the scene
  51813. * @param container contains the elements to remove
  51814. * @param dispose if the removed element should be disposed (default: false)
  51815. */
  51816. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51817. /**
  51818. * Disposes the component and the associated ressources.
  51819. */
  51820. dispose(): void;
  51821. private _isReadyForMesh;
  51822. private _renderMainTexture;
  51823. private _setStencil;
  51824. private _setStencilBack;
  51825. private _draw;
  51826. private _drawCamera;
  51827. private _drawRenderingGroup;
  51828. }
  51829. }
  51830. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51831. /** @hidden */
  51832. export var glowMapMergePixelShader: {
  51833. name: string;
  51834. shader: string;
  51835. };
  51836. }
  51837. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51838. /** @hidden */
  51839. export var glowMapMergeVertexShader: {
  51840. name: string;
  51841. shader: string;
  51842. };
  51843. }
  51844. declare module "babylonjs/Layers/glowLayer" {
  51845. import { Nullable } from "babylonjs/types";
  51846. import { Camera } from "babylonjs/Cameras/camera";
  51847. import { Scene } from "babylonjs/scene";
  51848. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51849. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51850. import { Mesh } from "babylonjs/Meshes/mesh";
  51851. import { Texture } from "babylonjs/Materials/Textures/texture";
  51852. import { Effect } from "babylonjs/Materials/effect";
  51853. import { Material } from "babylonjs/Materials/material";
  51854. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51855. import { Color4 } from "babylonjs/Maths/math.color";
  51856. import "babylonjs/Shaders/glowMapMerge.fragment";
  51857. import "babylonjs/Shaders/glowMapMerge.vertex";
  51858. import "babylonjs/Layers/effectLayerSceneComponent";
  51859. module "babylonjs/abstractScene" {
  51860. interface AbstractScene {
  51861. /**
  51862. * Return a the first highlight layer of the scene with a given name.
  51863. * @param name The name of the highlight layer to look for.
  51864. * @return The highlight layer if found otherwise null.
  51865. */
  51866. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51867. }
  51868. }
  51869. /**
  51870. * Glow layer options. This helps customizing the behaviour
  51871. * of the glow layer.
  51872. */
  51873. export interface IGlowLayerOptions {
  51874. /**
  51875. * Multiplication factor apply to the canvas size to compute the render target size
  51876. * used to generated the glowing objects (the smaller the faster).
  51877. */
  51878. mainTextureRatio: number;
  51879. /**
  51880. * Enforces a fixed size texture to ensure resize independant blur.
  51881. */
  51882. mainTextureFixedSize?: number;
  51883. /**
  51884. * How big is the kernel of the blur texture.
  51885. */
  51886. blurKernelSize: number;
  51887. /**
  51888. * The camera attached to the layer.
  51889. */
  51890. camera: Nullable<Camera>;
  51891. /**
  51892. * Enable MSAA by chosing the number of samples.
  51893. */
  51894. mainTextureSamples?: number;
  51895. /**
  51896. * The rendering group to draw the layer in.
  51897. */
  51898. renderingGroupId: number;
  51899. }
  51900. /**
  51901. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51902. *
  51903. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51904. * glowy meshes to your scene.
  51905. *
  51906. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51907. */
  51908. export class GlowLayer extends EffectLayer {
  51909. /**
  51910. * Effect Name of the layer.
  51911. */
  51912. static readonly EffectName: string;
  51913. /**
  51914. * The default blur kernel size used for the glow.
  51915. */
  51916. static DefaultBlurKernelSize: number;
  51917. /**
  51918. * The default texture size ratio used for the glow.
  51919. */
  51920. static DefaultTextureRatio: number;
  51921. /**
  51922. * Sets the kernel size of the blur.
  51923. */
  51924. /**
  51925. * Gets the kernel size of the blur.
  51926. */
  51927. blurKernelSize: number;
  51928. /**
  51929. * Sets the glow intensity.
  51930. */
  51931. /**
  51932. * Gets the glow intensity.
  51933. */
  51934. intensity: number;
  51935. private _options;
  51936. private _intensity;
  51937. private _horizontalBlurPostprocess1;
  51938. private _verticalBlurPostprocess1;
  51939. private _horizontalBlurPostprocess2;
  51940. private _verticalBlurPostprocess2;
  51941. private _blurTexture1;
  51942. private _blurTexture2;
  51943. private _postProcesses1;
  51944. private _postProcesses2;
  51945. private _includedOnlyMeshes;
  51946. private _excludedMeshes;
  51947. /**
  51948. * Callback used to let the user override the color selection on a per mesh basis
  51949. */
  51950. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51951. /**
  51952. * Callback used to let the user override the texture selection on a per mesh basis
  51953. */
  51954. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51955. /**
  51956. * Instantiates a new glow Layer and references it to the scene.
  51957. * @param name The name of the layer
  51958. * @param scene The scene to use the layer in
  51959. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51960. */
  51961. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51962. /**
  51963. * Get the effect name of the layer.
  51964. * @return The effect name
  51965. */
  51966. getEffectName(): string;
  51967. /**
  51968. * Create the merge effect. This is the shader use to blit the information back
  51969. * to the main canvas at the end of the scene rendering.
  51970. */
  51971. protected _createMergeEffect(): Effect;
  51972. /**
  51973. * Creates the render target textures and post processes used in the glow layer.
  51974. */
  51975. protected _createTextureAndPostProcesses(): void;
  51976. /**
  51977. * Checks for the readiness of the element composing the layer.
  51978. * @param subMesh the mesh to check for
  51979. * @param useInstances specify wether or not to use instances to render the mesh
  51980. * @param emissiveTexture the associated emissive texture used to generate the glow
  51981. * @return true if ready otherwise, false
  51982. */
  51983. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51984. /**
  51985. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51986. */
  51987. needStencil(): boolean;
  51988. /**
  51989. * Returns true if the mesh can be rendered, otherwise false.
  51990. * @param mesh The mesh to render
  51991. * @param material The material used on the mesh
  51992. * @returns true if it can be rendered otherwise false
  51993. */
  51994. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51995. /**
  51996. * Implementation specific of rendering the generating effect on the main canvas.
  51997. * @param effect The effect used to render through
  51998. */
  51999. protected _internalRender(effect: Effect): void;
  52000. /**
  52001. * Sets the required values for both the emissive texture and and the main color.
  52002. */
  52003. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52004. /**
  52005. * Returns true if the mesh should render, otherwise false.
  52006. * @param mesh The mesh to render
  52007. * @returns true if it should render otherwise false
  52008. */
  52009. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52010. /**
  52011. * Adds specific effects defines.
  52012. * @param defines The defines to add specifics to.
  52013. */
  52014. protected _addCustomEffectDefines(defines: string[]): void;
  52015. /**
  52016. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  52017. * @param mesh The mesh to exclude from the glow layer
  52018. */
  52019. addExcludedMesh(mesh: Mesh): void;
  52020. /**
  52021. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  52022. * @param mesh The mesh to remove
  52023. */
  52024. removeExcludedMesh(mesh: Mesh): void;
  52025. /**
  52026. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  52027. * @param mesh The mesh to include in the glow layer
  52028. */
  52029. addIncludedOnlyMesh(mesh: Mesh): void;
  52030. /**
  52031. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  52032. * @param mesh The mesh to remove
  52033. */
  52034. removeIncludedOnlyMesh(mesh: Mesh): void;
  52035. /**
  52036. * Determine if a given mesh will be used in the glow layer
  52037. * @param mesh The mesh to test
  52038. * @returns true if the mesh will be highlighted by the current glow layer
  52039. */
  52040. hasMesh(mesh: AbstractMesh): boolean;
  52041. /**
  52042. * Free any resources and references associated to a mesh.
  52043. * Internal use
  52044. * @param mesh The mesh to free.
  52045. * @hidden
  52046. */
  52047. _disposeMesh(mesh: Mesh): void;
  52048. /**
  52049. * Gets the class name of the effect layer
  52050. * @returns the string with the class name of the effect layer
  52051. */
  52052. getClassName(): string;
  52053. /**
  52054. * Serializes this glow layer
  52055. * @returns a serialized glow layer object
  52056. */
  52057. serialize(): any;
  52058. /**
  52059. * Creates a Glow Layer from parsed glow layer data
  52060. * @param parsedGlowLayer defines glow layer data
  52061. * @param scene defines the current scene
  52062. * @param rootUrl defines the root URL containing the glow layer information
  52063. * @returns a parsed Glow Layer
  52064. */
  52065. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52066. }
  52067. }
  52068. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52069. /** @hidden */
  52070. export var glowBlurPostProcessPixelShader: {
  52071. name: string;
  52072. shader: string;
  52073. };
  52074. }
  52075. declare module "babylonjs/Layers/highlightLayer" {
  52076. import { Observable } from "babylonjs/Misc/observable";
  52077. import { Nullable } from "babylonjs/types";
  52078. import { Camera } from "babylonjs/Cameras/camera";
  52079. import { Scene } from "babylonjs/scene";
  52080. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52081. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52082. import { Mesh } from "babylonjs/Meshes/mesh";
  52083. import { Effect } from "babylonjs/Materials/effect";
  52084. import { Material } from "babylonjs/Materials/material";
  52085. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52086. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52087. import "babylonjs/Shaders/glowMapMerge.fragment";
  52088. import "babylonjs/Shaders/glowMapMerge.vertex";
  52089. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52090. module "babylonjs/abstractScene" {
  52091. interface AbstractScene {
  52092. /**
  52093. * Return a the first highlight layer of the scene with a given name.
  52094. * @param name The name of the highlight layer to look for.
  52095. * @return The highlight layer if found otherwise null.
  52096. */
  52097. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52098. }
  52099. }
  52100. /**
  52101. * Highlight layer options. This helps customizing the behaviour
  52102. * of the highlight layer.
  52103. */
  52104. export interface IHighlightLayerOptions {
  52105. /**
  52106. * Multiplication factor apply to the canvas size to compute the render target size
  52107. * used to generated the glowing objects (the smaller the faster).
  52108. */
  52109. mainTextureRatio: number;
  52110. /**
  52111. * Enforces a fixed size texture to ensure resize independant blur.
  52112. */
  52113. mainTextureFixedSize?: number;
  52114. /**
  52115. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52116. * of the picture to blur (the smaller the faster).
  52117. */
  52118. blurTextureSizeRatio: number;
  52119. /**
  52120. * How big in texel of the blur texture is the vertical blur.
  52121. */
  52122. blurVerticalSize: number;
  52123. /**
  52124. * How big in texel of the blur texture is the horizontal blur.
  52125. */
  52126. blurHorizontalSize: number;
  52127. /**
  52128. * Alpha blending mode used to apply the blur. Default is combine.
  52129. */
  52130. alphaBlendingMode: number;
  52131. /**
  52132. * The camera attached to the layer.
  52133. */
  52134. camera: Nullable<Camera>;
  52135. /**
  52136. * Should we display highlight as a solid stroke?
  52137. */
  52138. isStroke?: boolean;
  52139. /**
  52140. * The rendering group to draw the layer in.
  52141. */
  52142. renderingGroupId: number;
  52143. }
  52144. /**
  52145. * The highlight layer Helps adding a glow effect around a mesh.
  52146. *
  52147. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52148. * glowy meshes to your scene.
  52149. *
  52150. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52151. */
  52152. export class HighlightLayer extends EffectLayer {
  52153. name: string;
  52154. /**
  52155. * Effect Name of the highlight layer.
  52156. */
  52157. static readonly EffectName: string;
  52158. /**
  52159. * The neutral color used during the preparation of the glow effect.
  52160. * This is black by default as the blend operation is a blend operation.
  52161. */
  52162. static NeutralColor: Color4;
  52163. /**
  52164. * Stencil value used for glowing meshes.
  52165. */
  52166. static GlowingMeshStencilReference: number;
  52167. /**
  52168. * Stencil value used for the other meshes in the scene.
  52169. */
  52170. static NormalMeshStencilReference: number;
  52171. /**
  52172. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52173. */
  52174. innerGlow: boolean;
  52175. /**
  52176. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52177. */
  52178. outerGlow: boolean;
  52179. /**
  52180. * Specifies the horizontal size of the blur.
  52181. */
  52182. /**
  52183. * Gets the horizontal size of the blur.
  52184. */
  52185. blurHorizontalSize: number;
  52186. /**
  52187. * Specifies the vertical size of the blur.
  52188. */
  52189. /**
  52190. * Gets the vertical size of the blur.
  52191. */
  52192. blurVerticalSize: number;
  52193. /**
  52194. * An event triggered when the highlight layer is being blurred.
  52195. */
  52196. onBeforeBlurObservable: Observable<HighlightLayer>;
  52197. /**
  52198. * An event triggered when the highlight layer has been blurred.
  52199. */
  52200. onAfterBlurObservable: Observable<HighlightLayer>;
  52201. private _instanceGlowingMeshStencilReference;
  52202. private _options;
  52203. private _downSamplePostprocess;
  52204. private _horizontalBlurPostprocess;
  52205. private _verticalBlurPostprocess;
  52206. private _blurTexture;
  52207. private _meshes;
  52208. private _excludedMeshes;
  52209. /**
  52210. * Instantiates a new highlight Layer and references it to the scene..
  52211. * @param name The name of the layer
  52212. * @param scene The scene to use the layer in
  52213. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52214. */
  52215. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52216. /**
  52217. * Get the effect name of the layer.
  52218. * @return The effect name
  52219. */
  52220. getEffectName(): string;
  52221. /**
  52222. * Create the merge effect. This is the shader use to blit the information back
  52223. * to the main canvas at the end of the scene rendering.
  52224. */
  52225. protected _createMergeEffect(): Effect;
  52226. /**
  52227. * Creates the render target textures and post processes used in the highlight layer.
  52228. */
  52229. protected _createTextureAndPostProcesses(): void;
  52230. /**
  52231. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52232. */
  52233. needStencil(): boolean;
  52234. /**
  52235. * Checks for the readiness of the element composing the layer.
  52236. * @param subMesh the mesh to check for
  52237. * @param useInstances specify wether or not to use instances to render the mesh
  52238. * @param emissiveTexture the associated emissive texture used to generate the glow
  52239. * @return true if ready otherwise, false
  52240. */
  52241. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52242. /**
  52243. * Implementation specific of rendering the generating effect on the main canvas.
  52244. * @param effect The effect used to render through
  52245. */
  52246. protected _internalRender(effect: Effect): void;
  52247. /**
  52248. * Returns true if the layer contains information to display, otherwise false.
  52249. */
  52250. shouldRender(): boolean;
  52251. /**
  52252. * Returns true if the mesh should render, otherwise false.
  52253. * @param mesh The mesh to render
  52254. * @returns true if it should render otherwise false
  52255. */
  52256. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52257. /**
  52258. * Sets the required values for both the emissive texture and and the main color.
  52259. */
  52260. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52261. /**
  52262. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52263. * @param mesh The mesh to exclude from the highlight layer
  52264. */
  52265. addExcludedMesh(mesh: Mesh): void;
  52266. /**
  52267. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52268. * @param mesh The mesh to highlight
  52269. */
  52270. removeExcludedMesh(mesh: Mesh): void;
  52271. /**
  52272. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52273. * @param mesh mesh to test
  52274. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52275. */
  52276. hasMesh(mesh: AbstractMesh): boolean;
  52277. /**
  52278. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52279. * @param mesh The mesh to highlight
  52280. * @param color The color of the highlight
  52281. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52282. */
  52283. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52284. /**
  52285. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52286. * @param mesh The mesh to highlight
  52287. */
  52288. removeMesh(mesh: Mesh): void;
  52289. /**
  52290. * Force the stencil to the normal expected value for none glowing parts
  52291. */
  52292. private _defaultStencilReference;
  52293. /**
  52294. * Free any resources and references associated to a mesh.
  52295. * Internal use
  52296. * @param mesh The mesh to free.
  52297. * @hidden
  52298. */
  52299. _disposeMesh(mesh: Mesh): void;
  52300. /**
  52301. * Dispose the highlight layer and free resources.
  52302. */
  52303. dispose(): void;
  52304. /**
  52305. * Gets the class name of the effect layer
  52306. * @returns the string with the class name of the effect layer
  52307. */
  52308. getClassName(): string;
  52309. /**
  52310. * Serializes this Highlight layer
  52311. * @returns a serialized Highlight layer object
  52312. */
  52313. serialize(): any;
  52314. /**
  52315. * Creates a Highlight layer from parsed Highlight layer data
  52316. * @param parsedHightlightLayer defines the Highlight layer data
  52317. * @param scene defines the current scene
  52318. * @param rootUrl defines the root URL containing the Highlight layer information
  52319. * @returns a parsed Highlight layer
  52320. */
  52321. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52322. }
  52323. }
  52324. declare module "babylonjs/Layers/layerSceneComponent" {
  52325. import { Scene } from "babylonjs/scene";
  52326. import { ISceneComponent } from "babylonjs/sceneComponent";
  52327. import { Layer } from "babylonjs/Layers/layer";
  52328. import { AbstractScene } from "babylonjs/abstractScene";
  52329. module "babylonjs/abstractScene" {
  52330. interface AbstractScene {
  52331. /**
  52332. * The list of layers (background and foreground) of the scene
  52333. */
  52334. layers: Array<Layer>;
  52335. }
  52336. }
  52337. /**
  52338. * Defines the layer scene component responsible to manage any layers
  52339. * in a given scene.
  52340. */
  52341. export class LayerSceneComponent implements ISceneComponent {
  52342. /**
  52343. * The component name helpfull to identify the component in the list of scene components.
  52344. */
  52345. readonly name: string;
  52346. /**
  52347. * The scene the component belongs to.
  52348. */
  52349. scene: Scene;
  52350. private _engine;
  52351. /**
  52352. * Creates a new instance of the component for the given scene
  52353. * @param scene Defines the scene to register the component in
  52354. */
  52355. constructor(scene: Scene);
  52356. /**
  52357. * Registers the component in a given scene
  52358. */
  52359. register(): void;
  52360. /**
  52361. * Rebuilds the elements related to this component in case of
  52362. * context lost for instance.
  52363. */
  52364. rebuild(): void;
  52365. /**
  52366. * Disposes the component and the associated ressources.
  52367. */
  52368. dispose(): void;
  52369. private _draw;
  52370. private _drawCameraPredicate;
  52371. private _drawCameraBackground;
  52372. private _drawCameraForeground;
  52373. private _drawRenderTargetPredicate;
  52374. private _drawRenderTargetBackground;
  52375. private _drawRenderTargetForeground;
  52376. /**
  52377. * Adds all the elements from the container to the scene
  52378. * @param container the container holding the elements
  52379. */
  52380. addFromContainer(container: AbstractScene): void;
  52381. /**
  52382. * Removes all the elements in the container from the scene
  52383. * @param container contains the elements to remove
  52384. * @param dispose if the removed element should be disposed (default: false)
  52385. */
  52386. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52387. }
  52388. }
  52389. declare module "babylonjs/Shaders/layer.fragment" {
  52390. /** @hidden */
  52391. export var layerPixelShader: {
  52392. name: string;
  52393. shader: string;
  52394. };
  52395. }
  52396. declare module "babylonjs/Shaders/layer.vertex" {
  52397. /** @hidden */
  52398. export var layerVertexShader: {
  52399. name: string;
  52400. shader: string;
  52401. };
  52402. }
  52403. declare module "babylonjs/Layers/layer" {
  52404. import { Observable } from "babylonjs/Misc/observable";
  52405. import { Nullable } from "babylonjs/types";
  52406. import { Scene } from "babylonjs/scene";
  52407. import { Vector2 } from "babylonjs/Maths/math.vector";
  52408. import { Color4 } from "babylonjs/Maths/math.color";
  52409. import { Texture } from "babylonjs/Materials/Textures/texture";
  52410. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52411. import "babylonjs/Shaders/layer.fragment";
  52412. import "babylonjs/Shaders/layer.vertex";
  52413. /**
  52414. * This represents a full screen 2d layer.
  52415. * This can be useful to display a picture in the background of your scene for instance.
  52416. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52417. */
  52418. export class Layer {
  52419. /**
  52420. * Define the name of the layer.
  52421. */
  52422. name: string;
  52423. /**
  52424. * Define the texture the layer should display.
  52425. */
  52426. texture: Nullable<Texture>;
  52427. /**
  52428. * Is the layer in background or foreground.
  52429. */
  52430. isBackground: boolean;
  52431. /**
  52432. * Define the color of the layer (instead of texture).
  52433. */
  52434. color: Color4;
  52435. /**
  52436. * Define the scale of the layer in order to zoom in out of the texture.
  52437. */
  52438. scale: Vector2;
  52439. /**
  52440. * Define an offset for the layer in order to shift the texture.
  52441. */
  52442. offset: Vector2;
  52443. /**
  52444. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52445. */
  52446. alphaBlendingMode: number;
  52447. /**
  52448. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52449. * Alpha test will not mix with the background color in case of transparency.
  52450. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52451. */
  52452. alphaTest: boolean;
  52453. /**
  52454. * Define a mask to restrict the layer to only some of the scene cameras.
  52455. */
  52456. layerMask: number;
  52457. /**
  52458. * Define the list of render target the layer is visible into.
  52459. */
  52460. renderTargetTextures: RenderTargetTexture[];
  52461. /**
  52462. * Define if the layer is only used in renderTarget or if it also
  52463. * renders in the main frame buffer of the canvas.
  52464. */
  52465. renderOnlyInRenderTargetTextures: boolean;
  52466. private _scene;
  52467. private _vertexBuffers;
  52468. private _indexBuffer;
  52469. private _effect;
  52470. private _alphaTestEffect;
  52471. /**
  52472. * An event triggered when the layer is disposed.
  52473. */
  52474. onDisposeObservable: Observable<Layer>;
  52475. private _onDisposeObserver;
  52476. /**
  52477. * Back compatibility with callback before the onDisposeObservable existed.
  52478. * The set callback will be triggered when the layer has been disposed.
  52479. */
  52480. onDispose: () => void;
  52481. /**
  52482. * An event triggered before rendering the scene
  52483. */
  52484. onBeforeRenderObservable: Observable<Layer>;
  52485. private _onBeforeRenderObserver;
  52486. /**
  52487. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52488. * The set callback will be triggered just before rendering the layer.
  52489. */
  52490. onBeforeRender: () => void;
  52491. /**
  52492. * An event triggered after rendering the scene
  52493. */
  52494. onAfterRenderObservable: Observable<Layer>;
  52495. private _onAfterRenderObserver;
  52496. /**
  52497. * Back compatibility with callback before the onAfterRenderObservable existed.
  52498. * The set callback will be triggered just after rendering the layer.
  52499. */
  52500. onAfterRender: () => void;
  52501. /**
  52502. * Instantiates a new layer.
  52503. * This represents a full screen 2d layer.
  52504. * This can be useful to display a picture in the background of your scene for instance.
  52505. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52506. * @param name Define the name of the layer in the scene
  52507. * @param imgUrl Define the url of the texture to display in the layer
  52508. * @param scene Define the scene the layer belongs to
  52509. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52510. * @param color Defines a color for the layer
  52511. */
  52512. constructor(
  52513. /**
  52514. * Define the name of the layer.
  52515. */
  52516. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52517. private _createIndexBuffer;
  52518. /** @hidden */
  52519. _rebuild(): void;
  52520. /**
  52521. * Renders the layer in the scene.
  52522. */
  52523. render(): void;
  52524. /**
  52525. * Disposes and releases the associated ressources.
  52526. */
  52527. dispose(): void;
  52528. }
  52529. }
  52530. declare module "babylonjs/Layers/index" {
  52531. export * from "babylonjs/Layers/effectLayer";
  52532. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52533. export * from "babylonjs/Layers/glowLayer";
  52534. export * from "babylonjs/Layers/highlightLayer";
  52535. export * from "babylonjs/Layers/layer";
  52536. export * from "babylonjs/Layers/layerSceneComponent";
  52537. }
  52538. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52539. /** @hidden */
  52540. export var lensFlarePixelShader: {
  52541. name: string;
  52542. shader: string;
  52543. };
  52544. }
  52545. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52546. /** @hidden */
  52547. export var lensFlareVertexShader: {
  52548. name: string;
  52549. shader: string;
  52550. };
  52551. }
  52552. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52553. import { Scene } from "babylonjs/scene";
  52554. import { Vector3 } from "babylonjs/Maths/math.vector";
  52555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52556. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52557. import "babylonjs/Shaders/lensFlare.fragment";
  52558. import "babylonjs/Shaders/lensFlare.vertex";
  52559. import { Viewport } from "babylonjs/Maths/math.viewport";
  52560. /**
  52561. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52562. * It is usually composed of several `lensFlare`.
  52563. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52564. */
  52565. export class LensFlareSystem {
  52566. /**
  52567. * Define the name of the lens flare system
  52568. */
  52569. name: string;
  52570. /**
  52571. * List of lens flares used in this system.
  52572. */
  52573. lensFlares: LensFlare[];
  52574. /**
  52575. * Define a limit from the border the lens flare can be visible.
  52576. */
  52577. borderLimit: number;
  52578. /**
  52579. * Define a viewport border we do not want to see the lens flare in.
  52580. */
  52581. viewportBorder: number;
  52582. /**
  52583. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52584. */
  52585. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52586. /**
  52587. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52588. */
  52589. layerMask: number;
  52590. /**
  52591. * Define the id of the lens flare system in the scene.
  52592. * (equal to name by default)
  52593. */
  52594. id: string;
  52595. private _scene;
  52596. private _emitter;
  52597. private _vertexBuffers;
  52598. private _indexBuffer;
  52599. private _effect;
  52600. private _positionX;
  52601. private _positionY;
  52602. private _isEnabled;
  52603. /** @hidden */
  52604. static _SceneComponentInitialization: (scene: Scene) => void;
  52605. /**
  52606. * Instantiates a lens flare system.
  52607. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52608. * It is usually composed of several `lensFlare`.
  52609. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52610. * @param name Define the name of the lens flare system in the scene
  52611. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52612. * @param scene Define the scene the lens flare system belongs to
  52613. */
  52614. constructor(
  52615. /**
  52616. * Define the name of the lens flare system
  52617. */
  52618. name: string, emitter: any, scene: Scene);
  52619. /**
  52620. * Define if the lens flare system is enabled.
  52621. */
  52622. isEnabled: boolean;
  52623. /**
  52624. * Get the scene the effects belongs to.
  52625. * @returns the scene holding the lens flare system
  52626. */
  52627. getScene(): Scene;
  52628. /**
  52629. * Get the emitter of the lens flare system.
  52630. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52631. * @returns the emitter of the lens flare system
  52632. */
  52633. getEmitter(): any;
  52634. /**
  52635. * Set the emitter of the lens flare system.
  52636. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52637. * @param newEmitter Define the new emitter of the system
  52638. */
  52639. setEmitter(newEmitter: any): void;
  52640. /**
  52641. * Get the lens flare system emitter position.
  52642. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52643. * @returns the position
  52644. */
  52645. getEmitterPosition(): Vector3;
  52646. /**
  52647. * @hidden
  52648. */
  52649. computeEffectivePosition(globalViewport: Viewport): boolean;
  52650. /** @hidden */
  52651. _isVisible(): boolean;
  52652. /**
  52653. * @hidden
  52654. */
  52655. render(): boolean;
  52656. /**
  52657. * Dispose and release the lens flare with its associated resources.
  52658. */
  52659. dispose(): void;
  52660. /**
  52661. * Parse a lens flare system from a JSON repressentation
  52662. * @param parsedLensFlareSystem Define the JSON to parse
  52663. * @param scene Define the scene the parsed system should be instantiated in
  52664. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52665. * @returns the parsed system
  52666. */
  52667. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52668. /**
  52669. * Serialize the current Lens Flare System into a JSON representation.
  52670. * @returns the serialized JSON
  52671. */
  52672. serialize(): any;
  52673. }
  52674. }
  52675. declare module "babylonjs/LensFlares/lensFlare" {
  52676. import { Nullable } from "babylonjs/types";
  52677. import { Color3 } from "babylonjs/Maths/math.color";
  52678. import { Texture } from "babylonjs/Materials/Textures/texture";
  52679. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52680. /**
  52681. * This represents one of the lens effect in a `lensFlareSystem`.
  52682. * It controls one of the indiviual texture used in the effect.
  52683. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52684. */
  52685. export class LensFlare {
  52686. /**
  52687. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52688. */
  52689. size: number;
  52690. /**
  52691. * 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.
  52692. */
  52693. position: number;
  52694. /**
  52695. * Define the lens color.
  52696. */
  52697. color: Color3;
  52698. /**
  52699. * Define the lens texture.
  52700. */
  52701. texture: Nullable<Texture>;
  52702. /**
  52703. * Define the alpha mode to render this particular lens.
  52704. */
  52705. alphaMode: number;
  52706. private _system;
  52707. /**
  52708. * Creates a new Lens Flare.
  52709. * This represents one of the lens effect in a `lensFlareSystem`.
  52710. * It controls one of the indiviual texture used in the effect.
  52711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52712. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52713. * @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.
  52714. * @param color Define the lens color
  52715. * @param imgUrl Define the lens texture url
  52716. * @param system Define the `lensFlareSystem` this flare is part of
  52717. * @returns The newly created Lens Flare
  52718. */
  52719. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52720. /**
  52721. * Instantiates a new Lens Flare.
  52722. * This represents one of the lens effect in a `lensFlareSystem`.
  52723. * It controls one of the indiviual texture used in the effect.
  52724. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52725. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52726. * @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.
  52727. * @param color Define the lens color
  52728. * @param imgUrl Define the lens texture url
  52729. * @param system Define the `lensFlareSystem` this flare is part of
  52730. */
  52731. constructor(
  52732. /**
  52733. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52734. */
  52735. size: number,
  52736. /**
  52737. * 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.
  52738. */
  52739. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52740. /**
  52741. * Dispose and release the lens flare with its associated resources.
  52742. */
  52743. dispose(): void;
  52744. }
  52745. }
  52746. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52747. import { Nullable } from "babylonjs/types";
  52748. import { Scene } from "babylonjs/scene";
  52749. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52750. import { AbstractScene } from "babylonjs/abstractScene";
  52751. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52752. module "babylonjs/abstractScene" {
  52753. interface AbstractScene {
  52754. /**
  52755. * The list of lens flare system added to the scene
  52756. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52757. */
  52758. lensFlareSystems: Array<LensFlareSystem>;
  52759. /**
  52760. * Removes the given lens flare system from this scene.
  52761. * @param toRemove The lens flare system to remove
  52762. * @returns The index of the removed lens flare system
  52763. */
  52764. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52765. /**
  52766. * Adds the given lens flare system to this scene
  52767. * @param newLensFlareSystem The lens flare system to add
  52768. */
  52769. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52770. /**
  52771. * Gets a lens flare system using its name
  52772. * @param name defines the name to look for
  52773. * @returns the lens flare system or null if not found
  52774. */
  52775. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52776. /**
  52777. * Gets a lens flare system using its id
  52778. * @param id defines the id to look for
  52779. * @returns the lens flare system or null if not found
  52780. */
  52781. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52782. }
  52783. }
  52784. /**
  52785. * Defines the lens flare scene component responsible to manage any lens flares
  52786. * in a given scene.
  52787. */
  52788. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52789. /**
  52790. * The component name helpfull to identify the component in the list of scene components.
  52791. */
  52792. readonly name: string;
  52793. /**
  52794. * The scene the component belongs to.
  52795. */
  52796. scene: Scene;
  52797. /**
  52798. * Creates a new instance of the component for the given scene
  52799. * @param scene Defines the scene to register the component in
  52800. */
  52801. constructor(scene: Scene);
  52802. /**
  52803. * Registers the component in a given scene
  52804. */
  52805. register(): void;
  52806. /**
  52807. * Rebuilds the elements related to this component in case of
  52808. * context lost for instance.
  52809. */
  52810. rebuild(): void;
  52811. /**
  52812. * Adds all the elements from the container to the scene
  52813. * @param container the container holding the elements
  52814. */
  52815. addFromContainer(container: AbstractScene): void;
  52816. /**
  52817. * Removes all the elements in the container from the scene
  52818. * @param container contains the elements to remove
  52819. * @param dispose if the removed element should be disposed (default: false)
  52820. */
  52821. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52822. /**
  52823. * Serializes the component data to the specified json object
  52824. * @param serializationObject The object to serialize to
  52825. */
  52826. serialize(serializationObject: any): void;
  52827. /**
  52828. * Disposes the component and the associated ressources.
  52829. */
  52830. dispose(): void;
  52831. private _draw;
  52832. }
  52833. }
  52834. declare module "babylonjs/LensFlares/index" {
  52835. export * from "babylonjs/LensFlares/lensFlare";
  52836. export * from "babylonjs/LensFlares/lensFlareSystem";
  52837. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52838. }
  52839. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52840. import { Scene } from "babylonjs/scene";
  52841. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52842. import { AbstractScene } from "babylonjs/abstractScene";
  52843. /**
  52844. * Defines the shadow generator component responsible to manage any shadow generators
  52845. * in a given scene.
  52846. */
  52847. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52848. /**
  52849. * The component name helpfull to identify the component in the list of scene components.
  52850. */
  52851. readonly name: string;
  52852. /**
  52853. * The scene the component belongs to.
  52854. */
  52855. scene: Scene;
  52856. /**
  52857. * Creates a new instance of the component for the given scene
  52858. * @param scene Defines the scene to register the component in
  52859. */
  52860. constructor(scene: Scene);
  52861. /**
  52862. * Registers the component in a given scene
  52863. */
  52864. register(): void;
  52865. /**
  52866. * Rebuilds the elements related to this component in case of
  52867. * context lost for instance.
  52868. */
  52869. rebuild(): void;
  52870. /**
  52871. * Serializes the component data to the specified json object
  52872. * @param serializationObject The object to serialize to
  52873. */
  52874. serialize(serializationObject: any): void;
  52875. /**
  52876. * Adds all the elements from the container to the scene
  52877. * @param container the container holding the elements
  52878. */
  52879. addFromContainer(container: AbstractScene): void;
  52880. /**
  52881. * Removes all the elements in the container from the scene
  52882. * @param container contains the elements to remove
  52883. * @param dispose if the removed element should be disposed (default: false)
  52884. */
  52885. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52886. /**
  52887. * Rebuilds the elements related to this component in case of
  52888. * context lost for instance.
  52889. */
  52890. dispose(): void;
  52891. private _gatherRenderTargets;
  52892. }
  52893. }
  52894. declare module "babylonjs/Lights/Shadows/index" {
  52895. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52896. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52897. }
  52898. declare module "babylonjs/Lights/pointLight" {
  52899. import { Scene } from "babylonjs/scene";
  52900. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52901. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52902. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52903. import { Effect } from "babylonjs/Materials/effect";
  52904. /**
  52905. * A point light is a light defined by an unique point in world space.
  52906. * The light is emitted in every direction from this point.
  52907. * A good example of a point light is a standard light bulb.
  52908. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52909. */
  52910. export class PointLight extends ShadowLight {
  52911. private _shadowAngle;
  52912. /**
  52913. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52914. * This specifies what angle the shadow will use to be created.
  52915. *
  52916. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52917. */
  52918. /**
  52919. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52920. * This specifies what angle the shadow will use to be created.
  52921. *
  52922. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52923. */
  52924. shadowAngle: number;
  52925. /**
  52926. * Gets the direction if it has been set.
  52927. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52928. */
  52929. /**
  52930. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52931. */
  52932. direction: Vector3;
  52933. /**
  52934. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52935. * A PointLight emits the light in every direction.
  52936. * It can cast shadows.
  52937. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52938. * ```javascript
  52939. * var pointLight = new PointLight("pl", camera.position, scene);
  52940. * ```
  52941. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52942. * @param name The light friendly name
  52943. * @param position The position of the point light in the scene
  52944. * @param scene The scene the lights belongs to
  52945. */
  52946. constructor(name: string, position: Vector3, scene: Scene);
  52947. /**
  52948. * Returns the string "PointLight"
  52949. * @returns the class name
  52950. */
  52951. getClassName(): string;
  52952. /**
  52953. * Returns the integer 0.
  52954. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52955. */
  52956. getTypeID(): number;
  52957. /**
  52958. * Specifies wether or not the shadowmap should be a cube texture.
  52959. * @returns true if the shadowmap needs to be a cube texture.
  52960. */
  52961. needCube(): boolean;
  52962. /**
  52963. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52964. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52965. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52966. */
  52967. getShadowDirection(faceIndex?: number): Vector3;
  52968. /**
  52969. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52970. * - fov = PI / 2
  52971. * - aspect ratio : 1.0
  52972. * - z-near and far equal to the active camera minZ and maxZ.
  52973. * Returns the PointLight.
  52974. */
  52975. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52976. protected _buildUniformLayout(): void;
  52977. /**
  52978. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52979. * @param effect The effect to update
  52980. * @param lightIndex The index of the light in the effect to update
  52981. * @returns The point light
  52982. */
  52983. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52984. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52985. /**
  52986. * Prepares the list of defines specific to the light type.
  52987. * @param defines the list of defines
  52988. * @param lightIndex defines the index of the light for the effect
  52989. */
  52990. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52991. }
  52992. }
  52993. declare module "babylonjs/Lights/index" {
  52994. export * from "babylonjs/Lights/light";
  52995. export * from "babylonjs/Lights/shadowLight";
  52996. export * from "babylonjs/Lights/Shadows/index";
  52997. export * from "babylonjs/Lights/directionalLight";
  52998. export * from "babylonjs/Lights/hemisphericLight";
  52999. export * from "babylonjs/Lights/pointLight";
  53000. export * from "babylonjs/Lights/spotLight";
  53001. }
  53002. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  53003. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  53004. /**
  53005. * Header information of HDR texture files.
  53006. */
  53007. export interface HDRInfo {
  53008. /**
  53009. * The height of the texture in pixels.
  53010. */
  53011. height: number;
  53012. /**
  53013. * The width of the texture in pixels.
  53014. */
  53015. width: number;
  53016. /**
  53017. * The index of the beginning of the data in the binary file.
  53018. */
  53019. dataPosition: number;
  53020. }
  53021. /**
  53022. * This groups tools to convert HDR texture to native colors array.
  53023. */
  53024. export class HDRTools {
  53025. private static Ldexp;
  53026. private static Rgbe2float;
  53027. private static readStringLine;
  53028. /**
  53029. * Reads header information from an RGBE texture stored in a native array.
  53030. * More information on this format are available here:
  53031. * https://en.wikipedia.org/wiki/RGBE_image_format
  53032. *
  53033. * @param uint8array The binary file stored in native array.
  53034. * @return The header information.
  53035. */
  53036. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  53037. /**
  53038. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  53039. * This RGBE texture needs to store the information as a panorama.
  53040. *
  53041. * More information on this format are available here:
  53042. * https://en.wikipedia.org/wiki/RGBE_image_format
  53043. *
  53044. * @param buffer The binary file stored in an array buffer.
  53045. * @param size The expected size of the extracted cubemap.
  53046. * @return The Cube Map information.
  53047. */
  53048. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53049. /**
  53050. * Returns the pixels data extracted from an RGBE texture.
  53051. * This pixels will be stored left to right up to down in the R G B order in one array.
  53052. *
  53053. * More information on this format are available here:
  53054. * https://en.wikipedia.org/wiki/RGBE_image_format
  53055. *
  53056. * @param uint8array The binary file stored in an array buffer.
  53057. * @param hdrInfo The header information of the file.
  53058. * @return The pixels data in RGB right to left up to down order.
  53059. */
  53060. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53061. private static RGBE_ReadPixels_RLE;
  53062. }
  53063. }
  53064. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53065. import { Nullable } from "babylonjs/types";
  53066. import { Scene } from "babylonjs/scene";
  53067. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53068. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53069. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53070. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53071. /**
  53072. * This represents a texture coming from an HDR input.
  53073. *
  53074. * The only supported format is currently panorama picture stored in RGBE format.
  53075. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53076. */
  53077. export class HDRCubeTexture extends BaseTexture {
  53078. private static _facesMapping;
  53079. private _generateHarmonics;
  53080. private _noMipmap;
  53081. private _textureMatrix;
  53082. private _size;
  53083. private _onLoad;
  53084. private _onError;
  53085. /**
  53086. * The texture URL.
  53087. */
  53088. url: string;
  53089. /**
  53090. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53091. */
  53092. coordinatesMode: number;
  53093. protected _isBlocking: boolean;
  53094. /**
  53095. * Sets wether or not the texture is blocking during loading.
  53096. */
  53097. /**
  53098. * Gets wether or not the texture is blocking during loading.
  53099. */
  53100. isBlocking: boolean;
  53101. protected _rotationY: number;
  53102. /**
  53103. * Sets texture matrix rotation angle around Y axis in radians.
  53104. */
  53105. /**
  53106. * Gets texture matrix rotation angle around Y axis radians.
  53107. */
  53108. rotationY: number;
  53109. /**
  53110. * Gets or sets the center of the bounding box associated with the cube texture
  53111. * It must define where the camera used to render the texture was set
  53112. */
  53113. boundingBoxPosition: Vector3;
  53114. private _boundingBoxSize;
  53115. /**
  53116. * Gets or sets the size of the bounding box associated with the cube texture
  53117. * When defined, the cubemap will switch to local mode
  53118. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53119. * @example https://www.babylonjs-playground.com/#RNASML
  53120. */
  53121. boundingBoxSize: Vector3;
  53122. /**
  53123. * Instantiates an HDRTexture from the following parameters.
  53124. *
  53125. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53126. * @param scene The scene the texture will be used in
  53127. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53128. * @param noMipmap Forces to not generate the mipmap if true
  53129. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53130. * @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)
  53131. * @param reserved Reserved flag for internal use.
  53132. */
  53133. 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>);
  53134. /**
  53135. * Get the current class name of the texture useful for serialization or dynamic coding.
  53136. * @returns "HDRCubeTexture"
  53137. */
  53138. getClassName(): string;
  53139. /**
  53140. * Occurs when the file is raw .hdr file.
  53141. */
  53142. private loadTexture;
  53143. clone(): HDRCubeTexture;
  53144. delayLoad(): void;
  53145. /**
  53146. * Get the texture reflection matrix used to rotate/transform the reflection.
  53147. * @returns the reflection matrix
  53148. */
  53149. getReflectionTextureMatrix(): Matrix;
  53150. /**
  53151. * Set the texture reflection matrix used to rotate/transform the reflection.
  53152. * @param value Define the reflection matrix to set
  53153. */
  53154. setReflectionTextureMatrix(value: Matrix): void;
  53155. /**
  53156. * Parses a JSON representation of an HDR Texture in order to create the texture
  53157. * @param parsedTexture Define the JSON representation
  53158. * @param scene Define the scene the texture should be created in
  53159. * @param rootUrl Define the root url in case we need to load relative dependencies
  53160. * @returns the newly created texture after parsing
  53161. */
  53162. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53163. serialize(): any;
  53164. }
  53165. }
  53166. declare module "babylonjs/Physics/physicsEngine" {
  53167. import { Nullable } from "babylonjs/types";
  53168. import { Vector3 } from "babylonjs/Maths/math.vector";
  53169. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53170. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53171. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53172. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53173. /**
  53174. * Class used to control physics engine
  53175. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53176. */
  53177. export class PhysicsEngine implements IPhysicsEngine {
  53178. private _physicsPlugin;
  53179. /**
  53180. * Global value used to control the smallest number supported by the simulation
  53181. */
  53182. static Epsilon: number;
  53183. private _impostors;
  53184. private _joints;
  53185. /**
  53186. * Gets the gravity vector used by the simulation
  53187. */
  53188. gravity: Vector3;
  53189. /**
  53190. * Factory used to create the default physics plugin.
  53191. * @returns The default physics plugin
  53192. */
  53193. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53194. /**
  53195. * Creates a new Physics Engine
  53196. * @param gravity defines the gravity vector used by the simulation
  53197. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53198. */
  53199. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53200. /**
  53201. * Sets the gravity vector used by the simulation
  53202. * @param gravity defines the gravity vector to use
  53203. */
  53204. setGravity(gravity: Vector3): void;
  53205. /**
  53206. * Set the time step of the physics engine.
  53207. * Default is 1/60.
  53208. * To slow it down, enter 1/600 for example.
  53209. * To speed it up, 1/30
  53210. * @param newTimeStep defines the new timestep to apply to this world.
  53211. */
  53212. setTimeStep(newTimeStep?: number): void;
  53213. /**
  53214. * Get the time step of the physics engine.
  53215. * @returns the current time step
  53216. */
  53217. getTimeStep(): number;
  53218. /**
  53219. * Release all resources
  53220. */
  53221. dispose(): void;
  53222. /**
  53223. * Gets the name of the current physics plugin
  53224. * @returns the name of the plugin
  53225. */
  53226. getPhysicsPluginName(): string;
  53227. /**
  53228. * Adding a new impostor for the impostor tracking.
  53229. * This will be done by the impostor itself.
  53230. * @param impostor the impostor to add
  53231. */
  53232. addImpostor(impostor: PhysicsImpostor): void;
  53233. /**
  53234. * Remove an impostor from the engine.
  53235. * This impostor and its mesh will not longer be updated by the physics engine.
  53236. * @param impostor the impostor to remove
  53237. */
  53238. removeImpostor(impostor: PhysicsImpostor): void;
  53239. /**
  53240. * Add a joint to the physics engine
  53241. * @param mainImpostor defines the main impostor to which the joint is added.
  53242. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53243. * @param joint defines the joint that will connect both impostors.
  53244. */
  53245. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53246. /**
  53247. * Removes a joint from the simulation
  53248. * @param mainImpostor defines the impostor used with the joint
  53249. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53250. * @param joint defines the joint to remove
  53251. */
  53252. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53253. /**
  53254. * Called by the scene. No need to call it.
  53255. * @param delta defines the timespam between frames
  53256. */
  53257. _step(delta: number): void;
  53258. /**
  53259. * Gets the current plugin used to run the simulation
  53260. * @returns current plugin
  53261. */
  53262. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53263. /**
  53264. * Gets the list of physic impostors
  53265. * @returns an array of PhysicsImpostor
  53266. */
  53267. getImpostors(): Array<PhysicsImpostor>;
  53268. /**
  53269. * Gets the impostor for a physics enabled object
  53270. * @param object defines the object impersonated by the impostor
  53271. * @returns the PhysicsImpostor or null if not found
  53272. */
  53273. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53274. /**
  53275. * Gets the impostor for a physics body object
  53276. * @param body defines physics body used by the impostor
  53277. * @returns the PhysicsImpostor or null if not found
  53278. */
  53279. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53280. /**
  53281. * Does a raycast in the physics world
  53282. * @param from when should the ray start?
  53283. * @param to when should the ray end?
  53284. * @returns PhysicsRaycastResult
  53285. */
  53286. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53287. }
  53288. }
  53289. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53290. import { Nullable } from "babylonjs/types";
  53291. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53292. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53293. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53294. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53295. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53296. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53297. /** @hidden */
  53298. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53299. private _useDeltaForWorldStep;
  53300. world: any;
  53301. name: string;
  53302. private _physicsMaterials;
  53303. private _fixedTimeStep;
  53304. private _cannonRaycastResult;
  53305. private _raycastResult;
  53306. private _physicsBodysToRemoveAfterStep;
  53307. BJSCANNON: any;
  53308. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53309. setGravity(gravity: Vector3): void;
  53310. setTimeStep(timeStep: number): void;
  53311. getTimeStep(): number;
  53312. executeStep(delta: number): void;
  53313. private _removeMarkedPhysicsBodiesFromWorld;
  53314. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53315. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53316. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53317. private _processChildMeshes;
  53318. removePhysicsBody(impostor: PhysicsImpostor): void;
  53319. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53320. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53321. private _addMaterial;
  53322. private _checkWithEpsilon;
  53323. private _createShape;
  53324. private _createHeightmap;
  53325. private _minus90X;
  53326. private _plus90X;
  53327. private _tmpPosition;
  53328. private _tmpDeltaPosition;
  53329. private _tmpUnityRotation;
  53330. private _updatePhysicsBodyTransformation;
  53331. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53332. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53333. isSupported(): boolean;
  53334. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53335. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53336. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53337. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53338. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53339. getBodyMass(impostor: PhysicsImpostor): number;
  53340. getBodyFriction(impostor: PhysicsImpostor): number;
  53341. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53342. getBodyRestitution(impostor: PhysicsImpostor): number;
  53343. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53344. sleepBody(impostor: PhysicsImpostor): void;
  53345. wakeUpBody(impostor: PhysicsImpostor): void;
  53346. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53347. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53348. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53349. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53350. getRadius(impostor: PhysicsImpostor): number;
  53351. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53352. dispose(): void;
  53353. private _extendNamespace;
  53354. /**
  53355. * Does a raycast in the physics world
  53356. * @param from when should the ray start?
  53357. * @param to when should the ray end?
  53358. * @returns PhysicsRaycastResult
  53359. */
  53360. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53361. }
  53362. }
  53363. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53364. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53365. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53366. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53368. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53369. import { Nullable } from "babylonjs/types";
  53370. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53371. /** @hidden */
  53372. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53373. world: any;
  53374. name: string;
  53375. BJSOIMO: any;
  53376. private _raycastResult;
  53377. constructor(iterations?: number, oimoInjection?: any);
  53378. setGravity(gravity: Vector3): void;
  53379. setTimeStep(timeStep: number): void;
  53380. getTimeStep(): number;
  53381. private _tmpImpostorsArray;
  53382. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53383. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53384. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53385. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53386. private _tmpPositionVector;
  53387. removePhysicsBody(impostor: PhysicsImpostor): void;
  53388. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53389. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53390. isSupported(): boolean;
  53391. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53392. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53393. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53394. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53395. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53396. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53397. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53398. getBodyMass(impostor: PhysicsImpostor): number;
  53399. getBodyFriction(impostor: PhysicsImpostor): number;
  53400. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53401. getBodyRestitution(impostor: PhysicsImpostor): number;
  53402. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53403. sleepBody(impostor: PhysicsImpostor): void;
  53404. wakeUpBody(impostor: PhysicsImpostor): void;
  53405. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53406. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53407. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53408. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53409. getRadius(impostor: PhysicsImpostor): number;
  53410. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53411. dispose(): void;
  53412. /**
  53413. * Does a raycast in the physics world
  53414. * @param from when should the ray start?
  53415. * @param to when should the ray end?
  53416. * @returns PhysicsRaycastResult
  53417. */
  53418. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53419. }
  53420. }
  53421. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53422. import { Nullable } from "babylonjs/types";
  53423. import { Scene } from "babylonjs/scene";
  53424. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53425. import { Color4 } from "babylonjs/Maths/math.color";
  53426. import { Mesh } from "babylonjs/Meshes/mesh";
  53427. /**
  53428. * Class containing static functions to help procedurally build meshes
  53429. */
  53430. export class RibbonBuilder {
  53431. /**
  53432. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53433. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53434. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53435. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53436. * * 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
  53437. * * 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
  53438. * * 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
  53439. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53440. * * 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
  53441. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53442. * * 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
  53443. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53444. * * 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
  53445. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53447. * @param name defines the name of the mesh
  53448. * @param options defines the options used to create the mesh
  53449. * @param scene defines the hosting scene
  53450. * @returns the ribbon mesh
  53451. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53452. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53453. */
  53454. static CreateRibbon(name: string, options: {
  53455. pathArray: Vector3[][];
  53456. closeArray?: boolean;
  53457. closePath?: boolean;
  53458. offset?: number;
  53459. updatable?: boolean;
  53460. sideOrientation?: number;
  53461. frontUVs?: Vector4;
  53462. backUVs?: Vector4;
  53463. instance?: Mesh;
  53464. invertUV?: boolean;
  53465. uvs?: Vector2[];
  53466. colors?: Color4[];
  53467. }, scene?: Nullable<Scene>): Mesh;
  53468. }
  53469. }
  53470. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53471. import { Nullable } from "babylonjs/types";
  53472. import { Scene } from "babylonjs/scene";
  53473. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53474. import { Mesh } from "babylonjs/Meshes/mesh";
  53475. /**
  53476. * Class containing static functions to help procedurally build meshes
  53477. */
  53478. export class ShapeBuilder {
  53479. /**
  53480. * 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.
  53481. * * 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.
  53482. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53483. * * 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.
  53484. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53485. * * 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
  53486. * * 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
  53487. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53488. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53489. * * 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
  53490. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53492. * @param name defines the name of the mesh
  53493. * @param options defines the options used to create the mesh
  53494. * @param scene defines the hosting scene
  53495. * @returns the extruded shape mesh
  53496. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53497. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53498. */
  53499. static ExtrudeShape(name: string, options: {
  53500. shape: Vector3[];
  53501. path: Vector3[];
  53502. scale?: number;
  53503. rotation?: number;
  53504. cap?: number;
  53505. updatable?: boolean;
  53506. sideOrientation?: number;
  53507. frontUVs?: Vector4;
  53508. backUVs?: Vector4;
  53509. instance?: Mesh;
  53510. invertUV?: boolean;
  53511. }, scene?: Nullable<Scene>): Mesh;
  53512. /**
  53513. * Creates an custom extruded shape mesh.
  53514. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53515. * * 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.
  53516. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53517. * * 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
  53518. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53519. * * 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
  53520. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53521. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53522. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53523. * * 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
  53524. * * 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
  53525. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53527. * * 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
  53528. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53529. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53530. * @param name defines the name of the mesh
  53531. * @param options defines the options used to create the mesh
  53532. * @param scene defines the hosting scene
  53533. * @returns the custom extruded shape mesh
  53534. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53535. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53537. */
  53538. static ExtrudeShapeCustom(name: string, options: {
  53539. shape: Vector3[];
  53540. path: Vector3[];
  53541. scaleFunction?: any;
  53542. rotationFunction?: any;
  53543. ribbonCloseArray?: boolean;
  53544. ribbonClosePath?: boolean;
  53545. cap?: number;
  53546. updatable?: boolean;
  53547. sideOrientation?: number;
  53548. frontUVs?: Vector4;
  53549. backUVs?: Vector4;
  53550. instance?: Mesh;
  53551. invertUV?: boolean;
  53552. }, scene?: Nullable<Scene>): Mesh;
  53553. private static _ExtrudeShapeGeneric;
  53554. }
  53555. }
  53556. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53557. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53558. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53559. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53560. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53561. import { Nullable } from "babylonjs/types";
  53562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53563. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53564. /**
  53565. * AmmoJS Physics plugin
  53566. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53567. * @see https://github.com/kripken/ammo.js/
  53568. */
  53569. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53570. private _useDeltaForWorldStep;
  53571. /**
  53572. * Reference to the Ammo library
  53573. */
  53574. bjsAMMO: any;
  53575. /**
  53576. * Created ammoJS world which physics bodies are added to
  53577. */
  53578. world: any;
  53579. /**
  53580. * Name of the plugin
  53581. */
  53582. name: string;
  53583. private _timeStep;
  53584. private _fixedTimeStep;
  53585. private _maxSteps;
  53586. private _tmpQuaternion;
  53587. private _tmpAmmoTransform;
  53588. private _tmpAmmoQuaternion;
  53589. private _tmpAmmoConcreteContactResultCallback;
  53590. private _collisionConfiguration;
  53591. private _dispatcher;
  53592. private _overlappingPairCache;
  53593. private _solver;
  53594. private _softBodySolver;
  53595. private _tmpAmmoVectorA;
  53596. private _tmpAmmoVectorB;
  53597. private _tmpAmmoVectorC;
  53598. private _tmpAmmoVectorD;
  53599. private _tmpContactCallbackResult;
  53600. private _tmpAmmoVectorRCA;
  53601. private _tmpAmmoVectorRCB;
  53602. private _raycastResult;
  53603. private static readonly DISABLE_COLLISION_FLAG;
  53604. private static readonly KINEMATIC_FLAG;
  53605. private static readonly DISABLE_DEACTIVATION_FLAG;
  53606. /**
  53607. * Initializes the ammoJS plugin
  53608. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53609. * @param ammoInjection can be used to inject your own ammo reference
  53610. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53611. */
  53612. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53613. /**
  53614. * Sets the gravity of the physics world (m/(s^2))
  53615. * @param gravity Gravity to set
  53616. */
  53617. setGravity(gravity: Vector3): void;
  53618. /**
  53619. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53620. * @param timeStep timestep to use in seconds
  53621. */
  53622. setTimeStep(timeStep: number): void;
  53623. /**
  53624. * 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)
  53625. * @param fixedTimeStep fixedTimeStep to use in seconds
  53626. */
  53627. setFixedTimeStep(fixedTimeStep: number): void;
  53628. /**
  53629. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53630. * @param maxSteps the maximum number of steps by the physics engine per frame
  53631. */
  53632. setMaxSteps(maxSteps: number): void;
  53633. /**
  53634. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53635. * @returns the current timestep in seconds
  53636. */
  53637. getTimeStep(): number;
  53638. private _isImpostorInContact;
  53639. private _isImpostorPairInContact;
  53640. private _stepSimulation;
  53641. /**
  53642. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53643. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53644. * After the step the babylon meshes are set to the position of the physics imposters
  53645. * @param delta amount of time to step forward
  53646. * @param impostors array of imposters to update before/after the step
  53647. */
  53648. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53649. /**
  53650. * Update babylon mesh to match physics world object
  53651. * @param impostor imposter to match
  53652. */
  53653. private _afterSoftStep;
  53654. /**
  53655. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53656. * @param impostor imposter to match
  53657. */
  53658. private _ropeStep;
  53659. /**
  53660. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53661. * @param impostor imposter to match
  53662. */
  53663. private _softbodyOrClothStep;
  53664. private _tmpVector;
  53665. private _tmpMatrix;
  53666. /**
  53667. * Applies an impulse on the imposter
  53668. * @param impostor imposter to apply impulse to
  53669. * @param force amount of force to be applied to the imposter
  53670. * @param contactPoint the location to apply the impulse on the imposter
  53671. */
  53672. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53673. /**
  53674. * Applies a force on the imposter
  53675. * @param impostor imposter to apply force
  53676. * @param force amount of force to be applied to the imposter
  53677. * @param contactPoint the location to apply the force on the imposter
  53678. */
  53679. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53680. /**
  53681. * Creates a physics body using the plugin
  53682. * @param impostor the imposter to create the physics body on
  53683. */
  53684. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53685. /**
  53686. * Removes the physics body from the imposter and disposes of the body's memory
  53687. * @param impostor imposter to remove the physics body from
  53688. */
  53689. removePhysicsBody(impostor: PhysicsImpostor): void;
  53690. /**
  53691. * Generates a joint
  53692. * @param impostorJoint the imposter joint to create the joint with
  53693. */
  53694. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53695. /**
  53696. * Removes a joint
  53697. * @param impostorJoint the imposter joint to remove the joint from
  53698. */
  53699. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53700. private _addMeshVerts;
  53701. /**
  53702. * Initialise the soft body vertices to match its object's (mesh) vertices
  53703. * Softbody vertices (nodes) are in world space and to match this
  53704. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53705. * @param impostor to create the softbody for
  53706. */
  53707. private _softVertexData;
  53708. /**
  53709. * Create an impostor's soft body
  53710. * @param impostor to create the softbody for
  53711. */
  53712. private _createSoftbody;
  53713. /**
  53714. * Create cloth for an impostor
  53715. * @param impostor to create the softbody for
  53716. */
  53717. private _createCloth;
  53718. /**
  53719. * Create rope for an impostor
  53720. * @param impostor to create the softbody for
  53721. */
  53722. private _createRope;
  53723. private _addHullVerts;
  53724. private _createShape;
  53725. /**
  53726. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53727. * @param impostor imposter containing the physics body and babylon object
  53728. */
  53729. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53730. /**
  53731. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53732. * @param impostor imposter containing the physics body and babylon object
  53733. * @param newPosition new position
  53734. * @param newRotation new rotation
  53735. */
  53736. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53737. /**
  53738. * If this plugin is supported
  53739. * @returns true if its supported
  53740. */
  53741. isSupported(): boolean;
  53742. /**
  53743. * Sets the linear velocity of the physics body
  53744. * @param impostor imposter to set the velocity on
  53745. * @param velocity velocity to set
  53746. */
  53747. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53748. /**
  53749. * Sets the angular velocity of the physics body
  53750. * @param impostor imposter to set the velocity on
  53751. * @param velocity velocity to set
  53752. */
  53753. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53754. /**
  53755. * gets the linear velocity
  53756. * @param impostor imposter to get linear velocity from
  53757. * @returns linear velocity
  53758. */
  53759. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53760. /**
  53761. * gets the angular velocity
  53762. * @param impostor imposter to get angular velocity from
  53763. * @returns angular velocity
  53764. */
  53765. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53766. /**
  53767. * Sets the mass of physics body
  53768. * @param impostor imposter to set the mass on
  53769. * @param mass mass to set
  53770. */
  53771. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53772. /**
  53773. * Gets the mass of the physics body
  53774. * @param impostor imposter to get the mass from
  53775. * @returns mass
  53776. */
  53777. getBodyMass(impostor: PhysicsImpostor): number;
  53778. /**
  53779. * Gets friction of the impostor
  53780. * @param impostor impostor to get friction from
  53781. * @returns friction value
  53782. */
  53783. getBodyFriction(impostor: PhysicsImpostor): number;
  53784. /**
  53785. * Sets friction of the impostor
  53786. * @param impostor impostor to set friction on
  53787. * @param friction friction value
  53788. */
  53789. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53790. /**
  53791. * Gets restitution of the impostor
  53792. * @param impostor impostor to get restitution from
  53793. * @returns restitution value
  53794. */
  53795. getBodyRestitution(impostor: PhysicsImpostor): number;
  53796. /**
  53797. * Sets resitution of the impostor
  53798. * @param impostor impostor to set resitution on
  53799. * @param restitution resitution value
  53800. */
  53801. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53802. /**
  53803. * Gets pressure inside the impostor
  53804. * @param impostor impostor to get pressure from
  53805. * @returns pressure value
  53806. */
  53807. getBodyPressure(impostor: PhysicsImpostor): number;
  53808. /**
  53809. * Sets pressure inside a soft body impostor
  53810. * Cloth and rope must remain 0 pressure
  53811. * @param impostor impostor to set pressure on
  53812. * @param pressure pressure value
  53813. */
  53814. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53815. /**
  53816. * Gets stiffness of the impostor
  53817. * @param impostor impostor to get stiffness from
  53818. * @returns pressure value
  53819. */
  53820. getBodyStiffness(impostor: PhysicsImpostor): number;
  53821. /**
  53822. * Sets stiffness of the impostor
  53823. * @param impostor impostor to set stiffness on
  53824. * @param stiffness stiffness value from 0 to 1
  53825. */
  53826. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53827. /**
  53828. * Gets velocityIterations of the impostor
  53829. * @param impostor impostor to get velocity iterations from
  53830. * @returns velocityIterations value
  53831. */
  53832. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53833. /**
  53834. * Sets velocityIterations of the impostor
  53835. * @param impostor impostor to set velocity iterations on
  53836. * @param velocityIterations velocityIterations value
  53837. */
  53838. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53839. /**
  53840. * Gets positionIterations of the impostor
  53841. * @param impostor impostor to get position iterations from
  53842. * @returns positionIterations value
  53843. */
  53844. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53845. /**
  53846. * Sets positionIterations of the impostor
  53847. * @param impostor impostor to set position on
  53848. * @param positionIterations positionIterations value
  53849. */
  53850. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53851. /**
  53852. * Append an anchor to a cloth object
  53853. * @param impostor is the cloth impostor to add anchor to
  53854. * @param otherImpostor is the rigid impostor to anchor to
  53855. * @param width ratio across width from 0 to 1
  53856. * @param height ratio up height from 0 to 1
  53857. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53858. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53859. */
  53860. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53861. /**
  53862. * Append an hook to a rope object
  53863. * @param impostor is the rope impostor to add hook to
  53864. * @param otherImpostor is the rigid impostor to hook to
  53865. * @param length ratio along the rope from 0 to 1
  53866. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53867. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53868. */
  53869. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53870. /**
  53871. * Sleeps the physics body and stops it from being active
  53872. * @param impostor impostor to sleep
  53873. */
  53874. sleepBody(impostor: PhysicsImpostor): void;
  53875. /**
  53876. * Activates the physics body
  53877. * @param impostor impostor to activate
  53878. */
  53879. wakeUpBody(impostor: PhysicsImpostor): void;
  53880. /**
  53881. * Updates the distance parameters of the joint
  53882. * @param joint joint to update
  53883. * @param maxDistance maximum distance of the joint
  53884. * @param minDistance minimum distance of the joint
  53885. */
  53886. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53887. /**
  53888. * Sets a motor on the joint
  53889. * @param joint joint to set motor on
  53890. * @param speed speed of the motor
  53891. * @param maxForce maximum force of the motor
  53892. * @param motorIndex index of the motor
  53893. */
  53894. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53895. /**
  53896. * Sets the motors limit
  53897. * @param joint joint to set limit on
  53898. * @param upperLimit upper limit
  53899. * @param lowerLimit lower limit
  53900. */
  53901. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53902. /**
  53903. * Syncs the position and rotation of a mesh with the impostor
  53904. * @param mesh mesh to sync
  53905. * @param impostor impostor to update the mesh with
  53906. */
  53907. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53908. /**
  53909. * Gets the radius of the impostor
  53910. * @param impostor impostor to get radius from
  53911. * @returns the radius
  53912. */
  53913. getRadius(impostor: PhysicsImpostor): number;
  53914. /**
  53915. * Gets the box size of the impostor
  53916. * @param impostor impostor to get box size from
  53917. * @param result the resulting box size
  53918. */
  53919. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53920. /**
  53921. * Disposes of the impostor
  53922. */
  53923. dispose(): void;
  53924. /**
  53925. * Does a raycast in the physics world
  53926. * @param from when should the ray start?
  53927. * @param to when should the ray end?
  53928. * @returns PhysicsRaycastResult
  53929. */
  53930. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53931. }
  53932. }
  53933. declare module "babylonjs/Probes/reflectionProbe" {
  53934. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53935. import { Vector3 } from "babylonjs/Maths/math.vector";
  53936. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53937. import { Nullable } from "babylonjs/types";
  53938. import { Scene } from "babylonjs/scene";
  53939. module "babylonjs/abstractScene" {
  53940. interface AbstractScene {
  53941. /**
  53942. * The list of reflection probes added to the scene
  53943. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53944. */
  53945. reflectionProbes: Array<ReflectionProbe>;
  53946. /**
  53947. * Removes the given reflection probe from this scene.
  53948. * @param toRemove The reflection probe to remove
  53949. * @returns The index of the removed reflection probe
  53950. */
  53951. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53952. /**
  53953. * Adds the given reflection probe to this scene.
  53954. * @param newReflectionProbe The reflection probe to add
  53955. */
  53956. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53957. }
  53958. }
  53959. /**
  53960. * Class used to generate realtime reflection / refraction cube textures
  53961. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53962. */
  53963. export class ReflectionProbe {
  53964. /** defines the name of the probe */
  53965. name: string;
  53966. private _scene;
  53967. private _renderTargetTexture;
  53968. private _projectionMatrix;
  53969. private _viewMatrix;
  53970. private _target;
  53971. private _add;
  53972. private _attachedMesh;
  53973. private _invertYAxis;
  53974. /** Gets or sets probe position (center of the cube map) */
  53975. position: Vector3;
  53976. /**
  53977. * Creates a new reflection probe
  53978. * @param name defines the name of the probe
  53979. * @param size defines the texture resolution (for each face)
  53980. * @param scene defines the hosting scene
  53981. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53982. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53983. */
  53984. constructor(
  53985. /** defines the name of the probe */
  53986. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53987. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53988. samples: number;
  53989. /** Gets or sets the refresh rate to use (on every frame by default) */
  53990. refreshRate: number;
  53991. /**
  53992. * Gets the hosting scene
  53993. * @returns a Scene
  53994. */
  53995. getScene(): Scene;
  53996. /** Gets the internal CubeTexture used to render to */
  53997. readonly cubeTexture: RenderTargetTexture;
  53998. /** Gets the list of meshes to render */
  53999. readonly renderList: Nullable<AbstractMesh[]>;
  54000. /**
  54001. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  54002. * @param mesh defines the mesh to attach to
  54003. */
  54004. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  54005. /**
  54006. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  54007. * @param renderingGroupId The rendering group id corresponding to its index
  54008. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  54009. */
  54010. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  54011. /**
  54012. * Clean all associated resources
  54013. */
  54014. dispose(): void;
  54015. /**
  54016. * Converts the reflection probe information to a readable string for debug purpose.
  54017. * @param fullDetails Supports for multiple levels of logging within scene loading
  54018. * @returns the human readable reflection probe info
  54019. */
  54020. toString(fullDetails?: boolean): string;
  54021. /**
  54022. * Get the class name of the relfection probe.
  54023. * @returns "ReflectionProbe"
  54024. */
  54025. getClassName(): string;
  54026. /**
  54027. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  54028. * @returns The JSON representation of the texture
  54029. */
  54030. serialize(): any;
  54031. /**
  54032. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  54033. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  54034. * @param scene Define the scene the parsed reflection probe should be instantiated in
  54035. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  54036. * @returns The parsed reflection probe if successful
  54037. */
  54038. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  54039. }
  54040. }
  54041. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  54042. /** @hidden */
  54043. export var _BabylonLoaderRegistered: boolean;
  54044. }
  54045. declare module "babylonjs/Loading/Plugins/index" {
  54046. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  54047. }
  54048. declare module "babylonjs/Loading/index" {
  54049. export * from "babylonjs/Loading/loadingScreen";
  54050. export * from "babylonjs/Loading/Plugins/index";
  54051. export * from "babylonjs/Loading/sceneLoader";
  54052. export * from "babylonjs/Loading/sceneLoaderFlags";
  54053. }
  54054. declare module "babylonjs/Materials/Background/index" {
  54055. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54056. }
  54057. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54058. import { Scene } from "babylonjs/scene";
  54059. import { Color3 } from "babylonjs/Maths/math.color";
  54060. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54061. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54062. /**
  54063. * The Physically based simple base material of BJS.
  54064. *
  54065. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54066. * It is used as the base class for both the specGloss and metalRough conventions.
  54067. */
  54068. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54069. /**
  54070. * Number of Simultaneous lights allowed on the material.
  54071. */
  54072. maxSimultaneousLights: number;
  54073. /**
  54074. * If sets to true, disables all the lights affecting the material.
  54075. */
  54076. disableLighting: boolean;
  54077. /**
  54078. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54079. */
  54080. environmentTexture: BaseTexture;
  54081. /**
  54082. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54083. */
  54084. invertNormalMapX: boolean;
  54085. /**
  54086. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54087. */
  54088. invertNormalMapY: boolean;
  54089. /**
  54090. * Normal map used in the model.
  54091. */
  54092. normalTexture: BaseTexture;
  54093. /**
  54094. * Emissivie color used to self-illuminate the model.
  54095. */
  54096. emissiveColor: Color3;
  54097. /**
  54098. * Emissivie texture used to self-illuminate the model.
  54099. */
  54100. emissiveTexture: BaseTexture;
  54101. /**
  54102. * Occlusion Channel Strenght.
  54103. */
  54104. occlusionStrength: number;
  54105. /**
  54106. * Occlusion Texture of the material (adding extra occlusion effects).
  54107. */
  54108. occlusionTexture: BaseTexture;
  54109. /**
  54110. * Defines the alpha limits in alpha test mode.
  54111. */
  54112. alphaCutOff: number;
  54113. /**
  54114. * Gets the current double sided mode.
  54115. */
  54116. /**
  54117. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54118. */
  54119. doubleSided: boolean;
  54120. /**
  54121. * Stores the pre-calculated light information of a mesh in a texture.
  54122. */
  54123. lightmapTexture: BaseTexture;
  54124. /**
  54125. * If true, the light map contains occlusion information instead of lighting info.
  54126. */
  54127. useLightmapAsShadowmap: boolean;
  54128. /**
  54129. * Instantiates a new PBRMaterial instance.
  54130. *
  54131. * @param name The material name
  54132. * @param scene The scene the material will be use in.
  54133. */
  54134. constructor(name: string, scene: Scene);
  54135. getClassName(): string;
  54136. }
  54137. }
  54138. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54139. import { Scene } from "babylonjs/scene";
  54140. import { Color3 } from "babylonjs/Maths/math.color";
  54141. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54142. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54143. /**
  54144. * The PBR material of BJS following the metal roughness convention.
  54145. *
  54146. * This fits to the PBR convention in the GLTF definition:
  54147. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54148. */
  54149. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54150. /**
  54151. * The base color has two different interpretations depending on the value of metalness.
  54152. * When the material is a metal, the base color is the specific measured reflectance value
  54153. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54154. * of the material.
  54155. */
  54156. baseColor: Color3;
  54157. /**
  54158. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54159. * well as opacity information in the alpha channel.
  54160. */
  54161. baseTexture: BaseTexture;
  54162. /**
  54163. * Specifies the metallic scalar value of the material.
  54164. * Can also be used to scale the metalness values of the metallic texture.
  54165. */
  54166. metallic: number;
  54167. /**
  54168. * Specifies the roughness scalar value of the material.
  54169. * Can also be used to scale the roughness values of the metallic texture.
  54170. */
  54171. roughness: number;
  54172. /**
  54173. * Texture containing both the metallic value in the B channel and the
  54174. * roughness value in the G channel to keep better precision.
  54175. */
  54176. metallicRoughnessTexture: BaseTexture;
  54177. /**
  54178. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54179. *
  54180. * @param name The material name
  54181. * @param scene The scene the material will be use in.
  54182. */
  54183. constructor(name: string, scene: Scene);
  54184. /**
  54185. * Return the currrent class name of the material.
  54186. */
  54187. getClassName(): string;
  54188. /**
  54189. * Makes a duplicate of the current material.
  54190. * @param name - name to use for the new material.
  54191. */
  54192. clone(name: string): PBRMetallicRoughnessMaterial;
  54193. /**
  54194. * Serialize the material to a parsable JSON object.
  54195. */
  54196. serialize(): any;
  54197. /**
  54198. * Parses a JSON object correponding to the serialize function.
  54199. */
  54200. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54201. }
  54202. }
  54203. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54204. import { Scene } from "babylonjs/scene";
  54205. import { Color3 } from "babylonjs/Maths/math.color";
  54206. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54207. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54208. /**
  54209. * The PBR material of BJS following the specular glossiness convention.
  54210. *
  54211. * This fits to the PBR convention in the GLTF definition:
  54212. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54213. */
  54214. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54215. /**
  54216. * Specifies the diffuse color of the material.
  54217. */
  54218. diffuseColor: Color3;
  54219. /**
  54220. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54221. * channel.
  54222. */
  54223. diffuseTexture: BaseTexture;
  54224. /**
  54225. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54226. */
  54227. specularColor: Color3;
  54228. /**
  54229. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54230. */
  54231. glossiness: number;
  54232. /**
  54233. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54234. */
  54235. specularGlossinessTexture: BaseTexture;
  54236. /**
  54237. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54238. *
  54239. * @param name The material name
  54240. * @param scene The scene the material will be use in.
  54241. */
  54242. constructor(name: string, scene: Scene);
  54243. /**
  54244. * Return the currrent class name of the material.
  54245. */
  54246. getClassName(): string;
  54247. /**
  54248. * Makes a duplicate of the current material.
  54249. * @param name - name to use for the new material.
  54250. */
  54251. clone(name: string): PBRSpecularGlossinessMaterial;
  54252. /**
  54253. * Serialize the material to a parsable JSON object.
  54254. */
  54255. serialize(): any;
  54256. /**
  54257. * Parses a JSON object correponding to the serialize function.
  54258. */
  54259. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54260. }
  54261. }
  54262. declare module "babylonjs/Materials/PBR/index" {
  54263. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54264. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54265. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54266. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54267. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54268. }
  54269. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54270. import { Nullable } from "babylonjs/types";
  54271. import { Scene } from "babylonjs/scene";
  54272. import { Matrix } from "babylonjs/Maths/math.vector";
  54273. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54274. /**
  54275. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54276. * It can help converting any input color in a desired output one. This can then be used to create effects
  54277. * from sepia, black and white to sixties or futuristic rendering...
  54278. *
  54279. * The only supported format is currently 3dl.
  54280. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54281. */
  54282. export class ColorGradingTexture extends BaseTexture {
  54283. /**
  54284. * The current texture matrix. (will always be identity in color grading texture)
  54285. */
  54286. private _textureMatrix;
  54287. /**
  54288. * The texture URL.
  54289. */
  54290. url: string;
  54291. /**
  54292. * Empty line regex stored for GC.
  54293. */
  54294. private static _noneEmptyLineRegex;
  54295. private _engine;
  54296. /**
  54297. * Instantiates a ColorGradingTexture from the following parameters.
  54298. *
  54299. * @param url The location of the color gradind data (currently only supporting 3dl)
  54300. * @param scene The scene the texture will be used in
  54301. */
  54302. constructor(url: string, scene: Scene);
  54303. /**
  54304. * Returns the texture matrix used in most of the material.
  54305. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54306. */
  54307. getTextureMatrix(): Matrix;
  54308. /**
  54309. * Occurs when the file being loaded is a .3dl LUT file.
  54310. */
  54311. private load3dlTexture;
  54312. /**
  54313. * Starts the loading process of the texture.
  54314. */
  54315. private loadTexture;
  54316. /**
  54317. * Clones the color gradind texture.
  54318. */
  54319. clone(): ColorGradingTexture;
  54320. /**
  54321. * Called during delayed load for textures.
  54322. */
  54323. delayLoad(): void;
  54324. /**
  54325. * Parses a color grading texture serialized by Babylon.
  54326. * @param parsedTexture The texture information being parsedTexture
  54327. * @param scene The scene to load the texture in
  54328. * @param rootUrl The root url of the data assets to load
  54329. * @return A color gradind texture
  54330. */
  54331. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54332. /**
  54333. * Serializes the LUT texture to json format.
  54334. */
  54335. serialize(): any;
  54336. }
  54337. }
  54338. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54340. import { Scene } from "babylonjs/scene";
  54341. import { Nullable } from "babylonjs/types";
  54342. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54343. /**
  54344. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54345. */
  54346. export class EquiRectangularCubeTexture extends BaseTexture {
  54347. /** The six faces of the cube. */
  54348. private static _FacesMapping;
  54349. private _noMipmap;
  54350. private _onLoad;
  54351. private _onError;
  54352. /** The size of the cubemap. */
  54353. private _size;
  54354. /** The buffer of the image. */
  54355. private _buffer;
  54356. /** The width of the input image. */
  54357. private _width;
  54358. /** The height of the input image. */
  54359. private _height;
  54360. /** The URL to the image. */
  54361. url: string;
  54362. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54363. coordinatesMode: number;
  54364. /**
  54365. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54366. * @param url The location of the image
  54367. * @param scene The scene the texture will be used in
  54368. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54369. * @param noMipmap Forces to not generate the mipmap if true
  54370. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54371. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54372. * @param onLoad — defines a callback called when texture is loaded
  54373. * @param onError — defines a callback called if there is an error
  54374. */
  54375. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54376. /**
  54377. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54378. */
  54379. private loadImage;
  54380. /**
  54381. * Convert the image buffer into a cubemap and create a CubeTexture.
  54382. */
  54383. private loadTexture;
  54384. /**
  54385. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54386. * @param buffer The ArrayBuffer that should be converted.
  54387. * @returns The buffer as Float32Array.
  54388. */
  54389. private getFloat32ArrayFromArrayBuffer;
  54390. /**
  54391. * Get the current class name of the texture useful for serialization or dynamic coding.
  54392. * @returns "EquiRectangularCubeTexture"
  54393. */
  54394. getClassName(): string;
  54395. /**
  54396. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54397. * @returns A clone of the current EquiRectangularCubeTexture.
  54398. */
  54399. clone(): EquiRectangularCubeTexture;
  54400. }
  54401. }
  54402. declare module "babylonjs/Misc/tga" {
  54403. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54404. /**
  54405. * Based on jsTGALoader - Javascript loader for TGA file
  54406. * By Vincent Thibault
  54407. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54408. */
  54409. export class TGATools {
  54410. private static _TYPE_INDEXED;
  54411. private static _TYPE_RGB;
  54412. private static _TYPE_GREY;
  54413. private static _TYPE_RLE_INDEXED;
  54414. private static _TYPE_RLE_RGB;
  54415. private static _TYPE_RLE_GREY;
  54416. private static _ORIGIN_MASK;
  54417. private static _ORIGIN_SHIFT;
  54418. private static _ORIGIN_BL;
  54419. private static _ORIGIN_BR;
  54420. private static _ORIGIN_UL;
  54421. private static _ORIGIN_UR;
  54422. /**
  54423. * Gets the header of a TGA file
  54424. * @param data defines the TGA data
  54425. * @returns the header
  54426. */
  54427. static GetTGAHeader(data: Uint8Array): any;
  54428. /**
  54429. * Uploads TGA content to a Babylon Texture
  54430. * @hidden
  54431. */
  54432. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54433. /** @hidden */
  54434. 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;
  54435. /** @hidden */
  54436. 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;
  54437. /** @hidden */
  54438. 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;
  54439. /** @hidden */
  54440. 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;
  54441. /** @hidden */
  54442. 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;
  54443. /** @hidden */
  54444. 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;
  54445. }
  54446. }
  54447. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54448. import { Nullable } from "babylonjs/types";
  54449. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54450. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54451. /**
  54452. * Implementation of the TGA Texture Loader.
  54453. * @hidden
  54454. */
  54455. export class _TGATextureLoader implements IInternalTextureLoader {
  54456. /**
  54457. * Defines wether the loader supports cascade loading the different faces.
  54458. */
  54459. readonly supportCascades: boolean;
  54460. /**
  54461. * This returns if the loader support the current file information.
  54462. * @param extension defines the file extension of the file being loaded
  54463. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54464. * @param fallback defines the fallback internal texture if any
  54465. * @param isBase64 defines whether the texture is encoded as a base64
  54466. * @param isBuffer defines whether the texture data are stored as a buffer
  54467. * @returns true if the loader can load the specified file
  54468. */
  54469. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54470. /**
  54471. * Transform the url before loading if required.
  54472. * @param rootUrl the url of the texture
  54473. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54474. * @returns the transformed texture
  54475. */
  54476. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54477. /**
  54478. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54479. * @param rootUrl the url of the texture
  54480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54481. * @returns the fallback texture
  54482. */
  54483. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54484. /**
  54485. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54486. * @param data contains the texture data
  54487. * @param texture defines the BabylonJS internal texture
  54488. * @param createPolynomials will be true if polynomials have been requested
  54489. * @param onLoad defines the callback to trigger once the texture is ready
  54490. * @param onError defines the callback to trigger in case of error
  54491. */
  54492. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54493. /**
  54494. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54495. * @param data contains the texture data
  54496. * @param texture defines the BabylonJS internal texture
  54497. * @param callback defines the method to call once ready to upload
  54498. */
  54499. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54500. }
  54501. }
  54502. declare module "babylonjs/Misc/basis" {
  54503. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54504. /**
  54505. * Info about the .basis files
  54506. */
  54507. class BasisFileInfo {
  54508. /**
  54509. * If the file has alpha
  54510. */
  54511. hasAlpha: boolean;
  54512. /**
  54513. * Info about each image of the basis file
  54514. */
  54515. images: Array<{
  54516. levels: Array<{
  54517. width: number;
  54518. height: number;
  54519. transcodedPixels: ArrayBufferView;
  54520. }>;
  54521. }>;
  54522. }
  54523. /**
  54524. * Result of transcoding a basis file
  54525. */
  54526. class TranscodeResult {
  54527. /**
  54528. * Info about the .basis file
  54529. */
  54530. fileInfo: BasisFileInfo;
  54531. /**
  54532. * Format to use when loading the file
  54533. */
  54534. format: number;
  54535. }
  54536. /**
  54537. * Configuration options for the Basis transcoder
  54538. */
  54539. export class BasisTranscodeConfiguration {
  54540. /**
  54541. * Supported compression formats used to determine the supported output format of the transcoder
  54542. */
  54543. supportedCompressionFormats?: {
  54544. /**
  54545. * etc1 compression format
  54546. */
  54547. etc1?: boolean;
  54548. /**
  54549. * s3tc compression format
  54550. */
  54551. s3tc?: boolean;
  54552. /**
  54553. * pvrtc compression format
  54554. */
  54555. pvrtc?: boolean;
  54556. /**
  54557. * etc2 compression format
  54558. */
  54559. etc2?: boolean;
  54560. };
  54561. /**
  54562. * If mipmap levels should be loaded for transcoded images (Default: true)
  54563. */
  54564. loadMipmapLevels?: boolean;
  54565. /**
  54566. * Index of a single image to load (Default: all images)
  54567. */
  54568. loadSingleImage?: number;
  54569. }
  54570. /**
  54571. * Used to load .Basis files
  54572. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54573. */
  54574. export class BasisTools {
  54575. private static _IgnoreSupportedFormats;
  54576. /**
  54577. * URL to use when loading the basis transcoder
  54578. */
  54579. static JSModuleURL: string;
  54580. /**
  54581. * URL to use when loading the wasm module for the transcoder
  54582. */
  54583. static WasmModuleURL: string;
  54584. /**
  54585. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54586. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54587. * @returns internal format corresponding to the Basis format
  54588. */
  54589. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54590. private static _WorkerPromise;
  54591. private static _Worker;
  54592. private static _actionId;
  54593. private static _CreateWorkerAsync;
  54594. /**
  54595. * Transcodes a loaded image file to compressed pixel data
  54596. * @param imageData image data to transcode
  54597. * @param config configuration options for the transcoding
  54598. * @returns a promise resulting in the transcoded image
  54599. */
  54600. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54601. /**
  54602. * Loads a texture from the transcode result
  54603. * @param texture texture load to
  54604. * @param transcodeResult the result of transcoding the basis file to load from
  54605. */
  54606. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54607. }
  54608. }
  54609. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54610. import { Nullable } from "babylonjs/types";
  54611. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54612. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54613. /**
  54614. * Loader for .basis file format
  54615. */
  54616. export class _BasisTextureLoader implements IInternalTextureLoader {
  54617. /**
  54618. * Defines whether the loader supports cascade loading the different faces.
  54619. */
  54620. readonly supportCascades: boolean;
  54621. /**
  54622. * This returns if the loader support the current file information.
  54623. * @param extension defines the file extension of the file being loaded
  54624. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54625. * @param fallback defines the fallback internal texture if any
  54626. * @param isBase64 defines whether the texture is encoded as a base64
  54627. * @param isBuffer defines whether the texture data are stored as a buffer
  54628. * @returns true if the loader can load the specified file
  54629. */
  54630. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54631. /**
  54632. * Transform the url before loading if required.
  54633. * @param rootUrl the url of the texture
  54634. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54635. * @returns the transformed texture
  54636. */
  54637. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54638. /**
  54639. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54640. * @param rootUrl the url of the texture
  54641. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54642. * @returns the fallback texture
  54643. */
  54644. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54645. /**
  54646. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54647. * @param data contains the texture data
  54648. * @param texture defines the BabylonJS internal texture
  54649. * @param createPolynomials will be true if polynomials have been requested
  54650. * @param onLoad defines the callback to trigger once the texture is ready
  54651. * @param onError defines the callback to trigger in case of error
  54652. */
  54653. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54654. /**
  54655. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54656. * @param data contains the texture data
  54657. * @param texture defines the BabylonJS internal texture
  54658. * @param callback defines the method to call once ready to upload
  54659. */
  54660. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54661. }
  54662. }
  54663. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54664. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54665. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54666. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54667. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54668. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54669. }
  54670. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54671. import { Scene } from "babylonjs/scene";
  54672. import { Texture } from "babylonjs/Materials/Textures/texture";
  54673. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54674. /**
  54675. * 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.
  54676. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54677. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54678. */
  54679. export class CustomProceduralTexture extends ProceduralTexture {
  54680. private _animate;
  54681. private _time;
  54682. private _config;
  54683. private _texturePath;
  54684. /**
  54685. * Instantiates a new Custom Procedural Texture.
  54686. * 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.
  54687. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54688. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54689. * @param name Define the name of the texture
  54690. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54691. * @param size Define the size of the texture to create
  54692. * @param scene Define the scene the texture belongs to
  54693. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54694. * @param generateMipMaps Define if the texture should creates mip maps or not
  54695. */
  54696. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54697. private _loadJson;
  54698. /**
  54699. * Is the texture ready to be used ? (rendered at least once)
  54700. * @returns true if ready, otherwise, false.
  54701. */
  54702. isReady(): boolean;
  54703. /**
  54704. * Render the texture to its associated render target.
  54705. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54706. */
  54707. render(useCameraPostProcess?: boolean): void;
  54708. /**
  54709. * Update the list of dependant textures samplers in the shader.
  54710. */
  54711. updateTextures(): void;
  54712. /**
  54713. * Update the uniform values of the procedural texture in the shader.
  54714. */
  54715. updateShaderUniforms(): void;
  54716. /**
  54717. * Define if the texture animates or not.
  54718. */
  54719. animate: boolean;
  54720. }
  54721. }
  54722. declare module "babylonjs/Shaders/noise.fragment" {
  54723. /** @hidden */
  54724. export var noisePixelShader: {
  54725. name: string;
  54726. shader: string;
  54727. };
  54728. }
  54729. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54730. import { Nullable } from "babylonjs/types";
  54731. import { Scene } from "babylonjs/scene";
  54732. import { Texture } from "babylonjs/Materials/Textures/texture";
  54733. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54734. import "babylonjs/Shaders/noise.fragment";
  54735. /**
  54736. * Class used to generate noise procedural textures
  54737. */
  54738. export class NoiseProceduralTexture extends ProceduralTexture {
  54739. private _time;
  54740. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54741. brightness: number;
  54742. /** Defines the number of octaves to process */
  54743. octaves: number;
  54744. /** Defines the level of persistence (0.8 by default) */
  54745. persistence: number;
  54746. /** Gets or sets animation speed factor (default is 1) */
  54747. animationSpeedFactor: number;
  54748. /**
  54749. * Creates a new NoiseProceduralTexture
  54750. * @param name defines the name fo the texture
  54751. * @param size defines the size of the texture (default is 256)
  54752. * @param scene defines the hosting scene
  54753. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54754. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54755. */
  54756. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54757. private _updateShaderUniforms;
  54758. protected _getDefines(): string;
  54759. /** Generate the current state of the procedural texture */
  54760. render(useCameraPostProcess?: boolean): void;
  54761. /**
  54762. * Serializes this noise procedural texture
  54763. * @returns a serialized noise procedural texture object
  54764. */
  54765. serialize(): any;
  54766. /**
  54767. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54768. * @param parsedTexture defines parsed texture data
  54769. * @param scene defines the current scene
  54770. * @param rootUrl defines the root URL containing noise procedural texture information
  54771. * @returns a parsed NoiseProceduralTexture
  54772. */
  54773. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54774. }
  54775. }
  54776. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54777. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54778. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54779. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54780. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54781. }
  54782. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54783. import { Nullable } from "babylonjs/types";
  54784. import { Scene } from "babylonjs/scene";
  54785. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54786. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54787. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54788. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54789. /**
  54790. * Raw cube texture where the raw buffers are passed in
  54791. */
  54792. export class RawCubeTexture extends CubeTexture {
  54793. /**
  54794. * Creates a cube texture where the raw buffers are passed in.
  54795. * @param scene defines the scene the texture is attached to
  54796. * @param data defines the array of data to use to create each face
  54797. * @param size defines the size of the textures
  54798. * @param format defines the format of the data
  54799. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54800. * @param generateMipMaps defines if the engine should generate the mip levels
  54801. * @param invertY defines if data must be stored with Y axis inverted
  54802. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54803. * @param compression defines the compression used (null by default)
  54804. */
  54805. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54806. /**
  54807. * Updates the raw cube texture.
  54808. * @param data defines the data to store
  54809. * @param format defines the data format
  54810. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54811. * @param invertY defines if data must be stored with Y axis inverted
  54812. * @param compression defines the compression used (null by default)
  54813. * @param level defines which level of the texture to update
  54814. */
  54815. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54816. /**
  54817. * Updates a raw cube texture with RGBD encoded data.
  54818. * @param data defines the array of data [mipmap][face] to use to create each face
  54819. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54820. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54821. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54822. * @returns a promsie that resolves when the operation is complete
  54823. */
  54824. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54825. /**
  54826. * Clones the raw cube texture.
  54827. * @return a new cube texture
  54828. */
  54829. clone(): CubeTexture;
  54830. /** @hidden */
  54831. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54832. }
  54833. }
  54834. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54835. import { Scene } from "babylonjs/scene";
  54836. import { Texture } from "babylonjs/Materials/Textures/texture";
  54837. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54838. /**
  54839. * Class used to store 3D textures containing user data
  54840. */
  54841. export class RawTexture3D extends Texture {
  54842. /** Gets or sets the texture format to use */
  54843. format: number;
  54844. private _engine;
  54845. /**
  54846. * Create a new RawTexture3D
  54847. * @param data defines the data of the texture
  54848. * @param width defines the width of the texture
  54849. * @param height defines the height of the texture
  54850. * @param depth defines the depth of the texture
  54851. * @param format defines the texture format to use
  54852. * @param scene defines the hosting scene
  54853. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54854. * @param invertY defines if texture must be stored with Y axis inverted
  54855. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54856. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54857. */
  54858. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54859. /** Gets or sets the texture format to use */
  54860. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54861. /**
  54862. * Update the texture with new data
  54863. * @param data defines the data to store in the texture
  54864. */
  54865. update(data: ArrayBufferView): void;
  54866. }
  54867. }
  54868. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54869. import { Scene } from "babylonjs/scene";
  54870. import { Plane } from "babylonjs/Maths/math.plane";
  54871. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54872. /**
  54873. * Creates a refraction texture used by refraction channel of the standard material.
  54874. * It is like a mirror but to see through a material.
  54875. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54876. */
  54877. export class RefractionTexture extends RenderTargetTexture {
  54878. /**
  54879. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54880. * 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.
  54881. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54882. */
  54883. refractionPlane: Plane;
  54884. /**
  54885. * Define how deep under the surface we should see.
  54886. */
  54887. depth: number;
  54888. /**
  54889. * Creates a refraction texture used by refraction channel of the standard material.
  54890. * It is like a mirror but to see through a material.
  54891. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54892. * @param name Define the texture name
  54893. * @param size Define the size of the underlying texture
  54894. * @param scene Define the scene the refraction belongs to
  54895. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54896. */
  54897. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54898. /**
  54899. * Clone the refraction texture.
  54900. * @returns the cloned texture
  54901. */
  54902. clone(): RefractionTexture;
  54903. /**
  54904. * Serialize the texture to a JSON representation you could use in Parse later on
  54905. * @returns the serialized JSON representation
  54906. */
  54907. serialize(): any;
  54908. }
  54909. }
  54910. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54911. import { Nullable } from "babylonjs/types";
  54912. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54913. import { Matrix } from "babylonjs/Maths/math.vector";
  54914. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54915. import "babylonjs/Engines/Extensions/engine.videoTexture";
  54916. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54917. import { Scene } from "babylonjs/scene";
  54918. /**
  54919. * Defines the options related to the creation of an HtmlElementTexture
  54920. */
  54921. export interface IHtmlElementTextureOptions {
  54922. /**
  54923. * Defines wether mip maps should be created or not.
  54924. */
  54925. generateMipMaps?: boolean;
  54926. /**
  54927. * Defines the sampling mode of the texture.
  54928. */
  54929. samplingMode?: number;
  54930. /**
  54931. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54932. */
  54933. engine: Nullable<ThinEngine>;
  54934. /**
  54935. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54936. */
  54937. scene: Nullable<Scene>;
  54938. }
  54939. /**
  54940. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54941. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54942. * is automatically managed.
  54943. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54944. * in your application.
  54945. *
  54946. * As the update is not automatic, you need to call them manually.
  54947. */
  54948. export class HtmlElementTexture extends BaseTexture {
  54949. /**
  54950. * The texture URL.
  54951. */
  54952. element: HTMLVideoElement | HTMLCanvasElement;
  54953. private static readonly DefaultOptions;
  54954. private _textureMatrix;
  54955. private _engine;
  54956. private _isVideo;
  54957. private _generateMipMaps;
  54958. private _samplingMode;
  54959. /**
  54960. * Instantiates a HtmlElementTexture from the following parameters.
  54961. *
  54962. * @param name Defines the name of the texture
  54963. * @param element Defines the video or canvas the texture is filled with
  54964. * @param options Defines the other none mandatory texture creation options
  54965. */
  54966. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54967. private _createInternalTexture;
  54968. /**
  54969. * Returns the texture matrix used in most of the material.
  54970. */
  54971. getTextureMatrix(): Matrix;
  54972. /**
  54973. * Updates the content of the texture.
  54974. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54975. */
  54976. update(invertY?: Nullable<boolean>): void;
  54977. }
  54978. }
  54979. declare module "babylonjs/Materials/Textures/index" {
  54980. export * from "babylonjs/Materials/Textures/baseTexture";
  54981. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  54982. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54983. export * from "babylonjs/Materials/Textures/cubeTexture";
  54984. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54985. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54986. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54987. export * from "babylonjs/Materials/Textures/internalTexture";
  54988. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54989. export * from "babylonjs/Materials/Textures/Loaders/index";
  54990. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54991. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54992. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54993. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54994. export * from "babylonjs/Materials/Textures/rawTexture";
  54995. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54996. export * from "babylonjs/Materials/Textures/refractionTexture";
  54997. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54998. export * from "babylonjs/Materials/Textures/texture";
  54999. export * from "babylonjs/Materials/Textures/videoTexture";
  55000. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  55001. }
  55002. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  55003. /**
  55004. * Enum used to define the target of a block
  55005. */
  55006. export enum NodeMaterialBlockTargets {
  55007. /** Vertex shader */
  55008. Vertex = 1,
  55009. /** Fragment shader */
  55010. Fragment = 2,
  55011. /** Neutral */
  55012. Neutral = 4,
  55013. /** Vertex and Fragment */
  55014. VertexAndFragment = 3
  55015. }
  55016. }
  55017. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  55018. /**
  55019. * Defines the kind of connection point for node based material
  55020. */
  55021. export enum NodeMaterialBlockConnectionPointTypes {
  55022. /** Float */
  55023. Float = 1,
  55024. /** Int */
  55025. Int = 2,
  55026. /** Vector2 */
  55027. Vector2 = 4,
  55028. /** Vector3 */
  55029. Vector3 = 8,
  55030. /** Vector4 */
  55031. Vector4 = 16,
  55032. /** Color3 */
  55033. Color3 = 32,
  55034. /** Color4 */
  55035. Color4 = 64,
  55036. /** Matrix */
  55037. Matrix = 128,
  55038. /** Detect type based on connection */
  55039. AutoDetect = 1024,
  55040. /** Output type that will be defined by input type */
  55041. BasedOnInput = 2048
  55042. }
  55043. }
  55044. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  55045. /**
  55046. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  55047. */
  55048. export enum NodeMaterialBlockConnectionPointMode {
  55049. /** Value is an uniform */
  55050. Uniform = 0,
  55051. /** Value is a mesh attribute */
  55052. Attribute = 1,
  55053. /** Value is a varying between vertex and fragment shaders */
  55054. Varying = 2,
  55055. /** Mode is undefined */
  55056. Undefined = 3
  55057. }
  55058. }
  55059. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55060. /**
  55061. * Enum used to define system values e.g. values automatically provided by the system
  55062. */
  55063. export enum NodeMaterialSystemValues {
  55064. /** World */
  55065. World = 1,
  55066. /** View */
  55067. View = 2,
  55068. /** Projection */
  55069. Projection = 3,
  55070. /** ViewProjection */
  55071. ViewProjection = 4,
  55072. /** WorldView */
  55073. WorldView = 5,
  55074. /** WorldViewProjection */
  55075. WorldViewProjection = 6,
  55076. /** CameraPosition */
  55077. CameraPosition = 7,
  55078. /** Fog Color */
  55079. FogColor = 8,
  55080. /** Delta time */
  55081. DeltaTime = 9
  55082. }
  55083. }
  55084. declare module "babylonjs/Materials/Node/Enums/index" {
  55085. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55086. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55087. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55088. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55089. }
  55090. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55091. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55092. /**
  55093. * Root class for all node material optimizers
  55094. */
  55095. export class NodeMaterialOptimizer {
  55096. /**
  55097. * Function used to optimize a NodeMaterial graph
  55098. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55099. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55100. */
  55101. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55102. }
  55103. }
  55104. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55108. import { Scene } from "babylonjs/scene";
  55109. /**
  55110. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55111. */
  55112. export class TransformBlock extends NodeMaterialBlock {
  55113. /**
  55114. * Defines the value to use to complement W value to transform it to a Vector4
  55115. */
  55116. complementW: number;
  55117. /**
  55118. * Defines the value to use to complement z value to transform it to a Vector4
  55119. */
  55120. complementZ: number;
  55121. /**
  55122. * Creates a new TransformBlock
  55123. * @param name defines the block name
  55124. */
  55125. constructor(name: string);
  55126. /**
  55127. * Gets the current class name
  55128. * @returns the class name
  55129. */
  55130. getClassName(): string;
  55131. /**
  55132. * Gets the vector input
  55133. */
  55134. readonly vector: NodeMaterialConnectionPoint;
  55135. /**
  55136. * Gets the output component
  55137. */
  55138. readonly output: NodeMaterialConnectionPoint;
  55139. /**
  55140. * Gets the matrix transform input
  55141. */
  55142. readonly transform: NodeMaterialConnectionPoint;
  55143. protected _buildBlock(state: NodeMaterialBuildState): this;
  55144. serialize(): any;
  55145. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55146. protected _dumpPropertiesCode(): string;
  55147. }
  55148. }
  55149. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55150. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55151. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55152. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55153. /**
  55154. * Block used to output the vertex position
  55155. */
  55156. export class VertexOutputBlock extends NodeMaterialBlock {
  55157. /**
  55158. * Creates a new VertexOutputBlock
  55159. * @param name defines the block name
  55160. */
  55161. constructor(name: string);
  55162. /**
  55163. * Gets the current class name
  55164. * @returns the class name
  55165. */
  55166. getClassName(): string;
  55167. /**
  55168. * Gets the vector input component
  55169. */
  55170. readonly vector: NodeMaterialConnectionPoint;
  55171. protected _buildBlock(state: NodeMaterialBuildState): this;
  55172. }
  55173. }
  55174. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55175. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55176. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55177. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55178. /**
  55179. * Block used to output the final color
  55180. */
  55181. export class FragmentOutputBlock extends NodeMaterialBlock {
  55182. /**
  55183. * Create a new FragmentOutputBlock
  55184. * @param name defines the block name
  55185. */
  55186. constructor(name: string);
  55187. /**
  55188. * Gets the current class name
  55189. * @returns the class name
  55190. */
  55191. getClassName(): string;
  55192. /**
  55193. * Gets the rgba input component
  55194. */
  55195. readonly rgba: NodeMaterialConnectionPoint;
  55196. /**
  55197. * Gets the rgb input component
  55198. */
  55199. readonly rgb: NodeMaterialConnectionPoint;
  55200. /**
  55201. * Gets the a input component
  55202. */
  55203. readonly a: NodeMaterialConnectionPoint;
  55204. protected _buildBlock(state: NodeMaterialBuildState): this;
  55205. }
  55206. }
  55207. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55208. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55209. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55210. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55211. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55212. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55213. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55214. import { Effect } from "babylonjs/Materials/effect";
  55215. import { Mesh } from "babylonjs/Meshes/mesh";
  55216. import { Nullable } from "babylonjs/types";
  55217. import { Scene } from "babylonjs/scene";
  55218. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55219. /**
  55220. * Block used to read a reflection texture from a sampler
  55221. */
  55222. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55223. private _define3DName;
  55224. private _defineCubicName;
  55225. private _defineExplicitName;
  55226. private _defineProjectionName;
  55227. private _defineLocalCubicName;
  55228. private _defineSphericalName;
  55229. private _definePlanarName;
  55230. private _defineEquirectangularName;
  55231. private _defineMirroredEquirectangularFixedName;
  55232. private _defineEquirectangularFixedName;
  55233. private _defineSkyboxName;
  55234. private _cubeSamplerName;
  55235. private _2DSamplerName;
  55236. private _positionUVWName;
  55237. private _directionWName;
  55238. private _reflectionCoordsName;
  55239. private _reflection2DCoordsName;
  55240. private _reflectionColorName;
  55241. private _reflectionMatrixName;
  55242. /**
  55243. * Gets or sets the texture associated with the node
  55244. */
  55245. texture: Nullable<BaseTexture>;
  55246. /**
  55247. * Create a new TextureBlock
  55248. * @param name defines the block name
  55249. */
  55250. constructor(name: string);
  55251. /**
  55252. * Gets the current class name
  55253. * @returns the class name
  55254. */
  55255. getClassName(): string;
  55256. /**
  55257. * Gets the world position input component
  55258. */
  55259. readonly position: NodeMaterialConnectionPoint;
  55260. /**
  55261. * Gets the world position input component
  55262. */
  55263. readonly worldPosition: NodeMaterialConnectionPoint;
  55264. /**
  55265. * Gets the world normal input component
  55266. */
  55267. readonly worldNormal: NodeMaterialConnectionPoint;
  55268. /**
  55269. * Gets the world input component
  55270. */
  55271. readonly world: NodeMaterialConnectionPoint;
  55272. /**
  55273. * Gets the camera (or eye) position component
  55274. */
  55275. readonly cameraPosition: NodeMaterialConnectionPoint;
  55276. /**
  55277. * Gets the view input component
  55278. */
  55279. readonly view: NodeMaterialConnectionPoint;
  55280. /**
  55281. * Gets the rgb output component
  55282. */
  55283. readonly rgb: NodeMaterialConnectionPoint;
  55284. /**
  55285. * Gets the r output component
  55286. */
  55287. readonly r: NodeMaterialConnectionPoint;
  55288. /**
  55289. * Gets the g output component
  55290. */
  55291. readonly g: NodeMaterialConnectionPoint;
  55292. /**
  55293. * Gets the b output component
  55294. */
  55295. readonly b: NodeMaterialConnectionPoint;
  55296. autoConfigure(material: NodeMaterial): void;
  55297. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55298. isReady(): boolean;
  55299. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55300. private _injectVertexCode;
  55301. private _writeOutput;
  55302. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55303. serialize(): any;
  55304. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55305. }
  55306. }
  55307. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55309. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55310. import { Scene } from "babylonjs/scene";
  55311. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55312. import { Matrix } from "babylonjs/Maths/math.vector";
  55313. import { Mesh } from "babylonjs/Meshes/mesh";
  55314. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55315. import { Observable } from "babylonjs/Misc/observable";
  55316. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55317. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55318. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55319. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55320. import { Nullable } from "babylonjs/types";
  55321. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55322. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55323. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55324. /**
  55325. * Interface used to configure the node material editor
  55326. */
  55327. export interface INodeMaterialEditorOptions {
  55328. /** Define the URl to load node editor script */
  55329. editorURL?: string;
  55330. }
  55331. /** @hidden */
  55332. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55333. /** BONES */
  55334. NUM_BONE_INFLUENCERS: number;
  55335. BonesPerMesh: number;
  55336. BONETEXTURE: boolean;
  55337. /** MORPH TARGETS */
  55338. MORPHTARGETS: boolean;
  55339. MORPHTARGETS_NORMAL: boolean;
  55340. MORPHTARGETS_TANGENT: boolean;
  55341. MORPHTARGETS_UV: boolean;
  55342. NUM_MORPH_INFLUENCERS: number;
  55343. /** IMAGE PROCESSING */
  55344. IMAGEPROCESSING: boolean;
  55345. VIGNETTE: boolean;
  55346. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55347. VIGNETTEBLENDMODEOPAQUE: boolean;
  55348. TONEMAPPING: boolean;
  55349. TONEMAPPING_ACES: boolean;
  55350. CONTRAST: boolean;
  55351. EXPOSURE: boolean;
  55352. COLORCURVES: boolean;
  55353. COLORGRADING: boolean;
  55354. COLORGRADING3D: boolean;
  55355. SAMPLER3DGREENDEPTH: boolean;
  55356. SAMPLER3DBGRMAP: boolean;
  55357. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55358. /** MISC. */
  55359. BUMPDIRECTUV: number;
  55360. constructor();
  55361. setValue(name: string, value: boolean): void;
  55362. }
  55363. /**
  55364. * Class used to configure NodeMaterial
  55365. */
  55366. export interface INodeMaterialOptions {
  55367. /**
  55368. * Defines if blocks should emit comments
  55369. */
  55370. emitComments: boolean;
  55371. }
  55372. /**
  55373. * Class used to create a node based material built by assembling shader blocks
  55374. */
  55375. export class NodeMaterial extends PushMaterial {
  55376. private static _BuildIdGenerator;
  55377. private _options;
  55378. private _vertexCompilationState;
  55379. private _fragmentCompilationState;
  55380. private _sharedData;
  55381. private _buildId;
  55382. private _buildWasSuccessful;
  55383. private _cachedWorldViewMatrix;
  55384. private _cachedWorldViewProjectionMatrix;
  55385. private _optimizers;
  55386. private _animationFrame;
  55387. /** Define the URl to load node editor script */
  55388. static EditorURL: string;
  55389. private BJSNODEMATERIALEDITOR;
  55390. /** Get the inspector from bundle or global */
  55391. private _getGlobalNodeMaterialEditor;
  55392. /**
  55393. * 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)
  55394. */
  55395. ignoreAlpha: boolean;
  55396. /**
  55397. * Defines the maximum number of lights that can be used in the material
  55398. */
  55399. maxSimultaneousLights: number;
  55400. /**
  55401. * Observable raised when the material is built
  55402. */
  55403. onBuildObservable: Observable<NodeMaterial>;
  55404. /**
  55405. * Gets or sets the root nodes of the material vertex shader
  55406. */
  55407. _vertexOutputNodes: NodeMaterialBlock[];
  55408. /**
  55409. * Gets or sets the root nodes of the material fragment (pixel) shader
  55410. */
  55411. _fragmentOutputNodes: NodeMaterialBlock[];
  55412. /** Gets or sets options to control the node material overall behavior */
  55413. options: INodeMaterialOptions;
  55414. /**
  55415. * Default configuration related to image processing available in the standard Material.
  55416. */
  55417. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55418. /**
  55419. * Gets the image processing configuration used either in this material.
  55420. */
  55421. /**
  55422. * Sets the Default image processing configuration used either in the this material.
  55423. *
  55424. * If sets to null, the scene one is in use.
  55425. */
  55426. imageProcessingConfiguration: ImageProcessingConfiguration;
  55427. /**
  55428. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55429. */
  55430. attachedBlocks: NodeMaterialBlock[];
  55431. /**
  55432. * Create a new node based material
  55433. * @param name defines the material name
  55434. * @param scene defines the hosting scene
  55435. * @param options defines creation option
  55436. */
  55437. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55438. /**
  55439. * Gets the current class name of the material e.g. "NodeMaterial"
  55440. * @returns the class name
  55441. */
  55442. getClassName(): string;
  55443. /**
  55444. * Keep track of the image processing observer to allow dispose and replace.
  55445. */
  55446. private _imageProcessingObserver;
  55447. /**
  55448. * Attaches a new image processing configuration to the Standard Material.
  55449. * @param configuration
  55450. */
  55451. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55452. /**
  55453. * Get a block by its name
  55454. * @param name defines the name of the block to retrieve
  55455. * @returns the required block or null if not found
  55456. */
  55457. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55458. /**
  55459. * Get a block by its name
  55460. * @param predicate defines the predicate used to find the good candidate
  55461. * @returns the required block or null if not found
  55462. */
  55463. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55464. /**
  55465. * Get an input block by its name
  55466. * @param predicate defines the predicate used to find the good candidate
  55467. * @returns the required input block or null if not found
  55468. */
  55469. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55470. /**
  55471. * Gets the list of input blocks attached to this material
  55472. * @returns an array of InputBlocks
  55473. */
  55474. getInputBlocks(): InputBlock[];
  55475. /**
  55476. * Adds a new optimizer to the list of optimizers
  55477. * @param optimizer defines the optimizers to add
  55478. * @returns the current material
  55479. */
  55480. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55481. /**
  55482. * Remove an optimizer from the list of optimizers
  55483. * @param optimizer defines the optimizers to remove
  55484. * @returns the current material
  55485. */
  55486. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55487. /**
  55488. * Add a new block to the list of output nodes
  55489. * @param node defines the node to add
  55490. * @returns the current material
  55491. */
  55492. addOutputNode(node: NodeMaterialBlock): this;
  55493. /**
  55494. * Remove a block from the list of root nodes
  55495. * @param node defines the node to remove
  55496. * @returns the current material
  55497. */
  55498. removeOutputNode(node: NodeMaterialBlock): this;
  55499. private _addVertexOutputNode;
  55500. private _removeVertexOutputNode;
  55501. private _addFragmentOutputNode;
  55502. private _removeFragmentOutputNode;
  55503. /**
  55504. * Specifies if the material will require alpha blending
  55505. * @returns a boolean specifying if alpha blending is needed
  55506. */
  55507. needAlphaBlending(): boolean;
  55508. /**
  55509. * Specifies if this material should be rendered in alpha test mode
  55510. * @returns a boolean specifying if an alpha test is needed.
  55511. */
  55512. needAlphaTesting(): boolean;
  55513. private _initializeBlock;
  55514. private _resetDualBlocks;
  55515. /**
  55516. * Build the material and generates the inner effect
  55517. * @param verbose defines if the build should log activity
  55518. */
  55519. build(verbose?: boolean): void;
  55520. /**
  55521. * Runs an otpimization phase to try to improve the shader code
  55522. */
  55523. optimize(): void;
  55524. private _prepareDefinesForAttributes;
  55525. /**
  55526. * Get if the submesh is ready to be used and all its information available.
  55527. * Child classes can use it to update shaders
  55528. * @param mesh defines the mesh to check
  55529. * @param subMesh defines which submesh to check
  55530. * @param useInstances specifies that instances should be used
  55531. * @returns a boolean indicating that the submesh is ready or not
  55532. */
  55533. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55534. /**
  55535. * Get a string representing the shaders built by the current node graph
  55536. */
  55537. readonly compiledShaders: string;
  55538. /**
  55539. * Binds the world matrix to the material
  55540. * @param world defines the world transformation matrix
  55541. */
  55542. bindOnlyWorldMatrix(world: Matrix): void;
  55543. /**
  55544. * Binds the submesh to this material by preparing the effect and shader to draw
  55545. * @param world defines the world transformation matrix
  55546. * @param mesh defines the mesh containing the submesh
  55547. * @param subMesh defines the submesh to bind the material to
  55548. */
  55549. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55550. /**
  55551. * Gets the active textures from the material
  55552. * @returns an array of textures
  55553. */
  55554. getActiveTextures(): BaseTexture[];
  55555. /**
  55556. * Gets the list of texture blocks
  55557. * @returns an array of texture blocks
  55558. */
  55559. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55560. /**
  55561. * Specifies if the material uses a texture
  55562. * @param texture defines the texture to check against the material
  55563. * @returns a boolean specifying if the material uses the texture
  55564. */
  55565. hasTexture(texture: BaseTexture): boolean;
  55566. /**
  55567. * Disposes the material
  55568. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55569. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55570. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55571. */
  55572. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55573. /** Creates the node editor window. */
  55574. private _createNodeEditor;
  55575. /**
  55576. * Launch the node material editor
  55577. * @param config Define the configuration of the editor
  55578. * @return a promise fulfilled when the node editor is visible
  55579. */
  55580. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55581. /**
  55582. * Clear the current material
  55583. */
  55584. clear(): void;
  55585. /**
  55586. * Clear the current material and set it to a default state
  55587. */
  55588. setToDefault(): void;
  55589. /**
  55590. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55591. * @param url defines the url to load from
  55592. * @returns a promise that will fullfil when the material is fully loaded
  55593. */
  55594. loadAsync(url: string): Promise<unknown>;
  55595. private _gatherBlocks;
  55596. /**
  55597. * Generate a string containing the code declaration required to create an equivalent of this material
  55598. * @returns a string
  55599. */
  55600. generateCode(): string;
  55601. /**
  55602. * Serializes this material in a JSON representation
  55603. * @returns the serialized material object
  55604. */
  55605. serialize(): any;
  55606. private _restoreConnections;
  55607. /**
  55608. * Clear the current graph and load a new one from a serialization object
  55609. * @param source defines the JSON representation of the material
  55610. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55611. */
  55612. loadFromSerialization(source: any, rootUrl?: string): void;
  55613. /**
  55614. * Creates a node material from parsed material data
  55615. * @param source defines the JSON representation of the material
  55616. * @param scene defines the hosting scene
  55617. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55618. * @returns a new node material
  55619. */
  55620. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55621. /**
  55622. * Creates a new node material set to default basic configuration
  55623. * @param name defines the name of the material
  55624. * @param scene defines the hosting scene
  55625. * @returns a new NodeMaterial
  55626. */
  55627. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55628. }
  55629. }
  55630. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55631. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55632. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55633. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55634. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55636. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55637. import { Effect } from "babylonjs/Materials/effect";
  55638. import { Mesh } from "babylonjs/Meshes/mesh";
  55639. import { Nullable } from "babylonjs/types";
  55640. import { Texture } from "babylonjs/Materials/Textures/texture";
  55641. import { Scene } from "babylonjs/scene";
  55642. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55643. /**
  55644. * Block used to read a texture from a sampler
  55645. */
  55646. export class TextureBlock extends NodeMaterialBlock {
  55647. private _defineName;
  55648. private _linearDefineName;
  55649. private _samplerName;
  55650. private _transformedUVName;
  55651. private _textureTransformName;
  55652. private _textureInfoName;
  55653. private _mainUVName;
  55654. private _mainUVDefineName;
  55655. /**
  55656. * Gets or sets the texture associated with the node
  55657. */
  55658. texture: Nullable<Texture>;
  55659. /**
  55660. * Create a new TextureBlock
  55661. * @param name defines the block name
  55662. */
  55663. constructor(name: string);
  55664. /**
  55665. * Gets the current class name
  55666. * @returns the class name
  55667. */
  55668. getClassName(): string;
  55669. /**
  55670. * Gets the uv input component
  55671. */
  55672. readonly uv: NodeMaterialConnectionPoint;
  55673. /**
  55674. * Gets the rgba output component
  55675. */
  55676. readonly rgba: NodeMaterialConnectionPoint;
  55677. /**
  55678. * Gets the rgb output component
  55679. */
  55680. readonly rgb: NodeMaterialConnectionPoint;
  55681. /**
  55682. * Gets the r output component
  55683. */
  55684. readonly r: NodeMaterialConnectionPoint;
  55685. /**
  55686. * Gets the g output component
  55687. */
  55688. readonly g: NodeMaterialConnectionPoint;
  55689. /**
  55690. * Gets the b output component
  55691. */
  55692. readonly b: NodeMaterialConnectionPoint;
  55693. /**
  55694. * Gets the a output component
  55695. */
  55696. readonly a: NodeMaterialConnectionPoint;
  55697. readonly target: NodeMaterialBlockTargets;
  55698. autoConfigure(material: NodeMaterial): void;
  55699. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55700. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55701. isReady(): boolean;
  55702. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55703. private readonly _isMixed;
  55704. private _injectVertexCode;
  55705. private _writeOutput;
  55706. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55707. protected _dumpPropertiesCode(): string;
  55708. serialize(): any;
  55709. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55710. }
  55711. }
  55712. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55714. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55715. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55716. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55717. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55718. import { Scene } from "babylonjs/scene";
  55719. /**
  55720. * Class used to store shared data between 2 NodeMaterialBuildState
  55721. */
  55722. export class NodeMaterialBuildStateSharedData {
  55723. /**
  55724. * Gets the list of emitted varyings
  55725. */
  55726. temps: string[];
  55727. /**
  55728. * Gets the list of emitted varyings
  55729. */
  55730. varyings: string[];
  55731. /**
  55732. * Gets the varying declaration string
  55733. */
  55734. varyingDeclaration: string;
  55735. /**
  55736. * Input blocks
  55737. */
  55738. inputBlocks: InputBlock[];
  55739. /**
  55740. * Input blocks
  55741. */
  55742. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55743. /**
  55744. * Bindable blocks (Blocks that need to set data to the effect)
  55745. */
  55746. bindableBlocks: NodeMaterialBlock[];
  55747. /**
  55748. * List of blocks that can provide a compilation fallback
  55749. */
  55750. blocksWithFallbacks: NodeMaterialBlock[];
  55751. /**
  55752. * List of blocks that can provide a define update
  55753. */
  55754. blocksWithDefines: NodeMaterialBlock[];
  55755. /**
  55756. * List of blocks that can provide a repeatable content
  55757. */
  55758. repeatableContentBlocks: NodeMaterialBlock[];
  55759. /**
  55760. * List of blocks that can provide a dynamic list of uniforms
  55761. */
  55762. dynamicUniformBlocks: NodeMaterialBlock[];
  55763. /**
  55764. * List of blocks that can block the isReady function for the material
  55765. */
  55766. blockingBlocks: NodeMaterialBlock[];
  55767. /**
  55768. * Gets the list of animated inputs
  55769. */
  55770. animatedInputs: InputBlock[];
  55771. /**
  55772. * Build Id used to avoid multiple recompilations
  55773. */
  55774. buildId: number;
  55775. /** List of emitted variables */
  55776. variableNames: {
  55777. [key: string]: number;
  55778. };
  55779. /** List of emitted defines */
  55780. defineNames: {
  55781. [key: string]: number;
  55782. };
  55783. /** Should emit comments? */
  55784. emitComments: boolean;
  55785. /** Emit build activity */
  55786. verbose: boolean;
  55787. /** Gets or sets the hosting scene */
  55788. scene: Scene;
  55789. /**
  55790. * Gets the compilation hints emitted at compilation time
  55791. */
  55792. hints: {
  55793. needWorldViewMatrix: boolean;
  55794. needWorldViewProjectionMatrix: boolean;
  55795. needAlphaBlending: boolean;
  55796. needAlphaTesting: boolean;
  55797. };
  55798. /**
  55799. * List of compilation checks
  55800. */
  55801. checks: {
  55802. emitVertex: boolean;
  55803. emitFragment: boolean;
  55804. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55805. };
  55806. /** Creates a new shared data */
  55807. constructor();
  55808. /**
  55809. * Emits console errors and exceptions if there is a failing check
  55810. */
  55811. emitErrors(): void;
  55812. }
  55813. }
  55814. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55815. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55816. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55817. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55818. /**
  55819. * Class used to store node based material build state
  55820. */
  55821. export class NodeMaterialBuildState {
  55822. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55823. supportUniformBuffers: boolean;
  55824. /**
  55825. * Gets the list of emitted attributes
  55826. */
  55827. attributes: string[];
  55828. /**
  55829. * Gets the list of emitted uniforms
  55830. */
  55831. uniforms: string[];
  55832. /**
  55833. * Gets the list of emitted constants
  55834. */
  55835. constants: string[];
  55836. /**
  55837. * Gets the list of emitted uniform buffers
  55838. */
  55839. uniformBuffers: string[];
  55840. /**
  55841. * Gets the list of emitted samplers
  55842. */
  55843. samplers: string[];
  55844. /**
  55845. * Gets the list of emitted functions
  55846. */
  55847. functions: {
  55848. [key: string]: string;
  55849. };
  55850. /**
  55851. * Gets the list of emitted extensions
  55852. */
  55853. extensions: {
  55854. [key: string]: string;
  55855. };
  55856. /**
  55857. * Gets the target of the compilation state
  55858. */
  55859. target: NodeMaterialBlockTargets;
  55860. /**
  55861. * Gets the list of emitted counters
  55862. */
  55863. counters: {
  55864. [key: string]: number;
  55865. };
  55866. /**
  55867. * Shared data between multiple NodeMaterialBuildState instances
  55868. */
  55869. sharedData: NodeMaterialBuildStateSharedData;
  55870. /** @hidden */
  55871. _vertexState: NodeMaterialBuildState;
  55872. /** @hidden */
  55873. _attributeDeclaration: string;
  55874. /** @hidden */
  55875. _uniformDeclaration: string;
  55876. /** @hidden */
  55877. _constantDeclaration: string;
  55878. /** @hidden */
  55879. _samplerDeclaration: string;
  55880. /** @hidden */
  55881. _varyingTransfer: string;
  55882. private _repeatableContentAnchorIndex;
  55883. /** @hidden */
  55884. _builtCompilationString: string;
  55885. /**
  55886. * Gets the emitted compilation strings
  55887. */
  55888. compilationString: string;
  55889. /**
  55890. * Finalize the compilation strings
  55891. * @param state defines the current compilation state
  55892. */
  55893. finalize(state: NodeMaterialBuildState): void;
  55894. /** @hidden */
  55895. readonly _repeatableContentAnchor: string;
  55896. /** @hidden */
  55897. _getFreeVariableName(prefix: string): string;
  55898. /** @hidden */
  55899. _getFreeDefineName(prefix: string): string;
  55900. /** @hidden */
  55901. _excludeVariableName(name: string): void;
  55902. /** @hidden */
  55903. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55904. /** @hidden */
  55905. _emitExtension(name: string, extension: string): void;
  55906. /** @hidden */
  55907. _emitFunction(name: string, code: string, comments: string): void;
  55908. /** @hidden */
  55909. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55910. replaceStrings?: {
  55911. search: RegExp;
  55912. replace: string;
  55913. }[];
  55914. repeatKey?: string;
  55915. }): string;
  55916. /** @hidden */
  55917. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55918. repeatKey?: string;
  55919. removeAttributes?: boolean;
  55920. removeUniforms?: boolean;
  55921. removeVaryings?: boolean;
  55922. removeIfDef?: boolean;
  55923. replaceStrings?: {
  55924. search: RegExp;
  55925. replace: string;
  55926. }[];
  55927. }, storeKey?: string): void;
  55928. /** @hidden */
  55929. _registerTempVariable(name: string): boolean;
  55930. /** @hidden */
  55931. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55932. /** @hidden */
  55933. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55934. /** @hidden */
  55935. _emitFloat(value: number): string;
  55936. }
  55937. }
  55938. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55939. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55940. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55941. import { Nullable } from "babylonjs/types";
  55942. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55943. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55944. import { Effect } from "babylonjs/Materials/effect";
  55945. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55946. import { Mesh } from "babylonjs/Meshes/mesh";
  55947. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55948. import { Scene } from "babylonjs/scene";
  55949. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55950. /**
  55951. * Defines a block that can be used inside a node based material
  55952. */
  55953. export class NodeMaterialBlock {
  55954. private _buildId;
  55955. private _buildTarget;
  55956. private _target;
  55957. private _isFinalMerger;
  55958. private _isInput;
  55959. /** @hidden */
  55960. _codeVariableName: string;
  55961. /** @hidden */
  55962. _inputs: NodeMaterialConnectionPoint[];
  55963. /** @hidden */
  55964. _outputs: NodeMaterialConnectionPoint[];
  55965. /** @hidden */
  55966. _preparationId: number;
  55967. /**
  55968. * Gets or sets the name of the block
  55969. */
  55970. name: string;
  55971. /**
  55972. * Gets or sets the unique id of the node
  55973. */
  55974. uniqueId: number;
  55975. /**
  55976. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55977. */
  55978. readonly isFinalMerger: boolean;
  55979. /**
  55980. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55981. */
  55982. readonly isInput: boolean;
  55983. /**
  55984. * Gets or sets the build Id
  55985. */
  55986. buildId: number;
  55987. /**
  55988. * Gets or sets the target of the block
  55989. */
  55990. target: NodeMaterialBlockTargets;
  55991. /**
  55992. * Gets the list of input points
  55993. */
  55994. readonly inputs: NodeMaterialConnectionPoint[];
  55995. /** Gets the list of output points */
  55996. readonly outputs: NodeMaterialConnectionPoint[];
  55997. /**
  55998. * Find an input by its name
  55999. * @param name defines the name of the input to look for
  56000. * @returns the input or null if not found
  56001. */
  56002. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56003. /**
  56004. * Find an output by its name
  56005. * @param name defines the name of the outputto look for
  56006. * @returns the output or null if not found
  56007. */
  56008. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  56009. /**
  56010. * Creates a new NodeMaterialBlock
  56011. * @param name defines the block name
  56012. * @param target defines the target of that block (Vertex by default)
  56013. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  56014. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  56015. */
  56016. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  56017. /**
  56018. * Initialize the block and prepare the context for build
  56019. * @param state defines the state that will be used for the build
  56020. */
  56021. initialize(state: NodeMaterialBuildState): void;
  56022. /**
  56023. * Bind data to effect. Will only be called for blocks with isBindable === true
  56024. * @param effect defines the effect to bind data to
  56025. * @param nodeMaterial defines the hosting NodeMaterial
  56026. * @param mesh defines the mesh that will be rendered
  56027. */
  56028. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56029. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  56030. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  56031. protected _writeFloat(value: number): string;
  56032. /**
  56033. * Gets the current class name e.g. "NodeMaterialBlock"
  56034. * @returns the class name
  56035. */
  56036. getClassName(): string;
  56037. /**
  56038. * Register a new input. Must be called inside a block constructor
  56039. * @param name defines the connection point name
  56040. * @param type defines the connection point type
  56041. * @param isOptional defines a boolean indicating that this input can be omitted
  56042. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56043. * @returns the current block
  56044. */
  56045. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  56046. /**
  56047. * Register a new output. Must be called inside a block constructor
  56048. * @param name defines the connection point name
  56049. * @param type defines the connection point type
  56050. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  56051. * @returns the current block
  56052. */
  56053. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56054. /**
  56055. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56056. * @param forOutput defines an optional connection point to check compatibility with
  56057. * @returns the first available input or null
  56058. */
  56059. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56060. /**
  56061. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56062. * @param forBlock defines an optional block to check compatibility with
  56063. * @returns the first available input or null
  56064. */
  56065. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56066. /**
  56067. * Gets the sibling of the given output
  56068. * @param current defines the current output
  56069. * @returns the next output in the list or null
  56070. */
  56071. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56072. /**
  56073. * Connect current block with another block
  56074. * @param other defines the block to connect with
  56075. * @param options define the various options to help pick the right connections
  56076. * @returns the current block
  56077. */
  56078. connectTo(other: NodeMaterialBlock, options?: {
  56079. input?: string;
  56080. output?: string;
  56081. outputSwizzle?: string;
  56082. }): this | undefined;
  56083. protected _buildBlock(state: NodeMaterialBuildState): void;
  56084. /**
  56085. * Add uniforms, samplers and uniform buffers at compilation time
  56086. * @param state defines the state to update
  56087. * @param nodeMaterial defines the node material requesting the update
  56088. * @param defines defines the material defines to update
  56089. */
  56090. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56091. /**
  56092. * Add potential fallbacks if shader compilation fails
  56093. * @param mesh defines the mesh to be rendered
  56094. * @param fallbacks defines the current prioritized list of fallbacks
  56095. */
  56096. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56097. /**
  56098. * Initialize defines for shader compilation
  56099. * @param mesh defines the mesh to be rendered
  56100. * @param nodeMaterial defines the node material requesting the update
  56101. * @param defines defines the material defines to update
  56102. * @param useInstances specifies that instances should be used
  56103. */
  56104. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56105. /**
  56106. * Update defines for shader compilation
  56107. * @param mesh defines the mesh to be rendered
  56108. * @param nodeMaterial defines the node material requesting the update
  56109. * @param defines defines the material defines to update
  56110. * @param useInstances specifies that instances should be used
  56111. */
  56112. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56113. /**
  56114. * Lets the block try to connect some inputs automatically
  56115. * @param material defines the hosting NodeMaterial
  56116. */
  56117. autoConfigure(material: NodeMaterial): void;
  56118. /**
  56119. * Function called when a block is declared as repeatable content generator
  56120. * @param vertexShaderState defines the current compilation state for the vertex shader
  56121. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56122. * @param mesh defines the mesh to be rendered
  56123. * @param defines defines the material defines to update
  56124. */
  56125. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56126. /**
  56127. * Checks if the block is ready
  56128. * @param mesh defines the mesh to be rendered
  56129. * @param nodeMaterial defines the node material requesting the update
  56130. * @param defines defines the material defines to update
  56131. * @param useInstances specifies that instances should be used
  56132. * @returns true if the block is ready
  56133. */
  56134. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56135. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56136. private _processBuild;
  56137. /**
  56138. * Compile the current node and generate the shader code
  56139. * @param state defines the current compilation state (uniforms, samplers, current string)
  56140. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56141. * @returns true if already built
  56142. */
  56143. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56144. protected _inputRename(name: string): string;
  56145. protected _outputRename(name: string): string;
  56146. protected _dumpPropertiesCode(): string;
  56147. /** @hidden */
  56148. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56149. /**
  56150. * Clone the current block to a new identical block
  56151. * @param scene defines the hosting scene
  56152. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56153. * @returns a copy of the current block
  56154. */
  56155. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56156. /**
  56157. * Serializes this block in a JSON representation
  56158. * @returns the serialized block object
  56159. */
  56160. serialize(): any;
  56161. /** @hidden */
  56162. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56163. }
  56164. }
  56165. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56166. /**
  56167. * Enum defining the type of animations supported by InputBlock
  56168. */
  56169. export enum AnimatedInputBlockTypes {
  56170. /** No animation */
  56171. None = 0,
  56172. /** Time based animation. Will only work for floats */
  56173. Time = 1
  56174. }
  56175. }
  56176. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56177. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56178. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56179. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56180. import { Nullable } from "babylonjs/types";
  56181. import { Effect } from "babylonjs/Materials/effect";
  56182. import { Matrix } from "babylonjs/Maths/math.vector";
  56183. import { Scene } from "babylonjs/scene";
  56184. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56186. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56187. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56188. /**
  56189. * Block used to expose an input value
  56190. */
  56191. export class InputBlock extends NodeMaterialBlock {
  56192. private _mode;
  56193. private _associatedVariableName;
  56194. private _storedValue;
  56195. private _valueCallback;
  56196. private _type;
  56197. private _animationType;
  56198. /** Gets or set a value used to limit the range of float values */
  56199. min: number;
  56200. /** Gets or set a value used to limit the range of float values */
  56201. max: number;
  56202. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56203. matrixMode: number;
  56204. /** @hidden */
  56205. _systemValue: Nullable<NodeMaterialSystemValues>;
  56206. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56207. visibleInInspector: boolean;
  56208. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56209. isConstant: boolean;
  56210. /**
  56211. * Gets or sets the connection point type (default is float)
  56212. */
  56213. readonly type: NodeMaterialBlockConnectionPointTypes;
  56214. /**
  56215. * Creates a new InputBlock
  56216. * @param name defines the block name
  56217. * @param target defines the target of that block (Vertex by default)
  56218. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56219. */
  56220. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56221. /**
  56222. * Gets the output component
  56223. */
  56224. readonly output: NodeMaterialConnectionPoint;
  56225. /**
  56226. * Set the source of this connection point to a vertex attribute
  56227. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56228. * @returns the current connection point
  56229. */
  56230. setAsAttribute(attributeName?: string): InputBlock;
  56231. /**
  56232. * Set the source of this connection point to a system value
  56233. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56234. * @returns the current connection point
  56235. */
  56236. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56237. /**
  56238. * Gets or sets the value of that point.
  56239. * Please note that this value will be ignored if valueCallback is defined
  56240. */
  56241. value: any;
  56242. /**
  56243. * Gets or sets a callback used to get the value of that point.
  56244. * Please note that setting this value will force the connection point to ignore the value property
  56245. */
  56246. valueCallback: () => any;
  56247. /**
  56248. * Gets or sets the associated variable name in the shader
  56249. */
  56250. associatedVariableName: string;
  56251. /** Gets or sets the type of animation applied to the input */
  56252. animationType: AnimatedInputBlockTypes;
  56253. /**
  56254. * Gets a boolean indicating that this connection point not defined yet
  56255. */
  56256. readonly isUndefined: boolean;
  56257. /**
  56258. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56259. * In this case the connection point name must be the name of the uniform to use.
  56260. * Can only be set on inputs
  56261. */
  56262. isUniform: boolean;
  56263. /**
  56264. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56265. * In this case the connection point name must be the name of the attribute to use
  56266. * Can only be set on inputs
  56267. */
  56268. isAttribute: boolean;
  56269. /**
  56270. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56271. * Can only be set on exit points
  56272. */
  56273. isVarying: boolean;
  56274. /**
  56275. * Gets a boolean indicating that the current connection point is a system value
  56276. */
  56277. readonly isSystemValue: boolean;
  56278. /**
  56279. * Gets or sets the current well known value or null if not defined as a system value
  56280. */
  56281. systemValue: Nullable<NodeMaterialSystemValues>;
  56282. /**
  56283. * Gets the current class name
  56284. * @returns the class name
  56285. */
  56286. getClassName(): string;
  56287. /**
  56288. * Animate the input if animationType !== None
  56289. * @param scene defines the rendering scene
  56290. */
  56291. animate(scene: Scene): void;
  56292. private _emitDefine;
  56293. initialize(state: NodeMaterialBuildState): void;
  56294. /**
  56295. * Set the input block to its default value (based on its type)
  56296. */
  56297. setDefaultValue(): void;
  56298. private _emitConstant;
  56299. private _emit;
  56300. /** @hidden */
  56301. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56302. /** @hidden */
  56303. _transmit(effect: Effect, scene: Scene): void;
  56304. protected _buildBlock(state: NodeMaterialBuildState): void;
  56305. protected _dumpPropertiesCode(): string;
  56306. serialize(): any;
  56307. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56308. }
  56309. }
  56310. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56311. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56312. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56313. import { Nullable } from "babylonjs/types";
  56314. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56315. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56316. /**
  56317. * Defines a connection point for a block
  56318. */
  56319. export class NodeMaterialConnectionPoint {
  56320. /** @hidden */
  56321. _ownerBlock: NodeMaterialBlock;
  56322. /** @hidden */
  56323. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56324. private _endpoints;
  56325. private _associatedVariableName;
  56326. /** @hidden */
  56327. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56328. /** @hidden */
  56329. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56330. private _type;
  56331. /** @hidden */
  56332. _enforceAssociatedVariableName: boolean;
  56333. /**
  56334. * Gets or sets the additional types supported by this connection point
  56335. */
  56336. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56337. /**
  56338. * Gets or sets the additional types excluded by this connection point
  56339. */
  56340. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56341. /**
  56342. * Gets or sets the associated variable name in the shader
  56343. */
  56344. associatedVariableName: string;
  56345. /**
  56346. * Gets or sets the connection point type (default is float)
  56347. */
  56348. type: NodeMaterialBlockConnectionPointTypes;
  56349. /**
  56350. * Gets or sets the connection point name
  56351. */
  56352. name: string;
  56353. /**
  56354. * Gets or sets a boolean indicating that this connection point can be omitted
  56355. */
  56356. isOptional: boolean;
  56357. /**
  56358. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56359. */
  56360. define: string;
  56361. /** Gets or sets the target of that connection point */
  56362. target: NodeMaterialBlockTargets;
  56363. /**
  56364. * Gets a boolean indicating that the current point is connected
  56365. */
  56366. readonly isConnected: boolean;
  56367. /**
  56368. * Gets a boolean indicating that the current point is connected to an input block
  56369. */
  56370. readonly isConnectedToInputBlock: boolean;
  56371. /**
  56372. * Gets a the connected input block (if any)
  56373. */
  56374. readonly connectInputBlock: Nullable<InputBlock>;
  56375. /** Get the other side of the connection (if any) */
  56376. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56377. /** Get the block that owns this connection point */
  56378. readonly ownerBlock: NodeMaterialBlock;
  56379. /** Get the block connected on the other side of this connection (if any) */
  56380. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56381. /** Get the block connected on the endpoints of this connection (if any) */
  56382. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56383. /** Gets the list of connected endpoints */
  56384. readonly endpoints: NodeMaterialConnectionPoint[];
  56385. /** Gets a boolean indicating if that output point is connected to at least one input */
  56386. readonly hasEndpoints: boolean;
  56387. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  56388. readonly isConnectedInVertexShader: boolean;
  56389. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  56390. readonly isConnectedInFragmentShader: boolean;
  56391. /**
  56392. * Creates a new connection point
  56393. * @param name defines the connection point name
  56394. * @param ownerBlock defines the block hosting this connection point
  56395. */
  56396. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56397. /**
  56398. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56399. * @returns the class name
  56400. */
  56401. getClassName(): string;
  56402. /**
  56403. * Gets an boolean indicating if the current point can be connected to another point
  56404. * @param connectionPoint defines the other connection point
  56405. * @returns true if the connection is possible
  56406. */
  56407. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56408. /**
  56409. * Connect this point to another connection point
  56410. * @param connectionPoint defines the other connection point
  56411. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56412. * @returns the current connection point
  56413. */
  56414. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56415. /**
  56416. * Disconnect this point from one of his endpoint
  56417. * @param endpoint defines the other connection point
  56418. * @returns the current connection point
  56419. */
  56420. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56421. /**
  56422. * Serializes this point in a JSON representation
  56423. * @returns the serialized point object
  56424. */
  56425. serialize(): any;
  56426. }
  56427. }
  56428. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56432. import { Mesh } from "babylonjs/Meshes/mesh";
  56433. import { Effect } from "babylonjs/Materials/effect";
  56434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56435. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56436. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56437. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56438. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56439. /**
  56440. * Block used to add support for vertex skinning (bones)
  56441. */
  56442. export class BonesBlock extends NodeMaterialBlock {
  56443. /**
  56444. * Creates a new BonesBlock
  56445. * @param name defines the block name
  56446. */
  56447. constructor(name: string);
  56448. /**
  56449. * Initialize the block and prepare the context for build
  56450. * @param state defines the state that will be used for the build
  56451. */
  56452. initialize(state: NodeMaterialBuildState): void;
  56453. /**
  56454. * Gets the current class name
  56455. * @returns the class name
  56456. */
  56457. getClassName(): string;
  56458. /**
  56459. * Gets the matrix indices input component
  56460. */
  56461. readonly matricesIndices: NodeMaterialConnectionPoint;
  56462. /**
  56463. * Gets the matrix weights input component
  56464. */
  56465. readonly matricesWeights: NodeMaterialConnectionPoint;
  56466. /**
  56467. * Gets the extra matrix indices input component
  56468. */
  56469. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56470. /**
  56471. * Gets the extra matrix weights input component
  56472. */
  56473. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56474. /**
  56475. * Gets the world input component
  56476. */
  56477. readonly world: NodeMaterialConnectionPoint;
  56478. /**
  56479. * Gets the output component
  56480. */
  56481. readonly output: NodeMaterialConnectionPoint;
  56482. autoConfigure(material: NodeMaterial): void;
  56483. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56484. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56485. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56486. protected _buildBlock(state: NodeMaterialBuildState): this;
  56487. }
  56488. }
  56489. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56490. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56491. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56492. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56493. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56494. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56495. /**
  56496. * Block used to add support for instances
  56497. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56498. */
  56499. export class InstancesBlock extends NodeMaterialBlock {
  56500. /**
  56501. * Creates a new InstancesBlock
  56502. * @param name defines the block name
  56503. */
  56504. constructor(name: string);
  56505. /**
  56506. * Gets the current class name
  56507. * @returns the class name
  56508. */
  56509. getClassName(): string;
  56510. /**
  56511. * Gets the first world row input component
  56512. */
  56513. readonly world0: NodeMaterialConnectionPoint;
  56514. /**
  56515. * Gets the second world row input component
  56516. */
  56517. readonly world1: NodeMaterialConnectionPoint;
  56518. /**
  56519. * Gets the third world row input component
  56520. */
  56521. readonly world2: NodeMaterialConnectionPoint;
  56522. /**
  56523. * Gets the forth world row input component
  56524. */
  56525. readonly world3: NodeMaterialConnectionPoint;
  56526. /**
  56527. * Gets the world input component
  56528. */
  56529. readonly world: NodeMaterialConnectionPoint;
  56530. /**
  56531. * Gets the output component
  56532. */
  56533. readonly output: NodeMaterialConnectionPoint;
  56534. autoConfigure(material: NodeMaterial): void;
  56535. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56536. protected _buildBlock(state: NodeMaterialBuildState): this;
  56537. }
  56538. }
  56539. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56543. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56544. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56545. import { Effect } from "babylonjs/Materials/effect";
  56546. import { Mesh } from "babylonjs/Meshes/mesh";
  56547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56548. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56549. /**
  56550. * Block used to add morph targets support to vertex shader
  56551. */
  56552. export class MorphTargetsBlock extends NodeMaterialBlock {
  56553. private _repeatableContentAnchor;
  56554. private _repeatebleContentGenerated;
  56555. /**
  56556. * Create a new MorphTargetsBlock
  56557. * @param name defines the block name
  56558. */
  56559. constructor(name: string);
  56560. /**
  56561. * Gets the current class name
  56562. * @returns the class name
  56563. */
  56564. getClassName(): string;
  56565. /**
  56566. * Gets the position input component
  56567. */
  56568. readonly position: NodeMaterialConnectionPoint;
  56569. /**
  56570. * Gets the normal input component
  56571. */
  56572. readonly normal: NodeMaterialConnectionPoint;
  56573. /**
  56574. * Gets the tangent input component
  56575. */
  56576. readonly tangent: NodeMaterialConnectionPoint;
  56577. /**
  56578. * Gets the tangent input component
  56579. */
  56580. readonly uv: NodeMaterialConnectionPoint;
  56581. /**
  56582. * Gets the position output component
  56583. */
  56584. readonly positionOutput: NodeMaterialConnectionPoint;
  56585. /**
  56586. * Gets the normal output component
  56587. */
  56588. readonly normalOutput: NodeMaterialConnectionPoint;
  56589. /**
  56590. * Gets the tangent output component
  56591. */
  56592. readonly tangentOutput: NodeMaterialConnectionPoint;
  56593. /**
  56594. * Gets the tangent output component
  56595. */
  56596. readonly uvOutput: NodeMaterialConnectionPoint;
  56597. initialize(state: NodeMaterialBuildState): void;
  56598. autoConfigure(material: NodeMaterial): void;
  56599. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56600. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56601. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56602. protected _buildBlock(state: NodeMaterialBuildState): this;
  56603. }
  56604. }
  56605. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56606. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56607. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56608. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56609. import { Nullable } from "babylonjs/types";
  56610. import { Scene } from "babylonjs/scene";
  56611. import { Effect } from "babylonjs/Materials/effect";
  56612. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56613. import { Mesh } from "babylonjs/Meshes/mesh";
  56614. import { Light } from "babylonjs/Lights/light";
  56615. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56616. /**
  56617. * Block used to get data information from a light
  56618. */
  56619. export class LightInformationBlock extends NodeMaterialBlock {
  56620. private _lightDataUniformName;
  56621. private _lightColorUniformName;
  56622. private _lightTypeDefineName;
  56623. /**
  56624. * Gets or sets the light associated with this block
  56625. */
  56626. light: Nullable<Light>;
  56627. /**
  56628. * Creates a new LightInformationBlock
  56629. * @param name defines the block name
  56630. */
  56631. constructor(name: string);
  56632. /**
  56633. * Gets the current class name
  56634. * @returns the class name
  56635. */
  56636. getClassName(): string;
  56637. /**
  56638. * Gets the world position input component
  56639. */
  56640. readonly worldPosition: NodeMaterialConnectionPoint;
  56641. /**
  56642. * Gets the direction output component
  56643. */
  56644. readonly direction: NodeMaterialConnectionPoint;
  56645. /**
  56646. * Gets the direction output component
  56647. */
  56648. readonly color: NodeMaterialConnectionPoint;
  56649. /**
  56650. * Gets the direction output component
  56651. */
  56652. readonly intensity: NodeMaterialConnectionPoint;
  56653. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56654. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56655. protected _buildBlock(state: NodeMaterialBuildState): this;
  56656. serialize(): any;
  56657. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56658. }
  56659. }
  56660. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56661. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56662. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56663. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56664. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56665. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56666. }
  56667. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56672. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56673. import { Effect } from "babylonjs/Materials/effect";
  56674. import { Mesh } from "babylonjs/Meshes/mesh";
  56675. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56676. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56677. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56678. /**
  56679. * Block used to add image processing support to fragment shader
  56680. */
  56681. export class ImageProcessingBlock extends NodeMaterialBlock {
  56682. /**
  56683. * Create a new ImageProcessingBlock
  56684. * @param name defines the block name
  56685. */
  56686. constructor(name: string);
  56687. /**
  56688. * Gets the current class name
  56689. * @returns the class name
  56690. */
  56691. getClassName(): string;
  56692. /**
  56693. * Gets the color input component
  56694. */
  56695. readonly color: NodeMaterialConnectionPoint;
  56696. /**
  56697. * Gets the output component
  56698. */
  56699. readonly output: NodeMaterialConnectionPoint;
  56700. /**
  56701. * Initialize the block and prepare the context for build
  56702. * @param state defines the state that will be used for the build
  56703. */
  56704. initialize(state: NodeMaterialBuildState): void;
  56705. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56706. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56707. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56708. protected _buildBlock(state: NodeMaterialBuildState): this;
  56709. }
  56710. }
  56711. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56713. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56714. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56715. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56717. import { Effect } from "babylonjs/Materials/effect";
  56718. import { Mesh } from "babylonjs/Meshes/mesh";
  56719. import { Scene } from "babylonjs/scene";
  56720. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56721. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56722. /**
  56723. * Block used to pertub normals based on a normal map
  56724. */
  56725. export class PerturbNormalBlock extends NodeMaterialBlock {
  56726. private _tangentSpaceParameterName;
  56727. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56728. invertX: boolean;
  56729. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56730. invertY: boolean;
  56731. /**
  56732. * Create a new PerturbNormalBlock
  56733. * @param name defines the block name
  56734. */
  56735. constructor(name: string);
  56736. /**
  56737. * Gets the current class name
  56738. * @returns the class name
  56739. */
  56740. getClassName(): string;
  56741. /**
  56742. * Gets the world position input component
  56743. */
  56744. readonly worldPosition: NodeMaterialConnectionPoint;
  56745. /**
  56746. * Gets the world normal input component
  56747. */
  56748. readonly worldNormal: NodeMaterialConnectionPoint;
  56749. /**
  56750. * Gets the uv input component
  56751. */
  56752. readonly uv: NodeMaterialConnectionPoint;
  56753. /**
  56754. * Gets the normal map color input component
  56755. */
  56756. readonly normalMapColor: NodeMaterialConnectionPoint;
  56757. /**
  56758. * Gets the strength input component
  56759. */
  56760. readonly strength: NodeMaterialConnectionPoint;
  56761. /**
  56762. * Gets the output component
  56763. */
  56764. readonly output: NodeMaterialConnectionPoint;
  56765. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56766. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56767. autoConfigure(material: NodeMaterial): void;
  56768. protected _buildBlock(state: NodeMaterialBuildState): this;
  56769. protected _dumpPropertiesCode(): string;
  56770. serialize(): any;
  56771. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56772. }
  56773. }
  56774. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56775. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56776. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56777. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56778. /**
  56779. * Block used to discard a pixel if a value is smaller than a cutoff
  56780. */
  56781. export class DiscardBlock extends NodeMaterialBlock {
  56782. /**
  56783. * Create a new DiscardBlock
  56784. * @param name defines the block name
  56785. */
  56786. constructor(name: string);
  56787. /**
  56788. * Gets the current class name
  56789. * @returns the class name
  56790. */
  56791. getClassName(): string;
  56792. /**
  56793. * Gets the color input component
  56794. */
  56795. readonly value: NodeMaterialConnectionPoint;
  56796. /**
  56797. * Gets the cutoff input component
  56798. */
  56799. readonly cutoff: NodeMaterialConnectionPoint;
  56800. protected _buildBlock(state: NodeMaterialBuildState): this;
  56801. }
  56802. }
  56803. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56804. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56805. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56806. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56807. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56808. }
  56809. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56811. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56812. import { Mesh } from "babylonjs/Meshes/mesh";
  56813. import { Effect } from "babylonjs/Materials/effect";
  56814. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56816. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56817. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56818. /**
  56819. * Block used to add support for scene fog
  56820. */
  56821. export class FogBlock extends NodeMaterialBlock {
  56822. private _fogDistanceName;
  56823. private _fogParameters;
  56824. /**
  56825. * Create a new FogBlock
  56826. * @param name defines the block name
  56827. */
  56828. constructor(name: string);
  56829. /**
  56830. * Gets the current class name
  56831. * @returns the class name
  56832. */
  56833. getClassName(): string;
  56834. /**
  56835. * Gets the world position input component
  56836. */
  56837. readonly worldPosition: NodeMaterialConnectionPoint;
  56838. /**
  56839. * Gets the view input component
  56840. */
  56841. readonly view: NodeMaterialConnectionPoint;
  56842. /**
  56843. * Gets the color input component
  56844. */
  56845. readonly input: NodeMaterialConnectionPoint;
  56846. /**
  56847. * Gets the fog color input component
  56848. */
  56849. readonly fogColor: NodeMaterialConnectionPoint;
  56850. /**
  56851. * Gets the output component
  56852. */
  56853. readonly output: NodeMaterialConnectionPoint;
  56854. autoConfigure(material: NodeMaterial): void;
  56855. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56856. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56857. protected _buildBlock(state: NodeMaterialBuildState): this;
  56858. }
  56859. }
  56860. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56861. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56862. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56863. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56864. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56865. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56866. import { Effect } from "babylonjs/Materials/effect";
  56867. import { Mesh } from "babylonjs/Meshes/mesh";
  56868. import { Light } from "babylonjs/Lights/light";
  56869. import { Nullable } from "babylonjs/types";
  56870. import { Scene } from "babylonjs/scene";
  56871. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56872. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56873. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56874. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56875. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56876. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56877. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56878. /**
  56879. * Block used to add light in the fragment shader
  56880. */
  56881. export class LightBlock extends NodeMaterialBlock {
  56882. private _lightId;
  56883. /**
  56884. * Gets or sets the light associated with this block
  56885. */
  56886. light: Nullable<Light>;
  56887. /**
  56888. * Create a new LightBlock
  56889. * @param name defines the block name
  56890. */
  56891. constructor(name: string);
  56892. /**
  56893. * Gets the current class name
  56894. * @returns the class name
  56895. */
  56896. getClassName(): string;
  56897. /**
  56898. * Gets the world position input component
  56899. */
  56900. readonly worldPosition: NodeMaterialConnectionPoint;
  56901. /**
  56902. * Gets the world normal input component
  56903. */
  56904. readonly worldNormal: NodeMaterialConnectionPoint;
  56905. /**
  56906. * Gets the camera (or eye) position component
  56907. */
  56908. readonly cameraPosition: NodeMaterialConnectionPoint;
  56909. /**
  56910. * Gets the glossiness component
  56911. */
  56912. readonly glossiness: NodeMaterialConnectionPoint;
  56913. /**
  56914. * Gets the glossinness power component
  56915. */
  56916. readonly glossPower: NodeMaterialConnectionPoint;
  56917. /**
  56918. * Gets the diffuse color component
  56919. */
  56920. readonly diffuseColor: NodeMaterialConnectionPoint;
  56921. /**
  56922. * Gets the specular color component
  56923. */
  56924. readonly specularColor: NodeMaterialConnectionPoint;
  56925. /**
  56926. * Gets the diffuse output component
  56927. */
  56928. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56929. /**
  56930. * Gets the specular output component
  56931. */
  56932. readonly specularOutput: NodeMaterialConnectionPoint;
  56933. autoConfigure(material: NodeMaterial): void;
  56934. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56935. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56936. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56937. private _injectVertexCode;
  56938. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56939. serialize(): any;
  56940. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56941. }
  56942. }
  56943. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56944. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56945. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56946. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56947. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56948. }
  56949. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56950. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56951. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56952. }
  56953. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56957. /**
  56958. * Block used to multiply 2 values
  56959. */
  56960. export class MultiplyBlock extends NodeMaterialBlock {
  56961. /**
  56962. * Creates a new MultiplyBlock
  56963. * @param name defines the block name
  56964. */
  56965. constructor(name: string);
  56966. /**
  56967. * Gets the current class name
  56968. * @returns the class name
  56969. */
  56970. getClassName(): string;
  56971. /**
  56972. * Gets the left operand input component
  56973. */
  56974. readonly left: NodeMaterialConnectionPoint;
  56975. /**
  56976. * Gets the right operand input component
  56977. */
  56978. readonly right: NodeMaterialConnectionPoint;
  56979. /**
  56980. * Gets the output component
  56981. */
  56982. readonly output: NodeMaterialConnectionPoint;
  56983. protected _buildBlock(state: NodeMaterialBuildState): this;
  56984. }
  56985. }
  56986. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56987. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56988. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56989. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56990. /**
  56991. * Block used to add 2 vectors
  56992. */
  56993. export class AddBlock extends NodeMaterialBlock {
  56994. /**
  56995. * Creates a new AddBlock
  56996. * @param name defines the block name
  56997. */
  56998. constructor(name: string);
  56999. /**
  57000. * Gets the current class name
  57001. * @returns the class name
  57002. */
  57003. getClassName(): string;
  57004. /**
  57005. * Gets the left operand input component
  57006. */
  57007. readonly left: NodeMaterialConnectionPoint;
  57008. /**
  57009. * Gets the right operand input component
  57010. */
  57011. readonly right: NodeMaterialConnectionPoint;
  57012. /**
  57013. * Gets the output component
  57014. */
  57015. readonly output: NodeMaterialConnectionPoint;
  57016. protected _buildBlock(state: NodeMaterialBuildState): this;
  57017. }
  57018. }
  57019. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  57020. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57021. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57022. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57023. /**
  57024. * Block used to scale a vector by a float
  57025. */
  57026. export class ScaleBlock extends NodeMaterialBlock {
  57027. /**
  57028. * Creates a new ScaleBlock
  57029. * @param name defines the block name
  57030. */
  57031. constructor(name: string);
  57032. /**
  57033. * Gets the current class name
  57034. * @returns the class name
  57035. */
  57036. getClassName(): string;
  57037. /**
  57038. * Gets the input component
  57039. */
  57040. readonly input: NodeMaterialConnectionPoint;
  57041. /**
  57042. * Gets the factor input component
  57043. */
  57044. readonly factor: NodeMaterialConnectionPoint;
  57045. /**
  57046. * Gets the output component
  57047. */
  57048. readonly output: NodeMaterialConnectionPoint;
  57049. protected _buildBlock(state: NodeMaterialBuildState): this;
  57050. }
  57051. }
  57052. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  57053. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57054. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57055. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57056. import { Scene } from "babylonjs/scene";
  57057. /**
  57058. * Block used to clamp a float
  57059. */
  57060. export class ClampBlock extends NodeMaterialBlock {
  57061. /** Gets or sets the minimum range */
  57062. minimum: number;
  57063. /** Gets or sets the maximum range */
  57064. maximum: number;
  57065. /**
  57066. * Creates a new ClampBlock
  57067. * @param name defines the block name
  57068. */
  57069. constructor(name: string);
  57070. /**
  57071. * Gets the current class name
  57072. * @returns the class name
  57073. */
  57074. getClassName(): string;
  57075. /**
  57076. * Gets the value input component
  57077. */
  57078. readonly value: NodeMaterialConnectionPoint;
  57079. /**
  57080. * Gets the output component
  57081. */
  57082. readonly output: NodeMaterialConnectionPoint;
  57083. protected _buildBlock(state: NodeMaterialBuildState): this;
  57084. protected _dumpPropertiesCode(): string;
  57085. serialize(): any;
  57086. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57087. }
  57088. }
  57089. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57090. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57091. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57092. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57093. /**
  57094. * Block used to apply a cross product between 2 vectors
  57095. */
  57096. export class CrossBlock extends NodeMaterialBlock {
  57097. /**
  57098. * Creates a new CrossBlock
  57099. * @param name defines the block name
  57100. */
  57101. constructor(name: string);
  57102. /**
  57103. * Gets the current class name
  57104. * @returns the class name
  57105. */
  57106. getClassName(): string;
  57107. /**
  57108. * Gets the left operand input component
  57109. */
  57110. readonly left: NodeMaterialConnectionPoint;
  57111. /**
  57112. * Gets the right operand input component
  57113. */
  57114. readonly right: NodeMaterialConnectionPoint;
  57115. /**
  57116. * Gets the output component
  57117. */
  57118. readonly output: NodeMaterialConnectionPoint;
  57119. protected _buildBlock(state: NodeMaterialBuildState): this;
  57120. }
  57121. }
  57122. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57123. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57124. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57125. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57126. /**
  57127. * Block used to apply a dot product between 2 vectors
  57128. */
  57129. export class DotBlock extends NodeMaterialBlock {
  57130. /**
  57131. * Creates a new DotBlock
  57132. * @param name defines the block name
  57133. */
  57134. constructor(name: string);
  57135. /**
  57136. * Gets the current class name
  57137. * @returns the class name
  57138. */
  57139. getClassName(): string;
  57140. /**
  57141. * Gets the left operand input component
  57142. */
  57143. readonly left: NodeMaterialConnectionPoint;
  57144. /**
  57145. * Gets the right operand input component
  57146. */
  57147. readonly right: NodeMaterialConnectionPoint;
  57148. /**
  57149. * Gets the output component
  57150. */
  57151. readonly output: NodeMaterialConnectionPoint;
  57152. protected _buildBlock(state: NodeMaterialBuildState): this;
  57153. }
  57154. }
  57155. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57159. import { Vector2 } from "babylonjs/Maths/math.vector";
  57160. import { Scene } from "babylonjs/scene";
  57161. /**
  57162. * Block used to remap a float from a range to a new one
  57163. */
  57164. export class RemapBlock extends NodeMaterialBlock {
  57165. /**
  57166. * Gets or sets the source range
  57167. */
  57168. sourceRange: Vector2;
  57169. /**
  57170. * Gets or sets the target range
  57171. */
  57172. targetRange: Vector2;
  57173. /**
  57174. * Creates a new RemapBlock
  57175. * @param name defines the block name
  57176. */
  57177. constructor(name: string);
  57178. /**
  57179. * Gets the current class name
  57180. * @returns the class name
  57181. */
  57182. getClassName(): string;
  57183. /**
  57184. * Gets the input component
  57185. */
  57186. readonly input: NodeMaterialConnectionPoint;
  57187. /**
  57188. * Gets the source min input component
  57189. */
  57190. readonly sourceMin: NodeMaterialConnectionPoint;
  57191. /**
  57192. * Gets the source max input component
  57193. */
  57194. readonly sourceMax: NodeMaterialConnectionPoint;
  57195. /**
  57196. * Gets the target min input component
  57197. */
  57198. readonly targetMin: NodeMaterialConnectionPoint;
  57199. /**
  57200. * Gets the target max input component
  57201. */
  57202. readonly targetMax: NodeMaterialConnectionPoint;
  57203. /**
  57204. * Gets the output component
  57205. */
  57206. readonly output: NodeMaterialConnectionPoint;
  57207. protected _buildBlock(state: NodeMaterialBuildState): this;
  57208. protected _dumpPropertiesCode(): string;
  57209. serialize(): any;
  57210. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57211. }
  57212. }
  57213. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57214. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57215. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57216. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57217. /**
  57218. * Block used to normalize a vector
  57219. */
  57220. export class NormalizeBlock extends NodeMaterialBlock {
  57221. /**
  57222. * Creates a new NormalizeBlock
  57223. * @param name defines the block name
  57224. */
  57225. constructor(name: string);
  57226. /**
  57227. * Gets the current class name
  57228. * @returns the class name
  57229. */
  57230. getClassName(): string;
  57231. /**
  57232. * Gets the input component
  57233. */
  57234. readonly input: NodeMaterialConnectionPoint;
  57235. /**
  57236. * Gets the output component
  57237. */
  57238. readonly output: NodeMaterialConnectionPoint;
  57239. protected _buildBlock(state: NodeMaterialBuildState): this;
  57240. }
  57241. }
  57242. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57243. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57244. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57245. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57246. import { Scene } from "babylonjs/scene";
  57247. /**
  57248. * Operations supported by the Trigonometry block
  57249. */
  57250. export enum TrigonometryBlockOperations {
  57251. /** Cos */
  57252. Cos = 0,
  57253. /** Sin */
  57254. Sin = 1,
  57255. /** Abs */
  57256. Abs = 2,
  57257. /** Exp */
  57258. Exp = 3,
  57259. /** Exp2 */
  57260. Exp2 = 4,
  57261. /** Round */
  57262. Round = 5,
  57263. /** Floor */
  57264. Floor = 6,
  57265. /** Ceiling */
  57266. Ceiling = 7,
  57267. /** Square root */
  57268. Sqrt = 8,
  57269. /** Log */
  57270. Log = 9,
  57271. /** Tangent */
  57272. Tan = 10,
  57273. /** Arc tangent */
  57274. ArcTan = 11,
  57275. /** Arc cosinus */
  57276. ArcCos = 12,
  57277. /** Arc sinus */
  57278. ArcSin = 13,
  57279. /** Fraction */
  57280. Fract = 14,
  57281. /** Sign */
  57282. Sign = 15,
  57283. /** To radians (from degrees) */
  57284. Radians = 16,
  57285. /** To degrees (from radians) */
  57286. Degrees = 17
  57287. }
  57288. /**
  57289. * Block used to apply trigonometry operation to floats
  57290. */
  57291. export class TrigonometryBlock extends NodeMaterialBlock {
  57292. /**
  57293. * Gets or sets the operation applied by the block
  57294. */
  57295. operation: TrigonometryBlockOperations;
  57296. /**
  57297. * Creates a new TrigonometryBlock
  57298. * @param name defines the block name
  57299. */
  57300. constructor(name: string);
  57301. /**
  57302. * Gets the current class name
  57303. * @returns the class name
  57304. */
  57305. getClassName(): string;
  57306. /**
  57307. * Gets the input component
  57308. */
  57309. readonly input: NodeMaterialConnectionPoint;
  57310. /**
  57311. * Gets the output component
  57312. */
  57313. readonly output: NodeMaterialConnectionPoint;
  57314. protected _buildBlock(state: NodeMaterialBuildState): this;
  57315. serialize(): any;
  57316. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57317. }
  57318. }
  57319. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57320. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57321. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57323. /**
  57324. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57325. */
  57326. export class ColorMergerBlock extends NodeMaterialBlock {
  57327. /**
  57328. * Create a new ColorMergerBlock
  57329. * @param name defines the block name
  57330. */
  57331. constructor(name: string);
  57332. /**
  57333. * Gets the current class name
  57334. * @returns the class name
  57335. */
  57336. getClassName(): string;
  57337. /**
  57338. * Gets the r component (input)
  57339. */
  57340. readonly r: NodeMaterialConnectionPoint;
  57341. /**
  57342. * Gets the g component (input)
  57343. */
  57344. readonly g: NodeMaterialConnectionPoint;
  57345. /**
  57346. * Gets the b component (input)
  57347. */
  57348. readonly b: NodeMaterialConnectionPoint;
  57349. /**
  57350. * Gets the a component (input)
  57351. */
  57352. readonly a: NodeMaterialConnectionPoint;
  57353. /**
  57354. * Gets the rgba component (output)
  57355. */
  57356. readonly rgba: NodeMaterialConnectionPoint;
  57357. /**
  57358. * Gets the rgb component (output)
  57359. */
  57360. readonly rgb: NodeMaterialConnectionPoint;
  57361. protected _buildBlock(state: NodeMaterialBuildState): this;
  57362. }
  57363. }
  57364. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57365. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57366. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57367. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57368. /**
  57369. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57370. */
  57371. export class VectorMergerBlock extends NodeMaterialBlock {
  57372. /**
  57373. * Create a new VectorMergerBlock
  57374. * @param name defines the block name
  57375. */
  57376. constructor(name: string);
  57377. /**
  57378. * Gets the current class name
  57379. * @returns the class name
  57380. */
  57381. getClassName(): string;
  57382. /**
  57383. * Gets the x component (input)
  57384. */
  57385. readonly x: NodeMaterialConnectionPoint;
  57386. /**
  57387. * Gets the y component (input)
  57388. */
  57389. readonly y: NodeMaterialConnectionPoint;
  57390. /**
  57391. * Gets the z component (input)
  57392. */
  57393. readonly z: NodeMaterialConnectionPoint;
  57394. /**
  57395. * Gets the w component (input)
  57396. */
  57397. readonly w: NodeMaterialConnectionPoint;
  57398. /**
  57399. * Gets the xyzw component (output)
  57400. */
  57401. readonly xyzw: NodeMaterialConnectionPoint;
  57402. /**
  57403. * Gets the xyz component (output)
  57404. */
  57405. readonly xyz: NodeMaterialConnectionPoint;
  57406. /**
  57407. * Gets the xy component (output)
  57408. */
  57409. readonly xy: NodeMaterialConnectionPoint;
  57410. protected _buildBlock(state: NodeMaterialBuildState): this;
  57411. }
  57412. }
  57413. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57414. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57415. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57416. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57417. /**
  57418. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57419. */
  57420. export class ColorSplitterBlock extends NodeMaterialBlock {
  57421. /**
  57422. * Create a new ColorSplitterBlock
  57423. * @param name defines the block name
  57424. */
  57425. constructor(name: string);
  57426. /**
  57427. * Gets the current class name
  57428. * @returns the class name
  57429. */
  57430. getClassName(): string;
  57431. /**
  57432. * Gets the rgba component (input)
  57433. */
  57434. readonly rgba: NodeMaterialConnectionPoint;
  57435. /**
  57436. * Gets the rgb component (input)
  57437. */
  57438. readonly rgbIn: NodeMaterialConnectionPoint;
  57439. /**
  57440. * Gets the rgb component (output)
  57441. */
  57442. readonly rgbOut: NodeMaterialConnectionPoint;
  57443. /**
  57444. * Gets the r component (output)
  57445. */
  57446. readonly r: NodeMaterialConnectionPoint;
  57447. /**
  57448. * Gets the g component (output)
  57449. */
  57450. readonly g: NodeMaterialConnectionPoint;
  57451. /**
  57452. * Gets the b component (output)
  57453. */
  57454. readonly b: NodeMaterialConnectionPoint;
  57455. /**
  57456. * Gets the a component (output)
  57457. */
  57458. readonly a: NodeMaterialConnectionPoint;
  57459. protected _inputRename(name: string): string;
  57460. protected _outputRename(name: string): string;
  57461. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57462. }
  57463. }
  57464. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57468. /**
  57469. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57470. */
  57471. export class VectorSplitterBlock extends NodeMaterialBlock {
  57472. /**
  57473. * Create a new VectorSplitterBlock
  57474. * @param name defines the block name
  57475. */
  57476. constructor(name: string);
  57477. /**
  57478. * Gets the current class name
  57479. * @returns the class name
  57480. */
  57481. getClassName(): string;
  57482. /**
  57483. * Gets the xyzw component (input)
  57484. */
  57485. readonly xyzw: NodeMaterialConnectionPoint;
  57486. /**
  57487. * Gets the xyz component (input)
  57488. */
  57489. readonly xyzIn: NodeMaterialConnectionPoint;
  57490. /**
  57491. * Gets the xy component (input)
  57492. */
  57493. readonly xyIn: NodeMaterialConnectionPoint;
  57494. /**
  57495. * Gets the xyz component (output)
  57496. */
  57497. readonly xyzOut: NodeMaterialConnectionPoint;
  57498. /**
  57499. * Gets the xy component (output)
  57500. */
  57501. readonly xyOut: NodeMaterialConnectionPoint;
  57502. /**
  57503. * Gets the x component (output)
  57504. */
  57505. readonly x: NodeMaterialConnectionPoint;
  57506. /**
  57507. * Gets the y component (output)
  57508. */
  57509. readonly y: NodeMaterialConnectionPoint;
  57510. /**
  57511. * Gets the z component (output)
  57512. */
  57513. readonly z: NodeMaterialConnectionPoint;
  57514. /**
  57515. * Gets the w component (output)
  57516. */
  57517. readonly w: NodeMaterialConnectionPoint;
  57518. protected _inputRename(name: string): string;
  57519. protected _outputRename(name: string): string;
  57520. protected _buildBlock(state: NodeMaterialBuildState): this;
  57521. }
  57522. }
  57523. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57524. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57525. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57526. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57527. /**
  57528. * Block used to lerp between 2 values
  57529. */
  57530. export class LerpBlock extends NodeMaterialBlock {
  57531. /**
  57532. * Creates a new LerpBlock
  57533. * @param name defines the block name
  57534. */
  57535. constructor(name: string);
  57536. /**
  57537. * Gets the current class name
  57538. * @returns the class name
  57539. */
  57540. getClassName(): string;
  57541. /**
  57542. * Gets the left operand input component
  57543. */
  57544. readonly left: NodeMaterialConnectionPoint;
  57545. /**
  57546. * Gets the right operand input component
  57547. */
  57548. readonly right: NodeMaterialConnectionPoint;
  57549. /**
  57550. * Gets the gradient operand input component
  57551. */
  57552. readonly gradient: NodeMaterialConnectionPoint;
  57553. /**
  57554. * Gets the output component
  57555. */
  57556. readonly output: NodeMaterialConnectionPoint;
  57557. protected _buildBlock(state: NodeMaterialBuildState): this;
  57558. }
  57559. }
  57560. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57564. /**
  57565. * Block used to divide 2 vectors
  57566. */
  57567. export class DivideBlock extends NodeMaterialBlock {
  57568. /**
  57569. * Creates a new DivideBlock
  57570. * @param name defines the block name
  57571. */
  57572. constructor(name: string);
  57573. /**
  57574. * Gets the current class name
  57575. * @returns the class name
  57576. */
  57577. getClassName(): string;
  57578. /**
  57579. * Gets the left operand input component
  57580. */
  57581. readonly left: NodeMaterialConnectionPoint;
  57582. /**
  57583. * Gets the right operand input component
  57584. */
  57585. readonly right: NodeMaterialConnectionPoint;
  57586. /**
  57587. * Gets the output component
  57588. */
  57589. readonly output: NodeMaterialConnectionPoint;
  57590. protected _buildBlock(state: NodeMaterialBuildState): this;
  57591. }
  57592. }
  57593. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57594. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57595. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57597. /**
  57598. * Block used to subtract 2 vectors
  57599. */
  57600. export class SubtractBlock extends NodeMaterialBlock {
  57601. /**
  57602. * Creates a new SubtractBlock
  57603. * @param name defines the block name
  57604. */
  57605. constructor(name: string);
  57606. /**
  57607. * Gets the current class name
  57608. * @returns the class name
  57609. */
  57610. getClassName(): string;
  57611. /**
  57612. * Gets the left operand input component
  57613. */
  57614. readonly left: NodeMaterialConnectionPoint;
  57615. /**
  57616. * Gets the right operand input component
  57617. */
  57618. readonly right: NodeMaterialConnectionPoint;
  57619. /**
  57620. * Gets the output component
  57621. */
  57622. readonly output: NodeMaterialConnectionPoint;
  57623. protected _buildBlock(state: NodeMaterialBuildState): this;
  57624. }
  57625. }
  57626. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57627. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57630. /**
  57631. * Block used to step a value
  57632. */
  57633. export class StepBlock extends NodeMaterialBlock {
  57634. /**
  57635. * Creates a new StepBlock
  57636. * @param name defines the block name
  57637. */
  57638. constructor(name: string);
  57639. /**
  57640. * Gets the current class name
  57641. * @returns the class name
  57642. */
  57643. getClassName(): string;
  57644. /**
  57645. * Gets the value operand input component
  57646. */
  57647. readonly value: NodeMaterialConnectionPoint;
  57648. /**
  57649. * Gets the edge operand input component
  57650. */
  57651. readonly edge: NodeMaterialConnectionPoint;
  57652. /**
  57653. * Gets the output component
  57654. */
  57655. readonly output: NodeMaterialConnectionPoint;
  57656. protected _buildBlock(state: NodeMaterialBuildState): this;
  57657. }
  57658. }
  57659. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57661. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57662. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57663. /**
  57664. * Block used to get the opposite (1 - x) of a value
  57665. */
  57666. export class OneMinusBlock extends NodeMaterialBlock {
  57667. /**
  57668. * Creates a new OneMinusBlock
  57669. * @param name defines the block name
  57670. */
  57671. constructor(name: string);
  57672. /**
  57673. * Gets the current class name
  57674. * @returns the class name
  57675. */
  57676. getClassName(): string;
  57677. /**
  57678. * Gets the input component
  57679. */
  57680. readonly input: NodeMaterialConnectionPoint;
  57681. /**
  57682. * Gets the output component
  57683. */
  57684. readonly output: NodeMaterialConnectionPoint;
  57685. protected _buildBlock(state: NodeMaterialBuildState): this;
  57686. }
  57687. }
  57688. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57689. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57690. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57691. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57692. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57693. /**
  57694. * Block used to get the view direction
  57695. */
  57696. export class ViewDirectionBlock extends NodeMaterialBlock {
  57697. /**
  57698. * Creates a new ViewDirectionBlock
  57699. * @param name defines the block name
  57700. */
  57701. constructor(name: string);
  57702. /**
  57703. * Gets the current class name
  57704. * @returns the class name
  57705. */
  57706. getClassName(): string;
  57707. /**
  57708. * Gets the world position component
  57709. */
  57710. readonly worldPosition: NodeMaterialConnectionPoint;
  57711. /**
  57712. * Gets the camera position component
  57713. */
  57714. readonly cameraPosition: NodeMaterialConnectionPoint;
  57715. /**
  57716. * Gets the output component
  57717. */
  57718. readonly output: NodeMaterialConnectionPoint;
  57719. autoConfigure(material: NodeMaterial): void;
  57720. protected _buildBlock(state: NodeMaterialBuildState): this;
  57721. }
  57722. }
  57723. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57727. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57728. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57729. /**
  57730. * Block used to compute fresnel value
  57731. */
  57732. export class FresnelBlock extends NodeMaterialBlock {
  57733. /**
  57734. * Create a new FresnelBlock
  57735. * @param name defines the block name
  57736. */
  57737. constructor(name: string);
  57738. /**
  57739. * Gets the current class name
  57740. * @returns the class name
  57741. */
  57742. getClassName(): string;
  57743. /**
  57744. * Gets the world normal input component
  57745. */
  57746. readonly worldNormal: NodeMaterialConnectionPoint;
  57747. /**
  57748. * Gets the view direction input component
  57749. */
  57750. readonly viewDirection: NodeMaterialConnectionPoint;
  57751. /**
  57752. * Gets the bias input component
  57753. */
  57754. readonly bias: NodeMaterialConnectionPoint;
  57755. /**
  57756. * Gets the camera (or eye) position component
  57757. */
  57758. readonly power: NodeMaterialConnectionPoint;
  57759. /**
  57760. * Gets the fresnel output component
  57761. */
  57762. readonly fresnel: NodeMaterialConnectionPoint;
  57763. autoConfigure(material: NodeMaterial): void;
  57764. protected _buildBlock(state: NodeMaterialBuildState): this;
  57765. }
  57766. }
  57767. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57768. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57769. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57770. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57771. /**
  57772. * Block used to get the max of 2 values
  57773. */
  57774. export class MaxBlock extends NodeMaterialBlock {
  57775. /**
  57776. * Creates a new MaxBlock
  57777. * @param name defines the block name
  57778. */
  57779. constructor(name: string);
  57780. /**
  57781. * Gets the current class name
  57782. * @returns the class name
  57783. */
  57784. getClassName(): string;
  57785. /**
  57786. * Gets the left operand input component
  57787. */
  57788. readonly left: NodeMaterialConnectionPoint;
  57789. /**
  57790. * Gets the right operand input component
  57791. */
  57792. readonly right: NodeMaterialConnectionPoint;
  57793. /**
  57794. * Gets the output component
  57795. */
  57796. readonly output: NodeMaterialConnectionPoint;
  57797. protected _buildBlock(state: NodeMaterialBuildState): this;
  57798. }
  57799. }
  57800. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57801. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57802. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57803. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57804. /**
  57805. * Block used to get the min of 2 values
  57806. */
  57807. export class MinBlock extends NodeMaterialBlock {
  57808. /**
  57809. * Creates a new MinBlock
  57810. * @param name defines the block name
  57811. */
  57812. constructor(name: string);
  57813. /**
  57814. * Gets the current class name
  57815. * @returns the class name
  57816. */
  57817. getClassName(): string;
  57818. /**
  57819. * Gets the left operand input component
  57820. */
  57821. readonly left: NodeMaterialConnectionPoint;
  57822. /**
  57823. * Gets the right operand input component
  57824. */
  57825. readonly right: NodeMaterialConnectionPoint;
  57826. /**
  57827. * Gets the output component
  57828. */
  57829. readonly output: NodeMaterialConnectionPoint;
  57830. protected _buildBlock(state: NodeMaterialBuildState): this;
  57831. }
  57832. }
  57833. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57834. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57835. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57836. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57837. /**
  57838. * Block used to get the distance between 2 values
  57839. */
  57840. export class DistanceBlock extends NodeMaterialBlock {
  57841. /**
  57842. * Creates a new DistanceBlock
  57843. * @param name defines the block name
  57844. */
  57845. constructor(name: string);
  57846. /**
  57847. * Gets the current class name
  57848. * @returns the class name
  57849. */
  57850. getClassName(): string;
  57851. /**
  57852. * Gets the left operand input component
  57853. */
  57854. readonly left: NodeMaterialConnectionPoint;
  57855. /**
  57856. * Gets the right operand input component
  57857. */
  57858. readonly right: NodeMaterialConnectionPoint;
  57859. /**
  57860. * Gets the output component
  57861. */
  57862. readonly output: NodeMaterialConnectionPoint;
  57863. protected _buildBlock(state: NodeMaterialBuildState): this;
  57864. }
  57865. }
  57866. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57867. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57868. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57869. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57870. /**
  57871. * Block used to get the length of a vector
  57872. */
  57873. export class LengthBlock extends NodeMaterialBlock {
  57874. /**
  57875. * Creates a new LengthBlock
  57876. * @param name defines the block name
  57877. */
  57878. constructor(name: string);
  57879. /**
  57880. * Gets the current class name
  57881. * @returns the class name
  57882. */
  57883. getClassName(): string;
  57884. /**
  57885. * Gets the value input component
  57886. */
  57887. readonly value: NodeMaterialConnectionPoint;
  57888. /**
  57889. * Gets the output component
  57890. */
  57891. readonly output: NodeMaterialConnectionPoint;
  57892. protected _buildBlock(state: NodeMaterialBuildState): this;
  57893. }
  57894. }
  57895. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57896. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57897. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57898. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57899. /**
  57900. * Block used to get negative version of a value (i.e. x * -1)
  57901. */
  57902. export class NegateBlock extends NodeMaterialBlock {
  57903. /**
  57904. * Creates a new NegateBlock
  57905. * @param name defines the block name
  57906. */
  57907. constructor(name: string);
  57908. /**
  57909. * Gets the current class name
  57910. * @returns the class name
  57911. */
  57912. getClassName(): string;
  57913. /**
  57914. * Gets the value input component
  57915. */
  57916. readonly value: NodeMaterialConnectionPoint;
  57917. /**
  57918. * Gets the output component
  57919. */
  57920. readonly output: NodeMaterialConnectionPoint;
  57921. protected _buildBlock(state: NodeMaterialBuildState): this;
  57922. }
  57923. }
  57924. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57925. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57926. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57927. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57928. /**
  57929. * Block used to get the value of the first parameter raised to the power of the second
  57930. */
  57931. export class PowBlock extends NodeMaterialBlock {
  57932. /**
  57933. * Creates a new PowBlock
  57934. * @param name defines the block name
  57935. */
  57936. constructor(name: string);
  57937. /**
  57938. * Gets the current class name
  57939. * @returns the class name
  57940. */
  57941. getClassName(): string;
  57942. /**
  57943. * Gets the value operand input component
  57944. */
  57945. readonly value: NodeMaterialConnectionPoint;
  57946. /**
  57947. * Gets the power operand input component
  57948. */
  57949. readonly power: NodeMaterialConnectionPoint;
  57950. /**
  57951. * Gets the output component
  57952. */
  57953. readonly output: NodeMaterialConnectionPoint;
  57954. protected _buildBlock(state: NodeMaterialBuildState): this;
  57955. }
  57956. }
  57957. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57958. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57959. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57960. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57961. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57962. /**
  57963. * Block used to get a random number
  57964. */
  57965. export class RandomNumberBlock extends NodeMaterialBlock {
  57966. /**
  57967. * Creates a new RandomNumberBlock
  57968. * @param name defines the block name
  57969. */
  57970. constructor(name: string);
  57971. /**
  57972. * Gets the current class name
  57973. * @returns the class name
  57974. */
  57975. getClassName(): string;
  57976. /**
  57977. * Gets the seed input component
  57978. */
  57979. readonly seed: NodeMaterialConnectionPoint;
  57980. /**
  57981. * Gets the output component
  57982. */
  57983. readonly output: NodeMaterialConnectionPoint;
  57984. protected _buildBlock(state: NodeMaterialBuildState): this;
  57985. }
  57986. }
  57987. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57988. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57989. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57990. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57991. /**
  57992. * Block used to compute arc tangent of 2 values
  57993. */
  57994. export class ArcTan2Block extends NodeMaterialBlock {
  57995. /**
  57996. * Creates a new ArcTan2Block
  57997. * @param name defines the block name
  57998. */
  57999. constructor(name: string);
  58000. /**
  58001. * Gets the current class name
  58002. * @returns the class name
  58003. */
  58004. getClassName(): string;
  58005. /**
  58006. * Gets the x operand input component
  58007. */
  58008. readonly x: NodeMaterialConnectionPoint;
  58009. /**
  58010. * Gets the y operand input component
  58011. */
  58012. readonly y: NodeMaterialConnectionPoint;
  58013. /**
  58014. * Gets the output component
  58015. */
  58016. readonly output: NodeMaterialConnectionPoint;
  58017. protected _buildBlock(state: NodeMaterialBuildState): this;
  58018. }
  58019. }
  58020. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  58021. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58022. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58023. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58024. /**
  58025. * Block used to smooth step a value
  58026. */
  58027. export class SmoothStepBlock extends NodeMaterialBlock {
  58028. /**
  58029. * Creates a new SmoothStepBlock
  58030. * @param name defines the block name
  58031. */
  58032. constructor(name: string);
  58033. /**
  58034. * Gets the current class name
  58035. * @returns the class name
  58036. */
  58037. getClassName(): string;
  58038. /**
  58039. * Gets the value operand input component
  58040. */
  58041. readonly value: NodeMaterialConnectionPoint;
  58042. /**
  58043. * Gets the first edge operand input component
  58044. */
  58045. readonly edge0: NodeMaterialConnectionPoint;
  58046. /**
  58047. * Gets the second edge operand input component
  58048. */
  58049. readonly edge1: NodeMaterialConnectionPoint;
  58050. /**
  58051. * Gets the output component
  58052. */
  58053. readonly output: NodeMaterialConnectionPoint;
  58054. protected _buildBlock(state: NodeMaterialBuildState): this;
  58055. }
  58056. }
  58057. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58061. /**
  58062. * Block used to get the reciprocal (1 / x) of a value
  58063. */
  58064. export class ReciprocalBlock extends NodeMaterialBlock {
  58065. /**
  58066. * Creates a new ReciprocalBlock
  58067. * @param name defines the block name
  58068. */
  58069. constructor(name: string);
  58070. /**
  58071. * Gets the current class name
  58072. * @returns the class name
  58073. */
  58074. getClassName(): string;
  58075. /**
  58076. * Gets the input component
  58077. */
  58078. readonly input: NodeMaterialConnectionPoint;
  58079. /**
  58080. * Gets the output component
  58081. */
  58082. readonly output: NodeMaterialConnectionPoint;
  58083. protected _buildBlock(state: NodeMaterialBuildState): this;
  58084. }
  58085. }
  58086. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58087. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58088. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58089. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58090. /**
  58091. * Block used to replace a color by another one
  58092. */
  58093. export class ReplaceColorBlock extends NodeMaterialBlock {
  58094. /**
  58095. * Creates a new ReplaceColorBlock
  58096. * @param name defines the block name
  58097. */
  58098. constructor(name: string);
  58099. /**
  58100. * Gets the current class name
  58101. * @returns the class name
  58102. */
  58103. getClassName(): string;
  58104. /**
  58105. * Gets the value input component
  58106. */
  58107. readonly value: NodeMaterialConnectionPoint;
  58108. /**
  58109. * Gets the reference input component
  58110. */
  58111. readonly reference: NodeMaterialConnectionPoint;
  58112. /**
  58113. * Gets the distance input component
  58114. */
  58115. readonly distance: NodeMaterialConnectionPoint;
  58116. /**
  58117. * Gets the replacement input component
  58118. */
  58119. readonly replacement: NodeMaterialConnectionPoint;
  58120. /**
  58121. * Gets the output component
  58122. */
  58123. readonly output: NodeMaterialConnectionPoint;
  58124. protected _buildBlock(state: NodeMaterialBuildState): this;
  58125. }
  58126. }
  58127. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58128. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58129. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58130. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58131. /**
  58132. * Block used to posterize a value
  58133. * @see https://en.wikipedia.org/wiki/Posterization
  58134. */
  58135. export class PosterizeBlock extends NodeMaterialBlock {
  58136. /**
  58137. * Creates a new PosterizeBlock
  58138. * @param name defines the block name
  58139. */
  58140. constructor(name: string);
  58141. /**
  58142. * Gets the current class name
  58143. * @returns the class name
  58144. */
  58145. getClassName(): string;
  58146. /**
  58147. * Gets the value input component
  58148. */
  58149. readonly value: NodeMaterialConnectionPoint;
  58150. /**
  58151. * Gets the steps input component
  58152. */
  58153. readonly steps: NodeMaterialConnectionPoint;
  58154. /**
  58155. * Gets the output component
  58156. */
  58157. readonly output: NodeMaterialConnectionPoint;
  58158. protected _buildBlock(state: NodeMaterialBuildState): this;
  58159. }
  58160. }
  58161. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58162. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58163. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58164. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58165. import { Scene } from "babylonjs/scene";
  58166. /**
  58167. * Operations supported by the Wave block
  58168. */
  58169. export enum WaveBlockKind {
  58170. /** SawTooth */
  58171. SawTooth = 0,
  58172. /** Square */
  58173. Square = 1,
  58174. /** Triangle */
  58175. Triangle = 2
  58176. }
  58177. /**
  58178. * Block used to apply wave operation to floats
  58179. */
  58180. export class WaveBlock extends NodeMaterialBlock {
  58181. /**
  58182. * Gets or sets the kibnd of wave to be applied by the block
  58183. */
  58184. kind: WaveBlockKind;
  58185. /**
  58186. * Creates a new WaveBlock
  58187. * @param name defines the block name
  58188. */
  58189. constructor(name: string);
  58190. /**
  58191. * Gets the current class name
  58192. * @returns the class name
  58193. */
  58194. getClassName(): string;
  58195. /**
  58196. * Gets the input component
  58197. */
  58198. readonly input: NodeMaterialConnectionPoint;
  58199. /**
  58200. * Gets the output component
  58201. */
  58202. readonly output: NodeMaterialConnectionPoint;
  58203. protected _buildBlock(state: NodeMaterialBuildState): this;
  58204. serialize(): any;
  58205. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58206. }
  58207. }
  58208. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58209. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58210. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58211. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58212. import { Color3 } from "babylonjs/Maths/math.color";
  58213. import { Scene } from "babylonjs/scene";
  58214. /**
  58215. * Class used to store a color step for the GradientBlock
  58216. */
  58217. export class GradientBlockColorStep {
  58218. /**
  58219. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58220. */
  58221. step: number;
  58222. /**
  58223. * Gets or sets the color associated with this step
  58224. */
  58225. color: Color3;
  58226. /**
  58227. * Creates a new GradientBlockColorStep
  58228. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58229. * @param color defines the color associated with this step
  58230. */
  58231. constructor(
  58232. /**
  58233. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58234. */
  58235. step: number,
  58236. /**
  58237. * Gets or sets the color associated with this step
  58238. */
  58239. color: Color3);
  58240. }
  58241. /**
  58242. * Block used to return a color from a gradient based on an input value between 0 and 1
  58243. */
  58244. export class GradientBlock extends NodeMaterialBlock {
  58245. /**
  58246. * Gets or sets the list of color steps
  58247. */
  58248. colorSteps: GradientBlockColorStep[];
  58249. /**
  58250. * Creates a new GradientBlock
  58251. * @param name defines the block name
  58252. */
  58253. constructor(name: string);
  58254. /**
  58255. * Gets the current class name
  58256. * @returns the class name
  58257. */
  58258. getClassName(): string;
  58259. /**
  58260. * Gets the gradient input component
  58261. */
  58262. readonly gradient: NodeMaterialConnectionPoint;
  58263. /**
  58264. * Gets the output component
  58265. */
  58266. readonly output: NodeMaterialConnectionPoint;
  58267. private _writeColorConstant;
  58268. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58269. serialize(): any;
  58270. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58271. protected _dumpPropertiesCode(): string;
  58272. }
  58273. }
  58274. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58275. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58276. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58277. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58278. /**
  58279. * Block used to normalize lerp between 2 values
  58280. */
  58281. export class NLerpBlock extends NodeMaterialBlock {
  58282. /**
  58283. * Creates a new NLerpBlock
  58284. * @param name defines the block name
  58285. */
  58286. constructor(name: string);
  58287. /**
  58288. * Gets the current class name
  58289. * @returns the class name
  58290. */
  58291. getClassName(): string;
  58292. /**
  58293. * Gets the left operand input component
  58294. */
  58295. readonly left: NodeMaterialConnectionPoint;
  58296. /**
  58297. * Gets the right operand input component
  58298. */
  58299. readonly right: NodeMaterialConnectionPoint;
  58300. /**
  58301. * Gets the gradient operand input component
  58302. */
  58303. readonly gradient: NodeMaterialConnectionPoint;
  58304. /**
  58305. * Gets the output component
  58306. */
  58307. readonly output: NodeMaterialConnectionPoint;
  58308. protected _buildBlock(state: NodeMaterialBuildState): this;
  58309. }
  58310. }
  58311. declare module "babylonjs/Materials/Node/Blocks/index" {
  58312. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58313. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58314. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58315. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58316. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58317. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58318. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58319. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58320. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58321. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58322. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58323. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58324. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58325. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58326. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58327. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58328. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58329. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58330. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58331. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58332. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58333. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58334. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58335. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58336. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58337. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58338. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58339. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58340. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58341. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58342. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58343. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58344. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58345. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58346. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58347. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58348. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58349. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58350. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58351. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58352. }
  58353. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58354. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58355. }
  58356. declare module "babylonjs/Materials/Node/index" {
  58357. export * from "babylonjs/Materials/Node/Enums/index";
  58358. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58359. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58360. export * from "babylonjs/Materials/Node/nodeMaterial";
  58361. export * from "babylonjs/Materials/Node/Blocks/index";
  58362. export * from "babylonjs/Materials/Node/Optimizers/index";
  58363. }
  58364. declare module "babylonjs/Materials/effectRenderer" {
  58365. import { Nullable } from "babylonjs/types";
  58366. import { Texture } from "babylonjs/Materials/Textures/texture";
  58367. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58368. import { Viewport } from "babylonjs/Maths/math.viewport";
  58369. import { Observable } from "babylonjs/Misc/observable";
  58370. import { Effect } from "babylonjs/Materials/effect";
  58371. import "babylonjs/Engines/Extensions/engine.renderTarget";
  58372. import "babylonjs/Shaders/postprocess.vertex";
  58373. /**
  58374. * Effect Render Options
  58375. */
  58376. export interface IEffectRendererOptions {
  58377. /**
  58378. * Defines the vertices positions.
  58379. */
  58380. positions?: number[];
  58381. /**
  58382. * Defines the indices.
  58383. */
  58384. indices?: number[];
  58385. }
  58386. /**
  58387. * Helper class to render one or more effects
  58388. */
  58389. export class EffectRenderer {
  58390. private engine;
  58391. private static _DefaultOptions;
  58392. private _vertexBuffers;
  58393. private _indexBuffer;
  58394. private _ringBufferIndex;
  58395. private _ringScreenBuffer;
  58396. private _fullscreenViewport;
  58397. private _getNextFrameBuffer;
  58398. /**
  58399. * Creates an effect renderer
  58400. * @param engine the engine to use for rendering
  58401. * @param options defines the options of the effect renderer
  58402. */
  58403. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  58404. /**
  58405. * Sets the current viewport in normalized coordinates 0-1
  58406. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58407. */
  58408. setViewport(viewport?: Viewport): void;
  58409. /**
  58410. * Binds the embedded attributes buffer to the effect.
  58411. * @param effect Defines the effect to bind the attributes for
  58412. */
  58413. bindBuffers(effect: Effect): void;
  58414. /**
  58415. * Sets the current effect wrapper to use during draw.
  58416. * The effect needs to be ready before calling this api.
  58417. * This also sets the default full screen position attribute.
  58418. * @param effectWrapper Defines the effect to draw with
  58419. */
  58420. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58421. /**
  58422. * Draws a full screen quad.
  58423. */
  58424. draw(): void;
  58425. /**
  58426. * renders one or more effects to a specified texture
  58427. * @param effectWrappers list of effects to renderer
  58428. * @param outputTexture texture to draw to, if null it will render to the screen
  58429. */
  58430. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58431. /**
  58432. * Disposes of the effect renderer
  58433. */
  58434. dispose(): void;
  58435. }
  58436. /**
  58437. * Options to create an EffectWrapper
  58438. */
  58439. interface EffectWrapperCreationOptions {
  58440. /**
  58441. * Engine to use to create the effect
  58442. */
  58443. engine: ThinEngine;
  58444. /**
  58445. * Fragment shader for the effect
  58446. */
  58447. fragmentShader: string;
  58448. /**
  58449. * Vertex shader for the effect
  58450. */
  58451. vertexShader?: string;
  58452. /**
  58453. * Attributes to use in the shader
  58454. */
  58455. attributeNames?: Array<string>;
  58456. /**
  58457. * Uniforms to use in the shader
  58458. */
  58459. uniformNames?: Array<string>;
  58460. /**
  58461. * Texture sampler names to use in the shader
  58462. */
  58463. samplerNames?: Array<string>;
  58464. /**
  58465. * The friendly name of the effect displayed in Spector.
  58466. */
  58467. name?: string;
  58468. }
  58469. /**
  58470. * Wraps an effect to be used for rendering
  58471. */
  58472. export class EffectWrapper {
  58473. /**
  58474. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58475. */
  58476. onApplyObservable: Observable<{}>;
  58477. /**
  58478. * The underlying effect
  58479. */
  58480. effect: Effect;
  58481. /**
  58482. * Creates an effect to be renderer
  58483. * @param creationOptions options to create the effect
  58484. */
  58485. constructor(creationOptions: EffectWrapperCreationOptions);
  58486. /**
  58487. * Disposes of the effect wrapper
  58488. */
  58489. dispose(): void;
  58490. }
  58491. }
  58492. declare module "babylonjs/Materials/index" {
  58493. export * from "babylonjs/Materials/Background/index";
  58494. export * from "babylonjs/Materials/colorCurves";
  58495. export * from "babylonjs/Materials/iEffectFallbacks";
  58496. export * from "babylonjs/Materials/effectFallbacks";
  58497. export * from "babylonjs/Materials/effect";
  58498. export * from "babylonjs/Materials/fresnelParameters";
  58499. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58500. export * from "babylonjs/Materials/material";
  58501. export * from "babylonjs/Materials/materialDefines";
  58502. export * from "babylonjs/Materials/materialHelper";
  58503. export * from "babylonjs/Materials/multiMaterial";
  58504. export * from "babylonjs/Materials/PBR/index";
  58505. export * from "babylonjs/Materials/pushMaterial";
  58506. export * from "babylonjs/Materials/shaderMaterial";
  58507. export * from "babylonjs/Materials/standardMaterial";
  58508. export * from "babylonjs/Materials/Textures/index";
  58509. export * from "babylonjs/Materials/uniformBuffer";
  58510. export * from "babylonjs/Materials/materialFlags";
  58511. export * from "babylonjs/Materials/Node/index";
  58512. export * from "babylonjs/Materials/effectRenderer";
  58513. }
  58514. declare module "babylonjs/Maths/index" {
  58515. export * from "babylonjs/Maths/math.scalar";
  58516. export * from "babylonjs/Maths/math";
  58517. export * from "babylonjs/Maths/sphericalPolynomial";
  58518. }
  58519. declare module "babylonjs/Misc/workerPool" {
  58520. import { IDisposable } from "babylonjs/scene";
  58521. /**
  58522. * Helper class to push actions to a pool of workers.
  58523. */
  58524. export class WorkerPool implements IDisposable {
  58525. private _workerInfos;
  58526. private _pendingActions;
  58527. /**
  58528. * Constructor
  58529. * @param workers Array of workers to use for actions
  58530. */
  58531. constructor(workers: Array<Worker>);
  58532. /**
  58533. * Terminates all workers and clears any pending actions.
  58534. */
  58535. dispose(): void;
  58536. /**
  58537. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58538. * pended until a worker has completed its action.
  58539. * @param action The action to perform. Call onComplete when the action is complete.
  58540. */
  58541. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58542. private _execute;
  58543. }
  58544. }
  58545. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58546. import { IDisposable } from "babylonjs/scene";
  58547. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58548. /**
  58549. * Configuration for Draco compression
  58550. */
  58551. export interface IDracoCompressionConfiguration {
  58552. /**
  58553. * Configuration for the decoder.
  58554. */
  58555. decoder: {
  58556. /**
  58557. * The url to the WebAssembly module.
  58558. */
  58559. wasmUrl?: string;
  58560. /**
  58561. * The url to the WebAssembly binary.
  58562. */
  58563. wasmBinaryUrl?: string;
  58564. /**
  58565. * The url to the fallback JavaScript module.
  58566. */
  58567. fallbackUrl?: string;
  58568. };
  58569. }
  58570. /**
  58571. * Draco compression (https://google.github.io/draco/)
  58572. *
  58573. * This class wraps the Draco module.
  58574. *
  58575. * **Encoder**
  58576. *
  58577. * The encoder is not currently implemented.
  58578. *
  58579. * **Decoder**
  58580. *
  58581. * 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.
  58582. *
  58583. * To update the configuration, use the following code:
  58584. * ```javascript
  58585. * DracoCompression.Configuration = {
  58586. * decoder: {
  58587. * wasmUrl: "<url to the WebAssembly library>",
  58588. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58589. * fallbackUrl: "<url to the fallback JavaScript library>",
  58590. * }
  58591. * };
  58592. * ```
  58593. *
  58594. * 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.
  58595. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58596. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58597. *
  58598. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58599. * ```javascript
  58600. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58601. * ```
  58602. *
  58603. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58604. */
  58605. export class DracoCompression implements IDisposable {
  58606. private _workerPoolPromise?;
  58607. private _decoderModulePromise?;
  58608. /**
  58609. * The configuration. Defaults to the following urls:
  58610. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58611. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58612. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58613. */
  58614. static Configuration: IDracoCompressionConfiguration;
  58615. /**
  58616. * Returns true if the decoder configuration is available.
  58617. */
  58618. static readonly DecoderAvailable: boolean;
  58619. /**
  58620. * Default number of workers to create when creating the draco compression object.
  58621. */
  58622. static DefaultNumWorkers: number;
  58623. private static GetDefaultNumWorkers;
  58624. private static _Default;
  58625. /**
  58626. * Default instance for the draco compression object.
  58627. */
  58628. static readonly Default: DracoCompression;
  58629. /**
  58630. * Constructor
  58631. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58632. */
  58633. constructor(numWorkers?: number);
  58634. /**
  58635. * Stop all async operations and release resources.
  58636. */
  58637. dispose(): void;
  58638. /**
  58639. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58640. * @returns a promise that resolves when ready
  58641. */
  58642. whenReadyAsync(): Promise<void>;
  58643. /**
  58644. * Decode Draco compressed mesh data to vertex data.
  58645. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58646. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58647. * @returns A promise that resolves with the decoded vertex data
  58648. */
  58649. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58650. [kind: string]: number;
  58651. }): Promise<VertexData>;
  58652. }
  58653. }
  58654. declare module "babylonjs/Meshes/Compression/index" {
  58655. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58656. }
  58657. declare module "babylonjs/Meshes/csg" {
  58658. import { Nullable } from "babylonjs/types";
  58659. import { Scene } from "babylonjs/scene";
  58660. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58661. import { Mesh } from "babylonjs/Meshes/mesh";
  58662. import { Material } from "babylonjs/Materials/material";
  58663. /**
  58664. * Class for building Constructive Solid Geometry
  58665. */
  58666. export class CSG {
  58667. private polygons;
  58668. /**
  58669. * The world matrix
  58670. */
  58671. matrix: Matrix;
  58672. /**
  58673. * Stores the position
  58674. */
  58675. position: Vector3;
  58676. /**
  58677. * Stores the rotation
  58678. */
  58679. rotation: Vector3;
  58680. /**
  58681. * Stores the rotation quaternion
  58682. */
  58683. rotationQuaternion: Nullable<Quaternion>;
  58684. /**
  58685. * Stores the scaling vector
  58686. */
  58687. scaling: Vector3;
  58688. /**
  58689. * Convert the Mesh to CSG
  58690. * @param mesh The Mesh to convert to CSG
  58691. * @returns A new CSG from the Mesh
  58692. */
  58693. static FromMesh(mesh: Mesh): CSG;
  58694. /**
  58695. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58696. * @param polygons Polygons used to construct a CSG solid
  58697. */
  58698. private static FromPolygons;
  58699. /**
  58700. * Clones, or makes a deep copy, of the CSG
  58701. * @returns A new CSG
  58702. */
  58703. clone(): CSG;
  58704. /**
  58705. * Unions this CSG with another CSG
  58706. * @param csg The CSG to union against this CSG
  58707. * @returns The unioned CSG
  58708. */
  58709. union(csg: CSG): CSG;
  58710. /**
  58711. * Unions this CSG with another CSG in place
  58712. * @param csg The CSG to union against this CSG
  58713. */
  58714. unionInPlace(csg: CSG): void;
  58715. /**
  58716. * Subtracts this CSG with another CSG
  58717. * @param csg The CSG to subtract against this CSG
  58718. * @returns A new CSG
  58719. */
  58720. subtract(csg: CSG): CSG;
  58721. /**
  58722. * Subtracts this CSG with another CSG in place
  58723. * @param csg The CSG to subtact against this CSG
  58724. */
  58725. subtractInPlace(csg: CSG): void;
  58726. /**
  58727. * Intersect this CSG with another CSG
  58728. * @param csg The CSG to intersect against this CSG
  58729. * @returns A new CSG
  58730. */
  58731. intersect(csg: CSG): CSG;
  58732. /**
  58733. * Intersects this CSG with another CSG in place
  58734. * @param csg The CSG to intersect against this CSG
  58735. */
  58736. intersectInPlace(csg: CSG): void;
  58737. /**
  58738. * Return a new CSG solid with solid and empty space switched. This solid is
  58739. * not modified.
  58740. * @returns A new CSG solid with solid and empty space switched
  58741. */
  58742. inverse(): CSG;
  58743. /**
  58744. * Inverses the CSG in place
  58745. */
  58746. inverseInPlace(): void;
  58747. /**
  58748. * This is used to keep meshes transformations so they can be restored
  58749. * when we build back a Babylon Mesh
  58750. * NB : All CSG operations are performed in world coordinates
  58751. * @param csg The CSG to copy the transform attributes from
  58752. * @returns This CSG
  58753. */
  58754. copyTransformAttributes(csg: CSG): CSG;
  58755. /**
  58756. * Build Raw mesh from CSG
  58757. * Coordinates here are in world space
  58758. * @param name The name of the mesh geometry
  58759. * @param scene The Scene
  58760. * @param keepSubMeshes Specifies if the submeshes should be kept
  58761. * @returns A new Mesh
  58762. */
  58763. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58764. /**
  58765. * Build Mesh from CSG taking material and transforms into account
  58766. * @param name The name of the Mesh
  58767. * @param material The material of the Mesh
  58768. * @param scene The Scene
  58769. * @param keepSubMeshes Specifies if submeshes should be kept
  58770. * @returns The new Mesh
  58771. */
  58772. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58773. }
  58774. }
  58775. declare module "babylonjs/Meshes/trailMesh" {
  58776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58777. import { Mesh } from "babylonjs/Meshes/mesh";
  58778. import { Scene } from "babylonjs/scene";
  58779. /**
  58780. * Class used to create a trail following a mesh
  58781. */
  58782. export class TrailMesh extends Mesh {
  58783. private _generator;
  58784. private _autoStart;
  58785. private _running;
  58786. private _diameter;
  58787. private _length;
  58788. private _sectionPolygonPointsCount;
  58789. private _sectionVectors;
  58790. private _sectionNormalVectors;
  58791. private _beforeRenderObserver;
  58792. /**
  58793. * @constructor
  58794. * @param name The value used by scene.getMeshByName() to do a lookup.
  58795. * @param generator The mesh to generate a trail.
  58796. * @param scene The scene to add this mesh to.
  58797. * @param diameter Diameter of trailing mesh. Default is 1.
  58798. * @param length Length of trailing mesh. Default is 60.
  58799. * @param autoStart Automatically start trailing mesh. Default true.
  58800. */
  58801. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58802. /**
  58803. * "TrailMesh"
  58804. * @returns "TrailMesh"
  58805. */
  58806. getClassName(): string;
  58807. private _createMesh;
  58808. /**
  58809. * Start trailing mesh.
  58810. */
  58811. start(): void;
  58812. /**
  58813. * Stop trailing mesh.
  58814. */
  58815. stop(): void;
  58816. /**
  58817. * Update trailing mesh geometry.
  58818. */
  58819. update(): void;
  58820. /**
  58821. * Returns a new TrailMesh object.
  58822. * @param name is a string, the name given to the new mesh
  58823. * @param newGenerator use new generator object for cloned trail mesh
  58824. * @returns a new mesh
  58825. */
  58826. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58827. /**
  58828. * Serializes this trail mesh
  58829. * @param serializationObject object to write serialization to
  58830. */
  58831. serialize(serializationObject: any): void;
  58832. /**
  58833. * Parses a serialized trail mesh
  58834. * @param parsedMesh the serialized mesh
  58835. * @param scene the scene to create the trail mesh in
  58836. * @returns the created trail mesh
  58837. */
  58838. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58839. }
  58840. }
  58841. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58842. import { Nullable } from "babylonjs/types";
  58843. import { Scene } from "babylonjs/scene";
  58844. import { Vector4 } from "babylonjs/Maths/math.vector";
  58845. import { Color4 } from "babylonjs/Maths/math.color";
  58846. import { Mesh } from "babylonjs/Meshes/mesh";
  58847. /**
  58848. * Class containing static functions to help procedurally build meshes
  58849. */
  58850. export class TiledBoxBuilder {
  58851. /**
  58852. * Creates a box mesh
  58853. * 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)
  58854. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58855. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58856. * * 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
  58857. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58858. * @param name defines the name of the mesh
  58859. * @param options defines the options used to create the mesh
  58860. * @param scene defines the hosting scene
  58861. * @returns the box mesh
  58862. */
  58863. static CreateTiledBox(name: string, options: {
  58864. pattern?: number;
  58865. width?: number;
  58866. height?: number;
  58867. depth?: number;
  58868. tileSize?: number;
  58869. tileWidth?: number;
  58870. tileHeight?: number;
  58871. alignHorizontal?: number;
  58872. alignVertical?: number;
  58873. faceUV?: Vector4[];
  58874. faceColors?: Color4[];
  58875. sideOrientation?: number;
  58876. updatable?: boolean;
  58877. }, scene?: Nullable<Scene>): Mesh;
  58878. }
  58879. }
  58880. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58881. import { Vector4 } from "babylonjs/Maths/math.vector";
  58882. import { Mesh } from "babylonjs/Meshes/mesh";
  58883. /**
  58884. * Class containing static functions to help procedurally build meshes
  58885. */
  58886. export class TorusKnotBuilder {
  58887. /**
  58888. * Creates a torus knot mesh
  58889. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58890. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58891. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58892. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58893. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58894. * * 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
  58895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58896. * @param name defines the name of the mesh
  58897. * @param options defines the options used to create the mesh
  58898. * @param scene defines the hosting scene
  58899. * @returns the torus knot mesh
  58900. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58901. */
  58902. static CreateTorusKnot(name: string, options: {
  58903. radius?: number;
  58904. tube?: number;
  58905. radialSegments?: number;
  58906. tubularSegments?: number;
  58907. p?: number;
  58908. q?: number;
  58909. updatable?: boolean;
  58910. sideOrientation?: number;
  58911. frontUVs?: Vector4;
  58912. backUVs?: Vector4;
  58913. }, scene: any): Mesh;
  58914. }
  58915. }
  58916. declare module "babylonjs/Meshes/polygonMesh" {
  58917. import { Scene } from "babylonjs/scene";
  58918. import { Vector2 } from "babylonjs/Maths/math.vector";
  58919. import { Mesh } from "babylonjs/Meshes/mesh";
  58920. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58921. import { Path2 } from "babylonjs/Maths/math.path";
  58922. /**
  58923. * Polygon
  58924. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58925. */
  58926. export class Polygon {
  58927. /**
  58928. * Creates a rectangle
  58929. * @param xmin bottom X coord
  58930. * @param ymin bottom Y coord
  58931. * @param xmax top X coord
  58932. * @param ymax top Y coord
  58933. * @returns points that make the resulting rectation
  58934. */
  58935. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58936. /**
  58937. * Creates a circle
  58938. * @param radius radius of circle
  58939. * @param cx scale in x
  58940. * @param cy scale in y
  58941. * @param numberOfSides number of sides that make up the circle
  58942. * @returns points that make the resulting circle
  58943. */
  58944. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58945. /**
  58946. * Creates a polygon from input string
  58947. * @param input Input polygon data
  58948. * @returns the parsed points
  58949. */
  58950. static Parse(input: string): Vector2[];
  58951. /**
  58952. * Starts building a polygon from x and y coordinates
  58953. * @param x x coordinate
  58954. * @param y y coordinate
  58955. * @returns the started path2
  58956. */
  58957. static StartingAt(x: number, y: number): Path2;
  58958. }
  58959. /**
  58960. * Builds a polygon
  58961. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58962. */
  58963. export class PolygonMeshBuilder {
  58964. private _points;
  58965. private _outlinepoints;
  58966. private _holes;
  58967. private _name;
  58968. private _scene;
  58969. private _epoints;
  58970. private _eholes;
  58971. private _addToepoint;
  58972. /**
  58973. * Babylon reference to the earcut plugin.
  58974. */
  58975. bjsEarcut: any;
  58976. /**
  58977. * Creates a PolygonMeshBuilder
  58978. * @param name name of the builder
  58979. * @param contours Path of the polygon
  58980. * @param scene scene to add to when creating the mesh
  58981. * @param earcutInjection can be used to inject your own earcut reference
  58982. */
  58983. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58984. /**
  58985. * Adds a whole within the polygon
  58986. * @param hole Array of points defining the hole
  58987. * @returns this
  58988. */
  58989. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58990. /**
  58991. * Creates the polygon
  58992. * @param updatable If the mesh should be updatable
  58993. * @param depth The depth of the mesh created
  58994. * @returns the created mesh
  58995. */
  58996. build(updatable?: boolean, depth?: number): Mesh;
  58997. /**
  58998. * Creates the polygon
  58999. * @param depth The depth of the mesh created
  59000. * @returns the created VertexData
  59001. */
  59002. buildVertexData(depth?: number): VertexData;
  59003. /**
  59004. * Adds a side to the polygon
  59005. * @param positions points that make the polygon
  59006. * @param normals normals of the polygon
  59007. * @param uvs uvs of the polygon
  59008. * @param indices indices of the polygon
  59009. * @param bounds bounds of the polygon
  59010. * @param points points of the polygon
  59011. * @param depth depth of the polygon
  59012. * @param flip flip of the polygon
  59013. */
  59014. private addSide;
  59015. }
  59016. }
  59017. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  59018. import { Scene } from "babylonjs/scene";
  59019. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59020. import { Color4 } from "babylonjs/Maths/math.color";
  59021. import { Mesh } from "babylonjs/Meshes/mesh";
  59022. import { Nullable } from "babylonjs/types";
  59023. /**
  59024. * Class containing static functions to help procedurally build meshes
  59025. */
  59026. export class PolygonBuilder {
  59027. /**
  59028. * Creates a polygon mesh
  59029. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59030. * * 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
  59031. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59033. * * 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)
  59034. * * Remember you can only change the shape positions, not their number when updating a polygon
  59035. * @param name defines the name of the mesh
  59036. * @param options defines the options used to create the mesh
  59037. * @param scene defines the hosting scene
  59038. * @param earcutInjection can be used to inject your own earcut reference
  59039. * @returns the polygon mesh
  59040. */
  59041. static CreatePolygon(name: string, options: {
  59042. shape: Vector3[];
  59043. holes?: Vector3[][];
  59044. depth?: number;
  59045. faceUV?: Vector4[];
  59046. faceColors?: Color4[];
  59047. updatable?: boolean;
  59048. sideOrientation?: number;
  59049. frontUVs?: Vector4;
  59050. backUVs?: Vector4;
  59051. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59052. /**
  59053. * Creates an extruded polygon mesh, with depth in the Y direction.
  59054. * * 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)
  59055. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59056. * @param name defines the name of the mesh
  59057. * @param options defines the options used to create the mesh
  59058. * @param scene defines the hosting scene
  59059. * @param earcutInjection can be used to inject your own earcut reference
  59060. * @returns the polygon mesh
  59061. */
  59062. static ExtrudePolygon(name: string, options: {
  59063. shape: Vector3[];
  59064. holes?: Vector3[][];
  59065. depth?: number;
  59066. faceUV?: Vector4[];
  59067. faceColors?: Color4[];
  59068. updatable?: boolean;
  59069. sideOrientation?: number;
  59070. frontUVs?: Vector4;
  59071. backUVs?: Vector4;
  59072. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59073. }
  59074. }
  59075. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59076. import { Scene } from "babylonjs/scene";
  59077. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59078. import { Mesh } from "babylonjs/Meshes/mesh";
  59079. import { Nullable } from "babylonjs/types";
  59080. /**
  59081. * Class containing static functions to help procedurally build meshes
  59082. */
  59083. export class LatheBuilder {
  59084. /**
  59085. * Creates lathe mesh.
  59086. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59087. * * 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
  59088. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59089. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59090. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59091. * * 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
  59092. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59093. * * 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
  59094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59095. * * 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
  59096. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59097. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59098. * @param name defines the name of the mesh
  59099. * @param options defines the options used to create the mesh
  59100. * @param scene defines the hosting scene
  59101. * @returns the lathe mesh
  59102. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59103. */
  59104. static CreateLathe(name: string, options: {
  59105. shape: Vector3[];
  59106. radius?: number;
  59107. tessellation?: number;
  59108. clip?: number;
  59109. arc?: number;
  59110. closed?: boolean;
  59111. updatable?: boolean;
  59112. sideOrientation?: number;
  59113. frontUVs?: Vector4;
  59114. backUVs?: Vector4;
  59115. cap?: number;
  59116. invertUV?: boolean;
  59117. }, scene?: Nullable<Scene>): Mesh;
  59118. }
  59119. }
  59120. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59121. import { Nullable } from "babylonjs/types";
  59122. import { Scene } from "babylonjs/scene";
  59123. import { Vector4 } from "babylonjs/Maths/math.vector";
  59124. import { Mesh } from "babylonjs/Meshes/mesh";
  59125. /**
  59126. * Class containing static functions to help procedurally build meshes
  59127. */
  59128. export class TiledPlaneBuilder {
  59129. /**
  59130. * Creates a tiled plane mesh
  59131. * * The parameter `pattern` will, depending on value, do nothing or
  59132. * * * flip (reflect about central vertical) alternate tiles across and up
  59133. * * * flip every tile on alternate rows
  59134. * * * rotate (180 degs) alternate tiles across and up
  59135. * * * rotate every tile on alternate rows
  59136. * * * flip and rotate alternate tiles across and up
  59137. * * * flip and rotate every tile on alternate rows
  59138. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59139. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59140. * * 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
  59141. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59142. * * 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)
  59143. * * 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)
  59144. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59145. * @param name defines the name of the mesh
  59146. * @param options defines the options used to create the mesh
  59147. * @param scene defines the hosting scene
  59148. * @returns the box mesh
  59149. */
  59150. static CreateTiledPlane(name: string, options: {
  59151. pattern?: number;
  59152. tileSize?: number;
  59153. tileWidth?: number;
  59154. tileHeight?: number;
  59155. size?: number;
  59156. width?: number;
  59157. height?: number;
  59158. alignHorizontal?: number;
  59159. alignVertical?: number;
  59160. sideOrientation?: number;
  59161. frontUVs?: Vector4;
  59162. backUVs?: Vector4;
  59163. updatable?: boolean;
  59164. }, scene?: Nullable<Scene>): Mesh;
  59165. }
  59166. }
  59167. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59168. import { Nullable } from "babylonjs/types";
  59169. import { Scene } from "babylonjs/scene";
  59170. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59171. import { Mesh } from "babylonjs/Meshes/mesh";
  59172. /**
  59173. * Class containing static functions to help procedurally build meshes
  59174. */
  59175. export class TubeBuilder {
  59176. /**
  59177. * Creates a tube mesh.
  59178. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59179. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59180. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59181. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59182. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59183. * * 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)
  59184. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59185. * * 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
  59186. * * 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
  59187. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59188. * * 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
  59189. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59190. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59191. * @param name defines the name of the mesh
  59192. * @param options defines the options used to create the mesh
  59193. * @param scene defines the hosting scene
  59194. * @returns the tube mesh
  59195. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59196. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59197. */
  59198. static CreateTube(name: string, options: {
  59199. path: Vector3[];
  59200. radius?: number;
  59201. tessellation?: number;
  59202. radiusFunction?: {
  59203. (i: number, distance: number): number;
  59204. };
  59205. cap?: number;
  59206. arc?: number;
  59207. updatable?: boolean;
  59208. sideOrientation?: number;
  59209. frontUVs?: Vector4;
  59210. backUVs?: Vector4;
  59211. instance?: Mesh;
  59212. invertUV?: boolean;
  59213. }, scene?: Nullable<Scene>): Mesh;
  59214. }
  59215. }
  59216. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59217. import { Scene } from "babylonjs/scene";
  59218. import { Vector4 } from "babylonjs/Maths/math.vector";
  59219. import { Mesh } from "babylonjs/Meshes/mesh";
  59220. import { Nullable } from "babylonjs/types";
  59221. /**
  59222. * Class containing static functions to help procedurally build meshes
  59223. */
  59224. export class IcoSphereBuilder {
  59225. /**
  59226. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59227. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59228. * * 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`)
  59229. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59230. * * 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
  59231. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59232. * * 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
  59233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59234. * @param name defines the name of the mesh
  59235. * @param options defines the options used to create the mesh
  59236. * @param scene defines the hosting scene
  59237. * @returns the icosahedron mesh
  59238. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59239. */
  59240. static CreateIcoSphere(name: string, options: {
  59241. radius?: number;
  59242. radiusX?: number;
  59243. radiusY?: number;
  59244. radiusZ?: number;
  59245. flat?: boolean;
  59246. subdivisions?: number;
  59247. sideOrientation?: number;
  59248. frontUVs?: Vector4;
  59249. backUVs?: Vector4;
  59250. updatable?: boolean;
  59251. }, scene?: Nullable<Scene>): Mesh;
  59252. }
  59253. }
  59254. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59255. import { Vector3 } from "babylonjs/Maths/math.vector";
  59256. import { Mesh } from "babylonjs/Meshes/mesh";
  59257. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59258. /**
  59259. * Class containing static functions to help procedurally build meshes
  59260. */
  59261. export class DecalBuilder {
  59262. /**
  59263. * Creates a decal mesh.
  59264. * 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
  59265. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59266. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59267. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59268. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59269. * @param name defines the name of the mesh
  59270. * @param sourceMesh defines the mesh where the decal must be applied
  59271. * @param options defines the options used to create the mesh
  59272. * @param scene defines the hosting scene
  59273. * @returns the decal mesh
  59274. * @see https://doc.babylonjs.com/how_to/decals
  59275. */
  59276. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59277. position?: Vector3;
  59278. normal?: Vector3;
  59279. size?: Vector3;
  59280. angle?: number;
  59281. }): Mesh;
  59282. }
  59283. }
  59284. declare module "babylonjs/Meshes/meshBuilder" {
  59285. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59286. import { Nullable } from "babylonjs/types";
  59287. import { Scene } from "babylonjs/scene";
  59288. import { Mesh } from "babylonjs/Meshes/mesh";
  59289. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59290. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59291. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59292. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59293. import { Plane } from "babylonjs/Maths/math.plane";
  59294. /**
  59295. * Class containing static functions to help procedurally build meshes
  59296. */
  59297. export class MeshBuilder {
  59298. /**
  59299. * Creates a box mesh
  59300. * * The parameter `size` sets the size (float) of each box side (default 1)
  59301. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59302. * * 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)
  59303. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59305. * * 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
  59306. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59307. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59308. * @param name defines the name of the mesh
  59309. * @param options defines the options used to create the mesh
  59310. * @param scene defines the hosting scene
  59311. * @returns the box mesh
  59312. */
  59313. static CreateBox(name: string, options: {
  59314. size?: number;
  59315. width?: number;
  59316. height?: number;
  59317. depth?: number;
  59318. faceUV?: Vector4[];
  59319. faceColors?: Color4[];
  59320. sideOrientation?: number;
  59321. frontUVs?: Vector4;
  59322. backUVs?: Vector4;
  59323. updatable?: boolean;
  59324. }, scene?: Nullable<Scene>): Mesh;
  59325. /**
  59326. * Creates a tiled box mesh
  59327. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59329. * @param name defines the name of the mesh
  59330. * @param options defines the options used to create the mesh
  59331. * @param scene defines the hosting scene
  59332. * @returns the tiled box mesh
  59333. */
  59334. static CreateTiledBox(name: string, options: {
  59335. pattern?: number;
  59336. size?: number;
  59337. width?: number;
  59338. height?: number;
  59339. depth: number;
  59340. tileSize?: number;
  59341. tileWidth?: number;
  59342. tileHeight?: number;
  59343. faceUV?: Vector4[];
  59344. faceColors?: Color4[];
  59345. alignHorizontal?: number;
  59346. alignVertical?: number;
  59347. sideOrientation?: number;
  59348. updatable?: boolean;
  59349. }, scene?: Nullable<Scene>): Mesh;
  59350. /**
  59351. * Creates a sphere mesh
  59352. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59353. * * 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`)
  59354. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59355. * * 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
  59356. * * 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)
  59357. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59358. * * 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
  59359. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59360. * @param name defines the name of the mesh
  59361. * @param options defines the options used to create the mesh
  59362. * @param scene defines the hosting scene
  59363. * @returns the sphere mesh
  59364. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59365. */
  59366. static CreateSphere(name: string, options: {
  59367. segments?: number;
  59368. diameter?: number;
  59369. diameterX?: number;
  59370. diameterY?: number;
  59371. diameterZ?: number;
  59372. arc?: number;
  59373. slice?: number;
  59374. sideOrientation?: number;
  59375. frontUVs?: Vector4;
  59376. backUVs?: Vector4;
  59377. updatable?: boolean;
  59378. }, scene?: Nullable<Scene>): Mesh;
  59379. /**
  59380. * Creates a plane polygonal mesh. By default, this is a disc
  59381. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59382. * * 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
  59383. * * 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
  59384. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59385. * * 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
  59386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59387. * @param name defines the name of the mesh
  59388. * @param options defines the options used to create the mesh
  59389. * @param scene defines the hosting scene
  59390. * @returns the plane polygonal mesh
  59391. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59392. */
  59393. static CreateDisc(name: string, options: {
  59394. radius?: number;
  59395. tessellation?: number;
  59396. arc?: number;
  59397. updatable?: boolean;
  59398. sideOrientation?: number;
  59399. frontUVs?: Vector4;
  59400. backUVs?: Vector4;
  59401. }, scene?: Nullable<Scene>): Mesh;
  59402. /**
  59403. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59404. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59405. * * 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`)
  59406. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59407. * * 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
  59408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59409. * * 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
  59410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59411. * @param name defines the name of the mesh
  59412. * @param options defines the options used to create the mesh
  59413. * @param scene defines the hosting scene
  59414. * @returns the icosahedron mesh
  59415. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59416. */
  59417. static CreateIcoSphere(name: string, options: {
  59418. radius?: number;
  59419. radiusX?: number;
  59420. radiusY?: number;
  59421. radiusZ?: number;
  59422. flat?: boolean;
  59423. subdivisions?: number;
  59424. sideOrientation?: number;
  59425. frontUVs?: Vector4;
  59426. backUVs?: Vector4;
  59427. updatable?: boolean;
  59428. }, scene?: Nullable<Scene>): Mesh;
  59429. /**
  59430. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59431. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59432. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59433. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59434. * * 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
  59435. * * 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
  59436. * * 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
  59437. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59438. * * 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
  59439. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59440. * * 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
  59441. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59442. * * 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
  59443. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59444. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59445. * @param name defines the name of the mesh
  59446. * @param options defines the options used to create the mesh
  59447. * @param scene defines the hosting scene
  59448. * @returns the ribbon mesh
  59449. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59450. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59451. */
  59452. static CreateRibbon(name: string, options: {
  59453. pathArray: Vector3[][];
  59454. closeArray?: boolean;
  59455. closePath?: boolean;
  59456. offset?: number;
  59457. updatable?: boolean;
  59458. sideOrientation?: number;
  59459. frontUVs?: Vector4;
  59460. backUVs?: Vector4;
  59461. instance?: Mesh;
  59462. invertUV?: boolean;
  59463. uvs?: Vector2[];
  59464. colors?: Color4[];
  59465. }, scene?: Nullable<Scene>): Mesh;
  59466. /**
  59467. * Creates a cylinder or a cone mesh
  59468. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59469. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59470. * * 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.
  59471. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59472. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59473. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59474. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59475. * * 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).
  59476. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59477. * * 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).
  59478. * * 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
  59479. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59480. * * 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
  59481. * * 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.
  59482. * * If `enclose` is false, a ring surface is one element.
  59483. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59484. * * 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
  59485. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59486. * * 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
  59487. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59488. * @param name defines the name of the mesh
  59489. * @param options defines the options used to create the mesh
  59490. * @param scene defines the hosting scene
  59491. * @returns the cylinder mesh
  59492. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59493. */
  59494. static CreateCylinder(name: string, options: {
  59495. height?: number;
  59496. diameterTop?: number;
  59497. diameterBottom?: number;
  59498. diameter?: number;
  59499. tessellation?: number;
  59500. subdivisions?: number;
  59501. arc?: number;
  59502. faceColors?: Color4[];
  59503. faceUV?: Vector4[];
  59504. updatable?: boolean;
  59505. hasRings?: boolean;
  59506. enclose?: boolean;
  59507. cap?: number;
  59508. sideOrientation?: number;
  59509. frontUVs?: Vector4;
  59510. backUVs?: Vector4;
  59511. }, scene?: Nullable<Scene>): Mesh;
  59512. /**
  59513. * Creates a torus mesh
  59514. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59515. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59516. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59517. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59518. * * 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
  59519. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59520. * @param name defines the name of the mesh
  59521. * @param options defines the options used to create the mesh
  59522. * @param scene defines the hosting scene
  59523. * @returns the torus mesh
  59524. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59525. */
  59526. static CreateTorus(name: string, options: {
  59527. diameter?: number;
  59528. thickness?: number;
  59529. tessellation?: number;
  59530. updatable?: boolean;
  59531. sideOrientation?: number;
  59532. frontUVs?: Vector4;
  59533. backUVs?: Vector4;
  59534. }, scene?: Nullable<Scene>): Mesh;
  59535. /**
  59536. * Creates a torus knot mesh
  59537. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59538. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59539. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59540. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59541. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59542. * * 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
  59543. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59544. * @param name defines the name of the mesh
  59545. * @param options defines the options used to create the mesh
  59546. * @param scene defines the hosting scene
  59547. * @returns the torus knot mesh
  59548. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59549. */
  59550. static CreateTorusKnot(name: string, options: {
  59551. radius?: number;
  59552. tube?: number;
  59553. radialSegments?: number;
  59554. tubularSegments?: number;
  59555. p?: number;
  59556. q?: number;
  59557. updatable?: boolean;
  59558. sideOrientation?: number;
  59559. frontUVs?: Vector4;
  59560. backUVs?: Vector4;
  59561. }, scene?: Nullable<Scene>): Mesh;
  59562. /**
  59563. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59564. * * 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
  59565. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59566. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59567. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59568. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59569. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59570. * * 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
  59571. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59572. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59573. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59574. * @param name defines the name of the new line system
  59575. * @param options defines the options used to create the line system
  59576. * @param scene defines the hosting scene
  59577. * @returns a new line system mesh
  59578. */
  59579. static CreateLineSystem(name: string, options: {
  59580. lines: Vector3[][];
  59581. updatable?: boolean;
  59582. instance?: Nullable<LinesMesh>;
  59583. colors?: Nullable<Color4[][]>;
  59584. useVertexAlpha?: boolean;
  59585. }, scene: Nullable<Scene>): LinesMesh;
  59586. /**
  59587. * Creates a line mesh
  59588. * 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
  59589. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59590. * * The parameter `points` is an array successive Vector3
  59591. * * 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
  59592. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59593. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59594. * * When updating an instance, remember that only point positions can change, not the number of points
  59595. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59596. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59597. * @param name defines the name of the new line system
  59598. * @param options defines the options used to create the line system
  59599. * @param scene defines the hosting scene
  59600. * @returns a new line mesh
  59601. */
  59602. static CreateLines(name: string, options: {
  59603. points: Vector3[];
  59604. updatable?: boolean;
  59605. instance?: Nullable<LinesMesh>;
  59606. colors?: Color4[];
  59607. useVertexAlpha?: boolean;
  59608. }, scene?: Nullable<Scene>): LinesMesh;
  59609. /**
  59610. * Creates a dashed line mesh
  59611. * * 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
  59612. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59613. * * The parameter `points` is an array successive Vector3
  59614. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59615. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59616. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59617. * * 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
  59618. * * When updating an instance, remember that only point positions can change, not the number of points
  59619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59620. * @param name defines the name of the mesh
  59621. * @param options defines the options used to create the mesh
  59622. * @param scene defines the hosting scene
  59623. * @returns the dashed line mesh
  59624. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59625. */
  59626. static CreateDashedLines(name: string, options: {
  59627. points: Vector3[];
  59628. dashSize?: number;
  59629. gapSize?: number;
  59630. dashNb?: number;
  59631. updatable?: boolean;
  59632. instance?: LinesMesh;
  59633. }, scene?: Nullable<Scene>): LinesMesh;
  59634. /**
  59635. * 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.
  59636. * * 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.
  59637. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59638. * * 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.
  59639. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59640. * * 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
  59641. * * 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
  59642. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59643. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59644. * * 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
  59645. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59646. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59647. * @param name defines the name of the mesh
  59648. * @param options defines the options used to create the mesh
  59649. * @param scene defines the hosting scene
  59650. * @returns the extruded shape mesh
  59651. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59652. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59653. */
  59654. static ExtrudeShape(name: string, options: {
  59655. shape: Vector3[];
  59656. path: Vector3[];
  59657. scale?: number;
  59658. rotation?: number;
  59659. cap?: number;
  59660. updatable?: boolean;
  59661. sideOrientation?: number;
  59662. frontUVs?: Vector4;
  59663. backUVs?: Vector4;
  59664. instance?: Mesh;
  59665. invertUV?: boolean;
  59666. }, scene?: Nullable<Scene>): Mesh;
  59667. /**
  59668. * Creates an custom extruded shape mesh.
  59669. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59670. * * 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.
  59671. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59672. * * 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
  59673. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59674. * * 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
  59675. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59676. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59677. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59678. * * 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
  59679. * * 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
  59680. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59681. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59682. * * 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
  59683. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59685. * @param name defines the name of the mesh
  59686. * @param options defines the options used to create the mesh
  59687. * @param scene defines the hosting scene
  59688. * @returns the custom extruded shape mesh
  59689. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59690. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59691. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59692. */
  59693. static ExtrudeShapeCustom(name: string, options: {
  59694. shape: Vector3[];
  59695. path: Vector3[];
  59696. scaleFunction?: any;
  59697. rotationFunction?: any;
  59698. ribbonCloseArray?: boolean;
  59699. ribbonClosePath?: boolean;
  59700. cap?: number;
  59701. updatable?: boolean;
  59702. sideOrientation?: number;
  59703. frontUVs?: Vector4;
  59704. backUVs?: Vector4;
  59705. instance?: Mesh;
  59706. invertUV?: boolean;
  59707. }, scene?: Nullable<Scene>): Mesh;
  59708. /**
  59709. * Creates lathe mesh.
  59710. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59711. * * 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
  59712. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59713. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59714. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59715. * * 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
  59716. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59717. * * 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
  59718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59719. * * 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
  59720. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59722. * @param name defines the name of the mesh
  59723. * @param options defines the options used to create the mesh
  59724. * @param scene defines the hosting scene
  59725. * @returns the lathe mesh
  59726. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59727. */
  59728. static CreateLathe(name: string, options: {
  59729. shape: Vector3[];
  59730. radius?: number;
  59731. tessellation?: number;
  59732. clip?: number;
  59733. arc?: number;
  59734. closed?: boolean;
  59735. updatable?: boolean;
  59736. sideOrientation?: number;
  59737. frontUVs?: Vector4;
  59738. backUVs?: Vector4;
  59739. cap?: number;
  59740. invertUV?: boolean;
  59741. }, scene?: Nullable<Scene>): Mesh;
  59742. /**
  59743. * Creates a tiled plane mesh
  59744. * * You can set a limited pattern arrangement with the tiles
  59745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59746. * * 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
  59747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59748. * @param name defines the name of the mesh
  59749. * @param options defines the options used to create the mesh
  59750. * @param scene defines the hosting scene
  59751. * @returns the plane mesh
  59752. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59753. */
  59754. static CreateTiledPlane(name: string, options: {
  59755. pattern?: number;
  59756. tileSize?: number;
  59757. tileWidth?: number;
  59758. tileHeight?: number;
  59759. size?: number;
  59760. width?: number;
  59761. height?: number;
  59762. alignHorizontal?: number;
  59763. alignVertical?: number;
  59764. sideOrientation?: number;
  59765. frontUVs?: Vector4;
  59766. backUVs?: Vector4;
  59767. updatable?: boolean;
  59768. }, scene?: Nullable<Scene>): Mesh;
  59769. /**
  59770. * Creates a plane mesh
  59771. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59772. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59773. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59775. * * 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
  59776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59777. * @param name defines the name of the mesh
  59778. * @param options defines the options used to create the mesh
  59779. * @param scene defines the hosting scene
  59780. * @returns the plane mesh
  59781. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59782. */
  59783. static CreatePlane(name: string, options: {
  59784. size?: number;
  59785. width?: number;
  59786. height?: number;
  59787. sideOrientation?: number;
  59788. frontUVs?: Vector4;
  59789. backUVs?: Vector4;
  59790. updatable?: boolean;
  59791. sourcePlane?: Plane;
  59792. }, scene?: Nullable<Scene>): Mesh;
  59793. /**
  59794. * Creates a ground mesh
  59795. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59796. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59798. * @param name defines the name of the mesh
  59799. * @param options defines the options used to create the mesh
  59800. * @param scene defines the hosting scene
  59801. * @returns the ground mesh
  59802. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59803. */
  59804. static CreateGround(name: string, options: {
  59805. width?: number;
  59806. height?: number;
  59807. subdivisions?: number;
  59808. subdivisionsX?: number;
  59809. subdivisionsY?: number;
  59810. updatable?: boolean;
  59811. }, scene?: Nullable<Scene>): Mesh;
  59812. /**
  59813. * Creates a tiled ground mesh
  59814. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59815. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59816. * * 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
  59817. * * 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
  59818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59819. * @param name defines the name of the mesh
  59820. * @param options defines the options used to create the mesh
  59821. * @param scene defines the hosting scene
  59822. * @returns the tiled ground mesh
  59823. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59824. */
  59825. static CreateTiledGround(name: string, options: {
  59826. xmin: number;
  59827. zmin: number;
  59828. xmax: number;
  59829. zmax: number;
  59830. subdivisions?: {
  59831. w: number;
  59832. h: number;
  59833. };
  59834. precision?: {
  59835. w: number;
  59836. h: number;
  59837. };
  59838. updatable?: boolean;
  59839. }, scene?: Nullable<Scene>): Mesh;
  59840. /**
  59841. * Creates a ground mesh from a height map
  59842. * * The parameter `url` sets the URL of the height map image resource.
  59843. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59844. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59845. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59846. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59847. * * 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.
  59848. * * 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).
  59849. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59850. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59851. * @param name defines the name of the mesh
  59852. * @param url defines the url to the height map
  59853. * @param options defines the options used to create the mesh
  59854. * @param scene defines the hosting scene
  59855. * @returns the ground mesh
  59856. * @see https://doc.babylonjs.com/babylon101/height_map
  59857. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59858. */
  59859. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59860. width?: number;
  59861. height?: number;
  59862. subdivisions?: number;
  59863. minHeight?: number;
  59864. maxHeight?: number;
  59865. colorFilter?: Color3;
  59866. alphaFilter?: number;
  59867. updatable?: boolean;
  59868. onReady?: (mesh: GroundMesh) => void;
  59869. }, scene?: Nullable<Scene>): GroundMesh;
  59870. /**
  59871. * Creates a polygon mesh
  59872. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59873. * * 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
  59874. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59876. * * 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)
  59877. * * Remember you can only change the shape positions, not their number when updating a polygon
  59878. * @param name defines the name of the mesh
  59879. * @param options defines the options used to create the mesh
  59880. * @param scene defines the hosting scene
  59881. * @param earcutInjection can be used to inject your own earcut reference
  59882. * @returns the polygon mesh
  59883. */
  59884. static CreatePolygon(name: string, options: {
  59885. shape: Vector3[];
  59886. holes?: Vector3[][];
  59887. depth?: number;
  59888. faceUV?: Vector4[];
  59889. faceColors?: Color4[];
  59890. updatable?: boolean;
  59891. sideOrientation?: number;
  59892. frontUVs?: Vector4;
  59893. backUVs?: Vector4;
  59894. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59895. /**
  59896. * Creates an extruded polygon mesh, with depth in the Y direction.
  59897. * * 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)
  59898. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59899. * @param name defines the name of the mesh
  59900. * @param options defines the options used to create the mesh
  59901. * @param scene defines the hosting scene
  59902. * @param earcutInjection can be used to inject your own earcut reference
  59903. * @returns the polygon mesh
  59904. */
  59905. static ExtrudePolygon(name: string, options: {
  59906. shape: Vector3[];
  59907. holes?: Vector3[][];
  59908. depth?: number;
  59909. faceUV?: Vector4[];
  59910. faceColors?: Color4[];
  59911. updatable?: boolean;
  59912. sideOrientation?: number;
  59913. frontUVs?: Vector4;
  59914. backUVs?: Vector4;
  59915. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59916. /**
  59917. * Creates a tube mesh.
  59918. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59919. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59920. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59921. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59922. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59923. * * 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)
  59924. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59925. * * 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
  59926. * * 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
  59927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59928. * * 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
  59929. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59930. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59931. * @param name defines the name of the mesh
  59932. * @param options defines the options used to create the mesh
  59933. * @param scene defines the hosting scene
  59934. * @returns the tube mesh
  59935. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59936. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59937. */
  59938. static CreateTube(name: string, options: {
  59939. path: Vector3[];
  59940. radius?: number;
  59941. tessellation?: number;
  59942. radiusFunction?: {
  59943. (i: number, distance: number): number;
  59944. };
  59945. cap?: number;
  59946. arc?: number;
  59947. updatable?: boolean;
  59948. sideOrientation?: number;
  59949. frontUVs?: Vector4;
  59950. backUVs?: Vector4;
  59951. instance?: Mesh;
  59952. invertUV?: boolean;
  59953. }, scene?: Nullable<Scene>): Mesh;
  59954. /**
  59955. * Creates a polyhedron mesh
  59956. * * 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
  59957. * * The parameter `size` (positive float, default 1) sets the polygon size
  59958. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59959. * * 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`
  59960. * * 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
  59961. * * 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)`)
  59962. * * 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
  59963. * * 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
  59964. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59965. * * 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
  59966. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59967. * @param name defines the name of the mesh
  59968. * @param options defines the options used to create the mesh
  59969. * @param scene defines the hosting scene
  59970. * @returns the polyhedron mesh
  59971. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59972. */
  59973. static CreatePolyhedron(name: string, options: {
  59974. type?: number;
  59975. size?: number;
  59976. sizeX?: number;
  59977. sizeY?: number;
  59978. sizeZ?: number;
  59979. custom?: any;
  59980. faceUV?: Vector4[];
  59981. faceColors?: Color4[];
  59982. flat?: boolean;
  59983. updatable?: boolean;
  59984. sideOrientation?: number;
  59985. frontUVs?: Vector4;
  59986. backUVs?: Vector4;
  59987. }, scene?: Nullable<Scene>): Mesh;
  59988. /**
  59989. * Creates a decal mesh.
  59990. * 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
  59991. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59992. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59993. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59994. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59995. * @param name defines the name of the mesh
  59996. * @param sourceMesh defines the mesh where the decal must be applied
  59997. * @param options defines the options used to create the mesh
  59998. * @param scene defines the hosting scene
  59999. * @returns the decal mesh
  60000. * @see https://doc.babylonjs.com/how_to/decals
  60001. */
  60002. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  60003. position?: Vector3;
  60004. normal?: Vector3;
  60005. size?: Vector3;
  60006. angle?: number;
  60007. }): Mesh;
  60008. }
  60009. }
  60010. declare module "babylonjs/Meshes/meshSimplification" {
  60011. import { Mesh } from "babylonjs/Meshes/mesh";
  60012. /**
  60013. * A simplifier interface for future simplification implementations
  60014. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60015. */
  60016. export interface ISimplifier {
  60017. /**
  60018. * Simplification of a given mesh according to the given settings.
  60019. * Since this requires computation, it is assumed that the function runs async.
  60020. * @param settings The settings of the simplification, including quality and distance
  60021. * @param successCallback A callback that will be called after the mesh was simplified.
  60022. * @param errorCallback in case of an error, this callback will be called. optional.
  60023. */
  60024. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  60025. }
  60026. /**
  60027. * Expected simplification settings.
  60028. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  60029. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60030. */
  60031. export interface ISimplificationSettings {
  60032. /**
  60033. * Gets or sets the expected quality
  60034. */
  60035. quality: number;
  60036. /**
  60037. * Gets or sets the distance when this optimized version should be used
  60038. */
  60039. distance: number;
  60040. /**
  60041. * Gets an already optimized mesh
  60042. */
  60043. optimizeMesh?: boolean;
  60044. }
  60045. /**
  60046. * Class used to specify simplification options
  60047. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60048. */
  60049. export class SimplificationSettings implements ISimplificationSettings {
  60050. /** expected quality */
  60051. quality: number;
  60052. /** distance when this optimized version should be used */
  60053. distance: number;
  60054. /** already optimized mesh */
  60055. optimizeMesh?: boolean | undefined;
  60056. /**
  60057. * Creates a SimplificationSettings
  60058. * @param quality expected quality
  60059. * @param distance distance when this optimized version should be used
  60060. * @param optimizeMesh already optimized mesh
  60061. */
  60062. constructor(
  60063. /** expected quality */
  60064. quality: number,
  60065. /** distance when this optimized version should be used */
  60066. distance: number,
  60067. /** already optimized mesh */
  60068. optimizeMesh?: boolean | undefined);
  60069. }
  60070. /**
  60071. * Interface used to define a simplification task
  60072. */
  60073. export interface ISimplificationTask {
  60074. /**
  60075. * Array of settings
  60076. */
  60077. settings: Array<ISimplificationSettings>;
  60078. /**
  60079. * Simplification type
  60080. */
  60081. simplificationType: SimplificationType;
  60082. /**
  60083. * Mesh to simplify
  60084. */
  60085. mesh: Mesh;
  60086. /**
  60087. * Callback called on success
  60088. */
  60089. successCallback?: () => void;
  60090. /**
  60091. * Defines if parallel processing can be used
  60092. */
  60093. parallelProcessing: boolean;
  60094. }
  60095. /**
  60096. * Queue used to order the simplification tasks
  60097. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60098. */
  60099. export class SimplificationQueue {
  60100. private _simplificationArray;
  60101. /**
  60102. * Gets a boolean indicating that the process is still running
  60103. */
  60104. running: boolean;
  60105. /**
  60106. * Creates a new queue
  60107. */
  60108. constructor();
  60109. /**
  60110. * Adds a new simplification task
  60111. * @param task defines a task to add
  60112. */
  60113. addTask(task: ISimplificationTask): void;
  60114. /**
  60115. * Execute next task
  60116. */
  60117. executeNext(): void;
  60118. /**
  60119. * Execute a simplification task
  60120. * @param task defines the task to run
  60121. */
  60122. runSimplification(task: ISimplificationTask): void;
  60123. private getSimplifier;
  60124. }
  60125. /**
  60126. * The implemented types of simplification
  60127. * At the moment only Quadratic Error Decimation is implemented
  60128. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60129. */
  60130. export enum SimplificationType {
  60131. /** Quadratic error decimation */
  60132. QUADRATIC = 0
  60133. }
  60134. }
  60135. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60136. import { Scene } from "babylonjs/scene";
  60137. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60138. import { ISceneComponent } from "babylonjs/sceneComponent";
  60139. module "babylonjs/scene" {
  60140. interface Scene {
  60141. /** @hidden (Backing field) */
  60142. _simplificationQueue: SimplificationQueue;
  60143. /**
  60144. * Gets or sets the simplification queue attached to the scene
  60145. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60146. */
  60147. simplificationQueue: SimplificationQueue;
  60148. }
  60149. }
  60150. module "babylonjs/Meshes/mesh" {
  60151. interface Mesh {
  60152. /**
  60153. * Simplify the mesh according to the given array of settings.
  60154. * Function will return immediately and will simplify async
  60155. * @param settings a collection of simplification settings
  60156. * @param parallelProcessing should all levels calculate parallel or one after the other
  60157. * @param simplificationType the type of simplification to run
  60158. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60159. * @returns the current mesh
  60160. */
  60161. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60162. }
  60163. }
  60164. /**
  60165. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60166. * created in a scene
  60167. */
  60168. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60169. /**
  60170. * The component name helpfull to identify the component in the list of scene components.
  60171. */
  60172. readonly name: string;
  60173. /**
  60174. * The scene the component belongs to.
  60175. */
  60176. scene: Scene;
  60177. /**
  60178. * Creates a new instance of the component for the given scene
  60179. * @param scene Defines the scene to register the component in
  60180. */
  60181. constructor(scene: Scene);
  60182. /**
  60183. * Registers the component in a given scene
  60184. */
  60185. register(): void;
  60186. /**
  60187. * Rebuilds the elements related to this component in case of
  60188. * context lost for instance.
  60189. */
  60190. rebuild(): void;
  60191. /**
  60192. * Disposes the component and the associated ressources
  60193. */
  60194. dispose(): void;
  60195. private _beforeCameraUpdate;
  60196. }
  60197. }
  60198. declare module "babylonjs/Meshes/Builders/index" {
  60199. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60200. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60201. export * from "babylonjs/Meshes/Builders/discBuilder";
  60202. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60203. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60204. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60205. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60206. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60207. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60208. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60209. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60210. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60211. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60212. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60213. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60214. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60215. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60216. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60217. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60218. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60219. }
  60220. declare module "babylonjs/Meshes/index" {
  60221. export * from "babylonjs/Meshes/abstractMesh";
  60222. export * from "babylonjs/Meshes/buffer";
  60223. export * from "babylonjs/Meshes/Compression/index";
  60224. export * from "babylonjs/Meshes/csg";
  60225. export * from "babylonjs/Meshes/geometry";
  60226. export * from "babylonjs/Meshes/groundMesh";
  60227. export * from "babylonjs/Meshes/trailMesh";
  60228. export * from "babylonjs/Meshes/instancedMesh";
  60229. export * from "babylonjs/Meshes/linesMesh";
  60230. export * from "babylonjs/Meshes/mesh";
  60231. export * from "babylonjs/Meshes/mesh.vertexData";
  60232. export * from "babylonjs/Meshes/meshBuilder";
  60233. export * from "babylonjs/Meshes/meshSimplification";
  60234. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60235. export * from "babylonjs/Meshes/polygonMesh";
  60236. export * from "babylonjs/Meshes/subMesh";
  60237. export * from "babylonjs/Meshes/meshLODLevel";
  60238. export * from "babylonjs/Meshes/transformNode";
  60239. export * from "babylonjs/Meshes/Builders/index";
  60240. export * from "babylonjs/Meshes/dataBuffer";
  60241. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60242. }
  60243. declare module "babylonjs/Morph/index" {
  60244. export * from "babylonjs/Morph/morphTarget";
  60245. export * from "babylonjs/Morph/morphTargetManager";
  60246. }
  60247. declare module "babylonjs/Navigation/INavigationEngine" {
  60248. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60249. import { Vector3 } from "babylonjs/Maths/math";
  60250. import { Mesh } from "babylonjs/Meshes/mesh";
  60251. import { Scene } from "babylonjs/scene";
  60252. /**
  60253. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60254. */
  60255. export interface INavigationEnginePlugin {
  60256. /**
  60257. * plugin name
  60258. */
  60259. name: string;
  60260. /**
  60261. * Creates a navigation mesh
  60262. * @param meshes array of all the geometry used to compute the navigatio mesh
  60263. * @param parameters bunch of parameters used to filter geometry
  60264. */
  60265. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60266. /**
  60267. * Create a navigation mesh debug mesh
  60268. * @param scene is where the mesh will be added
  60269. * @returns debug display mesh
  60270. */
  60271. createDebugNavMesh(scene: Scene): Mesh;
  60272. /**
  60273. * Get a navigation mesh constrained position, closest to the parameter position
  60274. * @param position world position
  60275. * @returns the closest point to position constrained by the navigation mesh
  60276. */
  60277. getClosestPoint(position: Vector3): Vector3;
  60278. /**
  60279. * Get a navigation mesh constrained position, within a particular radius
  60280. * @param position world position
  60281. * @param maxRadius the maximum distance to the constrained world position
  60282. * @returns the closest point to position constrained by the navigation mesh
  60283. */
  60284. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60285. /**
  60286. * Compute the final position from a segment made of destination-position
  60287. * @param position world position
  60288. * @param destination world position
  60289. * @returns the resulting point along the navmesh
  60290. */
  60291. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60292. /**
  60293. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60294. * @param start world position
  60295. * @param end world position
  60296. * @returns array containing world position composing the path
  60297. */
  60298. computePath(start: Vector3, end: Vector3): Vector3[];
  60299. /**
  60300. * If this plugin is supported
  60301. * @returns true if plugin is supported
  60302. */
  60303. isSupported(): boolean;
  60304. /**
  60305. * Create a new Crowd so you can add agents
  60306. * @param maxAgents the maximum agent count in the crowd
  60307. * @param maxAgentRadius the maximum radius an agent can have
  60308. * @param scene to attach the crowd to
  60309. * @returns the crowd you can add agents to
  60310. */
  60311. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60312. /**
  60313. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60314. * The queries will try to find a solution within those bounds
  60315. * default is (1,1,1)
  60316. * @param extent x,y,z value that define the extent around the queries point of reference
  60317. */
  60318. setDefaultQueryExtent(extent: Vector3): void;
  60319. /**
  60320. * Get the Bounding box extent specified by setDefaultQueryExtent
  60321. * @returns the box extent values
  60322. */
  60323. getDefaultQueryExtent(): Vector3;
  60324. /**
  60325. * Release all resources
  60326. */
  60327. dispose(): void;
  60328. }
  60329. /**
  60330. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60331. */
  60332. export interface ICrowd {
  60333. /**
  60334. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60335. * You can attach anything to that node. The node position is updated in the scene update tick.
  60336. * @param pos world position that will be constrained by the navigation mesh
  60337. * @param parameters agent parameters
  60338. * @param transform hooked to the agent that will be update by the scene
  60339. * @returns agent index
  60340. */
  60341. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60342. /**
  60343. * Returns the agent position in world space
  60344. * @param index agent index returned by addAgent
  60345. * @returns world space position
  60346. */
  60347. getAgentPosition(index: number): Vector3;
  60348. /**
  60349. * Gets the agent velocity in world space
  60350. * @param index agent index returned by addAgent
  60351. * @returns world space velocity
  60352. */
  60353. getAgentVelocity(index: number): Vector3;
  60354. /**
  60355. * remove a particular agent previously created
  60356. * @param index agent index returned by addAgent
  60357. */
  60358. removeAgent(index: number): void;
  60359. /**
  60360. * get the list of all agents attached to this crowd
  60361. * @returns list of agent indices
  60362. */
  60363. getAgents(): number[];
  60364. /**
  60365. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60366. * @param deltaTime in seconds
  60367. */
  60368. update(deltaTime: number): void;
  60369. /**
  60370. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60371. * @param index agent index returned by addAgent
  60372. * @param destination targeted world position
  60373. */
  60374. agentGoto(index: number, destination: Vector3): void;
  60375. /**
  60376. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60377. * The queries will try to find a solution within those bounds
  60378. * default is (1,1,1)
  60379. * @param extent x,y,z value that define the extent around the queries point of reference
  60380. */
  60381. setDefaultQueryExtent(extent: Vector3): void;
  60382. /**
  60383. * Get the Bounding box extent specified by setDefaultQueryExtent
  60384. * @returns the box extent values
  60385. */
  60386. getDefaultQueryExtent(): Vector3;
  60387. /**
  60388. * Release all resources
  60389. */
  60390. dispose(): void;
  60391. }
  60392. /**
  60393. * Configures an agent
  60394. */
  60395. export interface IAgentParameters {
  60396. /**
  60397. * Agent radius. [Limit: >= 0]
  60398. */
  60399. radius: number;
  60400. /**
  60401. * Agent height. [Limit: > 0]
  60402. */
  60403. height: number;
  60404. /**
  60405. * Maximum allowed acceleration. [Limit: >= 0]
  60406. */
  60407. maxAcceleration: number;
  60408. /**
  60409. * Maximum allowed speed. [Limit: >= 0]
  60410. */
  60411. maxSpeed: number;
  60412. /**
  60413. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60414. */
  60415. collisionQueryRange: number;
  60416. /**
  60417. * The path visibility optimization range. [Limit: > 0]
  60418. */
  60419. pathOptimizationRange: number;
  60420. /**
  60421. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60422. */
  60423. separationWeight: number;
  60424. }
  60425. /**
  60426. * Configures the navigation mesh creation
  60427. */
  60428. export interface INavMeshParameters {
  60429. /**
  60430. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60431. */
  60432. cs: number;
  60433. /**
  60434. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60435. */
  60436. ch: number;
  60437. /**
  60438. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60439. */
  60440. walkableSlopeAngle: number;
  60441. /**
  60442. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60443. * be considered walkable. [Limit: >= 3] [Units: vx]
  60444. */
  60445. walkableHeight: number;
  60446. /**
  60447. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60448. */
  60449. walkableClimb: number;
  60450. /**
  60451. * The distance to erode/shrink the walkable area of the heightfield away from
  60452. * obstructions. [Limit: >=0] [Units: vx]
  60453. */
  60454. walkableRadius: number;
  60455. /**
  60456. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60457. */
  60458. maxEdgeLen: number;
  60459. /**
  60460. * The maximum distance a simplfied contour's border edges should deviate
  60461. * the original raw contour. [Limit: >=0] [Units: vx]
  60462. */
  60463. maxSimplificationError: number;
  60464. /**
  60465. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60466. */
  60467. minRegionArea: number;
  60468. /**
  60469. * Any regions with a span count smaller than this value will, if possible,
  60470. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60471. */
  60472. mergeRegionArea: number;
  60473. /**
  60474. * The maximum number of vertices allowed for polygons generated during the
  60475. * contour to polygon conversion process. [Limit: >= 3]
  60476. */
  60477. maxVertsPerPoly: number;
  60478. /**
  60479. * Sets the sampling distance to use when generating the detail mesh.
  60480. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60481. */
  60482. detailSampleDist: number;
  60483. /**
  60484. * The maximum distance the detail mesh surface should deviate from heightfield
  60485. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60486. */
  60487. detailSampleMaxError: number;
  60488. }
  60489. }
  60490. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60491. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60492. import { Mesh } from "babylonjs/Meshes/mesh";
  60493. import { Scene } from "babylonjs/scene";
  60494. import { Vector3 } from "babylonjs/Maths/math";
  60495. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60496. /**
  60497. * RecastJS navigation plugin
  60498. */
  60499. export class RecastJSPlugin implements INavigationEnginePlugin {
  60500. /**
  60501. * Reference to the Recast library
  60502. */
  60503. bjsRECAST: any;
  60504. /**
  60505. * plugin name
  60506. */
  60507. name: string;
  60508. /**
  60509. * the first navmesh created. We might extend this to support multiple navmeshes
  60510. */
  60511. navMesh: any;
  60512. /**
  60513. * Initializes the recastJS plugin
  60514. * @param recastInjection can be used to inject your own recast reference
  60515. */
  60516. constructor(recastInjection?: any);
  60517. /**
  60518. * Creates a navigation mesh
  60519. * @param meshes array of all the geometry used to compute the navigatio mesh
  60520. * @param parameters bunch of parameters used to filter geometry
  60521. */
  60522. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60523. /**
  60524. * Create a navigation mesh debug mesh
  60525. * @param scene is where the mesh will be added
  60526. * @returns debug display mesh
  60527. */
  60528. createDebugNavMesh(scene: Scene): Mesh;
  60529. /**
  60530. * Get a navigation mesh constrained position, closest to the parameter position
  60531. * @param position world position
  60532. * @returns the closest point to position constrained by the navigation mesh
  60533. */
  60534. getClosestPoint(position: Vector3): Vector3;
  60535. /**
  60536. * Get a navigation mesh constrained position, within a particular radius
  60537. * @param position world position
  60538. * @param maxRadius the maximum distance to the constrained world position
  60539. * @returns the closest point to position constrained by the navigation mesh
  60540. */
  60541. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60542. /**
  60543. * Compute the final position from a segment made of destination-position
  60544. * @param position world position
  60545. * @param destination world position
  60546. * @returns the resulting point along the navmesh
  60547. */
  60548. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60549. /**
  60550. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60551. * @param start world position
  60552. * @param end world position
  60553. * @returns array containing world position composing the path
  60554. */
  60555. computePath(start: Vector3, end: Vector3): Vector3[];
  60556. /**
  60557. * Create a new Crowd so you can add agents
  60558. * @param maxAgents the maximum agent count in the crowd
  60559. * @param maxAgentRadius the maximum radius an agent can have
  60560. * @param scene to attach the crowd to
  60561. * @returns the crowd you can add agents to
  60562. */
  60563. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60564. /**
  60565. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60566. * The queries will try to find a solution within those bounds
  60567. * default is (1,1,1)
  60568. * @param extent x,y,z value that define the extent around the queries point of reference
  60569. */
  60570. setDefaultQueryExtent(extent: Vector3): void;
  60571. /**
  60572. * Get the Bounding box extent specified by setDefaultQueryExtent
  60573. * @returns the box extent values
  60574. */
  60575. getDefaultQueryExtent(): Vector3;
  60576. /**
  60577. * Disposes
  60578. */
  60579. dispose(): void;
  60580. /**
  60581. * If this plugin is supported
  60582. * @returns true if plugin is supported
  60583. */
  60584. isSupported(): boolean;
  60585. }
  60586. /**
  60587. * Recast detour crowd implementation
  60588. */
  60589. export class RecastJSCrowd implements ICrowd {
  60590. /**
  60591. * Recast/detour plugin
  60592. */
  60593. bjsRECASTPlugin: RecastJSPlugin;
  60594. /**
  60595. * Link to the detour crowd
  60596. */
  60597. recastCrowd: any;
  60598. /**
  60599. * One transform per agent
  60600. */
  60601. transforms: TransformNode[];
  60602. /**
  60603. * All agents created
  60604. */
  60605. agents: number[];
  60606. /**
  60607. * Link to the scene is kept to unregister the crowd from the scene
  60608. */
  60609. private _scene;
  60610. /**
  60611. * Observer for crowd updates
  60612. */
  60613. private _onBeforeAnimationsObserver;
  60614. /**
  60615. * Constructor
  60616. * @param plugin recastJS plugin
  60617. * @param maxAgents the maximum agent count in the crowd
  60618. * @param maxAgentRadius the maximum radius an agent can have
  60619. * @param scene to attach the crowd to
  60620. * @returns the crowd you can add agents to
  60621. */
  60622. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60623. /**
  60624. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60625. * You can attach anything to that node. The node position is updated in the scene update tick.
  60626. * @param pos world position that will be constrained by the navigation mesh
  60627. * @param parameters agent parameters
  60628. * @param transform hooked to the agent that will be update by the scene
  60629. * @returns agent index
  60630. */
  60631. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60632. /**
  60633. * Returns the agent position in world space
  60634. * @param index agent index returned by addAgent
  60635. * @returns world space position
  60636. */
  60637. getAgentPosition(index: number): Vector3;
  60638. /**
  60639. * Returns the agent velocity in world space
  60640. * @param index agent index returned by addAgent
  60641. * @returns world space velocity
  60642. */
  60643. getAgentVelocity(index: number): Vector3;
  60644. /**
  60645. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60646. * @param index agent index returned by addAgent
  60647. * @param destination targeted world position
  60648. */
  60649. agentGoto(index: number, destination: Vector3): void;
  60650. /**
  60651. * remove a particular agent previously created
  60652. * @param index agent index returned by addAgent
  60653. */
  60654. removeAgent(index: number): void;
  60655. /**
  60656. * get the list of all agents attached to this crowd
  60657. * @returns list of agent indices
  60658. */
  60659. getAgents(): number[];
  60660. /**
  60661. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60662. * @param deltaTime in seconds
  60663. */
  60664. update(deltaTime: number): void;
  60665. /**
  60666. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60667. * The queries will try to find a solution within those bounds
  60668. * default is (1,1,1)
  60669. * @param extent x,y,z value that define the extent around the queries point of reference
  60670. */
  60671. setDefaultQueryExtent(extent: Vector3): void;
  60672. /**
  60673. * Get the Bounding box extent specified by setDefaultQueryExtent
  60674. * @returns the box extent values
  60675. */
  60676. getDefaultQueryExtent(): Vector3;
  60677. /**
  60678. * Release all resources
  60679. */
  60680. dispose(): void;
  60681. }
  60682. }
  60683. declare module "babylonjs/Navigation/Plugins/index" {
  60684. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60685. }
  60686. declare module "babylonjs/Navigation/index" {
  60687. export * from "babylonjs/Navigation/INavigationEngine";
  60688. export * from "babylonjs/Navigation/Plugins/index";
  60689. }
  60690. declare module "babylonjs/Offline/database" {
  60691. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60692. /**
  60693. * Class used to enable access to IndexedDB
  60694. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60695. */
  60696. export class Database implements IOfflineProvider {
  60697. private _callbackManifestChecked;
  60698. private _currentSceneUrl;
  60699. private _db;
  60700. private _enableSceneOffline;
  60701. private _enableTexturesOffline;
  60702. private _manifestVersionFound;
  60703. private _mustUpdateRessources;
  60704. private _hasReachedQuota;
  60705. private _isSupported;
  60706. private _idbFactory;
  60707. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60708. private static IsUASupportingBlobStorage;
  60709. /**
  60710. * Gets a boolean indicating if Database storate is enabled (off by default)
  60711. */
  60712. static IDBStorageEnabled: boolean;
  60713. /**
  60714. * Gets a boolean indicating if scene must be saved in the database
  60715. */
  60716. readonly enableSceneOffline: boolean;
  60717. /**
  60718. * Gets a boolean indicating if textures must be saved in the database
  60719. */
  60720. readonly enableTexturesOffline: boolean;
  60721. /**
  60722. * Creates a new Database
  60723. * @param urlToScene defines the url to load the scene
  60724. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60725. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60726. */
  60727. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60728. private static _ParseURL;
  60729. private static _ReturnFullUrlLocation;
  60730. private _checkManifestFile;
  60731. /**
  60732. * Open the database and make it available
  60733. * @param successCallback defines the callback to call on success
  60734. * @param errorCallback defines the callback to call on error
  60735. */
  60736. open(successCallback: () => void, errorCallback: () => void): void;
  60737. /**
  60738. * Loads an image from the database
  60739. * @param url defines the url to load from
  60740. * @param image defines the target DOM image
  60741. */
  60742. loadImage(url: string, image: HTMLImageElement): void;
  60743. private _loadImageFromDBAsync;
  60744. private _saveImageIntoDBAsync;
  60745. private _checkVersionFromDB;
  60746. private _loadVersionFromDBAsync;
  60747. private _saveVersionIntoDBAsync;
  60748. /**
  60749. * Loads a file from database
  60750. * @param url defines the URL to load from
  60751. * @param sceneLoaded defines a callback to call on success
  60752. * @param progressCallBack defines a callback to call when progress changed
  60753. * @param errorCallback defines a callback to call on error
  60754. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60755. */
  60756. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60757. private _loadFileAsync;
  60758. private _saveFileAsync;
  60759. /**
  60760. * Validates if xhr data is correct
  60761. * @param xhr defines the request to validate
  60762. * @param dataType defines the expected data type
  60763. * @returns true if data is correct
  60764. */
  60765. private static _ValidateXHRData;
  60766. }
  60767. }
  60768. declare module "babylonjs/Offline/index" {
  60769. export * from "babylonjs/Offline/database";
  60770. export * from "babylonjs/Offline/IOfflineProvider";
  60771. }
  60772. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60773. /** @hidden */
  60774. export var gpuUpdateParticlesPixelShader: {
  60775. name: string;
  60776. shader: string;
  60777. };
  60778. }
  60779. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60780. /** @hidden */
  60781. export var gpuUpdateParticlesVertexShader: {
  60782. name: string;
  60783. shader: string;
  60784. };
  60785. }
  60786. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60787. /** @hidden */
  60788. export var clipPlaneFragmentDeclaration2: {
  60789. name: string;
  60790. shader: string;
  60791. };
  60792. }
  60793. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60794. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60795. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60796. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60797. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60798. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60799. /** @hidden */
  60800. export var gpuRenderParticlesPixelShader: {
  60801. name: string;
  60802. shader: string;
  60803. };
  60804. }
  60805. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60806. /** @hidden */
  60807. export var clipPlaneVertexDeclaration2: {
  60808. name: string;
  60809. shader: string;
  60810. };
  60811. }
  60812. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60813. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60814. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60815. /** @hidden */
  60816. export var gpuRenderParticlesVertexShader: {
  60817. name: string;
  60818. shader: string;
  60819. };
  60820. }
  60821. declare module "babylonjs/Particles/gpuParticleSystem" {
  60822. import { Nullable } from "babylonjs/types";
  60823. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60824. import { Observable } from "babylonjs/Misc/observable";
  60825. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60826. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60827. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60828. import { Scene, IDisposable } from "babylonjs/scene";
  60829. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60830. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60831. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60832. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60833. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60834. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60835. /**
  60836. * This represents a GPU particle system in Babylon
  60837. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60838. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60839. */
  60840. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60841. /**
  60842. * The layer mask we are rendering the particles through.
  60843. */
  60844. layerMask: number;
  60845. private _capacity;
  60846. private _activeCount;
  60847. private _currentActiveCount;
  60848. private _accumulatedCount;
  60849. private _renderEffect;
  60850. private _updateEffect;
  60851. private _buffer0;
  60852. private _buffer1;
  60853. private _spriteBuffer;
  60854. private _updateVAO;
  60855. private _renderVAO;
  60856. private _targetIndex;
  60857. private _sourceBuffer;
  60858. private _targetBuffer;
  60859. private _engine;
  60860. private _currentRenderId;
  60861. private _started;
  60862. private _stopped;
  60863. private _timeDelta;
  60864. private _randomTexture;
  60865. private _randomTexture2;
  60866. private _attributesStrideSize;
  60867. private _updateEffectOptions;
  60868. private _randomTextureSize;
  60869. private _actualFrame;
  60870. private readonly _rawTextureWidth;
  60871. /**
  60872. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60873. */
  60874. static readonly IsSupported: boolean;
  60875. /**
  60876. * An event triggered when the system is disposed.
  60877. */
  60878. onDisposeObservable: Observable<GPUParticleSystem>;
  60879. /**
  60880. * Gets the maximum number of particles active at the same time.
  60881. * @returns The max number of active particles.
  60882. */
  60883. getCapacity(): number;
  60884. /**
  60885. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60886. * to override the particles.
  60887. */
  60888. forceDepthWrite: boolean;
  60889. /**
  60890. * Gets or set the number of active particles
  60891. */
  60892. activeParticleCount: number;
  60893. private _preWarmDone;
  60894. /**
  60895. * Is this system ready to be used/rendered
  60896. * @return true if the system is ready
  60897. */
  60898. isReady(): boolean;
  60899. /**
  60900. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60901. * @returns True if it has been started, otherwise false.
  60902. */
  60903. isStarted(): boolean;
  60904. /**
  60905. * Starts the particle system and begins to emit
  60906. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60907. */
  60908. start(delay?: number): void;
  60909. /**
  60910. * Stops the particle system.
  60911. */
  60912. stop(): void;
  60913. /**
  60914. * Remove all active particles
  60915. */
  60916. reset(): void;
  60917. /**
  60918. * Returns the string "GPUParticleSystem"
  60919. * @returns a string containing the class name
  60920. */
  60921. getClassName(): string;
  60922. private _colorGradientsTexture;
  60923. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60924. /**
  60925. * Adds a new color gradient
  60926. * @param gradient defines the gradient to use (between 0 and 1)
  60927. * @param color1 defines the color to affect to the specified gradient
  60928. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60929. * @returns the current particle system
  60930. */
  60931. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60932. /**
  60933. * Remove a specific color gradient
  60934. * @param gradient defines the gradient to remove
  60935. * @returns the current particle system
  60936. */
  60937. removeColorGradient(gradient: number): GPUParticleSystem;
  60938. private _angularSpeedGradientsTexture;
  60939. private _sizeGradientsTexture;
  60940. private _velocityGradientsTexture;
  60941. private _limitVelocityGradientsTexture;
  60942. private _dragGradientsTexture;
  60943. private _addFactorGradient;
  60944. /**
  60945. * Adds a new size gradient
  60946. * @param gradient defines the gradient to use (between 0 and 1)
  60947. * @param factor defines the size factor to affect to the specified gradient
  60948. * @returns the current particle system
  60949. */
  60950. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60951. /**
  60952. * Remove a specific size gradient
  60953. * @param gradient defines the gradient to remove
  60954. * @returns the current particle system
  60955. */
  60956. removeSizeGradient(gradient: number): GPUParticleSystem;
  60957. /**
  60958. * Adds a new angular speed gradient
  60959. * @param gradient defines the gradient to use (between 0 and 1)
  60960. * @param factor defines the angular speed to affect to the specified gradient
  60961. * @returns the current particle system
  60962. */
  60963. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60964. /**
  60965. * Remove a specific angular speed gradient
  60966. * @param gradient defines the gradient to remove
  60967. * @returns the current particle system
  60968. */
  60969. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60970. /**
  60971. * Adds a new velocity gradient
  60972. * @param gradient defines the gradient to use (between 0 and 1)
  60973. * @param factor defines the velocity to affect to the specified gradient
  60974. * @returns the current particle system
  60975. */
  60976. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60977. /**
  60978. * Remove a specific velocity gradient
  60979. * @param gradient defines the gradient to remove
  60980. * @returns the current particle system
  60981. */
  60982. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60983. /**
  60984. * Adds a new limit velocity gradient
  60985. * @param gradient defines the gradient to use (between 0 and 1)
  60986. * @param factor defines the limit velocity value to affect to the specified gradient
  60987. * @returns the current particle system
  60988. */
  60989. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60990. /**
  60991. * Remove a specific limit velocity gradient
  60992. * @param gradient defines the gradient to remove
  60993. * @returns the current particle system
  60994. */
  60995. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60996. /**
  60997. * Adds a new drag gradient
  60998. * @param gradient defines the gradient to use (between 0 and 1)
  60999. * @param factor defines the drag value to affect to the specified gradient
  61000. * @returns the current particle system
  61001. */
  61002. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  61003. /**
  61004. * Remove a specific drag gradient
  61005. * @param gradient defines the gradient to remove
  61006. * @returns the current particle system
  61007. */
  61008. removeDragGradient(gradient: number): GPUParticleSystem;
  61009. /**
  61010. * Not supported by GPUParticleSystem
  61011. * @param gradient defines the gradient to use (between 0 and 1)
  61012. * @param factor defines the emit rate value to affect to the specified gradient
  61013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61014. * @returns the current particle system
  61015. */
  61016. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61017. /**
  61018. * Not supported by GPUParticleSystem
  61019. * @param gradient defines the gradient to remove
  61020. * @returns the current particle system
  61021. */
  61022. removeEmitRateGradient(gradient: number): IParticleSystem;
  61023. /**
  61024. * Not supported by GPUParticleSystem
  61025. * @param gradient defines the gradient to use (between 0 and 1)
  61026. * @param factor defines the start size value to affect to the specified gradient
  61027. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61028. * @returns the current particle system
  61029. */
  61030. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61031. /**
  61032. * Not supported by GPUParticleSystem
  61033. * @param gradient defines the gradient to remove
  61034. * @returns the current particle system
  61035. */
  61036. removeStartSizeGradient(gradient: number): IParticleSystem;
  61037. /**
  61038. * Not supported by GPUParticleSystem
  61039. * @param gradient defines the gradient to use (between 0 and 1)
  61040. * @param min defines the color remap minimal range
  61041. * @param max defines the color remap maximal range
  61042. * @returns the current particle system
  61043. */
  61044. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61045. /**
  61046. * Not supported by GPUParticleSystem
  61047. * @param gradient defines the gradient to remove
  61048. * @returns the current particle system
  61049. */
  61050. removeColorRemapGradient(): IParticleSystem;
  61051. /**
  61052. * Not supported by GPUParticleSystem
  61053. * @param gradient defines the gradient to use (between 0 and 1)
  61054. * @param min defines the alpha remap minimal range
  61055. * @param max defines the alpha remap maximal range
  61056. * @returns the current particle system
  61057. */
  61058. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61059. /**
  61060. * Not supported by GPUParticleSystem
  61061. * @param gradient defines the gradient to remove
  61062. * @returns the current particle system
  61063. */
  61064. removeAlphaRemapGradient(): IParticleSystem;
  61065. /**
  61066. * Not supported by GPUParticleSystem
  61067. * @param gradient defines the gradient to use (between 0 and 1)
  61068. * @param color defines the color to affect to the specified gradient
  61069. * @returns the current particle system
  61070. */
  61071. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61072. /**
  61073. * Not supported by GPUParticleSystem
  61074. * @param gradient defines the gradient to remove
  61075. * @returns the current particle system
  61076. */
  61077. removeRampGradient(): IParticleSystem;
  61078. /**
  61079. * Not supported by GPUParticleSystem
  61080. * @returns the list of ramp gradients
  61081. */
  61082. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61083. /**
  61084. * Not supported by GPUParticleSystem
  61085. * Gets or sets a boolean indicating that ramp gradients must be used
  61086. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61087. */
  61088. useRampGradients: boolean;
  61089. /**
  61090. * Not supported by GPUParticleSystem
  61091. * @param gradient defines the gradient to use (between 0 and 1)
  61092. * @param factor defines the life time factor to affect to the specified gradient
  61093. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61094. * @returns the current particle system
  61095. */
  61096. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61097. /**
  61098. * Not supported by GPUParticleSystem
  61099. * @param gradient defines the gradient to remove
  61100. * @returns the current particle system
  61101. */
  61102. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61103. /**
  61104. * Instantiates a GPU particle system.
  61105. * 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.
  61106. * @param name The name of the particle system
  61107. * @param options The options used to create the system
  61108. * @param scene The scene the particle system belongs to
  61109. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61110. */
  61111. constructor(name: string, options: Partial<{
  61112. capacity: number;
  61113. randomTextureSize: number;
  61114. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61115. protected _reset(): void;
  61116. private _createUpdateVAO;
  61117. private _createRenderVAO;
  61118. private _initialize;
  61119. /** @hidden */
  61120. _recreateUpdateEffect(): void;
  61121. /** @hidden */
  61122. _recreateRenderEffect(): void;
  61123. /**
  61124. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61125. * @param preWarm defines if we are in the pre-warmimg phase
  61126. */
  61127. animate(preWarm?: boolean): void;
  61128. private _createFactorGradientTexture;
  61129. private _createSizeGradientTexture;
  61130. private _createAngularSpeedGradientTexture;
  61131. private _createVelocityGradientTexture;
  61132. private _createLimitVelocityGradientTexture;
  61133. private _createDragGradientTexture;
  61134. private _createColorGradientTexture;
  61135. /**
  61136. * Renders the particle system in its current state
  61137. * @param preWarm defines if the system should only update the particles but not render them
  61138. * @returns the current number of particles
  61139. */
  61140. render(preWarm?: boolean): number;
  61141. /**
  61142. * Rebuilds the particle system
  61143. */
  61144. rebuild(): void;
  61145. private _releaseBuffers;
  61146. private _releaseVAOs;
  61147. /**
  61148. * Disposes the particle system and free the associated resources
  61149. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61150. */
  61151. dispose(disposeTexture?: boolean): void;
  61152. /**
  61153. * Clones the particle system.
  61154. * @param name The name of the cloned object
  61155. * @param newEmitter The new emitter to use
  61156. * @returns the cloned particle system
  61157. */
  61158. clone(name: string, newEmitter: any): GPUParticleSystem;
  61159. /**
  61160. * Serializes the particle system to a JSON object.
  61161. * @returns the JSON object
  61162. */
  61163. serialize(): any;
  61164. /**
  61165. * Parses a JSON object to create a GPU particle system.
  61166. * @param parsedParticleSystem The JSON object to parse
  61167. * @param scene The scene to create the particle system in
  61168. * @param rootUrl The root url to use to load external dependencies like texture
  61169. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61170. * @returns the parsed GPU particle system
  61171. */
  61172. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61173. }
  61174. }
  61175. declare module "babylonjs/Particles/particleSystemSet" {
  61176. import { Nullable } from "babylonjs/types";
  61177. import { Color3 } from "babylonjs/Maths/math.color";
  61178. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61180. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61181. import { Scene, IDisposable } from "babylonjs/scene";
  61182. /**
  61183. * Represents a set of particle systems working together to create a specific effect
  61184. */
  61185. export class ParticleSystemSet implements IDisposable {
  61186. private _emitterCreationOptions;
  61187. private _emitterNode;
  61188. /**
  61189. * Gets the particle system list
  61190. */
  61191. systems: IParticleSystem[];
  61192. /**
  61193. * Gets the emitter node used with this set
  61194. */
  61195. readonly emitterNode: Nullable<TransformNode>;
  61196. /**
  61197. * Creates a new emitter mesh as a sphere
  61198. * @param options defines the options used to create the sphere
  61199. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61200. * @param scene defines the hosting scene
  61201. */
  61202. setEmitterAsSphere(options: {
  61203. diameter: number;
  61204. segments: number;
  61205. color: Color3;
  61206. }, renderingGroupId: number, scene: Scene): void;
  61207. /**
  61208. * Starts all particle systems of the set
  61209. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61210. */
  61211. start(emitter?: AbstractMesh): void;
  61212. /**
  61213. * Release all associated resources
  61214. */
  61215. dispose(): void;
  61216. /**
  61217. * Serialize the set into a JSON compatible object
  61218. * @returns a JSON compatible representation of the set
  61219. */
  61220. serialize(): any;
  61221. /**
  61222. * Parse a new ParticleSystemSet from a serialized source
  61223. * @param data defines a JSON compatible representation of the set
  61224. * @param scene defines the hosting scene
  61225. * @param gpu defines if we want GPU particles or CPU particles
  61226. * @returns a new ParticleSystemSet
  61227. */
  61228. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61229. }
  61230. }
  61231. declare module "babylonjs/Particles/particleHelper" {
  61232. import { Nullable } from "babylonjs/types";
  61233. import { Scene } from "babylonjs/scene";
  61234. import { Vector3 } from "babylonjs/Maths/math.vector";
  61235. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61236. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61237. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61238. /**
  61239. * This class is made for on one-liner static method to help creating particle system set.
  61240. */
  61241. export class ParticleHelper {
  61242. /**
  61243. * Gets or sets base Assets URL
  61244. */
  61245. static BaseAssetsUrl: string;
  61246. /**
  61247. * Create a default particle system that you can tweak
  61248. * @param emitter defines the emitter to use
  61249. * @param capacity defines the system capacity (default is 500 particles)
  61250. * @param scene defines the hosting scene
  61251. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61252. * @returns the new Particle system
  61253. */
  61254. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61255. /**
  61256. * This is the main static method (one-liner) of this helper to create different particle systems
  61257. * @param type This string represents the type to the particle system to create
  61258. * @param scene The scene where the particle system should live
  61259. * @param gpu If the system will use gpu
  61260. * @returns the ParticleSystemSet created
  61261. */
  61262. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61263. /**
  61264. * Static function used to export a particle system to a ParticleSystemSet variable.
  61265. * Please note that the emitter shape is not exported
  61266. * @param systems defines the particle systems to export
  61267. * @returns the created particle system set
  61268. */
  61269. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61270. }
  61271. }
  61272. declare module "babylonjs/Particles/particleSystemComponent" {
  61273. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61274. import { Effect } from "babylonjs/Materials/effect";
  61275. import "babylonjs/Shaders/particles.vertex";
  61276. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61277. module "babylonjs/Engines/engine" {
  61278. interface Engine {
  61279. /**
  61280. * Create an effect to use with particle systems.
  61281. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61282. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61283. * @param uniformsNames defines a list of attribute names
  61284. * @param samplers defines an array of string used to represent textures
  61285. * @param defines defines the string containing the defines to use to compile the shaders
  61286. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61287. * @param onCompiled defines a function to call when the effect creation is successful
  61288. * @param onError defines a function to call when the effect creation has failed
  61289. * @returns the new Effect
  61290. */
  61291. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61292. }
  61293. }
  61294. module "babylonjs/Meshes/mesh" {
  61295. interface Mesh {
  61296. /**
  61297. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61298. * @returns an array of IParticleSystem
  61299. */
  61300. getEmittedParticleSystems(): IParticleSystem[];
  61301. /**
  61302. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61303. * @returns an array of IParticleSystem
  61304. */
  61305. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61306. }
  61307. }
  61308. /**
  61309. * @hidden
  61310. */
  61311. export var _IDoNeedToBeInTheBuild: number;
  61312. }
  61313. declare module "babylonjs/Particles/index" {
  61314. export * from "babylonjs/Particles/baseParticleSystem";
  61315. export * from "babylonjs/Particles/EmitterTypes/index";
  61316. export * from "babylonjs/Particles/gpuParticleSystem";
  61317. export * from "babylonjs/Particles/IParticleSystem";
  61318. export * from "babylonjs/Particles/particle";
  61319. export * from "babylonjs/Particles/particleHelper";
  61320. export * from "babylonjs/Particles/particleSystem";
  61321. export * from "babylonjs/Particles/particleSystemComponent";
  61322. export * from "babylonjs/Particles/particleSystemSet";
  61323. export * from "babylonjs/Particles/solidParticle";
  61324. export * from "babylonjs/Particles/solidParticleSystem";
  61325. export * from "babylonjs/Particles/subEmitter";
  61326. }
  61327. declare module "babylonjs/Physics/physicsEngineComponent" {
  61328. import { Nullable } from "babylonjs/types";
  61329. import { Observable, Observer } from "babylonjs/Misc/observable";
  61330. import { Vector3 } from "babylonjs/Maths/math.vector";
  61331. import { Mesh } from "babylonjs/Meshes/mesh";
  61332. import { ISceneComponent } from "babylonjs/sceneComponent";
  61333. import { Scene } from "babylonjs/scene";
  61334. import { Node } from "babylonjs/node";
  61335. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61336. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61337. module "babylonjs/scene" {
  61338. interface Scene {
  61339. /** @hidden (Backing field) */
  61340. _physicsEngine: Nullable<IPhysicsEngine>;
  61341. /**
  61342. * Gets the current physics engine
  61343. * @returns a IPhysicsEngine or null if none attached
  61344. */
  61345. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61346. /**
  61347. * Enables physics to the current scene
  61348. * @param gravity defines the scene's gravity for the physics engine
  61349. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61350. * @return a boolean indicating if the physics engine was initialized
  61351. */
  61352. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61353. /**
  61354. * Disables and disposes the physics engine associated with the scene
  61355. */
  61356. disablePhysicsEngine(): void;
  61357. /**
  61358. * Gets a boolean indicating if there is an active physics engine
  61359. * @returns a boolean indicating if there is an active physics engine
  61360. */
  61361. isPhysicsEnabled(): boolean;
  61362. /**
  61363. * Deletes a physics compound impostor
  61364. * @param compound defines the compound to delete
  61365. */
  61366. deleteCompoundImpostor(compound: any): void;
  61367. /**
  61368. * An event triggered when physic simulation is about to be run
  61369. */
  61370. onBeforePhysicsObservable: Observable<Scene>;
  61371. /**
  61372. * An event triggered when physic simulation has been done
  61373. */
  61374. onAfterPhysicsObservable: Observable<Scene>;
  61375. }
  61376. }
  61377. module "babylonjs/Meshes/abstractMesh" {
  61378. interface AbstractMesh {
  61379. /** @hidden */
  61380. _physicsImpostor: Nullable<PhysicsImpostor>;
  61381. /**
  61382. * Gets or sets impostor used for physic simulation
  61383. * @see http://doc.babylonjs.com/features/physics_engine
  61384. */
  61385. physicsImpostor: Nullable<PhysicsImpostor>;
  61386. /**
  61387. * Gets the current physics impostor
  61388. * @see http://doc.babylonjs.com/features/physics_engine
  61389. * @returns a physics impostor or null
  61390. */
  61391. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61392. /** Apply a physic impulse to the mesh
  61393. * @param force defines the force to apply
  61394. * @param contactPoint defines where to apply the force
  61395. * @returns the current mesh
  61396. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61397. */
  61398. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61399. /**
  61400. * Creates a physic joint between two meshes
  61401. * @param otherMesh defines the other mesh to use
  61402. * @param pivot1 defines the pivot to use on this mesh
  61403. * @param pivot2 defines the pivot to use on the other mesh
  61404. * @param options defines additional options (can be plugin dependent)
  61405. * @returns the current mesh
  61406. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61407. */
  61408. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61409. /** @hidden */
  61410. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61411. }
  61412. }
  61413. /**
  61414. * Defines the physics engine scene component responsible to manage a physics engine
  61415. */
  61416. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61417. /**
  61418. * The component name helpful to identify the component in the list of scene components.
  61419. */
  61420. readonly name: string;
  61421. /**
  61422. * The scene the component belongs to.
  61423. */
  61424. scene: Scene;
  61425. /**
  61426. * Creates a new instance of the component for the given scene
  61427. * @param scene Defines the scene to register the component in
  61428. */
  61429. constructor(scene: Scene);
  61430. /**
  61431. * Registers the component in a given scene
  61432. */
  61433. register(): void;
  61434. /**
  61435. * Rebuilds the elements related to this component in case of
  61436. * context lost for instance.
  61437. */
  61438. rebuild(): void;
  61439. /**
  61440. * Disposes the component and the associated ressources
  61441. */
  61442. dispose(): void;
  61443. }
  61444. }
  61445. declare module "babylonjs/Physics/physicsHelper" {
  61446. import { Nullable } from "babylonjs/types";
  61447. import { Vector3 } from "babylonjs/Maths/math.vector";
  61448. import { Mesh } from "babylonjs/Meshes/mesh";
  61449. import { Scene } from "babylonjs/scene";
  61450. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61451. /**
  61452. * A helper for physics simulations
  61453. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61454. */
  61455. export class PhysicsHelper {
  61456. private _scene;
  61457. private _physicsEngine;
  61458. /**
  61459. * Initializes the Physics helper
  61460. * @param scene Babylon.js scene
  61461. */
  61462. constructor(scene: Scene);
  61463. /**
  61464. * Applies a radial explosion impulse
  61465. * @param origin the origin of the explosion
  61466. * @param radiusOrEventOptions the radius or the options of radial explosion
  61467. * @param strength the explosion strength
  61468. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61469. * @returns A physics radial explosion event, or null
  61470. */
  61471. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61472. /**
  61473. * Applies a radial explosion force
  61474. * @param origin the origin of the explosion
  61475. * @param radiusOrEventOptions the radius or the options of radial explosion
  61476. * @param strength the explosion strength
  61477. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61478. * @returns A physics radial explosion event, or null
  61479. */
  61480. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61481. /**
  61482. * Creates a gravitational field
  61483. * @param origin the origin of the explosion
  61484. * @param radiusOrEventOptions the radius or the options of radial explosion
  61485. * @param strength the explosion strength
  61486. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61487. * @returns A physics gravitational field event, or null
  61488. */
  61489. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61490. /**
  61491. * Creates a physics updraft event
  61492. * @param origin the origin of the updraft
  61493. * @param radiusOrEventOptions the radius or the options of the updraft
  61494. * @param strength the strength of the updraft
  61495. * @param height the height of the updraft
  61496. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61497. * @returns A physics updraft event, or null
  61498. */
  61499. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61500. /**
  61501. * Creates a physics vortex event
  61502. * @param origin the of the vortex
  61503. * @param radiusOrEventOptions the radius or the options of the vortex
  61504. * @param strength the strength of the vortex
  61505. * @param height the height of the vortex
  61506. * @returns a Physics vortex event, or null
  61507. * A physics vortex event or null
  61508. */
  61509. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61510. }
  61511. /**
  61512. * Represents a physics radial explosion event
  61513. */
  61514. class PhysicsRadialExplosionEvent {
  61515. private _scene;
  61516. private _options;
  61517. private _sphere;
  61518. private _dataFetched;
  61519. /**
  61520. * Initializes a radial explosioin event
  61521. * @param _scene BabylonJS scene
  61522. * @param _options The options for the vortex event
  61523. */
  61524. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61525. /**
  61526. * Returns the data related to the radial explosion event (sphere).
  61527. * @returns The radial explosion event data
  61528. */
  61529. getData(): PhysicsRadialExplosionEventData;
  61530. /**
  61531. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61532. * @param impostor A physics imposter
  61533. * @param origin the origin of the explosion
  61534. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61535. */
  61536. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61537. /**
  61538. * Triggers affecterd impostors callbacks
  61539. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61540. */
  61541. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61542. /**
  61543. * Disposes the sphere.
  61544. * @param force Specifies if the sphere should be disposed by force
  61545. */
  61546. dispose(force?: boolean): void;
  61547. /*** Helpers ***/
  61548. private _prepareSphere;
  61549. private _intersectsWithSphere;
  61550. }
  61551. /**
  61552. * Represents a gravitational field event
  61553. */
  61554. class PhysicsGravitationalFieldEvent {
  61555. private _physicsHelper;
  61556. private _scene;
  61557. private _origin;
  61558. private _options;
  61559. private _tickCallback;
  61560. private _sphere;
  61561. private _dataFetched;
  61562. /**
  61563. * Initializes the physics gravitational field event
  61564. * @param _physicsHelper A physics helper
  61565. * @param _scene BabylonJS scene
  61566. * @param _origin The origin position of the gravitational field event
  61567. * @param _options The options for the vortex event
  61568. */
  61569. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61570. /**
  61571. * Returns the data related to the gravitational field event (sphere).
  61572. * @returns A gravitational field event
  61573. */
  61574. getData(): PhysicsGravitationalFieldEventData;
  61575. /**
  61576. * Enables the gravitational field.
  61577. */
  61578. enable(): void;
  61579. /**
  61580. * Disables the gravitational field.
  61581. */
  61582. disable(): void;
  61583. /**
  61584. * Disposes the sphere.
  61585. * @param force The force to dispose from the gravitational field event
  61586. */
  61587. dispose(force?: boolean): void;
  61588. private _tick;
  61589. }
  61590. /**
  61591. * Represents a physics updraft event
  61592. */
  61593. class PhysicsUpdraftEvent {
  61594. private _scene;
  61595. private _origin;
  61596. private _options;
  61597. private _physicsEngine;
  61598. private _originTop;
  61599. private _originDirection;
  61600. private _tickCallback;
  61601. private _cylinder;
  61602. private _cylinderPosition;
  61603. private _dataFetched;
  61604. /**
  61605. * Initializes the physics updraft event
  61606. * @param _scene BabylonJS scene
  61607. * @param _origin The origin position of the updraft
  61608. * @param _options The options for the updraft event
  61609. */
  61610. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61611. /**
  61612. * Returns the data related to the updraft event (cylinder).
  61613. * @returns A physics updraft event
  61614. */
  61615. getData(): PhysicsUpdraftEventData;
  61616. /**
  61617. * Enables the updraft.
  61618. */
  61619. enable(): void;
  61620. /**
  61621. * Disables the updraft.
  61622. */
  61623. disable(): void;
  61624. /**
  61625. * Disposes the cylinder.
  61626. * @param force Specifies if the updraft should be disposed by force
  61627. */
  61628. dispose(force?: boolean): void;
  61629. private getImpostorHitData;
  61630. private _tick;
  61631. /*** Helpers ***/
  61632. private _prepareCylinder;
  61633. private _intersectsWithCylinder;
  61634. }
  61635. /**
  61636. * Represents a physics vortex event
  61637. */
  61638. class PhysicsVortexEvent {
  61639. private _scene;
  61640. private _origin;
  61641. private _options;
  61642. private _physicsEngine;
  61643. private _originTop;
  61644. private _tickCallback;
  61645. private _cylinder;
  61646. private _cylinderPosition;
  61647. private _dataFetched;
  61648. /**
  61649. * Initializes the physics vortex event
  61650. * @param _scene The BabylonJS scene
  61651. * @param _origin The origin position of the vortex
  61652. * @param _options The options for the vortex event
  61653. */
  61654. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61655. /**
  61656. * Returns the data related to the vortex event (cylinder).
  61657. * @returns The physics vortex event data
  61658. */
  61659. getData(): PhysicsVortexEventData;
  61660. /**
  61661. * Enables the vortex.
  61662. */
  61663. enable(): void;
  61664. /**
  61665. * Disables the cortex.
  61666. */
  61667. disable(): void;
  61668. /**
  61669. * Disposes the sphere.
  61670. * @param force
  61671. */
  61672. dispose(force?: boolean): void;
  61673. private getImpostorHitData;
  61674. private _tick;
  61675. /*** Helpers ***/
  61676. private _prepareCylinder;
  61677. private _intersectsWithCylinder;
  61678. }
  61679. /**
  61680. * Options fot the radial explosion event
  61681. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61682. */
  61683. export class PhysicsRadialExplosionEventOptions {
  61684. /**
  61685. * The radius of the sphere for the radial explosion.
  61686. */
  61687. radius: number;
  61688. /**
  61689. * The strenth of the explosion.
  61690. */
  61691. strength: number;
  61692. /**
  61693. * The strenght of the force in correspondence to the distance of the affected object
  61694. */
  61695. falloff: PhysicsRadialImpulseFalloff;
  61696. /**
  61697. * Sphere options for the radial explosion.
  61698. */
  61699. sphere: {
  61700. segments: number;
  61701. diameter: number;
  61702. };
  61703. /**
  61704. * Sphere options for the radial explosion.
  61705. */
  61706. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61707. }
  61708. /**
  61709. * Options fot the updraft event
  61710. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61711. */
  61712. export class PhysicsUpdraftEventOptions {
  61713. /**
  61714. * The radius of the cylinder for the vortex
  61715. */
  61716. radius: number;
  61717. /**
  61718. * The strenth of the updraft.
  61719. */
  61720. strength: number;
  61721. /**
  61722. * The height of the cylinder for the updraft.
  61723. */
  61724. height: number;
  61725. /**
  61726. * The mode for the the updraft.
  61727. */
  61728. updraftMode: PhysicsUpdraftMode;
  61729. }
  61730. /**
  61731. * Options fot the vortex event
  61732. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61733. */
  61734. export class PhysicsVortexEventOptions {
  61735. /**
  61736. * The radius of the cylinder for the vortex
  61737. */
  61738. radius: number;
  61739. /**
  61740. * The strenth of the vortex.
  61741. */
  61742. strength: number;
  61743. /**
  61744. * The height of the cylinder for the vortex.
  61745. */
  61746. height: number;
  61747. /**
  61748. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61749. */
  61750. centripetalForceThreshold: number;
  61751. /**
  61752. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61753. */
  61754. centripetalForceMultiplier: number;
  61755. /**
  61756. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61757. */
  61758. centrifugalForceMultiplier: number;
  61759. /**
  61760. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61761. */
  61762. updraftForceMultiplier: number;
  61763. }
  61764. /**
  61765. * The strenght of the force in correspondence to the distance of the affected object
  61766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61767. */
  61768. export enum PhysicsRadialImpulseFalloff {
  61769. /** Defines that impulse is constant in strength across it's whole radius */
  61770. Constant = 0,
  61771. /** Defines that impulse gets weaker if it's further from the origin */
  61772. Linear = 1
  61773. }
  61774. /**
  61775. * The strength of the force in correspondence to the distance of the affected object
  61776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61777. */
  61778. export enum PhysicsUpdraftMode {
  61779. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61780. Center = 0,
  61781. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61782. Perpendicular = 1
  61783. }
  61784. /**
  61785. * Interface for a physics hit data
  61786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61787. */
  61788. export interface PhysicsHitData {
  61789. /**
  61790. * The force applied at the contact point
  61791. */
  61792. force: Vector3;
  61793. /**
  61794. * The contact point
  61795. */
  61796. contactPoint: Vector3;
  61797. /**
  61798. * The distance from the origin to the contact point
  61799. */
  61800. distanceFromOrigin: number;
  61801. }
  61802. /**
  61803. * Interface for radial explosion event data
  61804. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61805. */
  61806. export interface PhysicsRadialExplosionEventData {
  61807. /**
  61808. * A sphere used for the radial explosion event
  61809. */
  61810. sphere: Mesh;
  61811. }
  61812. /**
  61813. * Interface for gravitational field event data
  61814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61815. */
  61816. export interface PhysicsGravitationalFieldEventData {
  61817. /**
  61818. * A sphere mesh used for the gravitational field event
  61819. */
  61820. sphere: Mesh;
  61821. }
  61822. /**
  61823. * Interface for updraft event data
  61824. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61825. */
  61826. export interface PhysicsUpdraftEventData {
  61827. /**
  61828. * A cylinder used for the updraft event
  61829. */
  61830. cylinder: Mesh;
  61831. }
  61832. /**
  61833. * Interface for vortex event data
  61834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61835. */
  61836. export interface PhysicsVortexEventData {
  61837. /**
  61838. * A cylinder used for the vortex event
  61839. */
  61840. cylinder: Mesh;
  61841. }
  61842. /**
  61843. * Interface for an affected physics impostor
  61844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61845. */
  61846. export interface PhysicsAffectedImpostorWithData {
  61847. /**
  61848. * The impostor affected by the effect
  61849. */
  61850. impostor: PhysicsImpostor;
  61851. /**
  61852. * The data about the hit/horce from the explosion
  61853. */
  61854. hitData: PhysicsHitData;
  61855. }
  61856. }
  61857. declare module "babylonjs/Physics/Plugins/index" {
  61858. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61859. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61860. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61861. }
  61862. declare module "babylonjs/Physics/index" {
  61863. export * from "babylonjs/Physics/IPhysicsEngine";
  61864. export * from "babylonjs/Physics/physicsEngine";
  61865. export * from "babylonjs/Physics/physicsEngineComponent";
  61866. export * from "babylonjs/Physics/physicsHelper";
  61867. export * from "babylonjs/Physics/physicsImpostor";
  61868. export * from "babylonjs/Physics/physicsJoint";
  61869. export * from "babylonjs/Physics/Plugins/index";
  61870. }
  61871. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61872. /** @hidden */
  61873. export var blackAndWhitePixelShader: {
  61874. name: string;
  61875. shader: string;
  61876. };
  61877. }
  61878. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61879. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61880. import { Camera } from "babylonjs/Cameras/camera";
  61881. import { Engine } from "babylonjs/Engines/engine";
  61882. import "babylonjs/Shaders/blackAndWhite.fragment";
  61883. /**
  61884. * Post process used to render in black and white
  61885. */
  61886. export class BlackAndWhitePostProcess extends PostProcess {
  61887. /**
  61888. * Linear about to convert he result to black and white (default: 1)
  61889. */
  61890. degree: number;
  61891. /**
  61892. * Creates a black and white post process
  61893. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61894. * @param name The name of the effect.
  61895. * @param options The required width/height ratio to downsize to before computing the render pass.
  61896. * @param camera The camera to apply the render pass to.
  61897. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61898. * @param engine The engine which the post process will be applied. (default: current engine)
  61899. * @param reusable If the post process can be reused on the same frame. (default: false)
  61900. */
  61901. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61902. }
  61903. }
  61904. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61905. import { Nullable } from "babylonjs/types";
  61906. import { Camera } from "babylonjs/Cameras/camera";
  61907. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61908. import { Engine } from "babylonjs/Engines/engine";
  61909. /**
  61910. * This represents a set of one or more post processes in Babylon.
  61911. * A post process can be used to apply a shader to a texture after it is rendered.
  61912. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61913. */
  61914. export class PostProcessRenderEffect {
  61915. private _postProcesses;
  61916. private _getPostProcesses;
  61917. private _singleInstance;
  61918. private _cameras;
  61919. private _indicesForCamera;
  61920. /**
  61921. * Name of the effect
  61922. * @hidden
  61923. */
  61924. _name: string;
  61925. /**
  61926. * Instantiates a post process render effect.
  61927. * A post process can be used to apply a shader to a texture after it is rendered.
  61928. * @param engine The engine the effect is tied to
  61929. * @param name The name of the effect
  61930. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61931. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61932. */
  61933. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61934. /**
  61935. * Checks if all the post processes in the effect are supported.
  61936. */
  61937. readonly isSupported: boolean;
  61938. /**
  61939. * Updates the current state of the effect
  61940. * @hidden
  61941. */
  61942. _update(): void;
  61943. /**
  61944. * Attaches the effect on cameras
  61945. * @param cameras The camera to attach to.
  61946. * @hidden
  61947. */
  61948. _attachCameras(cameras: Camera): void;
  61949. /**
  61950. * Attaches the effect on cameras
  61951. * @param cameras The camera to attach to.
  61952. * @hidden
  61953. */
  61954. _attachCameras(cameras: Camera[]): void;
  61955. /**
  61956. * Detaches the effect on cameras
  61957. * @param cameras The camera to detatch from.
  61958. * @hidden
  61959. */
  61960. _detachCameras(cameras: Camera): void;
  61961. /**
  61962. * Detatches the effect on cameras
  61963. * @param cameras The camera to detatch from.
  61964. * @hidden
  61965. */
  61966. _detachCameras(cameras: Camera[]): void;
  61967. /**
  61968. * Enables the effect on given cameras
  61969. * @param cameras The camera to enable.
  61970. * @hidden
  61971. */
  61972. _enable(cameras: Camera): void;
  61973. /**
  61974. * Enables the effect on given cameras
  61975. * @param cameras The camera to enable.
  61976. * @hidden
  61977. */
  61978. _enable(cameras: Nullable<Camera[]>): void;
  61979. /**
  61980. * Disables the effect on the given cameras
  61981. * @param cameras The camera to disable.
  61982. * @hidden
  61983. */
  61984. _disable(cameras: Camera): void;
  61985. /**
  61986. * Disables the effect on the given cameras
  61987. * @param cameras The camera to disable.
  61988. * @hidden
  61989. */
  61990. _disable(cameras: Nullable<Camera[]>): void;
  61991. /**
  61992. * Gets a list of the post processes contained in the effect.
  61993. * @param camera The camera to get the post processes on.
  61994. * @returns The list of the post processes in the effect.
  61995. */
  61996. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61997. }
  61998. }
  61999. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  62000. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62001. /** @hidden */
  62002. export var extractHighlightsPixelShader: {
  62003. name: string;
  62004. shader: string;
  62005. };
  62006. }
  62007. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  62008. import { Nullable } from "babylonjs/types";
  62009. import { Camera } from "babylonjs/Cameras/camera";
  62010. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62011. import { Engine } from "babylonjs/Engines/engine";
  62012. import "babylonjs/Shaders/extractHighlights.fragment";
  62013. /**
  62014. * 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.
  62015. */
  62016. export class ExtractHighlightsPostProcess extends PostProcess {
  62017. /**
  62018. * The luminance threshold, pixels below this value will be set to black.
  62019. */
  62020. threshold: number;
  62021. /** @hidden */
  62022. _exposure: number;
  62023. /**
  62024. * Post process which has the input texture to be used when performing highlight extraction
  62025. * @hidden
  62026. */
  62027. _inputPostProcess: Nullable<PostProcess>;
  62028. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62029. }
  62030. }
  62031. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  62032. /** @hidden */
  62033. export var bloomMergePixelShader: {
  62034. name: string;
  62035. shader: string;
  62036. };
  62037. }
  62038. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  62039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62040. import { Nullable } from "babylonjs/types";
  62041. import { Engine } from "babylonjs/Engines/engine";
  62042. import { Camera } from "babylonjs/Cameras/camera";
  62043. import "babylonjs/Shaders/bloomMerge.fragment";
  62044. /**
  62045. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62046. */
  62047. export class BloomMergePostProcess extends PostProcess {
  62048. /** Weight of the bloom to be added to the original input. */
  62049. weight: number;
  62050. /**
  62051. * Creates a new instance of @see BloomMergePostProcess
  62052. * @param name The name of the effect.
  62053. * @param originalFromInput Post process which's input will be used for the merge.
  62054. * @param blurred Blurred highlights post process which's output will be used.
  62055. * @param weight Weight of the bloom to be added to the original input.
  62056. * @param options The required width/height ratio to downsize to before computing the render pass.
  62057. * @param camera The camera to apply the render pass to.
  62058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62059. * @param engine The engine which the post process will be applied. (default: current engine)
  62060. * @param reusable If the post process can be reused on the same frame. (default: false)
  62061. * @param textureType Type of textures used when performing the post process. (default: 0)
  62062. * @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)
  62063. */
  62064. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62065. /** Weight of the bloom to be added to the original input. */
  62066. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62067. }
  62068. }
  62069. declare module "babylonjs/PostProcesses/bloomEffect" {
  62070. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62071. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62072. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62073. import { Camera } from "babylonjs/Cameras/camera";
  62074. import { Scene } from "babylonjs/scene";
  62075. /**
  62076. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62077. */
  62078. export class BloomEffect extends PostProcessRenderEffect {
  62079. private bloomScale;
  62080. /**
  62081. * @hidden Internal
  62082. */
  62083. _effects: Array<PostProcess>;
  62084. /**
  62085. * @hidden Internal
  62086. */
  62087. _downscale: ExtractHighlightsPostProcess;
  62088. private _blurX;
  62089. private _blurY;
  62090. private _merge;
  62091. /**
  62092. * The luminance threshold to find bright areas of the image to bloom.
  62093. */
  62094. threshold: number;
  62095. /**
  62096. * The strength of the bloom.
  62097. */
  62098. weight: number;
  62099. /**
  62100. * Specifies the size of the bloom blur kernel, relative to the final output size
  62101. */
  62102. kernel: number;
  62103. /**
  62104. * Creates a new instance of @see BloomEffect
  62105. * @param scene The scene the effect belongs to.
  62106. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62107. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62108. * @param bloomWeight The the strength of bloom.
  62109. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62110. * @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)
  62111. */
  62112. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62113. /**
  62114. * Disposes each of the internal effects for a given camera.
  62115. * @param camera The camera to dispose the effect on.
  62116. */
  62117. disposeEffects(camera: Camera): void;
  62118. /**
  62119. * @hidden Internal
  62120. */
  62121. _updateEffects(): void;
  62122. /**
  62123. * Internal
  62124. * @returns if all the contained post processes are ready.
  62125. * @hidden
  62126. */
  62127. _isReady(): boolean;
  62128. }
  62129. }
  62130. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62131. /** @hidden */
  62132. export var chromaticAberrationPixelShader: {
  62133. name: string;
  62134. shader: string;
  62135. };
  62136. }
  62137. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62138. import { Vector2 } from "babylonjs/Maths/math.vector";
  62139. import { Nullable } from "babylonjs/types";
  62140. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62141. import { Camera } from "babylonjs/Cameras/camera";
  62142. import { Engine } from "babylonjs/Engines/engine";
  62143. import "babylonjs/Shaders/chromaticAberration.fragment";
  62144. /**
  62145. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62146. */
  62147. export class ChromaticAberrationPostProcess extends PostProcess {
  62148. /**
  62149. * The amount of seperation of rgb channels (default: 30)
  62150. */
  62151. aberrationAmount: number;
  62152. /**
  62153. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62154. */
  62155. radialIntensity: number;
  62156. /**
  62157. * 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))
  62158. */
  62159. direction: Vector2;
  62160. /**
  62161. * 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))
  62162. */
  62163. centerPosition: Vector2;
  62164. /**
  62165. * Creates a new instance ChromaticAberrationPostProcess
  62166. * @param name The name of the effect.
  62167. * @param screenWidth The width of the screen to apply the effect on.
  62168. * @param screenHeight The height of the screen to apply the effect on.
  62169. * @param options The required width/height ratio to downsize to before computing the render pass.
  62170. * @param camera The camera to apply the render pass to.
  62171. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62172. * @param engine The engine which the post process will be applied. (default: current engine)
  62173. * @param reusable If the post process can be reused on the same frame. (default: false)
  62174. * @param textureType Type of textures used when performing the post process. (default: 0)
  62175. * @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)
  62176. */
  62177. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62178. }
  62179. }
  62180. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62181. /** @hidden */
  62182. export var circleOfConfusionPixelShader: {
  62183. name: string;
  62184. shader: string;
  62185. };
  62186. }
  62187. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62188. import { Nullable } from "babylonjs/types";
  62189. import { Engine } from "babylonjs/Engines/engine";
  62190. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62191. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62192. import { Camera } from "babylonjs/Cameras/camera";
  62193. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62194. /**
  62195. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62196. */
  62197. export class CircleOfConfusionPostProcess extends PostProcess {
  62198. /**
  62199. * 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.
  62200. */
  62201. lensSize: number;
  62202. /**
  62203. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62204. */
  62205. fStop: number;
  62206. /**
  62207. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62208. */
  62209. focusDistance: number;
  62210. /**
  62211. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62212. */
  62213. focalLength: number;
  62214. private _depthTexture;
  62215. /**
  62216. * Creates a new instance CircleOfConfusionPostProcess
  62217. * @param name The name of the effect.
  62218. * @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.
  62219. * @param options The required width/height ratio to downsize to before computing the render pass.
  62220. * @param camera The camera to apply the render pass to.
  62221. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62222. * @param engine The engine which the post process will be applied. (default: current engine)
  62223. * @param reusable If the post process can be reused on the same frame. (default: false)
  62224. * @param textureType Type of textures used when performing the post process. (default: 0)
  62225. * @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)
  62226. */
  62227. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62228. /**
  62229. * 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.
  62230. */
  62231. depthTexture: RenderTargetTexture;
  62232. }
  62233. }
  62234. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62235. /** @hidden */
  62236. export var colorCorrectionPixelShader: {
  62237. name: string;
  62238. shader: string;
  62239. };
  62240. }
  62241. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62242. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62243. import { Engine } from "babylonjs/Engines/engine";
  62244. import { Camera } from "babylonjs/Cameras/camera";
  62245. import "babylonjs/Shaders/colorCorrection.fragment";
  62246. /**
  62247. *
  62248. * This post-process allows the modification of rendered colors by using
  62249. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62250. *
  62251. * The object needs to be provided an url to a texture containing the color
  62252. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62253. * Use an image editing software to tweak the LUT to match your needs.
  62254. *
  62255. * For an example of a color LUT, see here:
  62256. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62257. * For explanations on color grading, see here:
  62258. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62259. *
  62260. */
  62261. export class ColorCorrectionPostProcess extends PostProcess {
  62262. private _colorTableTexture;
  62263. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62264. }
  62265. }
  62266. declare module "babylonjs/Shaders/convolution.fragment" {
  62267. /** @hidden */
  62268. export var convolutionPixelShader: {
  62269. name: string;
  62270. shader: string;
  62271. };
  62272. }
  62273. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62274. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62275. import { Nullable } from "babylonjs/types";
  62276. import { Camera } from "babylonjs/Cameras/camera";
  62277. import { Engine } from "babylonjs/Engines/engine";
  62278. import "babylonjs/Shaders/convolution.fragment";
  62279. /**
  62280. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62281. * input texture to perform effects such as edge detection or sharpening
  62282. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62283. */
  62284. export class ConvolutionPostProcess extends PostProcess {
  62285. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62286. kernel: number[];
  62287. /**
  62288. * Creates a new instance ConvolutionPostProcess
  62289. * @param name The name of the effect.
  62290. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62291. * @param options The required width/height ratio to downsize to before computing the render pass.
  62292. * @param camera The camera to apply the render pass to.
  62293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62294. * @param engine The engine which the post process will be applied. (default: current engine)
  62295. * @param reusable If the post process can be reused on the same frame. (default: false)
  62296. * @param textureType Type of textures used when performing the post process. (default: 0)
  62297. */
  62298. constructor(name: string,
  62299. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62300. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62301. /**
  62302. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62303. */
  62304. static EdgeDetect0Kernel: number[];
  62305. /**
  62306. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62307. */
  62308. static EdgeDetect1Kernel: number[];
  62309. /**
  62310. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62311. */
  62312. static EdgeDetect2Kernel: number[];
  62313. /**
  62314. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62315. */
  62316. static SharpenKernel: number[];
  62317. /**
  62318. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62319. */
  62320. static EmbossKernel: number[];
  62321. /**
  62322. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62323. */
  62324. static GaussianKernel: number[];
  62325. }
  62326. }
  62327. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62328. import { Nullable } from "babylonjs/types";
  62329. import { Vector2 } from "babylonjs/Maths/math.vector";
  62330. import { Camera } from "babylonjs/Cameras/camera";
  62331. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62332. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62333. import { Engine } from "babylonjs/Engines/engine";
  62334. import { Scene } from "babylonjs/scene";
  62335. /**
  62336. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62337. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62338. * based on samples that have a large difference in distance than the center pixel.
  62339. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62340. */
  62341. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62342. direction: Vector2;
  62343. /**
  62344. * Creates a new instance CircleOfConfusionPostProcess
  62345. * @param name The name of the effect.
  62346. * @param scene The scene the effect belongs to.
  62347. * @param direction The direction the blur should be applied.
  62348. * @param kernel The size of the kernel used to blur.
  62349. * @param options The required width/height ratio to downsize to before computing the render pass.
  62350. * @param camera The camera to apply the render pass to.
  62351. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62352. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62354. * @param engine The engine which the post process will be applied. (default: current engine)
  62355. * @param reusable If the post process can be reused on the same frame. (default: false)
  62356. * @param textureType Type of textures used when performing the post process. (default: 0)
  62357. * @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)
  62358. */
  62359. 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);
  62360. }
  62361. }
  62362. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62363. /** @hidden */
  62364. export var depthOfFieldMergePixelShader: {
  62365. name: string;
  62366. shader: string;
  62367. };
  62368. }
  62369. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62370. import { Nullable } from "babylonjs/types";
  62371. import { Camera } from "babylonjs/Cameras/camera";
  62372. import { Effect } from "babylonjs/Materials/effect";
  62373. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62374. import { Engine } from "babylonjs/Engines/engine";
  62375. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62376. /**
  62377. * Options to be set when merging outputs from the default pipeline.
  62378. */
  62379. export class DepthOfFieldMergePostProcessOptions {
  62380. /**
  62381. * The original image to merge on top of
  62382. */
  62383. originalFromInput: PostProcess;
  62384. /**
  62385. * Parameters to perform the merge of the depth of field effect
  62386. */
  62387. depthOfField?: {
  62388. circleOfConfusion: PostProcess;
  62389. blurSteps: Array<PostProcess>;
  62390. };
  62391. /**
  62392. * Parameters to perform the merge of bloom effect
  62393. */
  62394. bloom?: {
  62395. blurred: PostProcess;
  62396. weight: number;
  62397. };
  62398. }
  62399. /**
  62400. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62401. */
  62402. export class DepthOfFieldMergePostProcess extends PostProcess {
  62403. private blurSteps;
  62404. /**
  62405. * Creates a new instance of DepthOfFieldMergePostProcess
  62406. * @param name The name of the effect.
  62407. * @param originalFromInput Post process which's input will be used for the merge.
  62408. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62409. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62410. * @param options The required width/height ratio to downsize to before computing the render pass.
  62411. * @param camera The camera to apply the render pass to.
  62412. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62413. * @param engine The engine which the post process will be applied. (default: current engine)
  62414. * @param reusable If the post process can be reused on the same frame. (default: false)
  62415. * @param textureType Type of textures used when performing the post process. (default: 0)
  62416. * @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)
  62417. */
  62418. 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);
  62419. /**
  62420. * Updates the effect with the current post process compile time values and recompiles the shader.
  62421. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62422. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62423. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62424. * @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
  62425. * @param onCompiled Called when the shader has been compiled.
  62426. * @param onError Called if there is an error when compiling a shader.
  62427. */
  62428. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62429. }
  62430. }
  62431. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62432. import { Nullable } from "babylonjs/types";
  62433. import { Camera } from "babylonjs/Cameras/camera";
  62434. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62435. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62436. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62437. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62438. import { Scene } from "babylonjs/scene";
  62439. /**
  62440. * Specifies the level of max blur that should be applied when using the depth of field effect
  62441. */
  62442. export enum DepthOfFieldEffectBlurLevel {
  62443. /**
  62444. * Subtle blur
  62445. */
  62446. Low = 0,
  62447. /**
  62448. * Medium blur
  62449. */
  62450. Medium = 1,
  62451. /**
  62452. * Large blur
  62453. */
  62454. High = 2
  62455. }
  62456. /**
  62457. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62458. */
  62459. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62460. private _circleOfConfusion;
  62461. /**
  62462. * @hidden Internal, blurs from high to low
  62463. */
  62464. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62465. private _depthOfFieldBlurY;
  62466. private _dofMerge;
  62467. /**
  62468. * @hidden Internal post processes in depth of field effect
  62469. */
  62470. _effects: Array<PostProcess>;
  62471. /**
  62472. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62473. */
  62474. focalLength: number;
  62475. /**
  62476. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62477. */
  62478. fStop: number;
  62479. /**
  62480. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62481. */
  62482. focusDistance: number;
  62483. /**
  62484. * 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.
  62485. */
  62486. lensSize: number;
  62487. /**
  62488. * Creates a new instance DepthOfFieldEffect
  62489. * @param scene The scene the effect belongs to.
  62490. * @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.
  62491. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62492. * @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)
  62493. */
  62494. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62495. /**
  62496. * Get the current class name of the current effet
  62497. * @returns "DepthOfFieldEffect"
  62498. */
  62499. getClassName(): string;
  62500. /**
  62501. * 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.
  62502. */
  62503. depthTexture: RenderTargetTexture;
  62504. /**
  62505. * Disposes each of the internal effects for a given camera.
  62506. * @param camera The camera to dispose the effect on.
  62507. */
  62508. disposeEffects(camera: Camera): void;
  62509. /**
  62510. * @hidden Internal
  62511. */
  62512. _updateEffects(): void;
  62513. /**
  62514. * Internal
  62515. * @returns if all the contained post processes are ready.
  62516. * @hidden
  62517. */
  62518. _isReady(): boolean;
  62519. }
  62520. }
  62521. declare module "babylonjs/Shaders/displayPass.fragment" {
  62522. /** @hidden */
  62523. export var displayPassPixelShader: {
  62524. name: string;
  62525. shader: string;
  62526. };
  62527. }
  62528. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62529. import { Nullable } from "babylonjs/types";
  62530. import { Camera } from "babylonjs/Cameras/camera";
  62531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62532. import { Engine } from "babylonjs/Engines/engine";
  62533. import "babylonjs/Shaders/displayPass.fragment";
  62534. /**
  62535. * DisplayPassPostProcess which produces an output the same as it's input
  62536. */
  62537. export class DisplayPassPostProcess extends PostProcess {
  62538. /**
  62539. * Creates the DisplayPassPostProcess
  62540. * @param name The name of the effect.
  62541. * @param options The required width/height ratio to downsize to before computing the render pass.
  62542. * @param camera The camera to apply the render pass to.
  62543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62544. * @param engine The engine which the post process will be applied. (default: current engine)
  62545. * @param reusable If the post process can be reused on the same frame. (default: false)
  62546. */
  62547. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62548. }
  62549. }
  62550. declare module "babylonjs/Shaders/filter.fragment" {
  62551. /** @hidden */
  62552. export var filterPixelShader: {
  62553. name: string;
  62554. shader: string;
  62555. };
  62556. }
  62557. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62558. import { Nullable } from "babylonjs/types";
  62559. import { Matrix } from "babylonjs/Maths/math.vector";
  62560. import { Camera } from "babylonjs/Cameras/camera";
  62561. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62562. import { Engine } from "babylonjs/Engines/engine";
  62563. import "babylonjs/Shaders/filter.fragment";
  62564. /**
  62565. * Applies a kernel filter to the image
  62566. */
  62567. export class FilterPostProcess extends PostProcess {
  62568. /** The matrix to be applied to the image */
  62569. kernelMatrix: Matrix;
  62570. /**
  62571. *
  62572. * @param name The name of the effect.
  62573. * @param kernelMatrix The matrix to be applied to the image
  62574. * @param options The required width/height ratio to downsize to before computing the render pass.
  62575. * @param camera The camera to apply the render pass to.
  62576. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62577. * @param engine The engine which the post process will be applied. (default: current engine)
  62578. * @param reusable If the post process can be reused on the same frame. (default: false)
  62579. */
  62580. constructor(name: string,
  62581. /** The matrix to be applied to the image */
  62582. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62583. }
  62584. }
  62585. declare module "babylonjs/Shaders/fxaa.fragment" {
  62586. /** @hidden */
  62587. export var fxaaPixelShader: {
  62588. name: string;
  62589. shader: string;
  62590. };
  62591. }
  62592. declare module "babylonjs/Shaders/fxaa.vertex" {
  62593. /** @hidden */
  62594. export var fxaaVertexShader: {
  62595. name: string;
  62596. shader: string;
  62597. };
  62598. }
  62599. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62600. import { Nullable } from "babylonjs/types";
  62601. import { Camera } from "babylonjs/Cameras/camera";
  62602. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62603. import { Engine } from "babylonjs/Engines/engine";
  62604. import "babylonjs/Shaders/fxaa.fragment";
  62605. import "babylonjs/Shaders/fxaa.vertex";
  62606. /**
  62607. * Fxaa post process
  62608. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62609. */
  62610. export class FxaaPostProcess extends PostProcess {
  62611. /** @hidden */
  62612. texelWidth: number;
  62613. /** @hidden */
  62614. texelHeight: number;
  62615. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62616. private _getDefines;
  62617. }
  62618. }
  62619. declare module "babylonjs/Shaders/grain.fragment" {
  62620. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62621. /** @hidden */
  62622. export var grainPixelShader: {
  62623. name: string;
  62624. shader: string;
  62625. };
  62626. }
  62627. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62628. import { Nullable } from "babylonjs/types";
  62629. import { Camera } from "babylonjs/Cameras/camera";
  62630. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62631. import { Engine } from "babylonjs/Engines/engine";
  62632. import "babylonjs/Shaders/grain.fragment";
  62633. /**
  62634. * The GrainPostProcess adds noise to the image at mid luminance levels
  62635. */
  62636. export class GrainPostProcess extends PostProcess {
  62637. /**
  62638. * The intensity of the grain added (default: 30)
  62639. */
  62640. intensity: number;
  62641. /**
  62642. * If the grain should be randomized on every frame
  62643. */
  62644. animated: boolean;
  62645. /**
  62646. * Creates a new instance of @see GrainPostProcess
  62647. * @param name The name of the effect.
  62648. * @param options The required width/height ratio to downsize to before computing the render pass.
  62649. * @param camera The camera to apply the render pass to.
  62650. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62651. * @param engine The engine which the post process will be applied. (default: current engine)
  62652. * @param reusable If the post process can be reused on the same frame. (default: false)
  62653. * @param textureType Type of textures used when performing the post process. (default: 0)
  62654. * @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)
  62655. */
  62656. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62657. }
  62658. }
  62659. declare module "babylonjs/Shaders/highlights.fragment" {
  62660. /** @hidden */
  62661. export var highlightsPixelShader: {
  62662. name: string;
  62663. shader: string;
  62664. };
  62665. }
  62666. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62667. import { Nullable } from "babylonjs/types";
  62668. import { Camera } from "babylonjs/Cameras/camera";
  62669. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62670. import { Engine } from "babylonjs/Engines/engine";
  62671. import "babylonjs/Shaders/highlights.fragment";
  62672. /**
  62673. * Extracts highlights from the image
  62674. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62675. */
  62676. export class HighlightsPostProcess extends PostProcess {
  62677. /**
  62678. * Extracts highlights from the image
  62679. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62680. * @param name The name of the effect.
  62681. * @param options The required width/height ratio to downsize to before computing the render pass.
  62682. * @param camera The camera to apply the render pass to.
  62683. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62684. * @param engine The engine which the post process will be applied. (default: current engine)
  62685. * @param reusable If the post process can be reused on the same frame. (default: false)
  62686. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62687. */
  62688. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62689. }
  62690. }
  62691. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62692. /** @hidden */
  62693. export var mrtFragmentDeclaration: {
  62694. name: string;
  62695. shader: string;
  62696. };
  62697. }
  62698. declare module "babylonjs/Shaders/geometry.fragment" {
  62699. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62700. /** @hidden */
  62701. export var geometryPixelShader: {
  62702. name: string;
  62703. shader: string;
  62704. };
  62705. }
  62706. declare module "babylonjs/Shaders/geometry.vertex" {
  62707. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62708. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62709. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62710. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62711. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62712. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62713. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62714. /** @hidden */
  62715. export var geometryVertexShader: {
  62716. name: string;
  62717. shader: string;
  62718. };
  62719. }
  62720. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62721. import { Matrix } from "babylonjs/Maths/math.vector";
  62722. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62723. import { Mesh } from "babylonjs/Meshes/mesh";
  62724. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62725. import { Effect } from "babylonjs/Materials/effect";
  62726. import { Scene } from "babylonjs/scene";
  62727. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62728. import "babylonjs/Shaders/geometry.fragment";
  62729. import "babylonjs/Shaders/geometry.vertex";
  62730. /** @hidden */
  62731. interface ISavedTransformationMatrix {
  62732. world: Matrix;
  62733. viewProjection: Matrix;
  62734. }
  62735. /**
  62736. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62737. */
  62738. export class GeometryBufferRenderer {
  62739. /**
  62740. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62741. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62742. */
  62743. static readonly POSITION_TEXTURE_TYPE: number;
  62744. /**
  62745. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62746. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62747. */
  62748. static readonly VELOCITY_TEXTURE_TYPE: number;
  62749. /**
  62750. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62751. * in order to compute objects velocities when enableVelocity is set to "true"
  62752. * @hidden
  62753. */
  62754. _previousTransformationMatrices: {
  62755. [index: number]: ISavedTransformationMatrix;
  62756. };
  62757. /**
  62758. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62759. * in order to compute objects velocities when enableVelocity is set to "true"
  62760. * @hidden
  62761. */
  62762. _previousBonesTransformationMatrices: {
  62763. [index: number]: Float32Array;
  62764. };
  62765. /**
  62766. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62767. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62768. */
  62769. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62770. private _scene;
  62771. private _multiRenderTarget;
  62772. private _ratio;
  62773. private _enablePosition;
  62774. private _enableVelocity;
  62775. private _positionIndex;
  62776. private _velocityIndex;
  62777. protected _effect: Effect;
  62778. protected _cachedDefines: string;
  62779. /**
  62780. * Set the render list (meshes to be rendered) used in the G buffer.
  62781. */
  62782. renderList: Mesh[];
  62783. /**
  62784. * Gets wether or not G buffer are supported by the running hardware.
  62785. * This requires draw buffer supports
  62786. */
  62787. readonly isSupported: boolean;
  62788. /**
  62789. * Returns the index of the given texture type in the G-Buffer textures array
  62790. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62791. * @returns the index of the given texture type in the G-Buffer textures array
  62792. */
  62793. getTextureIndex(textureType: number): number;
  62794. /**
  62795. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62796. */
  62797. /**
  62798. * Sets whether or not objects positions are enabled for the G buffer.
  62799. */
  62800. enablePosition: boolean;
  62801. /**
  62802. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62803. */
  62804. /**
  62805. * Sets wether or not objects velocities are enabled for the G buffer.
  62806. */
  62807. enableVelocity: boolean;
  62808. /**
  62809. * Gets the scene associated with the buffer.
  62810. */
  62811. readonly scene: Scene;
  62812. /**
  62813. * Gets the ratio used by the buffer during its creation.
  62814. * How big is the buffer related to the main canvas.
  62815. */
  62816. readonly ratio: number;
  62817. /** @hidden */
  62818. static _SceneComponentInitialization: (scene: Scene) => void;
  62819. /**
  62820. * Creates a new G Buffer for the scene
  62821. * @param scene The scene the buffer belongs to
  62822. * @param ratio How big is the buffer related to the main canvas.
  62823. */
  62824. constructor(scene: Scene, ratio?: number);
  62825. /**
  62826. * Checks wether everything is ready to render a submesh to the G buffer.
  62827. * @param subMesh the submesh to check readiness for
  62828. * @param useInstances is the mesh drawn using instance or not
  62829. * @returns true if ready otherwise false
  62830. */
  62831. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62832. /**
  62833. * Gets the current underlying G Buffer.
  62834. * @returns the buffer
  62835. */
  62836. getGBuffer(): MultiRenderTarget;
  62837. /**
  62838. * Gets the number of samples used to render the buffer (anti aliasing).
  62839. */
  62840. /**
  62841. * Sets the number of samples used to render the buffer (anti aliasing).
  62842. */
  62843. samples: number;
  62844. /**
  62845. * Disposes the renderer and frees up associated resources.
  62846. */
  62847. dispose(): void;
  62848. protected _createRenderTargets(): void;
  62849. private _copyBonesTransformationMatrices;
  62850. }
  62851. }
  62852. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62853. import { Nullable } from "babylonjs/types";
  62854. import { Scene } from "babylonjs/scene";
  62855. import { ISceneComponent } from "babylonjs/sceneComponent";
  62856. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62857. module "babylonjs/scene" {
  62858. interface Scene {
  62859. /** @hidden (Backing field) */
  62860. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62861. /**
  62862. * Gets or Sets the current geometry buffer associated to the scene.
  62863. */
  62864. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62865. /**
  62866. * Enables a GeometryBufferRender and associates it with the scene
  62867. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62868. * @returns the GeometryBufferRenderer
  62869. */
  62870. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62871. /**
  62872. * Disables the GeometryBufferRender associated with the scene
  62873. */
  62874. disableGeometryBufferRenderer(): void;
  62875. }
  62876. }
  62877. /**
  62878. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62879. * in several rendering techniques.
  62880. */
  62881. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62882. /**
  62883. * The component name helpful to identify the component in the list of scene components.
  62884. */
  62885. readonly name: string;
  62886. /**
  62887. * The scene the component belongs to.
  62888. */
  62889. scene: Scene;
  62890. /**
  62891. * Creates a new instance of the component for the given scene
  62892. * @param scene Defines the scene to register the component in
  62893. */
  62894. constructor(scene: Scene);
  62895. /**
  62896. * Registers the component in a given scene
  62897. */
  62898. register(): void;
  62899. /**
  62900. * Rebuilds the elements related to this component in case of
  62901. * context lost for instance.
  62902. */
  62903. rebuild(): void;
  62904. /**
  62905. * Disposes the component and the associated ressources
  62906. */
  62907. dispose(): void;
  62908. private _gatherRenderTargets;
  62909. }
  62910. }
  62911. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62912. /** @hidden */
  62913. export var motionBlurPixelShader: {
  62914. name: string;
  62915. shader: string;
  62916. };
  62917. }
  62918. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62919. import { Nullable } from "babylonjs/types";
  62920. import { Camera } from "babylonjs/Cameras/camera";
  62921. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62922. import { Scene } from "babylonjs/scene";
  62923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62924. import "babylonjs/Animations/animatable";
  62925. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62926. import "babylonjs/Shaders/motionBlur.fragment";
  62927. import { Engine } from "babylonjs/Engines/engine";
  62928. /**
  62929. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62930. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62931. * As an example, all you have to do is to create the post-process:
  62932. * var mb = new BABYLON.MotionBlurPostProcess(
  62933. * 'mb', // The name of the effect.
  62934. * scene, // The scene containing the objects to blur according to their velocity.
  62935. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62936. * camera // The camera to apply the render pass to.
  62937. * );
  62938. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62939. */
  62940. export class MotionBlurPostProcess extends PostProcess {
  62941. /**
  62942. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62943. */
  62944. motionStrength: number;
  62945. /**
  62946. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62947. */
  62948. /**
  62949. * Sets the number of iterations to be used for motion blur quality
  62950. */
  62951. motionBlurSamples: number;
  62952. private _motionBlurSamples;
  62953. private _geometryBufferRenderer;
  62954. /**
  62955. * Creates a new instance MotionBlurPostProcess
  62956. * @param name The name of the effect.
  62957. * @param scene The scene containing the objects to blur according to their velocity.
  62958. * @param options The required width/height ratio to downsize to before computing the render pass.
  62959. * @param camera The camera to apply the render pass to.
  62960. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62961. * @param engine The engine which the post process will be applied. (default: current engine)
  62962. * @param reusable If the post process can be reused on the same frame. (default: false)
  62963. * @param textureType Type of textures used when performing the post process. (default: 0)
  62964. * @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)
  62965. */
  62966. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62967. /**
  62968. * Excludes the given skinned mesh from computing bones velocities.
  62969. * 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.
  62970. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62971. */
  62972. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62973. /**
  62974. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62975. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62976. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62977. */
  62978. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62979. /**
  62980. * Disposes the post process.
  62981. * @param camera The camera to dispose the post process on.
  62982. */
  62983. dispose(camera?: Camera): void;
  62984. }
  62985. }
  62986. declare module "babylonjs/Shaders/refraction.fragment" {
  62987. /** @hidden */
  62988. export var refractionPixelShader: {
  62989. name: string;
  62990. shader: string;
  62991. };
  62992. }
  62993. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62994. import { Color3 } from "babylonjs/Maths/math.color";
  62995. import { Camera } from "babylonjs/Cameras/camera";
  62996. import { Texture } from "babylonjs/Materials/Textures/texture";
  62997. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62998. import { Engine } from "babylonjs/Engines/engine";
  62999. import "babylonjs/Shaders/refraction.fragment";
  63000. /**
  63001. * Post process which applies a refractin texture
  63002. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63003. */
  63004. export class RefractionPostProcess extends PostProcess {
  63005. /** the base color of the refraction (used to taint the rendering) */
  63006. color: Color3;
  63007. /** simulated refraction depth */
  63008. depth: number;
  63009. /** the coefficient of the base color (0 to remove base color tainting) */
  63010. colorLevel: number;
  63011. private _refTexture;
  63012. private _ownRefractionTexture;
  63013. /**
  63014. * Gets or sets the refraction texture
  63015. * Please note that you are responsible for disposing the texture if you set it manually
  63016. */
  63017. refractionTexture: Texture;
  63018. /**
  63019. * Initializes the RefractionPostProcess
  63020. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  63021. * @param name The name of the effect.
  63022. * @param refractionTextureUrl Url of the refraction texture to use
  63023. * @param color the base color of the refraction (used to taint the rendering)
  63024. * @param depth simulated refraction depth
  63025. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  63026. * @param camera The camera to apply the render pass to.
  63027. * @param options The required width/height ratio to downsize to before computing the render pass.
  63028. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63029. * @param engine The engine which the post process will be applied. (default: current engine)
  63030. * @param reusable If the post process can be reused on the same frame. (default: false)
  63031. */
  63032. constructor(name: string, refractionTextureUrl: string,
  63033. /** the base color of the refraction (used to taint the rendering) */
  63034. color: Color3,
  63035. /** simulated refraction depth */
  63036. depth: number,
  63037. /** the coefficient of the base color (0 to remove base color tainting) */
  63038. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  63039. /**
  63040. * Disposes of the post process
  63041. * @param camera Camera to dispose post process on
  63042. */
  63043. dispose(camera: Camera): void;
  63044. }
  63045. }
  63046. declare module "babylonjs/Shaders/sharpen.fragment" {
  63047. /** @hidden */
  63048. export var sharpenPixelShader: {
  63049. name: string;
  63050. shader: string;
  63051. };
  63052. }
  63053. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  63054. import { Nullable } from "babylonjs/types";
  63055. import { Camera } from "babylonjs/Cameras/camera";
  63056. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  63057. import "babylonjs/Shaders/sharpen.fragment";
  63058. import { Engine } from "babylonjs/Engines/engine";
  63059. /**
  63060. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63061. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63062. */
  63063. export class SharpenPostProcess extends PostProcess {
  63064. /**
  63065. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63066. */
  63067. colorAmount: number;
  63068. /**
  63069. * How much sharpness should be applied (default: 0.3)
  63070. */
  63071. edgeAmount: number;
  63072. /**
  63073. * Creates a new instance ConvolutionPostProcess
  63074. * @param name The name of the effect.
  63075. * @param options The required width/height ratio to downsize to before computing the render pass.
  63076. * @param camera The camera to apply the render pass to.
  63077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63078. * @param engine The engine which the post process will be applied. (default: current engine)
  63079. * @param reusable If the post process can be reused on the same frame. (default: false)
  63080. * @param textureType Type of textures used when performing the post process. (default: 0)
  63081. * @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)
  63082. */
  63083. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63084. }
  63085. }
  63086. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63087. import { Nullable } from "babylonjs/types";
  63088. import { Camera } from "babylonjs/Cameras/camera";
  63089. import { Engine } from "babylonjs/Engines/engine";
  63090. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63091. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63092. /**
  63093. * PostProcessRenderPipeline
  63094. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63095. */
  63096. export class PostProcessRenderPipeline {
  63097. private engine;
  63098. private _renderEffects;
  63099. private _renderEffectsForIsolatedPass;
  63100. /**
  63101. * List of inspectable custom properties (used by the Inspector)
  63102. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63103. */
  63104. inspectableCustomProperties: IInspectable[];
  63105. /**
  63106. * @hidden
  63107. */
  63108. protected _cameras: Camera[];
  63109. /** @hidden */
  63110. _name: string;
  63111. /**
  63112. * Gets pipeline name
  63113. */
  63114. readonly name: string;
  63115. /**
  63116. * Initializes a PostProcessRenderPipeline
  63117. * @param engine engine to add the pipeline to
  63118. * @param name name of the pipeline
  63119. */
  63120. constructor(engine: Engine, name: string);
  63121. /**
  63122. * Gets the class name
  63123. * @returns "PostProcessRenderPipeline"
  63124. */
  63125. getClassName(): string;
  63126. /**
  63127. * If all the render effects in the pipeline are supported
  63128. */
  63129. readonly isSupported: boolean;
  63130. /**
  63131. * Adds an effect to the pipeline
  63132. * @param renderEffect the effect to add
  63133. */
  63134. addEffect(renderEffect: PostProcessRenderEffect): void;
  63135. /** @hidden */
  63136. _rebuild(): void;
  63137. /** @hidden */
  63138. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63139. /** @hidden */
  63140. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63141. /** @hidden */
  63142. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63143. /** @hidden */
  63144. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63145. /** @hidden */
  63146. _attachCameras(cameras: Camera, unique: boolean): void;
  63147. /** @hidden */
  63148. _attachCameras(cameras: Camera[], unique: boolean): void;
  63149. /** @hidden */
  63150. _detachCameras(cameras: Camera): void;
  63151. /** @hidden */
  63152. _detachCameras(cameras: Nullable<Camera[]>): void;
  63153. /** @hidden */
  63154. _update(): void;
  63155. /** @hidden */
  63156. _reset(): void;
  63157. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63158. /**
  63159. * Disposes of the pipeline
  63160. */
  63161. dispose(): void;
  63162. }
  63163. }
  63164. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63165. import { Camera } from "babylonjs/Cameras/camera";
  63166. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63167. /**
  63168. * PostProcessRenderPipelineManager class
  63169. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63170. */
  63171. export class PostProcessRenderPipelineManager {
  63172. private _renderPipelines;
  63173. /**
  63174. * Initializes a PostProcessRenderPipelineManager
  63175. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63176. */
  63177. constructor();
  63178. /**
  63179. * Gets the list of supported render pipelines
  63180. */
  63181. readonly supportedPipelines: PostProcessRenderPipeline[];
  63182. /**
  63183. * Adds a pipeline to the manager
  63184. * @param renderPipeline The pipeline to add
  63185. */
  63186. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63187. /**
  63188. * Attaches a camera to the pipeline
  63189. * @param renderPipelineName The name of the pipeline to attach to
  63190. * @param cameras the camera to attach
  63191. * @param unique if the camera can be attached multiple times to the pipeline
  63192. */
  63193. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63194. /**
  63195. * Detaches a camera from the pipeline
  63196. * @param renderPipelineName The name of the pipeline to detach from
  63197. * @param cameras the camera to detach
  63198. */
  63199. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63200. /**
  63201. * Enables an effect by name on a pipeline
  63202. * @param renderPipelineName the name of the pipeline to enable the effect in
  63203. * @param renderEffectName the name of the effect to enable
  63204. * @param cameras the cameras that the effect should be enabled on
  63205. */
  63206. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63207. /**
  63208. * Disables an effect by name on a pipeline
  63209. * @param renderPipelineName the name of the pipeline to disable the effect in
  63210. * @param renderEffectName the name of the effect to disable
  63211. * @param cameras the cameras that the effect should be disabled on
  63212. */
  63213. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63214. /**
  63215. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63216. */
  63217. update(): void;
  63218. /** @hidden */
  63219. _rebuild(): void;
  63220. /**
  63221. * Disposes of the manager and pipelines
  63222. */
  63223. dispose(): void;
  63224. }
  63225. }
  63226. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63227. import { ISceneComponent } from "babylonjs/sceneComponent";
  63228. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63229. import { Scene } from "babylonjs/scene";
  63230. module "babylonjs/scene" {
  63231. interface Scene {
  63232. /** @hidden (Backing field) */
  63233. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63234. /**
  63235. * Gets the postprocess render pipeline manager
  63236. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63237. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63238. */
  63239. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63240. }
  63241. }
  63242. /**
  63243. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63244. */
  63245. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63246. /**
  63247. * The component name helpfull to identify the component in the list of scene components.
  63248. */
  63249. readonly name: string;
  63250. /**
  63251. * The scene the component belongs to.
  63252. */
  63253. scene: Scene;
  63254. /**
  63255. * Creates a new instance of the component for the given scene
  63256. * @param scene Defines the scene to register the component in
  63257. */
  63258. constructor(scene: Scene);
  63259. /**
  63260. * Registers the component in a given scene
  63261. */
  63262. register(): void;
  63263. /**
  63264. * Rebuilds the elements related to this component in case of
  63265. * context lost for instance.
  63266. */
  63267. rebuild(): void;
  63268. /**
  63269. * Disposes the component and the associated ressources
  63270. */
  63271. dispose(): void;
  63272. private _gatherRenderTargets;
  63273. }
  63274. }
  63275. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63276. import { Nullable } from "babylonjs/types";
  63277. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63278. import { Camera } from "babylonjs/Cameras/camera";
  63279. import { IDisposable } from "babylonjs/scene";
  63280. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63281. import { Scene } from "babylonjs/scene";
  63282. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63283. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63284. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63285. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63286. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63287. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63288. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63289. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63290. import { Animation } from "babylonjs/Animations/animation";
  63291. /**
  63292. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63293. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63294. */
  63295. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63296. private _scene;
  63297. private _camerasToBeAttached;
  63298. /**
  63299. * ID of the sharpen post process,
  63300. */
  63301. private readonly SharpenPostProcessId;
  63302. /**
  63303. * @ignore
  63304. * ID of the image processing post process;
  63305. */
  63306. readonly ImageProcessingPostProcessId: string;
  63307. /**
  63308. * @ignore
  63309. * ID of the Fast Approximate Anti-Aliasing post process;
  63310. */
  63311. readonly FxaaPostProcessId: string;
  63312. /**
  63313. * ID of the chromatic aberration post process,
  63314. */
  63315. private readonly ChromaticAberrationPostProcessId;
  63316. /**
  63317. * ID of the grain post process
  63318. */
  63319. private readonly GrainPostProcessId;
  63320. /**
  63321. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63322. */
  63323. sharpen: SharpenPostProcess;
  63324. private _sharpenEffect;
  63325. private bloom;
  63326. /**
  63327. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63328. */
  63329. depthOfField: DepthOfFieldEffect;
  63330. /**
  63331. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63332. */
  63333. fxaa: FxaaPostProcess;
  63334. /**
  63335. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63336. */
  63337. imageProcessing: ImageProcessingPostProcess;
  63338. /**
  63339. * Chromatic aberration post process which will shift rgb colors in the image
  63340. */
  63341. chromaticAberration: ChromaticAberrationPostProcess;
  63342. private _chromaticAberrationEffect;
  63343. /**
  63344. * Grain post process which add noise to the image
  63345. */
  63346. grain: GrainPostProcess;
  63347. private _grainEffect;
  63348. /**
  63349. * Glow post process which adds a glow to emissive areas of the image
  63350. */
  63351. private _glowLayer;
  63352. /**
  63353. * Animations which can be used to tweak settings over a period of time
  63354. */
  63355. animations: Animation[];
  63356. private _imageProcessingConfigurationObserver;
  63357. private _sharpenEnabled;
  63358. private _bloomEnabled;
  63359. private _depthOfFieldEnabled;
  63360. private _depthOfFieldBlurLevel;
  63361. private _fxaaEnabled;
  63362. private _imageProcessingEnabled;
  63363. private _defaultPipelineTextureType;
  63364. private _bloomScale;
  63365. private _chromaticAberrationEnabled;
  63366. private _grainEnabled;
  63367. private _buildAllowed;
  63368. /**
  63369. * Gets active scene
  63370. */
  63371. readonly scene: Scene;
  63372. /**
  63373. * Enable or disable the sharpen process from the pipeline
  63374. */
  63375. sharpenEnabled: boolean;
  63376. private _resizeObserver;
  63377. private _hardwareScaleLevel;
  63378. private _bloomKernel;
  63379. /**
  63380. * Specifies the size of the bloom blur kernel, relative to the final output size
  63381. */
  63382. bloomKernel: number;
  63383. /**
  63384. * Specifies the weight of the bloom in the final rendering
  63385. */
  63386. private _bloomWeight;
  63387. /**
  63388. * Specifies the luma threshold for the area that will be blurred by the bloom
  63389. */
  63390. private _bloomThreshold;
  63391. private _hdr;
  63392. /**
  63393. * The strength of the bloom.
  63394. */
  63395. bloomWeight: number;
  63396. /**
  63397. * The strength of the bloom.
  63398. */
  63399. bloomThreshold: number;
  63400. /**
  63401. * The scale of the bloom, lower value will provide better performance.
  63402. */
  63403. bloomScale: number;
  63404. /**
  63405. * Enable or disable the bloom from the pipeline
  63406. */
  63407. bloomEnabled: boolean;
  63408. private _rebuildBloom;
  63409. /**
  63410. * If the depth of field is enabled.
  63411. */
  63412. depthOfFieldEnabled: boolean;
  63413. /**
  63414. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63415. */
  63416. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63417. /**
  63418. * If the anti aliasing is enabled.
  63419. */
  63420. fxaaEnabled: boolean;
  63421. private _samples;
  63422. /**
  63423. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63424. */
  63425. samples: number;
  63426. /**
  63427. * If image processing is enabled.
  63428. */
  63429. imageProcessingEnabled: boolean;
  63430. /**
  63431. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63432. */
  63433. glowLayerEnabled: boolean;
  63434. /**
  63435. * Gets the glow layer (or null if not defined)
  63436. */
  63437. readonly glowLayer: Nullable<GlowLayer>;
  63438. /**
  63439. * Enable or disable the chromaticAberration process from the pipeline
  63440. */
  63441. chromaticAberrationEnabled: boolean;
  63442. /**
  63443. * Enable or disable the grain process from the pipeline
  63444. */
  63445. grainEnabled: boolean;
  63446. /**
  63447. * @constructor
  63448. * @param name - The rendering pipeline name (default: "")
  63449. * @param hdr - If high dynamic range textures should be used (default: true)
  63450. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63451. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63452. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63453. */
  63454. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63455. /**
  63456. * Get the class name
  63457. * @returns "DefaultRenderingPipeline"
  63458. */
  63459. getClassName(): string;
  63460. /**
  63461. * Force the compilation of the entire pipeline.
  63462. */
  63463. prepare(): void;
  63464. private _hasCleared;
  63465. private _prevPostProcess;
  63466. private _prevPrevPostProcess;
  63467. private _setAutoClearAndTextureSharing;
  63468. private _depthOfFieldSceneObserver;
  63469. private _buildPipeline;
  63470. private _disposePostProcesses;
  63471. /**
  63472. * Adds a camera to the pipeline
  63473. * @param camera the camera to be added
  63474. */
  63475. addCamera(camera: Camera): void;
  63476. /**
  63477. * Removes a camera from the pipeline
  63478. * @param camera the camera to remove
  63479. */
  63480. removeCamera(camera: Camera): void;
  63481. /**
  63482. * Dispose of the pipeline and stop all post processes
  63483. */
  63484. dispose(): void;
  63485. /**
  63486. * Serialize the rendering pipeline (Used when exporting)
  63487. * @returns the serialized object
  63488. */
  63489. serialize(): any;
  63490. /**
  63491. * Parse the serialized pipeline
  63492. * @param source Source pipeline.
  63493. * @param scene The scene to load the pipeline to.
  63494. * @param rootUrl The URL of the serialized pipeline.
  63495. * @returns An instantiated pipeline from the serialized object.
  63496. */
  63497. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63498. }
  63499. }
  63500. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63501. /** @hidden */
  63502. export var lensHighlightsPixelShader: {
  63503. name: string;
  63504. shader: string;
  63505. };
  63506. }
  63507. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63508. /** @hidden */
  63509. export var depthOfFieldPixelShader: {
  63510. name: string;
  63511. shader: string;
  63512. };
  63513. }
  63514. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63515. import { Camera } from "babylonjs/Cameras/camera";
  63516. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63517. import { Scene } from "babylonjs/scene";
  63518. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63519. import "babylonjs/Shaders/chromaticAberration.fragment";
  63520. import "babylonjs/Shaders/lensHighlights.fragment";
  63521. import "babylonjs/Shaders/depthOfField.fragment";
  63522. /**
  63523. * BABYLON.JS Chromatic Aberration GLSL Shader
  63524. * Author: Olivier Guyot
  63525. * Separates very slightly R, G and B colors on the edges of the screen
  63526. * Inspired by Francois Tarlier & Martins Upitis
  63527. */
  63528. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63529. /**
  63530. * @ignore
  63531. * The chromatic aberration PostProcess id in the pipeline
  63532. */
  63533. LensChromaticAberrationEffect: string;
  63534. /**
  63535. * @ignore
  63536. * The highlights enhancing PostProcess id in the pipeline
  63537. */
  63538. HighlightsEnhancingEffect: string;
  63539. /**
  63540. * @ignore
  63541. * The depth-of-field PostProcess id in the pipeline
  63542. */
  63543. LensDepthOfFieldEffect: string;
  63544. private _scene;
  63545. private _depthTexture;
  63546. private _grainTexture;
  63547. private _chromaticAberrationPostProcess;
  63548. private _highlightsPostProcess;
  63549. private _depthOfFieldPostProcess;
  63550. private _edgeBlur;
  63551. private _grainAmount;
  63552. private _chromaticAberration;
  63553. private _distortion;
  63554. private _highlightsGain;
  63555. private _highlightsThreshold;
  63556. private _dofDistance;
  63557. private _dofAperture;
  63558. private _dofDarken;
  63559. private _dofPentagon;
  63560. private _blurNoise;
  63561. /**
  63562. * @constructor
  63563. *
  63564. * Effect parameters are as follow:
  63565. * {
  63566. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63567. * edge_blur: number; // from 0 to x (1 for realism)
  63568. * distortion: number; // from 0 to x (1 for realism)
  63569. * grain_amount: number; // from 0 to 1
  63570. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63571. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63572. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63573. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63574. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63575. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63576. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63577. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63578. * }
  63579. * Note: if an effect parameter is unset, effect is disabled
  63580. *
  63581. * @param name The rendering pipeline name
  63582. * @param parameters - An object containing all parameters (see above)
  63583. * @param scene The scene linked to this pipeline
  63584. * @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)
  63585. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63586. */
  63587. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63588. /**
  63589. * Get the class name
  63590. * @returns "LensRenderingPipeline"
  63591. */
  63592. getClassName(): string;
  63593. /**
  63594. * Gets associated scene
  63595. */
  63596. readonly scene: Scene;
  63597. /**
  63598. * Gets or sets the edge blur
  63599. */
  63600. edgeBlur: number;
  63601. /**
  63602. * Gets or sets the grain amount
  63603. */
  63604. grainAmount: number;
  63605. /**
  63606. * Gets or sets the chromatic aberration amount
  63607. */
  63608. chromaticAberration: number;
  63609. /**
  63610. * Gets or sets the depth of field aperture
  63611. */
  63612. dofAperture: number;
  63613. /**
  63614. * Gets or sets the edge distortion
  63615. */
  63616. edgeDistortion: number;
  63617. /**
  63618. * Gets or sets the depth of field distortion
  63619. */
  63620. dofDistortion: number;
  63621. /**
  63622. * Gets or sets the darken out of focus amount
  63623. */
  63624. darkenOutOfFocus: number;
  63625. /**
  63626. * Gets or sets a boolean indicating if blur noise is enabled
  63627. */
  63628. blurNoise: boolean;
  63629. /**
  63630. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63631. */
  63632. pentagonBokeh: boolean;
  63633. /**
  63634. * Gets or sets the highlight grain amount
  63635. */
  63636. highlightsGain: number;
  63637. /**
  63638. * Gets or sets the highlight threshold
  63639. */
  63640. highlightsThreshold: number;
  63641. /**
  63642. * Sets the amount of blur at the edges
  63643. * @param amount blur amount
  63644. */
  63645. setEdgeBlur(amount: number): void;
  63646. /**
  63647. * Sets edge blur to 0
  63648. */
  63649. disableEdgeBlur(): void;
  63650. /**
  63651. * Sets the amout of grain
  63652. * @param amount Amount of grain
  63653. */
  63654. setGrainAmount(amount: number): void;
  63655. /**
  63656. * Set grain amount to 0
  63657. */
  63658. disableGrain(): void;
  63659. /**
  63660. * Sets the chromatic aberration amount
  63661. * @param amount amount of chromatic aberration
  63662. */
  63663. setChromaticAberration(amount: number): void;
  63664. /**
  63665. * Sets chromatic aberration amount to 0
  63666. */
  63667. disableChromaticAberration(): void;
  63668. /**
  63669. * Sets the EdgeDistortion amount
  63670. * @param amount amount of EdgeDistortion
  63671. */
  63672. setEdgeDistortion(amount: number): void;
  63673. /**
  63674. * Sets edge distortion to 0
  63675. */
  63676. disableEdgeDistortion(): void;
  63677. /**
  63678. * Sets the FocusDistance amount
  63679. * @param amount amount of FocusDistance
  63680. */
  63681. setFocusDistance(amount: number): void;
  63682. /**
  63683. * Disables depth of field
  63684. */
  63685. disableDepthOfField(): void;
  63686. /**
  63687. * Sets the Aperture amount
  63688. * @param amount amount of Aperture
  63689. */
  63690. setAperture(amount: number): void;
  63691. /**
  63692. * Sets the DarkenOutOfFocus amount
  63693. * @param amount amount of DarkenOutOfFocus
  63694. */
  63695. setDarkenOutOfFocus(amount: number): void;
  63696. private _pentagonBokehIsEnabled;
  63697. /**
  63698. * Creates a pentagon bokeh effect
  63699. */
  63700. enablePentagonBokeh(): void;
  63701. /**
  63702. * Disables the pentagon bokeh effect
  63703. */
  63704. disablePentagonBokeh(): void;
  63705. /**
  63706. * Enables noise blur
  63707. */
  63708. enableNoiseBlur(): void;
  63709. /**
  63710. * Disables noise blur
  63711. */
  63712. disableNoiseBlur(): void;
  63713. /**
  63714. * Sets the HighlightsGain amount
  63715. * @param amount amount of HighlightsGain
  63716. */
  63717. setHighlightsGain(amount: number): void;
  63718. /**
  63719. * Sets the HighlightsThreshold amount
  63720. * @param amount amount of HighlightsThreshold
  63721. */
  63722. setHighlightsThreshold(amount: number): void;
  63723. /**
  63724. * Disables highlights
  63725. */
  63726. disableHighlights(): void;
  63727. /**
  63728. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63729. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63730. */
  63731. dispose(disableDepthRender?: boolean): void;
  63732. private _createChromaticAberrationPostProcess;
  63733. private _createHighlightsPostProcess;
  63734. private _createDepthOfFieldPostProcess;
  63735. private _createGrainTexture;
  63736. }
  63737. }
  63738. declare module "babylonjs/Shaders/ssao2.fragment" {
  63739. /** @hidden */
  63740. export var ssao2PixelShader: {
  63741. name: string;
  63742. shader: string;
  63743. };
  63744. }
  63745. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63746. /** @hidden */
  63747. export var ssaoCombinePixelShader: {
  63748. name: string;
  63749. shader: string;
  63750. };
  63751. }
  63752. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63753. import { Camera } from "babylonjs/Cameras/camera";
  63754. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63755. import { Scene } from "babylonjs/scene";
  63756. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63757. import "babylonjs/Shaders/ssao2.fragment";
  63758. import "babylonjs/Shaders/ssaoCombine.fragment";
  63759. /**
  63760. * Render pipeline to produce ssao effect
  63761. */
  63762. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63763. /**
  63764. * @ignore
  63765. * The PassPostProcess id in the pipeline that contains the original scene color
  63766. */
  63767. SSAOOriginalSceneColorEffect: string;
  63768. /**
  63769. * @ignore
  63770. * The SSAO PostProcess id in the pipeline
  63771. */
  63772. SSAORenderEffect: string;
  63773. /**
  63774. * @ignore
  63775. * The horizontal blur PostProcess id in the pipeline
  63776. */
  63777. SSAOBlurHRenderEffect: string;
  63778. /**
  63779. * @ignore
  63780. * The vertical blur PostProcess id in the pipeline
  63781. */
  63782. SSAOBlurVRenderEffect: string;
  63783. /**
  63784. * @ignore
  63785. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63786. */
  63787. SSAOCombineRenderEffect: string;
  63788. /**
  63789. * The output strength of the SSAO post-process. Default value is 1.0.
  63790. */
  63791. totalStrength: number;
  63792. /**
  63793. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63794. */
  63795. maxZ: number;
  63796. /**
  63797. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63798. */
  63799. minZAspect: number;
  63800. private _samples;
  63801. /**
  63802. * Number of samples used for the SSAO calculations. Default value is 8
  63803. */
  63804. samples: number;
  63805. private _textureSamples;
  63806. /**
  63807. * Number of samples to use for antialiasing
  63808. */
  63809. textureSamples: number;
  63810. /**
  63811. * Ratio object used for SSAO ratio and blur ratio
  63812. */
  63813. private _ratio;
  63814. /**
  63815. * Dynamically generated sphere sampler.
  63816. */
  63817. private _sampleSphere;
  63818. /**
  63819. * Blur filter offsets
  63820. */
  63821. private _samplerOffsets;
  63822. private _expensiveBlur;
  63823. /**
  63824. * If bilateral blur should be used
  63825. */
  63826. expensiveBlur: boolean;
  63827. /**
  63828. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63829. */
  63830. radius: number;
  63831. /**
  63832. * The base color of the SSAO post-process
  63833. * The final result is "base + ssao" between [0, 1]
  63834. */
  63835. base: number;
  63836. /**
  63837. * Support test.
  63838. */
  63839. static readonly IsSupported: boolean;
  63840. private _scene;
  63841. private _depthTexture;
  63842. private _normalTexture;
  63843. private _randomTexture;
  63844. private _originalColorPostProcess;
  63845. private _ssaoPostProcess;
  63846. private _blurHPostProcess;
  63847. private _blurVPostProcess;
  63848. private _ssaoCombinePostProcess;
  63849. private _firstUpdate;
  63850. /**
  63851. * Gets active scene
  63852. */
  63853. readonly scene: Scene;
  63854. /**
  63855. * @constructor
  63856. * @param name The rendering pipeline name
  63857. * @param scene The scene linked to this pipeline
  63858. * @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 }
  63859. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63860. */
  63861. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63862. /**
  63863. * Get the class name
  63864. * @returns "SSAO2RenderingPipeline"
  63865. */
  63866. getClassName(): string;
  63867. /**
  63868. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63869. */
  63870. dispose(disableGeometryBufferRenderer?: boolean): void;
  63871. private _createBlurPostProcess;
  63872. /** @hidden */
  63873. _rebuild(): void;
  63874. private _bits;
  63875. private _radicalInverse_VdC;
  63876. private _hammersley;
  63877. private _hemisphereSample_uniform;
  63878. private _generateHemisphere;
  63879. private _createSSAOPostProcess;
  63880. private _createSSAOCombinePostProcess;
  63881. private _createRandomTexture;
  63882. /**
  63883. * Serialize the rendering pipeline (Used when exporting)
  63884. * @returns the serialized object
  63885. */
  63886. serialize(): any;
  63887. /**
  63888. * Parse the serialized pipeline
  63889. * @param source Source pipeline.
  63890. * @param scene The scene to load the pipeline to.
  63891. * @param rootUrl The URL of the serialized pipeline.
  63892. * @returns An instantiated pipeline from the serialized object.
  63893. */
  63894. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63895. }
  63896. }
  63897. declare module "babylonjs/Shaders/ssao.fragment" {
  63898. /** @hidden */
  63899. export var ssaoPixelShader: {
  63900. name: string;
  63901. shader: string;
  63902. };
  63903. }
  63904. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63905. import { Camera } from "babylonjs/Cameras/camera";
  63906. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63907. import { Scene } from "babylonjs/scene";
  63908. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63909. import "babylonjs/Shaders/ssao.fragment";
  63910. import "babylonjs/Shaders/ssaoCombine.fragment";
  63911. /**
  63912. * Render pipeline to produce ssao effect
  63913. */
  63914. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63915. /**
  63916. * @ignore
  63917. * The PassPostProcess id in the pipeline that contains the original scene color
  63918. */
  63919. SSAOOriginalSceneColorEffect: string;
  63920. /**
  63921. * @ignore
  63922. * The SSAO PostProcess id in the pipeline
  63923. */
  63924. SSAORenderEffect: string;
  63925. /**
  63926. * @ignore
  63927. * The horizontal blur PostProcess id in the pipeline
  63928. */
  63929. SSAOBlurHRenderEffect: string;
  63930. /**
  63931. * @ignore
  63932. * The vertical blur PostProcess id in the pipeline
  63933. */
  63934. SSAOBlurVRenderEffect: string;
  63935. /**
  63936. * @ignore
  63937. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63938. */
  63939. SSAOCombineRenderEffect: string;
  63940. /**
  63941. * The output strength of the SSAO post-process. Default value is 1.0.
  63942. */
  63943. totalStrength: number;
  63944. /**
  63945. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63946. */
  63947. radius: number;
  63948. /**
  63949. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63950. * Must not be equal to fallOff and superior to fallOff.
  63951. * Default value is 0.0075
  63952. */
  63953. area: number;
  63954. /**
  63955. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63956. * Must not be equal to area and inferior to area.
  63957. * Default value is 0.000001
  63958. */
  63959. fallOff: number;
  63960. /**
  63961. * The base color of the SSAO post-process
  63962. * The final result is "base + ssao" between [0, 1]
  63963. */
  63964. base: number;
  63965. private _scene;
  63966. private _depthTexture;
  63967. private _randomTexture;
  63968. private _originalColorPostProcess;
  63969. private _ssaoPostProcess;
  63970. private _blurHPostProcess;
  63971. private _blurVPostProcess;
  63972. private _ssaoCombinePostProcess;
  63973. private _firstUpdate;
  63974. /**
  63975. * Gets active scene
  63976. */
  63977. readonly scene: Scene;
  63978. /**
  63979. * @constructor
  63980. * @param name - The rendering pipeline name
  63981. * @param scene - The scene linked to this pipeline
  63982. * @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 }
  63983. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63984. */
  63985. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63986. /**
  63987. * Get the class name
  63988. * @returns "SSAORenderingPipeline"
  63989. */
  63990. getClassName(): string;
  63991. /**
  63992. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63993. */
  63994. dispose(disableDepthRender?: boolean): void;
  63995. private _createBlurPostProcess;
  63996. /** @hidden */
  63997. _rebuild(): void;
  63998. private _createSSAOPostProcess;
  63999. private _createSSAOCombinePostProcess;
  64000. private _createRandomTexture;
  64001. }
  64002. }
  64003. declare module "babylonjs/Shaders/standard.fragment" {
  64004. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64005. /** @hidden */
  64006. export var standardPixelShader: {
  64007. name: string;
  64008. shader: string;
  64009. };
  64010. }
  64011. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  64012. import { Nullable } from "babylonjs/types";
  64013. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  64014. import { Camera } from "babylonjs/Cameras/camera";
  64015. import { Texture } from "babylonjs/Materials/Textures/texture";
  64016. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64017. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64018. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  64019. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  64020. import { IDisposable } from "babylonjs/scene";
  64021. import { SpotLight } from "babylonjs/Lights/spotLight";
  64022. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  64023. import { Scene } from "babylonjs/scene";
  64024. import { Animation } from "babylonjs/Animations/animation";
  64025. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64026. import "babylonjs/Shaders/standard.fragment";
  64027. /**
  64028. * Standard rendering pipeline
  64029. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64030. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  64031. */
  64032. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  64033. /**
  64034. * Public members
  64035. */
  64036. /**
  64037. * Post-process which contains the original scene color before the pipeline applies all the effects
  64038. */
  64039. originalPostProcess: Nullable<PostProcess>;
  64040. /**
  64041. * Post-process used to down scale an image x4
  64042. */
  64043. downSampleX4PostProcess: Nullable<PostProcess>;
  64044. /**
  64045. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  64046. */
  64047. brightPassPostProcess: Nullable<PostProcess>;
  64048. /**
  64049. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  64050. */
  64051. blurHPostProcesses: PostProcess[];
  64052. /**
  64053. * Post-process array storing all the vertical blur post-processes used by the pipeline
  64054. */
  64055. blurVPostProcesses: PostProcess[];
  64056. /**
  64057. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64058. */
  64059. textureAdderPostProcess: Nullable<PostProcess>;
  64060. /**
  64061. * Post-process used to create volumetric lighting effect
  64062. */
  64063. volumetricLightPostProcess: Nullable<PostProcess>;
  64064. /**
  64065. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64066. */
  64067. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64068. /**
  64069. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64070. */
  64071. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64072. /**
  64073. * Post-process used to merge the volumetric light effect and the real scene color
  64074. */
  64075. volumetricLightMergePostProces: Nullable<PostProcess>;
  64076. /**
  64077. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64078. */
  64079. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64080. /**
  64081. * Base post-process used to calculate the average luminance of the final image for HDR
  64082. */
  64083. luminancePostProcess: Nullable<PostProcess>;
  64084. /**
  64085. * Post-processes used to create down sample post-processes in order to get
  64086. * the average luminance of the final image for HDR
  64087. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64088. */
  64089. luminanceDownSamplePostProcesses: PostProcess[];
  64090. /**
  64091. * Post-process used to create a HDR effect (light adaptation)
  64092. */
  64093. hdrPostProcess: Nullable<PostProcess>;
  64094. /**
  64095. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64096. */
  64097. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64098. /**
  64099. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64100. */
  64101. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64102. /**
  64103. * Post-process used to merge the final HDR post-process and the real scene color
  64104. */
  64105. hdrFinalPostProcess: Nullable<PostProcess>;
  64106. /**
  64107. * Post-process used to create a lens flare effect
  64108. */
  64109. lensFlarePostProcess: Nullable<PostProcess>;
  64110. /**
  64111. * Post-process that merges the result of the lens flare post-process and the real scene color
  64112. */
  64113. lensFlareComposePostProcess: Nullable<PostProcess>;
  64114. /**
  64115. * Post-process used to create a motion blur effect
  64116. */
  64117. motionBlurPostProcess: Nullable<PostProcess>;
  64118. /**
  64119. * Post-process used to create a depth of field effect
  64120. */
  64121. depthOfFieldPostProcess: Nullable<PostProcess>;
  64122. /**
  64123. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64124. */
  64125. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64126. /**
  64127. * Represents the brightness threshold in order to configure the illuminated surfaces
  64128. */
  64129. brightThreshold: number;
  64130. /**
  64131. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64132. */
  64133. blurWidth: number;
  64134. /**
  64135. * Sets if the blur for highlighted surfaces must be only horizontal
  64136. */
  64137. horizontalBlur: boolean;
  64138. /**
  64139. * Gets the overall exposure used by the pipeline
  64140. */
  64141. /**
  64142. * Sets the overall exposure used by the pipeline
  64143. */
  64144. exposure: number;
  64145. /**
  64146. * Texture used typically to simulate "dirty" on camera lens
  64147. */
  64148. lensTexture: Nullable<Texture>;
  64149. /**
  64150. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64151. */
  64152. volumetricLightCoefficient: number;
  64153. /**
  64154. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64155. */
  64156. volumetricLightPower: number;
  64157. /**
  64158. * Used the set the blur intensity to smooth the volumetric lights
  64159. */
  64160. volumetricLightBlurScale: number;
  64161. /**
  64162. * Light (spot or directional) used to generate the volumetric lights rays
  64163. * The source light must have a shadow generate so the pipeline can get its
  64164. * depth map
  64165. */
  64166. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64167. /**
  64168. * For eye adaptation, represents the minimum luminance the eye can see
  64169. */
  64170. hdrMinimumLuminance: number;
  64171. /**
  64172. * For eye adaptation, represents the decrease luminance speed
  64173. */
  64174. hdrDecreaseRate: number;
  64175. /**
  64176. * For eye adaptation, represents the increase luminance speed
  64177. */
  64178. hdrIncreaseRate: number;
  64179. /**
  64180. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64181. */
  64182. /**
  64183. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64184. */
  64185. hdrAutoExposure: boolean;
  64186. /**
  64187. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64188. */
  64189. lensColorTexture: Nullable<Texture>;
  64190. /**
  64191. * The overall strengh for the lens flare effect
  64192. */
  64193. lensFlareStrength: number;
  64194. /**
  64195. * Dispersion coefficient for lens flare ghosts
  64196. */
  64197. lensFlareGhostDispersal: number;
  64198. /**
  64199. * Main lens flare halo width
  64200. */
  64201. lensFlareHaloWidth: number;
  64202. /**
  64203. * Based on the lens distortion effect, defines how much the lens flare result
  64204. * is distorted
  64205. */
  64206. lensFlareDistortionStrength: number;
  64207. /**
  64208. * Configures the blur intensity used for for lens flare (halo)
  64209. */
  64210. lensFlareBlurWidth: number;
  64211. /**
  64212. * Lens star texture must be used to simulate rays on the flares and is available
  64213. * in the documentation
  64214. */
  64215. lensStarTexture: Nullable<Texture>;
  64216. /**
  64217. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64218. * flare effect by taking account of the dirt texture
  64219. */
  64220. lensFlareDirtTexture: Nullable<Texture>;
  64221. /**
  64222. * Represents the focal length for the depth of field effect
  64223. */
  64224. depthOfFieldDistance: number;
  64225. /**
  64226. * Represents the blur intensity for the blurred part of the depth of field effect
  64227. */
  64228. depthOfFieldBlurWidth: number;
  64229. /**
  64230. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64231. */
  64232. /**
  64233. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64234. */
  64235. motionStrength: number;
  64236. /**
  64237. * Gets wether or not the motion blur post-process is object based or screen based.
  64238. */
  64239. /**
  64240. * Sets wether or not the motion blur post-process should be object based or screen based
  64241. */
  64242. objectBasedMotionBlur: boolean;
  64243. /**
  64244. * List of animations for the pipeline (IAnimatable implementation)
  64245. */
  64246. animations: Animation[];
  64247. /**
  64248. * Private members
  64249. */
  64250. private _scene;
  64251. private _currentDepthOfFieldSource;
  64252. private _basePostProcess;
  64253. private _fixedExposure;
  64254. private _currentExposure;
  64255. private _hdrAutoExposure;
  64256. private _hdrCurrentLuminance;
  64257. private _motionStrength;
  64258. private _isObjectBasedMotionBlur;
  64259. private _floatTextureType;
  64260. private _camerasToBeAttached;
  64261. private _ratio;
  64262. private _bloomEnabled;
  64263. private _depthOfFieldEnabled;
  64264. private _vlsEnabled;
  64265. private _lensFlareEnabled;
  64266. private _hdrEnabled;
  64267. private _motionBlurEnabled;
  64268. private _fxaaEnabled;
  64269. private _motionBlurSamples;
  64270. private _volumetricLightStepsCount;
  64271. private _samples;
  64272. /**
  64273. * @ignore
  64274. * Specifies if the bloom pipeline is enabled
  64275. */
  64276. BloomEnabled: boolean;
  64277. /**
  64278. * @ignore
  64279. * Specifies if the depth of field pipeline is enabed
  64280. */
  64281. DepthOfFieldEnabled: boolean;
  64282. /**
  64283. * @ignore
  64284. * Specifies if the lens flare pipeline is enabed
  64285. */
  64286. LensFlareEnabled: boolean;
  64287. /**
  64288. * @ignore
  64289. * Specifies if the HDR pipeline is enabled
  64290. */
  64291. HDREnabled: boolean;
  64292. /**
  64293. * @ignore
  64294. * Specifies if the volumetric lights scattering effect is enabled
  64295. */
  64296. VLSEnabled: boolean;
  64297. /**
  64298. * @ignore
  64299. * Specifies if the motion blur effect is enabled
  64300. */
  64301. MotionBlurEnabled: boolean;
  64302. /**
  64303. * Specifies if anti-aliasing is enabled
  64304. */
  64305. fxaaEnabled: boolean;
  64306. /**
  64307. * Specifies the number of steps used to calculate the volumetric lights
  64308. * Typically in interval [50, 200]
  64309. */
  64310. volumetricLightStepsCount: number;
  64311. /**
  64312. * Specifies the number of samples used for the motion blur effect
  64313. * Typically in interval [16, 64]
  64314. */
  64315. motionBlurSamples: number;
  64316. /**
  64317. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64318. */
  64319. samples: number;
  64320. /**
  64321. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64322. * @constructor
  64323. * @param name The rendering pipeline name
  64324. * @param scene The scene linked to this pipeline
  64325. * @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)
  64326. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64327. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64328. */
  64329. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64330. private _buildPipeline;
  64331. private _createDownSampleX4PostProcess;
  64332. private _createBrightPassPostProcess;
  64333. private _createBlurPostProcesses;
  64334. private _createTextureAdderPostProcess;
  64335. private _createVolumetricLightPostProcess;
  64336. private _createLuminancePostProcesses;
  64337. private _createHdrPostProcess;
  64338. private _createLensFlarePostProcess;
  64339. private _createDepthOfFieldPostProcess;
  64340. private _createMotionBlurPostProcess;
  64341. private _getDepthTexture;
  64342. private _disposePostProcesses;
  64343. /**
  64344. * Dispose of the pipeline and stop all post processes
  64345. */
  64346. dispose(): void;
  64347. /**
  64348. * Serialize the rendering pipeline (Used when exporting)
  64349. * @returns the serialized object
  64350. */
  64351. serialize(): any;
  64352. /**
  64353. * Parse the serialized pipeline
  64354. * @param source Source pipeline.
  64355. * @param scene The scene to load the pipeline to.
  64356. * @param rootUrl The URL of the serialized pipeline.
  64357. * @returns An instantiated pipeline from the serialized object.
  64358. */
  64359. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64360. /**
  64361. * Luminance steps
  64362. */
  64363. static LuminanceSteps: number;
  64364. }
  64365. }
  64366. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64367. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64368. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64369. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64370. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64371. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64372. }
  64373. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64374. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64375. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64376. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64377. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64378. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64379. }
  64380. declare module "babylonjs/Shaders/tonemap.fragment" {
  64381. /** @hidden */
  64382. export var tonemapPixelShader: {
  64383. name: string;
  64384. shader: string;
  64385. };
  64386. }
  64387. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64388. import { Camera } from "babylonjs/Cameras/camera";
  64389. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64390. import "babylonjs/Shaders/tonemap.fragment";
  64391. import { Engine } from "babylonjs/Engines/engine";
  64392. /** Defines operator used for tonemapping */
  64393. export enum TonemappingOperator {
  64394. /** Hable */
  64395. Hable = 0,
  64396. /** Reinhard */
  64397. Reinhard = 1,
  64398. /** HejiDawson */
  64399. HejiDawson = 2,
  64400. /** Photographic */
  64401. Photographic = 3
  64402. }
  64403. /**
  64404. * Defines a post process to apply tone mapping
  64405. */
  64406. export class TonemapPostProcess extends PostProcess {
  64407. private _operator;
  64408. /** Defines the required exposure adjustement */
  64409. exposureAdjustment: number;
  64410. /**
  64411. * Creates a new TonemapPostProcess
  64412. * @param name defines the name of the postprocess
  64413. * @param _operator defines the operator to use
  64414. * @param exposureAdjustment defines the required exposure adjustement
  64415. * @param camera defines the camera to use (can be null)
  64416. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64417. * @param engine defines the hosting engine (can be ignore if camera is set)
  64418. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64419. */
  64420. constructor(name: string, _operator: TonemappingOperator,
  64421. /** Defines the required exposure adjustement */
  64422. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64423. }
  64424. }
  64425. declare module "babylonjs/Shaders/depth.vertex" {
  64426. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64427. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64428. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64429. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64430. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64431. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64432. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64433. /** @hidden */
  64434. export var depthVertexShader: {
  64435. name: string;
  64436. shader: string;
  64437. };
  64438. }
  64439. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64440. /** @hidden */
  64441. export var volumetricLightScatteringPixelShader: {
  64442. name: string;
  64443. shader: string;
  64444. };
  64445. }
  64446. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64447. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64448. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64449. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64450. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64451. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64452. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64453. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64454. /** @hidden */
  64455. export var volumetricLightScatteringPassVertexShader: {
  64456. name: string;
  64457. shader: string;
  64458. };
  64459. }
  64460. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64461. /** @hidden */
  64462. export var volumetricLightScatteringPassPixelShader: {
  64463. name: string;
  64464. shader: string;
  64465. };
  64466. }
  64467. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64468. import { Vector3 } from "babylonjs/Maths/math.vector";
  64469. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64470. import { Mesh } from "babylonjs/Meshes/mesh";
  64471. import { Camera } from "babylonjs/Cameras/camera";
  64472. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64473. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64474. import { Scene } from "babylonjs/scene";
  64475. import "babylonjs/Meshes/Builders/planeBuilder";
  64476. import "babylonjs/Shaders/depth.vertex";
  64477. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64478. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64479. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64480. import { Engine } from "babylonjs/Engines/engine";
  64481. /**
  64482. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64483. */
  64484. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64485. private _volumetricLightScatteringPass;
  64486. private _volumetricLightScatteringRTT;
  64487. private _viewPort;
  64488. private _screenCoordinates;
  64489. private _cachedDefines;
  64490. /**
  64491. * If not undefined, the mesh position is computed from the attached node position
  64492. */
  64493. attachedNode: {
  64494. position: Vector3;
  64495. };
  64496. /**
  64497. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64498. */
  64499. customMeshPosition: Vector3;
  64500. /**
  64501. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64502. */
  64503. useCustomMeshPosition: boolean;
  64504. /**
  64505. * If the post-process should inverse the light scattering direction
  64506. */
  64507. invert: boolean;
  64508. /**
  64509. * The internal mesh used by the post-process
  64510. */
  64511. mesh: Mesh;
  64512. /**
  64513. * @hidden
  64514. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64515. */
  64516. useDiffuseColor: boolean;
  64517. /**
  64518. * Array containing the excluded meshes not rendered in the internal pass
  64519. */
  64520. excludedMeshes: AbstractMesh[];
  64521. /**
  64522. * Controls the overall intensity of the post-process
  64523. */
  64524. exposure: number;
  64525. /**
  64526. * Dissipates each sample's contribution in range [0, 1]
  64527. */
  64528. decay: number;
  64529. /**
  64530. * Controls the overall intensity of each sample
  64531. */
  64532. weight: number;
  64533. /**
  64534. * Controls the density of each sample
  64535. */
  64536. density: number;
  64537. /**
  64538. * @constructor
  64539. * @param name The post-process name
  64540. * @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)
  64541. * @param camera The camera that the post-process will be attached to
  64542. * @param mesh The mesh used to create the light scattering
  64543. * @param samples The post-process quality, default 100
  64544. * @param samplingModeThe post-process filtering mode
  64545. * @param engine The babylon engine
  64546. * @param reusable If the post-process is reusable
  64547. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64548. */
  64549. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64550. /**
  64551. * Returns the string "VolumetricLightScatteringPostProcess"
  64552. * @returns "VolumetricLightScatteringPostProcess"
  64553. */
  64554. getClassName(): string;
  64555. private _isReady;
  64556. /**
  64557. * Sets the new light position for light scattering effect
  64558. * @param position The new custom light position
  64559. */
  64560. setCustomMeshPosition(position: Vector3): void;
  64561. /**
  64562. * Returns the light position for light scattering effect
  64563. * @return Vector3 The custom light position
  64564. */
  64565. getCustomMeshPosition(): Vector3;
  64566. /**
  64567. * Disposes the internal assets and detaches the post-process from the camera
  64568. */
  64569. dispose(camera: Camera): void;
  64570. /**
  64571. * Returns the render target texture used by the post-process
  64572. * @return the render target texture used by the post-process
  64573. */
  64574. getPass(): RenderTargetTexture;
  64575. private _meshExcluded;
  64576. private _createPass;
  64577. private _updateMeshScreenCoordinates;
  64578. /**
  64579. * Creates a default mesh for the Volumeric Light Scattering post-process
  64580. * @param name The mesh name
  64581. * @param scene The scene where to create the mesh
  64582. * @return the default mesh
  64583. */
  64584. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64585. }
  64586. }
  64587. declare module "babylonjs/PostProcesses/index" {
  64588. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64589. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64590. export * from "babylonjs/PostProcesses/bloomEffect";
  64591. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64592. export * from "babylonjs/PostProcesses/blurPostProcess";
  64593. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64594. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64595. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64596. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64597. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64598. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64599. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64600. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64601. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64602. export * from "babylonjs/PostProcesses/filterPostProcess";
  64603. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64604. export * from "babylonjs/PostProcesses/grainPostProcess";
  64605. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64606. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64607. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64608. export * from "babylonjs/PostProcesses/passPostProcess";
  64609. export * from "babylonjs/PostProcesses/postProcess";
  64610. export * from "babylonjs/PostProcesses/postProcessManager";
  64611. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64612. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64613. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64614. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64615. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64616. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64617. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64618. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64619. }
  64620. declare module "babylonjs/Probes/index" {
  64621. export * from "babylonjs/Probes/reflectionProbe";
  64622. }
  64623. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64624. import { Scene } from "babylonjs/scene";
  64625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64626. import { SmartArray } from "babylonjs/Misc/smartArray";
  64627. import { ISceneComponent } from "babylonjs/sceneComponent";
  64628. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64629. import "babylonjs/Meshes/Builders/boxBuilder";
  64630. import "babylonjs/Shaders/color.fragment";
  64631. import "babylonjs/Shaders/color.vertex";
  64632. import { Color3 } from "babylonjs/Maths/math.color";
  64633. module "babylonjs/scene" {
  64634. interface Scene {
  64635. /** @hidden (Backing field) */
  64636. _boundingBoxRenderer: BoundingBoxRenderer;
  64637. /** @hidden (Backing field) */
  64638. _forceShowBoundingBoxes: boolean;
  64639. /**
  64640. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64641. */
  64642. forceShowBoundingBoxes: boolean;
  64643. /**
  64644. * Gets the bounding box renderer associated with the scene
  64645. * @returns a BoundingBoxRenderer
  64646. */
  64647. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64648. }
  64649. }
  64650. module "babylonjs/Meshes/abstractMesh" {
  64651. interface AbstractMesh {
  64652. /** @hidden (Backing field) */
  64653. _showBoundingBox: boolean;
  64654. /**
  64655. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64656. */
  64657. showBoundingBox: boolean;
  64658. }
  64659. }
  64660. /**
  64661. * Component responsible of rendering the bounding box of the meshes in a scene.
  64662. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64663. */
  64664. export class BoundingBoxRenderer implements ISceneComponent {
  64665. /**
  64666. * The component name helpfull to identify the component in the list of scene components.
  64667. */
  64668. readonly name: string;
  64669. /**
  64670. * The scene the component belongs to.
  64671. */
  64672. scene: Scene;
  64673. /**
  64674. * Color of the bounding box lines placed in front of an object
  64675. */
  64676. frontColor: Color3;
  64677. /**
  64678. * Color of the bounding box lines placed behind an object
  64679. */
  64680. backColor: Color3;
  64681. /**
  64682. * Defines if the renderer should show the back lines or not
  64683. */
  64684. showBackLines: boolean;
  64685. /**
  64686. * @hidden
  64687. */
  64688. renderList: SmartArray<BoundingBox>;
  64689. private _colorShader;
  64690. private _vertexBuffers;
  64691. private _indexBuffer;
  64692. private _fillIndexBuffer;
  64693. private _fillIndexData;
  64694. /**
  64695. * Instantiates a new bounding box renderer in a scene.
  64696. * @param scene the scene the renderer renders in
  64697. */
  64698. constructor(scene: Scene);
  64699. /**
  64700. * Registers the component in a given scene
  64701. */
  64702. register(): void;
  64703. private _evaluateSubMesh;
  64704. private _activeMesh;
  64705. private _prepareRessources;
  64706. private _createIndexBuffer;
  64707. /**
  64708. * Rebuilds the elements related to this component in case of
  64709. * context lost for instance.
  64710. */
  64711. rebuild(): void;
  64712. /**
  64713. * @hidden
  64714. */
  64715. reset(): void;
  64716. /**
  64717. * Render the bounding boxes of a specific rendering group
  64718. * @param renderingGroupId defines the rendering group to render
  64719. */
  64720. render(renderingGroupId: number): void;
  64721. /**
  64722. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64723. * @param mesh Define the mesh to render the occlusion bounding box for
  64724. */
  64725. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64726. /**
  64727. * Dispose and release the resources attached to this renderer.
  64728. */
  64729. dispose(): void;
  64730. }
  64731. }
  64732. declare module "babylonjs/Shaders/depth.fragment" {
  64733. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64734. /** @hidden */
  64735. export var depthPixelShader: {
  64736. name: string;
  64737. shader: string;
  64738. };
  64739. }
  64740. declare module "babylonjs/Rendering/depthRenderer" {
  64741. import { Nullable } from "babylonjs/types";
  64742. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64743. import { Scene } from "babylonjs/scene";
  64744. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64745. import { Camera } from "babylonjs/Cameras/camera";
  64746. import "babylonjs/Shaders/depth.fragment";
  64747. import "babylonjs/Shaders/depth.vertex";
  64748. /**
  64749. * This represents a depth renderer in Babylon.
  64750. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64751. */
  64752. export class DepthRenderer {
  64753. private _scene;
  64754. private _depthMap;
  64755. private _effect;
  64756. private readonly _storeNonLinearDepth;
  64757. private readonly _clearColor;
  64758. /** Get if the depth renderer is using packed depth or not */
  64759. readonly isPacked: boolean;
  64760. private _cachedDefines;
  64761. private _camera;
  64762. /**
  64763. * Specifiess that the depth renderer will only be used within
  64764. * the camera it is created for.
  64765. * This can help forcing its rendering during the camera processing.
  64766. */
  64767. useOnlyInActiveCamera: boolean;
  64768. /** @hidden */
  64769. static _SceneComponentInitialization: (scene: Scene) => void;
  64770. /**
  64771. * Instantiates a depth renderer
  64772. * @param scene The scene the renderer belongs to
  64773. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64774. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64775. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64776. */
  64777. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64778. /**
  64779. * Creates the depth rendering effect and checks if the effect is ready.
  64780. * @param subMesh The submesh to be used to render the depth map of
  64781. * @param useInstances If multiple world instances should be used
  64782. * @returns if the depth renderer is ready to render the depth map
  64783. */
  64784. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64785. /**
  64786. * Gets the texture which the depth map will be written to.
  64787. * @returns The depth map texture
  64788. */
  64789. getDepthMap(): RenderTargetTexture;
  64790. /**
  64791. * Disposes of the depth renderer.
  64792. */
  64793. dispose(): void;
  64794. }
  64795. }
  64796. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64797. import { Nullable } from "babylonjs/types";
  64798. import { Scene } from "babylonjs/scene";
  64799. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64800. import { Camera } from "babylonjs/Cameras/camera";
  64801. import { ISceneComponent } from "babylonjs/sceneComponent";
  64802. module "babylonjs/scene" {
  64803. interface Scene {
  64804. /** @hidden (Backing field) */
  64805. _depthRenderer: {
  64806. [id: string]: DepthRenderer;
  64807. };
  64808. /**
  64809. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64810. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64811. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64812. * @returns the created depth renderer
  64813. */
  64814. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64815. /**
  64816. * Disables a depth renderer for a given camera
  64817. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64818. */
  64819. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64820. }
  64821. }
  64822. /**
  64823. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64824. * in several rendering techniques.
  64825. */
  64826. export class DepthRendererSceneComponent implements ISceneComponent {
  64827. /**
  64828. * The component name helpfull to identify the component in the list of scene components.
  64829. */
  64830. readonly name: string;
  64831. /**
  64832. * The scene the component belongs to.
  64833. */
  64834. scene: Scene;
  64835. /**
  64836. * Creates a new instance of the component for the given scene
  64837. * @param scene Defines the scene to register the component in
  64838. */
  64839. constructor(scene: Scene);
  64840. /**
  64841. * Registers the component in a given scene
  64842. */
  64843. register(): void;
  64844. /**
  64845. * Rebuilds the elements related to this component in case of
  64846. * context lost for instance.
  64847. */
  64848. rebuild(): void;
  64849. /**
  64850. * Disposes the component and the associated ressources
  64851. */
  64852. dispose(): void;
  64853. private _gatherRenderTargets;
  64854. private _gatherActiveCameraRenderTargets;
  64855. }
  64856. }
  64857. declare module "babylonjs/Shaders/outline.fragment" {
  64858. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64859. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64860. /** @hidden */
  64861. export var outlinePixelShader: {
  64862. name: string;
  64863. shader: string;
  64864. };
  64865. }
  64866. declare module "babylonjs/Shaders/outline.vertex" {
  64867. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64868. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64869. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64870. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64871. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64872. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64873. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64874. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64875. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64876. /** @hidden */
  64877. export var outlineVertexShader: {
  64878. name: string;
  64879. shader: string;
  64880. };
  64881. }
  64882. declare module "babylonjs/Rendering/outlineRenderer" {
  64883. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64884. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64885. import { Scene } from "babylonjs/scene";
  64886. import { ISceneComponent } from "babylonjs/sceneComponent";
  64887. import "babylonjs/Shaders/outline.fragment";
  64888. import "babylonjs/Shaders/outline.vertex";
  64889. module "babylonjs/scene" {
  64890. interface Scene {
  64891. /** @hidden */
  64892. _outlineRenderer: OutlineRenderer;
  64893. /**
  64894. * Gets the outline renderer associated with the scene
  64895. * @returns a OutlineRenderer
  64896. */
  64897. getOutlineRenderer(): OutlineRenderer;
  64898. }
  64899. }
  64900. module "babylonjs/Meshes/abstractMesh" {
  64901. interface AbstractMesh {
  64902. /** @hidden (Backing field) */
  64903. _renderOutline: boolean;
  64904. /**
  64905. * Gets or sets a boolean indicating if the outline must be rendered as well
  64906. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64907. */
  64908. renderOutline: boolean;
  64909. /** @hidden (Backing field) */
  64910. _renderOverlay: boolean;
  64911. /**
  64912. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64913. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64914. */
  64915. renderOverlay: boolean;
  64916. }
  64917. }
  64918. /**
  64919. * This class is responsible to draw bothe outline/overlay of meshes.
  64920. * It should not be used directly but through the available method on mesh.
  64921. */
  64922. export class OutlineRenderer implements ISceneComponent {
  64923. /**
  64924. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64925. */
  64926. private static _StencilReference;
  64927. /**
  64928. * The name of the component. Each component must have a unique name.
  64929. */
  64930. name: string;
  64931. /**
  64932. * The scene the component belongs to.
  64933. */
  64934. scene: Scene;
  64935. /**
  64936. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64937. */
  64938. zOffset: number;
  64939. private _engine;
  64940. private _effect;
  64941. private _cachedDefines;
  64942. private _savedDepthWrite;
  64943. /**
  64944. * Instantiates a new outline renderer. (There could be only one per scene).
  64945. * @param scene Defines the scene it belongs to
  64946. */
  64947. constructor(scene: Scene);
  64948. /**
  64949. * Register the component to one instance of a scene.
  64950. */
  64951. register(): void;
  64952. /**
  64953. * Rebuilds the elements related to this component in case of
  64954. * context lost for instance.
  64955. */
  64956. rebuild(): void;
  64957. /**
  64958. * Disposes the component and the associated ressources.
  64959. */
  64960. dispose(): void;
  64961. /**
  64962. * Renders the outline in the canvas.
  64963. * @param subMesh Defines the sumesh to render
  64964. * @param batch Defines the batch of meshes in case of instances
  64965. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64966. */
  64967. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64968. /**
  64969. * Returns whether or not the outline renderer is ready for a given submesh.
  64970. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64971. * @param subMesh Defines the submesh to check readyness for
  64972. * @param useInstances Defines wheter wee are trying to render instances or not
  64973. * @returns true if ready otherwise false
  64974. */
  64975. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64976. private _beforeRenderingMesh;
  64977. private _afterRenderingMesh;
  64978. }
  64979. }
  64980. declare module "babylonjs/Rendering/index" {
  64981. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64982. export * from "babylonjs/Rendering/depthRenderer";
  64983. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64984. export * from "babylonjs/Rendering/edgesRenderer";
  64985. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64986. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64987. export * from "babylonjs/Rendering/outlineRenderer";
  64988. export * from "babylonjs/Rendering/renderingGroup";
  64989. export * from "babylonjs/Rendering/renderingManager";
  64990. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64991. }
  64992. declare module "babylonjs/Sprites/spritePackedManager" {
  64993. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64994. import { Scene } from "babylonjs/scene";
  64995. /**
  64996. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64997. * @see http://doc.babylonjs.com/babylon101/sprites
  64998. */
  64999. export class SpritePackedManager extends SpriteManager {
  65000. /** defines the packed manager's name */
  65001. name: string;
  65002. /**
  65003. * Creates a new sprite manager from a packed sprite sheet
  65004. * @param name defines the manager's name
  65005. * @param imgUrl defines the sprite sheet url
  65006. * @param capacity defines the maximum allowed number of sprites
  65007. * @param scene defines the hosting scene
  65008. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  65009. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  65010. * @param samplingMode defines the smapling mode to use with spritesheet
  65011. * @param fromPacked set to true; do not alter
  65012. */
  65013. constructor(
  65014. /** defines the packed manager's name */
  65015. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  65016. }
  65017. }
  65018. declare module "babylonjs/Sprites/index" {
  65019. export * from "babylonjs/Sprites/sprite";
  65020. export * from "babylonjs/Sprites/spriteManager";
  65021. export * from "babylonjs/Sprites/spritePackedManager";
  65022. export * from "babylonjs/Sprites/spriteSceneComponent";
  65023. }
  65024. declare module "babylonjs/States/index" {
  65025. export * from "babylonjs/States/alphaCullingState";
  65026. export * from "babylonjs/States/depthCullingState";
  65027. export * from "babylonjs/States/stencilState";
  65028. }
  65029. declare module "babylonjs/Misc/assetsManager" {
  65030. import { Scene } from "babylonjs/scene";
  65031. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65032. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65033. import { Skeleton } from "babylonjs/Bones/skeleton";
  65034. import { Observable } from "babylonjs/Misc/observable";
  65035. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  65036. import { Texture } from "babylonjs/Materials/Textures/texture";
  65037. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65038. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  65039. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65040. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  65041. /**
  65042. * Defines the list of states available for a task inside a AssetsManager
  65043. */
  65044. export enum AssetTaskState {
  65045. /**
  65046. * Initialization
  65047. */
  65048. INIT = 0,
  65049. /**
  65050. * Running
  65051. */
  65052. RUNNING = 1,
  65053. /**
  65054. * Done
  65055. */
  65056. DONE = 2,
  65057. /**
  65058. * Error
  65059. */
  65060. ERROR = 3
  65061. }
  65062. /**
  65063. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65064. */
  65065. export abstract class AbstractAssetTask {
  65066. /**
  65067. * Task name
  65068. */ name: string;
  65069. /**
  65070. * Callback called when the task is successful
  65071. */
  65072. onSuccess: (task: any) => void;
  65073. /**
  65074. * Callback called when the task is not successful
  65075. */
  65076. onError: (task: any, message?: string, exception?: any) => void;
  65077. /**
  65078. * Creates a new AssetsManager
  65079. * @param name defines the name of the task
  65080. */
  65081. constructor(
  65082. /**
  65083. * Task name
  65084. */ name: string);
  65085. private _isCompleted;
  65086. private _taskState;
  65087. private _errorObject;
  65088. /**
  65089. * Get if the task is completed
  65090. */
  65091. readonly isCompleted: boolean;
  65092. /**
  65093. * Gets the current state of the task
  65094. */
  65095. readonly taskState: AssetTaskState;
  65096. /**
  65097. * Gets the current error object (if task is in error)
  65098. */
  65099. readonly errorObject: {
  65100. message?: string;
  65101. exception?: any;
  65102. };
  65103. /**
  65104. * Internal only
  65105. * @hidden
  65106. */
  65107. _setErrorObject(message?: string, exception?: any): void;
  65108. /**
  65109. * Execute the current task
  65110. * @param scene defines the scene where you want your assets to be loaded
  65111. * @param onSuccess is a callback called when the task is successfully executed
  65112. * @param onError is a callback called if an error occurs
  65113. */
  65114. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65115. /**
  65116. * Execute the current task
  65117. * @param scene defines the scene where you want your assets to be loaded
  65118. * @param onSuccess is a callback called when the task is successfully executed
  65119. * @param onError is a callback called if an error occurs
  65120. */
  65121. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65122. /**
  65123. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65124. * This can be used with failed tasks that have the reason for failure fixed.
  65125. */
  65126. reset(): void;
  65127. private onErrorCallback;
  65128. private onDoneCallback;
  65129. }
  65130. /**
  65131. * Define the interface used by progress events raised during assets loading
  65132. */
  65133. export interface IAssetsProgressEvent {
  65134. /**
  65135. * Defines the number of remaining tasks to process
  65136. */
  65137. remainingCount: number;
  65138. /**
  65139. * Defines the total number of tasks
  65140. */
  65141. totalCount: number;
  65142. /**
  65143. * Defines the task that was just processed
  65144. */
  65145. task: AbstractAssetTask;
  65146. }
  65147. /**
  65148. * Class used to share progress information about assets loading
  65149. */
  65150. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65151. /**
  65152. * Defines the number of remaining tasks to process
  65153. */
  65154. remainingCount: number;
  65155. /**
  65156. * Defines the total number of tasks
  65157. */
  65158. totalCount: number;
  65159. /**
  65160. * Defines the task that was just processed
  65161. */
  65162. task: AbstractAssetTask;
  65163. /**
  65164. * Creates a AssetsProgressEvent
  65165. * @param remainingCount defines the number of remaining tasks to process
  65166. * @param totalCount defines the total number of tasks
  65167. * @param task defines the task that was just processed
  65168. */
  65169. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65170. }
  65171. /**
  65172. * Define a task used by AssetsManager to load meshes
  65173. */
  65174. export class MeshAssetTask extends AbstractAssetTask {
  65175. /**
  65176. * Defines the name of the task
  65177. */
  65178. name: string;
  65179. /**
  65180. * Defines the list of mesh's names you want to load
  65181. */
  65182. meshesNames: any;
  65183. /**
  65184. * Defines the root url to use as a base to load your meshes and associated resources
  65185. */
  65186. rootUrl: string;
  65187. /**
  65188. * Defines the filename of the scene to load from
  65189. */
  65190. sceneFilename: string;
  65191. /**
  65192. * Gets the list of loaded meshes
  65193. */
  65194. loadedMeshes: Array<AbstractMesh>;
  65195. /**
  65196. * Gets the list of loaded particle systems
  65197. */
  65198. loadedParticleSystems: Array<IParticleSystem>;
  65199. /**
  65200. * Gets the list of loaded skeletons
  65201. */
  65202. loadedSkeletons: Array<Skeleton>;
  65203. /**
  65204. * Gets the list of loaded animation groups
  65205. */
  65206. loadedAnimationGroups: Array<AnimationGroup>;
  65207. /**
  65208. * Callback called when the task is successful
  65209. */
  65210. onSuccess: (task: MeshAssetTask) => void;
  65211. /**
  65212. * Callback called when the task is successful
  65213. */
  65214. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65215. /**
  65216. * Creates a new MeshAssetTask
  65217. * @param name defines the name of the task
  65218. * @param meshesNames defines the list of mesh's names you want to load
  65219. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65220. * @param sceneFilename defines the filename of the scene to load from
  65221. */
  65222. constructor(
  65223. /**
  65224. * Defines the name of the task
  65225. */
  65226. name: string,
  65227. /**
  65228. * Defines the list of mesh's names you want to load
  65229. */
  65230. meshesNames: any,
  65231. /**
  65232. * Defines the root url to use as a base to load your meshes and associated resources
  65233. */
  65234. rootUrl: string,
  65235. /**
  65236. * Defines the filename of the scene to load from
  65237. */
  65238. sceneFilename: string);
  65239. /**
  65240. * Execute the current task
  65241. * @param scene defines the scene where you want your assets to be loaded
  65242. * @param onSuccess is a callback called when the task is successfully executed
  65243. * @param onError is a callback called if an error occurs
  65244. */
  65245. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65246. }
  65247. /**
  65248. * Define a task used by AssetsManager to load text content
  65249. */
  65250. export class TextFileAssetTask extends AbstractAssetTask {
  65251. /**
  65252. * Defines the name of the task
  65253. */
  65254. name: string;
  65255. /**
  65256. * Defines the location of the file to load
  65257. */
  65258. url: string;
  65259. /**
  65260. * Gets the loaded text string
  65261. */
  65262. text: string;
  65263. /**
  65264. * Callback called when the task is successful
  65265. */
  65266. onSuccess: (task: TextFileAssetTask) => void;
  65267. /**
  65268. * Callback called when the task is successful
  65269. */
  65270. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65271. /**
  65272. * Creates a new TextFileAssetTask object
  65273. * @param name defines the name of the task
  65274. * @param url defines the location of the file to load
  65275. */
  65276. constructor(
  65277. /**
  65278. * Defines the name of the task
  65279. */
  65280. name: string,
  65281. /**
  65282. * Defines the location of the file to load
  65283. */
  65284. url: string);
  65285. /**
  65286. * Execute the current task
  65287. * @param scene defines the scene where you want your assets to be loaded
  65288. * @param onSuccess is a callback called when the task is successfully executed
  65289. * @param onError is a callback called if an error occurs
  65290. */
  65291. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65292. }
  65293. /**
  65294. * Define a task used by AssetsManager to load binary data
  65295. */
  65296. export class BinaryFileAssetTask extends AbstractAssetTask {
  65297. /**
  65298. * Defines the name of the task
  65299. */
  65300. name: string;
  65301. /**
  65302. * Defines the location of the file to load
  65303. */
  65304. url: string;
  65305. /**
  65306. * Gets the lodaded data (as an array buffer)
  65307. */
  65308. data: ArrayBuffer;
  65309. /**
  65310. * Callback called when the task is successful
  65311. */
  65312. onSuccess: (task: BinaryFileAssetTask) => void;
  65313. /**
  65314. * Callback called when the task is successful
  65315. */
  65316. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65317. /**
  65318. * Creates a new BinaryFileAssetTask object
  65319. * @param name defines the name of the new task
  65320. * @param url defines the location of the file to load
  65321. */
  65322. constructor(
  65323. /**
  65324. * Defines the name of the task
  65325. */
  65326. name: string,
  65327. /**
  65328. * Defines the location of the file to load
  65329. */
  65330. url: string);
  65331. /**
  65332. * Execute the current task
  65333. * @param scene defines the scene where you want your assets to be loaded
  65334. * @param onSuccess is a callback called when the task is successfully executed
  65335. * @param onError is a callback called if an error occurs
  65336. */
  65337. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65338. }
  65339. /**
  65340. * Define a task used by AssetsManager to load images
  65341. */
  65342. export class ImageAssetTask extends AbstractAssetTask {
  65343. /**
  65344. * Defines the name of the task
  65345. */
  65346. name: string;
  65347. /**
  65348. * Defines the location of the image to load
  65349. */
  65350. url: string;
  65351. /**
  65352. * Gets the loaded images
  65353. */
  65354. image: HTMLImageElement;
  65355. /**
  65356. * Callback called when the task is successful
  65357. */
  65358. onSuccess: (task: ImageAssetTask) => void;
  65359. /**
  65360. * Callback called when the task is successful
  65361. */
  65362. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65363. /**
  65364. * Creates a new ImageAssetTask
  65365. * @param name defines the name of the task
  65366. * @param url defines the location of the image to load
  65367. */
  65368. constructor(
  65369. /**
  65370. * Defines the name of the task
  65371. */
  65372. name: string,
  65373. /**
  65374. * Defines the location of the image to load
  65375. */
  65376. url: string);
  65377. /**
  65378. * Execute the current task
  65379. * @param scene defines the scene where you want your assets to be loaded
  65380. * @param onSuccess is a callback called when the task is successfully executed
  65381. * @param onError is a callback called if an error occurs
  65382. */
  65383. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65384. }
  65385. /**
  65386. * Defines the interface used by texture loading tasks
  65387. */
  65388. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65389. /**
  65390. * Gets the loaded texture
  65391. */
  65392. texture: TEX;
  65393. }
  65394. /**
  65395. * Define a task used by AssetsManager to load 2D textures
  65396. */
  65397. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65398. /**
  65399. * Defines the name of the task
  65400. */
  65401. name: string;
  65402. /**
  65403. * Defines the location of the file to load
  65404. */
  65405. url: string;
  65406. /**
  65407. * Defines if mipmap should not be generated (default is false)
  65408. */
  65409. noMipmap?: boolean | undefined;
  65410. /**
  65411. * Defines if texture must be inverted on Y axis (default is false)
  65412. */
  65413. invertY?: boolean | undefined;
  65414. /**
  65415. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65416. */
  65417. samplingMode: number;
  65418. /**
  65419. * Gets the loaded texture
  65420. */
  65421. texture: Texture;
  65422. /**
  65423. * Callback called when the task is successful
  65424. */
  65425. onSuccess: (task: TextureAssetTask) => void;
  65426. /**
  65427. * Callback called when the task is successful
  65428. */
  65429. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65430. /**
  65431. * Creates a new TextureAssetTask object
  65432. * @param name defines the name of the task
  65433. * @param url defines the location of the file to load
  65434. * @param noMipmap defines if mipmap should not be generated (default is false)
  65435. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65436. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65437. */
  65438. constructor(
  65439. /**
  65440. * Defines the name of the task
  65441. */
  65442. name: string,
  65443. /**
  65444. * Defines the location of the file to load
  65445. */
  65446. url: string,
  65447. /**
  65448. * Defines if mipmap should not be generated (default is false)
  65449. */
  65450. noMipmap?: boolean | undefined,
  65451. /**
  65452. * Defines if texture must be inverted on Y axis (default is false)
  65453. */
  65454. invertY?: boolean | undefined,
  65455. /**
  65456. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65457. */
  65458. samplingMode?: number);
  65459. /**
  65460. * Execute the current task
  65461. * @param scene defines the scene where you want your assets to be loaded
  65462. * @param onSuccess is a callback called when the task is successfully executed
  65463. * @param onError is a callback called if an error occurs
  65464. */
  65465. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65466. }
  65467. /**
  65468. * Define a task used by AssetsManager to load cube textures
  65469. */
  65470. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65471. /**
  65472. * Defines the name of the task
  65473. */
  65474. name: string;
  65475. /**
  65476. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65477. */
  65478. url: string;
  65479. /**
  65480. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65481. */
  65482. extensions?: string[] | undefined;
  65483. /**
  65484. * Defines if mipmaps should not be generated (default is false)
  65485. */
  65486. noMipmap?: boolean | undefined;
  65487. /**
  65488. * Defines the explicit list of files (undefined by default)
  65489. */
  65490. files?: string[] | undefined;
  65491. /**
  65492. * Gets the loaded texture
  65493. */
  65494. texture: CubeTexture;
  65495. /**
  65496. * Callback called when the task is successful
  65497. */
  65498. onSuccess: (task: CubeTextureAssetTask) => void;
  65499. /**
  65500. * Callback called when the task is successful
  65501. */
  65502. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65503. /**
  65504. * Creates a new CubeTextureAssetTask
  65505. * @param name defines the name of the task
  65506. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65507. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65508. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65509. * @param files defines the explicit list of files (undefined by default)
  65510. */
  65511. constructor(
  65512. /**
  65513. * Defines the name of the task
  65514. */
  65515. name: string,
  65516. /**
  65517. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65518. */
  65519. url: string,
  65520. /**
  65521. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65522. */
  65523. extensions?: string[] | undefined,
  65524. /**
  65525. * Defines if mipmaps should not be generated (default is false)
  65526. */
  65527. noMipmap?: boolean | undefined,
  65528. /**
  65529. * Defines the explicit list of files (undefined by default)
  65530. */
  65531. files?: string[] | undefined);
  65532. /**
  65533. * Execute the current task
  65534. * @param scene defines the scene where you want your assets to be loaded
  65535. * @param onSuccess is a callback called when the task is successfully executed
  65536. * @param onError is a callback called if an error occurs
  65537. */
  65538. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65539. }
  65540. /**
  65541. * Define a task used by AssetsManager to load HDR cube textures
  65542. */
  65543. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65544. /**
  65545. * Defines the name of the task
  65546. */
  65547. name: string;
  65548. /**
  65549. * Defines the location of the file to load
  65550. */
  65551. url: string;
  65552. /**
  65553. * Defines the desired size (the more it increases the longer the generation will be)
  65554. */
  65555. size: number;
  65556. /**
  65557. * Defines if mipmaps should not be generated (default is false)
  65558. */
  65559. noMipmap: boolean;
  65560. /**
  65561. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65562. */
  65563. generateHarmonics: boolean;
  65564. /**
  65565. * 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)
  65566. */
  65567. gammaSpace: boolean;
  65568. /**
  65569. * Internal Use Only
  65570. */
  65571. reserved: boolean;
  65572. /**
  65573. * Gets the loaded texture
  65574. */
  65575. texture: HDRCubeTexture;
  65576. /**
  65577. * Callback called when the task is successful
  65578. */
  65579. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65580. /**
  65581. * Callback called when the task is successful
  65582. */
  65583. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65584. /**
  65585. * Creates a new HDRCubeTextureAssetTask object
  65586. * @param name defines the name of the task
  65587. * @param url defines the location of the file to load
  65588. * @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.
  65589. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65590. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65591. * @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)
  65592. * @param reserved Internal use only
  65593. */
  65594. constructor(
  65595. /**
  65596. * Defines the name of the task
  65597. */
  65598. name: string,
  65599. /**
  65600. * Defines the location of the file to load
  65601. */
  65602. url: string,
  65603. /**
  65604. * Defines the desired size (the more it increases the longer the generation will be)
  65605. */
  65606. size: number,
  65607. /**
  65608. * Defines if mipmaps should not be generated (default is false)
  65609. */
  65610. noMipmap?: boolean,
  65611. /**
  65612. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65613. */
  65614. generateHarmonics?: boolean,
  65615. /**
  65616. * 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)
  65617. */
  65618. gammaSpace?: boolean,
  65619. /**
  65620. * Internal Use Only
  65621. */
  65622. reserved?: boolean);
  65623. /**
  65624. * Execute the current task
  65625. * @param scene defines the scene where you want your assets to be loaded
  65626. * @param onSuccess is a callback called when the task is successfully executed
  65627. * @param onError is a callback called if an error occurs
  65628. */
  65629. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65630. }
  65631. /**
  65632. * Define a task used by AssetsManager to load Equirectangular cube textures
  65633. */
  65634. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65635. /**
  65636. * Defines the name of the task
  65637. */
  65638. name: string;
  65639. /**
  65640. * Defines the location of the file to load
  65641. */
  65642. url: string;
  65643. /**
  65644. * Defines the desired size (the more it increases the longer the generation will be)
  65645. */
  65646. size: number;
  65647. /**
  65648. * Defines if mipmaps should not be generated (default is false)
  65649. */
  65650. noMipmap: boolean;
  65651. /**
  65652. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65653. * but the standard material would require them in Gamma space) (default is true)
  65654. */
  65655. gammaSpace: boolean;
  65656. /**
  65657. * Gets the loaded texture
  65658. */
  65659. texture: EquiRectangularCubeTexture;
  65660. /**
  65661. * Callback called when the task is successful
  65662. */
  65663. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65664. /**
  65665. * Callback called when the task is successful
  65666. */
  65667. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65668. /**
  65669. * Creates a new EquiRectangularCubeTextureAssetTask object
  65670. * @param name defines the name of the task
  65671. * @param url defines the location of the file to load
  65672. * @param size defines the desired size (the more it increases the longer the generation will be)
  65673. * If the size is omitted this implies you are using a preprocessed cubemap.
  65674. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65675. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65676. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65677. * (default is true)
  65678. */
  65679. constructor(
  65680. /**
  65681. * Defines the name of the task
  65682. */
  65683. name: string,
  65684. /**
  65685. * Defines the location of the file to load
  65686. */
  65687. url: string,
  65688. /**
  65689. * Defines the desired size (the more it increases the longer the generation will be)
  65690. */
  65691. size: number,
  65692. /**
  65693. * Defines if mipmaps should not be generated (default is false)
  65694. */
  65695. noMipmap?: boolean,
  65696. /**
  65697. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65698. * but the standard material would require them in Gamma space) (default is true)
  65699. */
  65700. gammaSpace?: boolean);
  65701. /**
  65702. * Execute the current task
  65703. * @param scene defines the scene where you want your assets to be loaded
  65704. * @param onSuccess is a callback called when the task is successfully executed
  65705. * @param onError is a callback called if an error occurs
  65706. */
  65707. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65708. }
  65709. /**
  65710. * This class can be used to easily import assets into a scene
  65711. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65712. */
  65713. export class AssetsManager {
  65714. private _scene;
  65715. private _isLoading;
  65716. protected _tasks: AbstractAssetTask[];
  65717. protected _waitingTasksCount: number;
  65718. protected _totalTasksCount: number;
  65719. /**
  65720. * Callback called when all tasks are processed
  65721. */
  65722. onFinish: (tasks: AbstractAssetTask[]) => void;
  65723. /**
  65724. * Callback called when a task is successful
  65725. */
  65726. onTaskSuccess: (task: AbstractAssetTask) => void;
  65727. /**
  65728. * Callback called when a task had an error
  65729. */
  65730. onTaskError: (task: AbstractAssetTask) => void;
  65731. /**
  65732. * Callback called when a task is done (whatever the result is)
  65733. */
  65734. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65735. /**
  65736. * Observable called when all tasks are processed
  65737. */
  65738. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65739. /**
  65740. * Observable called when a task had an error
  65741. */
  65742. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65743. /**
  65744. * Observable called when all tasks were executed
  65745. */
  65746. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65747. /**
  65748. * Observable called when a task is done (whatever the result is)
  65749. */
  65750. onProgressObservable: Observable<IAssetsProgressEvent>;
  65751. /**
  65752. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65753. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65754. */
  65755. useDefaultLoadingScreen: boolean;
  65756. /**
  65757. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65758. * when all assets have been downloaded.
  65759. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65760. */
  65761. autoHideLoadingUI: boolean;
  65762. /**
  65763. * Creates a new AssetsManager
  65764. * @param scene defines the scene to work on
  65765. */
  65766. constructor(scene: Scene);
  65767. /**
  65768. * Add a MeshAssetTask to the list of active tasks
  65769. * @param taskName defines the name of the new task
  65770. * @param meshesNames defines the name of meshes to load
  65771. * @param rootUrl defines the root url to use to locate files
  65772. * @param sceneFilename defines the filename of the scene file
  65773. * @returns a new MeshAssetTask object
  65774. */
  65775. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65776. /**
  65777. * Add a TextFileAssetTask to the list of active tasks
  65778. * @param taskName defines the name of the new task
  65779. * @param url defines the url of the file to load
  65780. * @returns a new TextFileAssetTask object
  65781. */
  65782. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65783. /**
  65784. * Add a BinaryFileAssetTask to the list of active tasks
  65785. * @param taskName defines the name of the new task
  65786. * @param url defines the url of the file to load
  65787. * @returns a new BinaryFileAssetTask object
  65788. */
  65789. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65790. /**
  65791. * Add a ImageAssetTask to the list of active tasks
  65792. * @param taskName defines the name of the new task
  65793. * @param url defines the url of the file to load
  65794. * @returns a new ImageAssetTask object
  65795. */
  65796. addImageTask(taskName: string, url: string): ImageAssetTask;
  65797. /**
  65798. * Add a TextureAssetTask to the list of active tasks
  65799. * @param taskName defines the name of the new task
  65800. * @param url defines the url of the file to load
  65801. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65802. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65803. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65804. * @returns a new TextureAssetTask object
  65805. */
  65806. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65807. /**
  65808. * Add a CubeTextureAssetTask to the list of active tasks
  65809. * @param taskName defines the name of the new task
  65810. * @param url defines the url of the file to load
  65811. * @param extensions defines the extension to use to load the cube map (can be null)
  65812. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65813. * @param files defines the list of files to load (can be null)
  65814. * @returns a new CubeTextureAssetTask object
  65815. */
  65816. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65817. /**
  65818. *
  65819. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65820. * @param taskName defines the name of the new task
  65821. * @param url defines the url of the file to load
  65822. * @param size defines the size you want for the cubemap (can be null)
  65823. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65824. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65825. * @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)
  65826. * @param reserved Internal use only
  65827. * @returns a new HDRCubeTextureAssetTask object
  65828. */
  65829. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65830. /**
  65831. *
  65832. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65833. * @param taskName defines the name of the new task
  65834. * @param url defines the url of the file to load
  65835. * @param size defines the size you want for the cubemap (can be null)
  65836. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65837. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65838. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65839. * @returns a new EquiRectangularCubeTextureAssetTask object
  65840. */
  65841. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65842. /**
  65843. * Remove a task from the assets manager.
  65844. * @param task the task to remove
  65845. */
  65846. removeTask(task: AbstractAssetTask): void;
  65847. private _decreaseWaitingTasksCount;
  65848. private _runTask;
  65849. /**
  65850. * Reset the AssetsManager and remove all tasks
  65851. * @return the current instance of the AssetsManager
  65852. */
  65853. reset(): AssetsManager;
  65854. /**
  65855. * Start the loading process
  65856. * @return the current instance of the AssetsManager
  65857. */
  65858. load(): AssetsManager;
  65859. /**
  65860. * Start the loading process as an async operation
  65861. * @return a promise returning the list of failed tasks
  65862. */
  65863. loadAsync(): Promise<void>;
  65864. }
  65865. }
  65866. declare module "babylonjs/Misc/deferred" {
  65867. /**
  65868. * Wrapper class for promise with external resolve and reject.
  65869. */
  65870. export class Deferred<T> {
  65871. /**
  65872. * The promise associated with this deferred object.
  65873. */
  65874. readonly promise: Promise<T>;
  65875. private _resolve;
  65876. private _reject;
  65877. /**
  65878. * The resolve method of the promise associated with this deferred object.
  65879. */
  65880. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65881. /**
  65882. * The reject method of the promise associated with this deferred object.
  65883. */
  65884. readonly reject: (reason?: any) => void;
  65885. /**
  65886. * Constructor for this deferred object.
  65887. */
  65888. constructor();
  65889. }
  65890. }
  65891. declare module "babylonjs/Misc/meshExploder" {
  65892. import { Mesh } from "babylonjs/Meshes/mesh";
  65893. /**
  65894. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65895. */
  65896. export class MeshExploder {
  65897. private _centerMesh;
  65898. private _meshes;
  65899. private _meshesOrigins;
  65900. private _toCenterVectors;
  65901. private _scaledDirection;
  65902. private _newPosition;
  65903. private _centerPosition;
  65904. /**
  65905. * Explodes meshes from a center mesh.
  65906. * @param meshes The meshes to explode.
  65907. * @param centerMesh The mesh to be center of explosion.
  65908. */
  65909. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65910. private _setCenterMesh;
  65911. /**
  65912. * Get class name
  65913. * @returns "MeshExploder"
  65914. */
  65915. getClassName(): string;
  65916. /**
  65917. * "Exploded meshes"
  65918. * @returns Array of meshes with the centerMesh at index 0.
  65919. */
  65920. getMeshes(): Array<Mesh>;
  65921. /**
  65922. * Explodes meshes giving a specific direction
  65923. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65924. */
  65925. explode(direction?: number): void;
  65926. }
  65927. }
  65928. declare module "babylonjs/Misc/filesInput" {
  65929. import { Engine } from "babylonjs/Engines/engine";
  65930. import { Scene } from "babylonjs/scene";
  65931. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65932. /**
  65933. * Class used to help managing file picking and drag'n'drop
  65934. */
  65935. export class FilesInput {
  65936. /**
  65937. * List of files ready to be loaded
  65938. */
  65939. static readonly FilesToLoad: {
  65940. [key: string]: File;
  65941. };
  65942. /**
  65943. * Callback called when a file is processed
  65944. */
  65945. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65946. private _engine;
  65947. private _currentScene;
  65948. private _sceneLoadedCallback;
  65949. private _progressCallback;
  65950. private _additionalRenderLoopLogicCallback;
  65951. private _textureLoadingCallback;
  65952. private _startingProcessingFilesCallback;
  65953. private _onReloadCallback;
  65954. private _errorCallback;
  65955. private _elementToMonitor;
  65956. private _sceneFileToLoad;
  65957. private _filesToLoad;
  65958. /**
  65959. * Creates a new FilesInput
  65960. * @param engine defines the rendering engine
  65961. * @param scene defines the hosting scene
  65962. * @param sceneLoadedCallback callback called when scene is loaded
  65963. * @param progressCallback callback called to track progress
  65964. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65965. * @param textureLoadingCallback callback called when a texture is loading
  65966. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65967. * @param onReloadCallback callback called when a reload is requested
  65968. * @param errorCallback callback call if an error occurs
  65969. */
  65970. 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);
  65971. private _dragEnterHandler;
  65972. private _dragOverHandler;
  65973. private _dropHandler;
  65974. /**
  65975. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65976. * @param elementToMonitor defines the DOM element to track
  65977. */
  65978. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65979. /**
  65980. * Release all associated resources
  65981. */
  65982. dispose(): void;
  65983. private renderFunction;
  65984. private drag;
  65985. private drop;
  65986. private _traverseFolder;
  65987. private _processFiles;
  65988. /**
  65989. * Load files from a drop event
  65990. * @param event defines the drop event to use as source
  65991. */
  65992. loadFiles(event: any): void;
  65993. private _processReload;
  65994. /**
  65995. * Reload the current scene from the loaded files
  65996. */
  65997. reload(): void;
  65998. }
  65999. }
  66000. declare module "babylonjs/Misc/HighDynamicRange/index" {
  66001. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  66002. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  66003. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  66004. }
  66005. declare module "babylonjs/Misc/sceneOptimizer" {
  66006. import { Scene, IDisposable } from "babylonjs/scene";
  66007. import { Observable } from "babylonjs/Misc/observable";
  66008. /**
  66009. * Defines the root class used to create scene optimization to use with SceneOptimizer
  66010. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66011. */
  66012. export class SceneOptimization {
  66013. /**
  66014. * Defines the priority of this optimization (0 by default which means first in the list)
  66015. */
  66016. priority: number;
  66017. /**
  66018. * Gets a string describing the action executed by the current optimization
  66019. * @returns description string
  66020. */
  66021. getDescription(): string;
  66022. /**
  66023. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66024. * @param scene defines the current scene where to apply this optimization
  66025. * @param optimizer defines the current optimizer
  66026. * @returns true if everything that can be done was applied
  66027. */
  66028. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66029. /**
  66030. * Creates the SceneOptimization object
  66031. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66032. * @param desc defines the description associated with the optimization
  66033. */
  66034. constructor(
  66035. /**
  66036. * Defines the priority of this optimization (0 by default which means first in the list)
  66037. */
  66038. priority?: number);
  66039. }
  66040. /**
  66041. * Defines an optimization used to reduce the size of render target textures
  66042. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66043. */
  66044. export class TextureOptimization extends SceneOptimization {
  66045. /**
  66046. * Defines the priority of this optimization (0 by default which means first in the list)
  66047. */
  66048. priority: number;
  66049. /**
  66050. * 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
  66051. */
  66052. maximumSize: number;
  66053. /**
  66054. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66055. */
  66056. step: number;
  66057. /**
  66058. * Gets a string describing the action executed by the current optimization
  66059. * @returns description string
  66060. */
  66061. getDescription(): string;
  66062. /**
  66063. * Creates the TextureOptimization object
  66064. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66065. * @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
  66066. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66067. */
  66068. constructor(
  66069. /**
  66070. * Defines the priority of this optimization (0 by default which means first in the list)
  66071. */
  66072. priority?: number,
  66073. /**
  66074. * 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
  66075. */
  66076. maximumSize?: number,
  66077. /**
  66078. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66079. */
  66080. step?: number);
  66081. /**
  66082. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66083. * @param scene defines the current scene where to apply this optimization
  66084. * @param optimizer defines the current optimizer
  66085. * @returns true if everything that can be done was applied
  66086. */
  66087. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66088. }
  66089. /**
  66090. * Defines an optimization used to increase or decrease the rendering resolution
  66091. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66092. */
  66093. export class HardwareScalingOptimization extends SceneOptimization {
  66094. /**
  66095. * Defines the priority of this optimization (0 by default which means first in the list)
  66096. */
  66097. priority: number;
  66098. /**
  66099. * Defines the maximum scale to use (2 by default)
  66100. */
  66101. maximumScale: number;
  66102. /**
  66103. * Defines the step to use between two passes (0.5 by default)
  66104. */
  66105. step: number;
  66106. private _currentScale;
  66107. private _directionOffset;
  66108. /**
  66109. * Gets a string describing the action executed by the current optimization
  66110. * @return description string
  66111. */
  66112. getDescription(): string;
  66113. /**
  66114. * Creates the HardwareScalingOptimization object
  66115. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66116. * @param maximumScale defines the maximum scale to use (2 by default)
  66117. * @param step defines the step to use between two passes (0.5 by default)
  66118. */
  66119. constructor(
  66120. /**
  66121. * Defines the priority of this optimization (0 by default which means first in the list)
  66122. */
  66123. priority?: number,
  66124. /**
  66125. * Defines the maximum scale to use (2 by default)
  66126. */
  66127. maximumScale?: number,
  66128. /**
  66129. * Defines the step to use between two passes (0.5 by default)
  66130. */
  66131. step?: number);
  66132. /**
  66133. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66134. * @param scene defines the current scene where to apply this optimization
  66135. * @param optimizer defines the current optimizer
  66136. * @returns true if everything that can be done was applied
  66137. */
  66138. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66139. }
  66140. /**
  66141. * Defines an optimization used to remove shadows
  66142. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66143. */
  66144. export class ShadowsOptimization extends SceneOptimization {
  66145. /**
  66146. * Gets a string describing the action executed by the current optimization
  66147. * @return description string
  66148. */
  66149. getDescription(): string;
  66150. /**
  66151. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66152. * @param scene defines the current scene where to apply this optimization
  66153. * @param optimizer defines the current optimizer
  66154. * @returns true if everything that can be done was applied
  66155. */
  66156. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66157. }
  66158. /**
  66159. * Defines an optimization used to turn post-processes off
  66160. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66161. */
  66162. export class PostProcessesOptimization extends SceneOptimization {
  66163. /**
  66164. * Gets a string describing the action executed by the current optimization
  66165. * @return description string
  66166. */
  66167. getDescription(): string;
  66168. /**
  66169. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66170. * @param scene defines the current scene where to apply this optimization
  66171. * @param optimizer defines the current optimizer
  66172. * @returns true if everything that can be done was applied
  66173. */
  66174. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66175. }
  66176. /**
  66177. * Defines an optimization used to turn lens flares off
  66178. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66179. */
  66180. export class LensFlaresOptimization extends SceneOptimization {
  66181. /**
  66182. * Gets a string describing the action executed by the current optimization
  66183. * @return description string
  66184. */
  66185. getDescription(): string;
  66186. /**
  66187. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66188. * @param scene defines the current scene where to apply this optimization
  66189. * @param optimizer defines the current optimizer
  66190. * @returns true if everything that can be done was applied
  66191. */
  66192. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66193. }
  66194. /**
  66195. * Defines an optimization based on user defined callback.
  66196. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66197. */
  66198. export class CustomOptimization extends SceneOptimization {
  66199. /**
  66200. * Callback called to apply the custom optimization.
  66201. */
  66202. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66203. /**
  66204. * Callback called to get custom description
  66205. */
  66206. onGetDescription: () => string;
  66207. /**
  66208. * Gets a string describing the action executed by the current optimization
  66209. * @returns description string
  66210. */
  66211. getDescription(): string;
  66212. /**
  66213. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66214. * @param scene defines the current scene where to apply this optimization
  66215. * @param optimizer defines the current optimizer
  66216. * @returns true if everything that can be done was applied
  66217. */
  66218. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66219. }
  66220. /**
  66221. * Defines an optimization used to turn particles off
  66222. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66223. */
  66224. export class ParticlesOptimization extends SceneOptimization {
  66225. /**
  66226. * Gets a string describing the action executed by the current optimization
  66227. * @return description string
  66228. */
  66229. getDescription(): string;
  66230. /**
  66231. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66232. * @param scene defines the current scene where to apply this optimization
  66233. * @param optimizer defines the current optimizer
  66234. * @returns true if everything that can be done was applied
  66235. */
  66236. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66237. }
  66238. /**
  66239. * Defines an optimization used to turn render targets off
  66240. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66241. */
  66242. export class RenderTargetsOptimization extends SceneOptimization {
  66243. /**
  66244. * Gets a string describing the action executed by the current optimization
  66245. * @return description string
  66246. */
  66247. getDescription(): string;
  66248. /**
  66249. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66250. * @param scene defines the current scene where to apply this optimization
  66251. * @param optimizer defines the current optimizer
  66252. * @returns true if everything that can be done was applied
  66253. */
  66254. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66255. }
  66256. /**
  66257. * Defines an optimization used to merge meshes with compatible materials
  66258. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66259. */
  66260. export class MergeMeshesOptimization extends SceneOptimization {
  66261. private static _UpdateSelectionTree;
  66262. /**
  66263. * Gets or sets a boolean which defines if optimization octree has to be updated
  66264. */
  66265. /**
  66266. * Gets or sets a boolean which defines if optimization octree has to be updated
  66267. */
  66268. static UpdateSelectionTree: boolean;
  66269. /**
  66270. * Gets a string describing the action executed by the current optimization
  66271. * @return description string
  66272. */
  66273. getDescription(): string;
  66274. private _canBeMerged;
  66275. /**
  66276. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66277. * @param scene defines the current scene where to apply this optimization
  66278. * @param optimizer defines the current optimizer
  66279. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66280. * @returns true if everything that can be done was applied
  66281. */
  66282. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66283. }
  66284. /**
  66285. * Defines a list of options used by SceneOptimizer
  66286. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66287. */
  66288. export class SceneOptimizerOptions {
  66289. /**
  66290. * Defines the target frame rate to reach (60 by default)
  66291. */
  66292. targetFrameRate: number;
  66293. /**
  66294. * Defines the interval between two checkes (2000ms by default)
  66295. */
  66296. trackerDuration: number;
  66297. /**
  66298. * Gets the list of optimizations to apply
  66299. */
  66300. optimizations: SceneOptimization[];
  66301. /**
  66302. * Creates a new list of options used by SceneOptimizer
  66303. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66304. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66305. */
  66306. constructor(
  66307. /**
  66308. * Defines the target frame rate to reach (60 by default)
  66309. */
  66310. targetFrameRate?: number,
  66311. /**
  66312. * Defines the interval between two checkes (2000ms by default)
  66313. */
  66314. trackerDuration?: number);
  66315. /**
  66316. * Add a new optimization
  66317. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66318. * @returns the current SceneOptimizerOptions
  66319. */
  66320. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66321. /**
  66322. * Add a new custom optimization
  66323. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66324. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66325. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66326. * @returns the current SceneOptimizerOptions
  66327. */
  66328. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66329. /**
  66330. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66331. * @param targetFrameRate defines the target frame rate (60 by default)
  66332. * @returns a SceneOptimizerOptions object
  66333. */
  66334. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66335. /**
  66336. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66337. * @param targetFrameRate defines the target frame rate (60 by default)
  66338. * @returns a SceneOptimizerOptions object
  66339. */
  66340. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66341. /**
  66342. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66343. * @param targetFrameRate defines the target frame rate (60 by default)
  66344. * @returns a SceneOptimizerOptions object
  66345. */
  66346. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66347. }
  66348. /**
  66349. * Class used to run optimizations in order to reach a target frame rate
  66350. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66351. */
  66352. export class SceneOptimizer implements IDisposable {
  66353. private _isRunning;
  66354. private _options;
  66355. private _scene;
  66356. private _currentPriorityLevel;
  66357. private _targetFrameRate;
  66358. private _trackerDuration;
  66359. private _currentFrameRate;
  66360. private _sceneDisposeObserver;
  66361. private _improvementMode;
  66362. /**
  66363. * Defines an observable called when the optimizer reaches the target frame rate
  66364. */
  66365. onSuccessObservable: Observable<SceneOptimizer>;
  66366. /**
  66367. * Defines an observable called when the optimizer enables an optimization
  66368. */
  66369. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66370. /**
  66371. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66372. */
  66373. onFailureObservable: Observable<SceneOptimizer>;
  66374. /**
  66375. * Gets a boolean indicating if the optimizer is in improvement mode
  66376. */
  66377. readonly isInImprovementMode: boolean;
  66378. /**
  66379. * Gets the current priority level (0 at start)
  66380. */
  66381. readonly currentPriorityLevel: number;
  66382. /**
  66383. * Gets the current frame rate checked by the SceneOptimizer
  66384. */
  66385. readonly currentFrameRate: number;
  66386. /**
  66387. * Gets or sets the current target frame rate (60 by default)
  66388. */
  66389. /**
  66390. * Gets or sets the current target frame rate (60 by default)
  66391. */
  66392. targetFrameRate: number;
  66393. /**
  66394. * Gets or sets the current interval between two checks (every 2000ms by default)
  66395. */
  66396. /**
  66397. * Gets or sets the current interval between two checks (every 2000ms by default)
  66398. */
  66399. trackerDuration: number;
  66400. /**
  66401. * Gets the list of active optimizations
  66402. */
  66403. readonly optimizations: SceneOptimization[];
  66404. /**
  66405. * Creates a new SceneOptimizer
  66406. * @param scene defines the scene to work on
  66407. * @param options defines the options to use with the SceneOptimizer
  66408. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66409. * @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)
  66410. */
  66411. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66412. /**
  66413. * Stops the current optimizer
  66414. */
  66415. stop(): void;
  66416. /**
  66417. * Reset the optimizer to initial step (current priority level = 0)
  66418. */
  66419. reset(): void;
  66420. /**
  66421. * Start the optimizer. By default it will try to reach a specific framerate
  66422. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66423. */
  66424. start(): void;
  66425. private _checkCurrentState;
  66426. /**
  66427. * Release all resources
  66428. */
  66429. dispose(): void;
  66430. /**
  66431. * Helper function to create a SceneOptimizer with one single line of code
  66432. * @param scene defines the scene to work on
  66433. * @param options defines the options to use with the SceneOptimizer
  66434. * @param onSuccess defines a callback to call on success
  66435. * @param onFailure defines a callback to call on failure
  66436. * @returns the new SceneOptimizer object
  66437. */
  66438. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66439. }
  66440. }
  66441. declare module "babylonjs/Misc/sceneSerializer" {
  66442. import { Scene } from "babylonjs/scene";
  66443. /**
  66444. * Class used to serialize a scene into a string
  66445. */
  66446. export class SceneSerializer {
  66447. /**
  66448. * Clear cache used by a previous serialization
  66449. */
  66450. static ClearCache(): void;
  66451. /**
  66452. * Serialize a scene into a JSON compatible object
  66453. * @param scene defines the scene to serialize
  66454. * @returns a JSON compatible object
  66455. */
  66456. static Serialize(scene: Scene): any;
  66457. /**
  66458. * Serialize a mesh into a JSON compatible object
  66459. * @param toSerialize defines the mesh to serialize
  66460. * @param withParents defines if parents must be serialized as well
  66461. * @param withChildren defines if children must be serialized as well
  66462. * @returns a JSON compatible object
  66463. */
  66464. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66465. }
  66466. }
  66467. declare module "babylonjs/Misc/textureTools" {
  66468. import { Texture } from "babylonjs/Materials/Textures/texture";
  66469. /**
  66470. * Class used to host texture specific utilities
  66471. */
  66472. export class TextureTools {
  66473. /**
  66474. * Uses the GPU to create a copy texture rescaled at a given size
  66475. * @param texture Texture to copy from
  66476. * @param width defines the desired width
  66477. * @param height defines the desired height
  66478. * @param useBilinearMode defines if bilinear mode has to be used
  66479. * @return the generated texture
  66480. */
  66481. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66482. }
  66483. }
  66484. declare module "babylonjs/Misc/videoRecorder" {
  66485. import { Nullable } from "babylonjs/types";
  66486. import { Engine } from "babylonjs/Engines/engine";
  66487. /**
  66488. * This represents the different options available for the video capture.
  66489. */
  66490. export interface VideoRecorderOptions {
  66491. /** Defines the mime type of the video. */
  66492. mimeType: string;
  66493. /** Defines the FPS the video should be recorded at. */
  66494. fps: number;
  66495. /** Defines the chunk size for the recording data. */
  66496. recordChunckSize: number;
  66497. /** The audio tracks to attach to the recording. */
  66498. audioTracks?: MediaStreamTrack[];
  66499. }
  66500. /**
  66501. * This can help with recording videos from BabylonJS.
  66502. * This is based on the available WebRTC functionalities of the browser.
  66503. *
  66504. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66505. */
  66506. export class VideoRecorder {
  66507. private static readonly _defaultOptions;
  66508. /**
  66509. * Returns whether or not the VideoRecorder is available in your browser.
  66510. * @param engine Defines the Babylon Engine.
  66511. * @returns true if supported otherwise false.
  66512. */
  66513. static IsSupported(engine: Engine): boolean;
  66514. private readonly _options;
  66515. private _canvas;
  66516. private _mediaRecorder;
  66517. private _recordedChunks;
  66518. private _fileName;
  66519. private _resolve;
  66520. private _reject;
  66521. /**
  66522. * True when a recording is already in progress.
  66523. */
  66524. readonly isRecording: boolean;
  66525. /**
  66526. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66527. * @param engine Defines the BabylonJS Engine you wish to record.
  66528. * @param options Defines options that can be used to customize the capture.
  66529. */
  66530. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66531. /**
  66532. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66533. */
  66534. stopRecording(): void;
  66535. /**
  66536. * Starts recording the canvas for a max duration specified in parameters.
  66537. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66538. * If null no automatic download will start and you can rely on the promise to get the data back.
  66539. * @param maxDuration Defines the maximum recording time in seconds.
  66540. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66541. * @return A promise callback at the end of the recording with the video data in Blob.
  66542. */
  66543. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66544. /**
  66545. * Releases internal resources used during the recording.
  66546. */
  66547. dispose(): void;
  66548. private _handleDataAvailable;
  66549. private _handleError;
  66550. private _handleStop;
  66551. }
  66552. }
  66553. declare module "babylonjs/Misc/screenshotTools" {
  66554. import { Camera } from "babylonjs/Cameras/camera";
  66555. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66556. import { Engine } from "babylonjs/Engines/engine";
  66557. /**
  66558. * Class containing a set of static utilities functions for screenshots
  66559. */
  66560. export class ScreenshotTools {
  66561. /**
  66562. * Captures a screenshot of the current rendering
  66563. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66564. * @param engine defines the rendering engine
  66565. * @param camera defines the source camera
  66566. * @param size This parameter can be set to a single number or to an object with the
  66567. * following (optional) properties: precision, width, height. If a single number is passed,
  66568. * it will be used for both width and height. If an object is passed, the screenshot size
  66569. * will be derived from the parameters. The precision property is a multiplier allowing
  66570. * rendering at a higher or lower resolution
  66571. * @param successCallback defines the callback receives a single parameter which contains the
  66572. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66573. * src parameter of an <img> to display it
  66574. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66575. * Check your browser for supported MIME types
  66576. */
  66577. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66578. /**
  66579. * Captures a screenshot of the current rendering
  66580. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66581. * @param engine defines the rendering engine
  66582. * @param camera defines the source camera
  66583. * @param size This parameter can be set to a single number or to an object with the
  66584. * following (optional) properties: precision, width, height. If a single number is passed,
  66585. * it will be used for both width and height. If an object is passed, the screenshot size
  66586. * will be derived from the parameters. The precision property is a multiplier allowing
  66587. * rendering at a higher or lower resolution
  66588. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66589. * Check your browser for supported MIME types
  66590. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66591. * to the src parameter of an <img> to display it
  66592. */
  66593. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66594. /**
  66595. * Generates an image screenshot from the specified camera.
  66596. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66597. * @param engine The engine to use for rendering
  66598. * @param camera The camera to use for rendering
  66599. * @param size This parameter can be set to a single number or to an object with the
  66600. * following (optional) properties: precision, width, height. If a single number is passed,
  66601. * it will be used for both width and height. If an object is passed, the screenshot size
  66602. * will be derived from the parameters. The precision property is a multiplier allowing
  66603. * rendering at a higher or lower resolution
  66604. * @param successCallback The callback receives a single parameter which contains the
  66605. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66606. * src parameter of an <img> to display it
  66607. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66608. * Check your browser for supported MIME types
  66609. * @param samples Texture samples (default: 1)
  66610. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66611. * @param fileName A name for for the downloaded file.
  66612. */
  66613. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66614. /**
  66615. * Generates an image screenshot from the specified camera.
  66616. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66617. * @param engine The engine to use for rendering
  66618. * @param camera The camera to use for rendering
  66619. * @param size This parameter can be set to a single number or to an object with the
  66620. * following (optional) properties: precision, width, height. If a single number is passed,
  66621. * it will be used for both width and height. If an object is passed, the screenshot size
  66622. * will be derived from the parameters. The precision property is a multiplier allowing
  66623. * rendering at a higher or lower resolution
  66624. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66625. * Check your browser for supported MIME types
  66626. * @param samples Texture samples (default: 1)
  66627. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66628. * @param fileName A name for for the downloaded file.
  66629. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66630. * to the src parameter of an <img> to display it
  66631. */
  66632. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66633. /**
  66634. * Gets height and width for screenshot size
  66635. * @private
  66636. */
  66637. private static _getScreenshotSize;
  66638. }
  66639. }
  66640. declare module "babylonjs/Misc/index" {
  66641. export * from "babylonjs/Misc/andOrNotEvaluator";
  66642. export * from "babylonjs/Misc/assetsManager";
  66643. export * from "babylonjs/Misc/dds";
  66644. export * from "babylonjs/Misc/decorators";
  66645. export * from "babylonjs/Misc/deferred";
  66646. export * from "babylonjs/Misc/environmentTextureTools";
  66647. export * from "babylonjs/Misc/meshExploder";
  66648. export * from "babylonjs/Misc/filesInput";
  66649. export * from "babylonjs/Misc/HighDynamicRange/index";
  66650. export * from "babylonjs/Misc/khronosTextureContainer";
  66651. export * from "babylonjs/Misc/observable";
  66652. export * from "babylonjs/Misc/performanceMonitor";
  66653. export * from "babylonjs/Misc/promise";
  66654. export * from "babylonjs/Misc/sceneOptimizer";
  66655. export * from "babylonjs/Misc/sceneSerializer";
  66656. export * from "babylonjs/Misc/smartArray";
  66657. export * from "babylonjs/Misc/stringDictionary";
  66658. export * from "babylonjs/Misc/tags";
  66659. export * from "babylonjs/Misc/textureTools";
  66660. export * from "babylonjs/Misc/tga";
  66661. export * from "babylonjs/Misc/tools";
  66662. export * from "babylonjs/Misc/videoRecorder";
  66663. export * from "babylonjs/Misc/virtualJoystick";
  66664. export * from "babylonjs/Misc/workerPool";
  66665. export * from "babylonjs/Misc/logger";
  66666. export * from "babylonjs/Misc/typeStore";
  66667. export * from "babylonjs/Misc/filesInputStore";
  66668. export * from "babylonjs/Misc/deepCopier";
  66669. export * from "babylonjs/Misc/pivotTools";
  66670. export * from "babylonjs/Misc/precisionDate";
  66671. export * from "babylonjs/Misc/screenshotTools";
  66672. export * from "babylonjs/Misc/typeStore";
  66673. export * from "babylonjs/Misc/webRequest";
  66674. export * from "babylonjs/Misc/iInspectable";
  66675. export * from "babylonjs/Misc/brdfTextureTools";
  66676. export * from "babylonjs/Misc/rgbdTextureTools";
  66677. export * from "babylonjs/Misc/gradients";
  66678. export * from "babylonjs/Misc/perfCounter";
  66679. export * from "babylonjs/Misc/fileRequest";
  66680. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66681. export * from "babylonjs/Misc/retryStrategy";
  66682. export * from "babylonjs/Misc/loadFileError";
  66683. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66684. }
  66685. declare module "babylonjs/index" {
  66686. export * from "babylonjs/abstractScene";
  66687. export * from "babylonjs/Actions/index";
  66688. export * from "babylonjs/Animations/index";
  66689. export * from "babylonjs/assetContainer";
  66690. export * from "babylonjs/Audio/index";
  66691. export * from "babylonjs/Behaviors/index";
  66692. export * from "babylonjs/Bones/index";
  66693. export * from "babylonjs/Cameras/index";
  66694. export * from "babylonjs/Collisions/index";
  66695. export * from "babylonjs/Culling/index";
  66696. export * from "babylonjs/Debug/index";
  66697. export * from "babylonjs/Engines/index";
  66698. export * from "babylonjs/Events/index";
  66699. export * from "babylonjs/Gamepads/index";
  66700. export * from "babylonjs/Gizmos/index";
  66701. export * from "babylonjs/Helpers/index";
  66702. export * from "babylonjs/Instrumentation/index";
  66703. export * from "babylonjs/Layers/index";
  66704. export * from "babylonjs/LensFlares/index";
  66705. export * from "babylonjs/Lights/index";
  66706. export * from "babylonjs/Loading/index";
  66707. export * from "babylonjs/Materials/index";
  66708. export * from "babylonjs/Maths/index";
  66709. export * from "babylonjs/Meshes/index";
  66710. export * from "babylonjs/Morph/index";
  66711. export * from "babylonjs/Navigation/index";
  66712. export * from "babylonjs/node";
  66713. export * from "babylonjs/Offline/index";
  66714. export * from "babylonjs/Particles/index";
  66715. export * from "babylonjs/Physics/index";
  66716. export * from "babylonjs/PostProcesses/index";
  66717. export * from "babylonjs/Probes/index";
  66718. export * from "babylonjs/Rendering/index";
  66719. export * from "babylonjs/scene";
  66720. export * from "babylonjs/sceneComponent";
  66721. export * from "babylonjs/Sprites/index";
  66722. export * from "babylonjs/States/index";
  66723. export * from "babylonjs/Misc/index";
  66724. export * from "babylonjs/types";
  66725. }
  66726. declare module "babylonjs/Animations/pathCursor" {
  66727. import { Vector3 } from "babylonjs/Maths/math.vector";
  66728. import { Path2 } from "babylonjs/Maths/math.path";
  66729. /**
  66730. * A cursor which tracks a point on a path
  66731. */
  66732. export class PathCursor {
  66733. private path;
  66734. /**
  66735. * Stores path cursor callbacks for when an onchange event is triggered
  66736. */
  66737. private _onchange;
  66738. /**
  66739. * The value of the path cursor
  66740. */
  66741. value: number;
  66742. /**
  66743. * The animation array of the path cursor
  66744. */
  66745. animations: Animation[];
  66746. /**
  66747. * Initializes the path cursor
  66748. * @param path The path to track
  66749. */
  66750. constructor(path: Path2);
  66751. /**
  66752. * Gets the cursor point on the path
  66753. * @returns A point on the path cursor at the cursor location
  66754. */
  66755. getPoint(): Vector3;
  66756. /**
  66757. * Moves the cursor ahead by the step amount
  66758. * @param step The amount to move the cursor forward
  66759. * @returns This path cursor
  66760. */
  66761. moveAhead(step?: number): PathCursor;
  66762. /**
  66763. * Moves the cursor behind by the step amount
  66764. * @param step The amount to move the cursor back
  66765. * @returns This path cursor
  66766. */
  66767. moveBack(step?: number): PathCursor;
  66768. /**
  66769. * Moves the cursor by the step amount
  66770. * If the step amount is greater than one, an exception is thrown
  66771. * @param step The amount to move the cursor
  66772. * @returns This path cursor
  66773. */
  66774. move(step: number): PathCursor;
  66775. /**
  66776. * Ensures that the value is limited between zero and one
  66777. * @returns This path cursor
  66778. */
  66779. private ensureLimits;
  66780. /**
  66781. * Runs onchange callbacks on change (used by the animation engine)
  66782. * @returns This path cursor
  66783. */
  66784. private raiseOnChange;
  66785. /**
  66786. * Executes a function on change
  66787. * @param f A path cursor onchange callback
  66788. * @returns This path cursor
  66789. */
  66790. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66791. }
  66792. }
  66793. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66794. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66795. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66796. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66797. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66798. }
  66799. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66800. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66801. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66802. }
  66803. declare module "babylonjs/Engines/Processors/index" {
  66804. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66805. export * from "babylonjs/Engines/Processors/Expressions/index";
  66806. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66807. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66808. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66809. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66810. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66811. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66812. }
  66813. declare module "babylonjs/Legacy/legacy" {
  66814. import * as Babylon from "babylonjs/index";
  66815. export * from "babylonjs/index";
  66816. }
  66817. declare module "babylonjs/Shaders/blur.fragment" {
  66818. /** @hidden */
  66819. export var blurPixelShader: {
  66820. name: string;
  66821. shader: string;
  66822. };
  66823. }
  66824. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66825. /** @hidden */
  66826. export var pointCloudVertexDeclaration: {
  66827. name: string;
  66828. shader: string;
  66829. };
  66830. }
  66831. declare module "babylonjs" {
  66832. export * from "babylonjs/Legacy/legacy";
  66833. }
  66834. declare module BABYLON {
  66835. /** Alias type for value that can be null */
  66836. export type Nullable<T> = T | null;
  66837. /**
  66838. * Alias type for number that are floats
  66839. * @ignorenaming
  66840. */
  66841. export type float = number;
  66842. /**
  66843. * Alias type for number that are doubles.
  66844. * @ignorenaming
  66845. */
  66846. export type double = number;
  66847. /**
  66848. * Alias type for number that are integer
  66849. * @ignorenaming
  66850. */
  66851. export type int = number;
  66852. /** Alias type for number array or Float32Array */
  66853. export type FloatArray = number[] | Float32Array;
  66854. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66855. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66856. /**
  66857. * Alias for types that can be used by a Buffer or VertexBuffer.
  66858. */
  66859. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66860. /**
  66861. * Alias type for primitive types
  66862. * @ignorenaming
  66863. */
  66864. type Primitive = undefined | null | boolean | string | number | Function;
  66865. /**
  66866. * Type modifier to make all the properties of an object Readonly
  66867. */
  66868. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66869. /**
  66870. * Type modifier to make all the properties of an object Readonly recursively
  66871. */
  66872. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66873. /**
  66874. * Type modifier to make object properties readonly.
  66875. */
  66876. export type DeepImmutableObject<T> = {
  66877. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66878. };
  66879. /** @hidden */
  66880. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66881. }
  66882. }
  66883. declare module BABYLON {
  66884. /**
  66885. * A class serves as a medium between the observable and its observers
  66886. */
  66887. export class EventState {
  66888. /**
  66889. * Create a new EventState
  66890. * @param mask defines the mask associated with this state
  66891. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66892. * @param target defines the original target of the state
  66893. * @param currentTarget defines the current target of the state
  66894. */
  66895. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66896. /**
  66897. * Initialize the current event state
  66898. * @param mask defines the mask associated with this state
  66899. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66900. * @param target defines the original target of the state
  66901. * @param currentTarget defines the current target of the state
  66902. * @returns the current event state
  66903. */
  66904. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66905. /**
  66906. * An Observer can set this property to true to prevent subsequent observers of being notified
  66907. */
  66908. skipNextObservers: boolean;
  66909. /**
  66910. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66911. */
  66912. mask: number;
  66913. /**
  66914. * The object that originally notified the event
  66915. */
  66916. target?: any;
  66917. /**
  66918. * The current object in the bubbling phase
  66919. */
  66920. currentTarget?: any;
  66921. /**
  66922. * This will be populated with the return value of the last function that was executed.
  66923. * If it is the first function in the callback chain it will be the event data.
  66924. */
  66925. lastReturnValue?: any;
  66926. }
  66927. /**
  66928. * Represent an Observer registered to a given Observable object.
  66929. */
  66930. export class Observer<T> {
  66931. /**
  66932. * Defines the callback to call when the observer is notified
  66933. */
  66934. callback: (eventData: T, eventState: EventState) => void;
  66935. /**
  66936. * Defines the mask of the observer (used to filter notifications)
  66937. */
  66938. mask: number;
  66939. /**
  66940. * Defines the current scope used to restore the JS context
  66941. */
  66942. scope: any;
  66943. /** @hidden */
  66944. _willBeUnregistered: boolean;
  66945. /**
  66946. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66947. */
  66948. unregisterOnNextCall: boolean;
  66949. /**
  66950. * Creates a new observer
  66951. * @param callback defines the callback to call when the observer is notified
  66952. * @param mask defines the mask of the observer (used to filter notifications)
  66953. * @param scope defines the current scope used to restore the JS context
  66954. */
  66955. constructor(
  66956. /**
  66957. * Defines the callback to call when the observer is notified
  66958. */
  66959. callback: (eventData: T, eventState: EventState) => void,
  66960. /**
  66961. * Defines the mask of the observer (used to filter notifications)
  66962. */
  66963. mask: number,
  66964. /**
  66965. * Defines the current scope used to restore the JS context
  66966. */
  66967. scope?: any);
  66968. }
  66969. /**
  66970. * Represent a list of observers registered to multiple Observables object.
  66971. */
  66972. export class MultiObserver<T> {
  66973. private _observers;
  66974. private _observables;
  66975. /**
  66976. * Release associated resources
  66977. */
  66978. dispose(): void;
  66979. /**
  66980. * Raise a callback when one of the observable will notify
  66981. * @param observables defines a list of observables to watch
  66982. * @param callback defines the callback to call on notification
  66983. * @param mask defines the mask used to filter notifications
  66984. * @param scope defines the current scope used to restore the JS context
  66985. * @returns the new MultiObserver
  66986. */
  66987. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66988. }
  66989. /**
  66990. * The Observable class is a simple implementation of the Observable pattern.
  66991. *
  66992. * 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.
  66993. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66994. * 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).
  66995. * 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.
  66996. */
  66997. export class Observable<T> {
  66998. private _observers;
  66999. private _eventState;
  67000. private _onObserverAdded;
  67001. /**
  67002. * Gets the list of observers
  67003. */
  67004. readonly observers: Array<Observer<T>>;
  67005. /**
  67006. * Creates a new observable
  67007. * @param onObserverAdded defines a callback to call when a new observer is added
  67008. */
  67009. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  67010. /**
  67011. * Create a new Observer with the specified callback
  67012. * @param callback the callback that will be executed for that Observer
  67013. * @param mask the mask used to filter observers
  67014. * @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.
  67015. * @param scope optional scope for the callback to be called from
  67016. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  67017. * @returns the new observer created for the callback
  67018. */
  67019. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  67020. /**
  67021. * Create a new Observer with the specified callback and unregisters after the next notification
  67022. * @param callback the callback that will be executed for that Observer
  67023. * @returns the new observer created for the callback
  67024. */
  67025. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  67026. /**
  67027. * Remove an Observer from the Observable object
  67028. * @param observer the instance of the Observer to remove
  67029. * @returns false if it doesn't belong to this Observable
  67030. */
  67031. remove(observer: Nullable<Observer<T>>): boolean;
  67032. /**
  67033. * Remove a callback from the Observable object
  67034. * @param callback the callback to remove
  67035. * @param scope optional scope. If used only the callbacks with this scope will be removed
  67036. * @returns false if it doesn't belong to this Observable
  67037. */
  67038. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  67039. private _deferUnregister;
  67040. private _remove;
  67041. /**
  67042. * Moves the observable to the top of the observer list making it get called first when notified
  67043. * @param observer the observer to move
  67044. */
  67045. makeObserverTopPriority(observer: Observer<T>): void;
  67046. /**
  67047. * Moves the observable to the bottom of the observer list making it get called last when notified
  67048. * @param observer the observer to move
  67049. */
  67050. makeObserverBottomPriority(observer: Observer<T>): void;
  67051. /**
  67052. * Notify all Observers by calling their respective callback with the given data
  67053. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  67054. * @param eventData defines the data to send to all observers
  67055. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  67056. * @param target defines the original target of the state
  67057. * @param currentTarget defines the current target of the state
  67058. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67059. */
  67060. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67061. /**
  67062. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67063. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67064. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67065. * and it is crucial that all callbacks will be executed.
  67066. * The order of the callbacks is kept, callbacks are not executed parallel.
  67067. *
  67068. * @param eventData The data to be sent to each callback
  67069. * @param mask is used to filter observers defaults to -1
  67070. * @param target defines the callback target (see EventState)
  67071. * @param currentTarget defines he current object in the bubbling phase
  67072. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67073. */
  67074. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67075. /**
  67076. * Notify a specific observer
  67077. * @param observer defines the observer to notify
  67078. * @param eventData defines the data to be sent to each callback
  67079. * @param mask is used to filter observers defaults to -1
  67080. */
  67081. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67082. /**
  67083. * Gets a boolean indicating if the observable has at least one observer
  67084. * @returns true is the Observable has at least one Observer registered
  67085. */
  67086. hasObservers(): boolean;
  67087. /**
  67088. * Clear the list of observers
  67089. */
  67090. clear(): void;
  67091. /**
  67092. * Clone the current observable
  67093. * @returns a new observable
  67094. */
  67095. clone(): Observable<T>;
  67096. /**
  67097. * Does this observable handles observer registered with a given mask
  67098. * @param mask defines the mask to be tested
  67099. * @return whether or not one observer registered with the given mask is handeled
  67100. **/
  67101. hasSpecificMask(mask?: number): boolean;
  67102. }
  67103. }
  67104. declare module BABYLON {
  67105. /**
  67106. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67107. * Babylon.js
  67108. */
  67109. export class DomManagement {
  67110. /**
  67111. * Checks if the window object exists
  67112. * @returns true if the window object exists
  67113. */
  67114. static IsWindowObjectExist(): boolean;
  67115. /**
  67116. * Checks if the navigator object exists
  67117. * @returns true if the navigator object exists
  67118. */
  67119. static IsNavigatorAvailable(): boolean;
  67120. /**
  67121. * Extracts text content from a DOM element hierarchy
  67122. * @param element defines the root element
  67123. * @returns a string
  67124. */
  67125. static GetDOMTextContent(element: HTMLElement): string;
  67126. }
  67127. }
  67128. declare module BABYLON {
  67129. /**
  67130. * Logger used througouht the application to allow configuration of
  67131. * the log level required for the messages.
  67132. */
  67133. export class Logger {
  67134. /**
  67135. * No log
  67136. */
  67137. static readonly NoneLogLevel: number;
  67138. /**
  67139. * Only message logs
  67140. */
  67141. static readonly MessageLogLevel: number;
  67142. /**
  67143. * Only warning logs
  67144. */
  67145. static readonly WarningLogLevel: number;
  67146. /**
  67147. * Only error logs
  67148. */
  67149. static readonly ErrorLogLevel: number;
  67150. /**
  67151. * All logs
  67152. */
  67153. static readonly AllLogLevel: number;
  67154. private static _LogCache;
  67155. /**
  67156. * Gets a value indicating the number of loading errors
  67157. * @ignorenaming
  67158. */
  67159. static errorsCount: number;
  67160. /**
  67161. * Callback called when a new log is added
  67162. */
  67163. static OnNewCacheEntry: (entry: string) => void;
  67164. private static _AddLogEntry;
  67165. private static _FormatMessage;
  67166. private static _LogDisabled;
  67167. private static _LogEnabled;
  67168. private static _WarnDisabled;
  67169. private static _WarnEnabled;
  67170. private static _ErrorDisabled;
  67171. private static _ErrorEnabled;
  67172. /**
  67173. * Log a message to the console
  67174. */
  67175. static Log: (message: string) => void;
  67176. /**
  67177. * Write a warning message to the console
  67178. */
  67179. static Warn: (message: string) => void;
  67180. /**
  67181. * Write an error message to the console
  67182. */
  67183. static Error: (message: string) => void;
  67184. /**
  67185. * Gets current log cache (list of logs)
  67186. */
  67187. static readonly LogCache: string;
  67188. /**
  67189. * Clears the log cache
  67190. */
  67191. static ClearLogCache(): void;
  67192. /**
  67193. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67194. */
  67195. static LogLevels: number;
  67196. }
  67197. }
  67198. declare module BABYLON {
  67199. /** @hidden */
  67200. export class _TypeStore {
  67201. /** @hidden */
  67202. static RegisteredTypes: {
  67203. [key: string]: Object;
  67204. };
  67205. /** @hidden */
  67206. static GetClass(fqdn: string): any;
  67207. }
  67208. }
  67209. declare module BABYLON {
  67210. /**
  67211. * Class containing a set of static utilities functions for deep copy.
  67212. */
  67213. export class DeepCopier {
  67214. /**
  67215. * Tries to copy an object by duplicating every property
  67216. * @param source defines the source object
  67217. * @param destination defines the target object
  67218. * @param doNotCopyList defines a list of properties to avoid
  67219. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67220. */
  67221. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67222. }
  67223. }
  67224. declare module BABYLON {
  67225. /**
  67226. * Class containing a set of static utilities functions for precision date
  67227. */
  67228. export class PrecisionDate {
  67229. /**
  67230. * Gets either window.performance.now() if supported or Date.now() else
  67231. */
  67232. static readonly Now: number;
  67233. }
  67234. }
  67235. declare module BABYLON {
  67236. /** @hidden */
  67237. export class _DevTools {
  67238. static WarnImport(name: string): string;
  67239. }
  67240. }
  67241. declare module BABYLON {
  67242. /**
  67243. * Interface used to define the mechanism to get data from the network
  67244. */
  67245. export interface IWebRequest {
  67246. /**
  67247. * Returns client's response url
  67248. */
  67249. responseURL: string;
  67250. /**
  67251. * Returns client's status
  67252. */
  67253. status: number;
  67254. /**
  67255. * Returns client's status as a text
  67256. */
  67257. statusText: string;
  67258. }
  67259. }
  67260. declare module BABYLON {
  67261. /**
  67262. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67263. */
  67264. export class WebRequest implements IWebRequest {
  67265. private _xhr;
  67266. /**
  67267. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67268. * i.e. when loading files, where the server/service expects an Authorization header
  67269. */
  67270. static CustomRequestHeaders: {
  67271. [key: string]: string;
  67272. };
  67273. /**
  67274. * Add callback functions in this array to update all the requests before they get sent to the network
  67275. */
  67276. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67277. private _injectCustomRequestHeaders;
  67278. /**
  67279. * Gets or sets a function to be called when loading progress changes
  67280. */
  67281. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67282. /**
  67283. * Returns client's state
  67284. */
  67285. readonly readyState: number;
  67286. /**
  67287. * Returns client's status
  67288. */
  67289. readonly status: number;
  67290. /**
  67291. * Returns client's status as a text
  67292. */
  67293. readonly statusText: string;
  67294. /**
  67295. * Returns client's response
  67296. */
  67297. readonly response: any;
  67298. /**
  67299. * Returns client's response url
  67300. */
  67301. readonly responseURL: string;
  67302. /**
  67303. * Returns client's response as text
  67304. */
  67305. readonly responseText: string;
  67306. /**
  67307. * Gets or sets the expected response type
  67308. */
  67309. responseType: XMLHttpRequestResponseType;
  67310. /** @hidden */
  67311. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67312. /** @hidden */
  67313. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67314. /**
  67315. * Cancels any network activity
  67316. */
  67317. abort(): void;
  67318. /**
  67319. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67320. * @param body defines an optional request body
  67321. */
  67322. send(body?: Document | BodyInit | null): void;
  67323. /**
  67324. * Sets the request method, request URL
  67325. * @param method defines the method to use (GET, POST, etc..)
  67326. * @param url defines the url to connect with
  67327. */
  67328. open(method: string, url: string): void;
  67329. }
  67330. }
  67331. declare module BABYLON {
  67332. /**
  67333. * File request interface
  67334. */
  67335. export interface IFileRequest {
  67336. /**
  67337. * Raised when the request is complete (success or error).
  67338. */
  67339. onCompleteObservable: Observable<IFileRequest>;
  67340. /**
  67341. * Aborts the request for a file.
  67342. */
  67343. abort: () => void;
  67344. }
  67345. }
  67346. declare module BABYLON {
  67347. /**
  67348. * Define options used to create a render target texture
  67349. */
  67350. export class RenderTargetCreationOptions {
  67351. /**
  67352. * Specifies is mipmaps must be generated
  67353. */
  67354. generateMipMaps?: boolean;
  67355. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  67356. generateDepthBuffer?: boolean;
  67357. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  67358. generateStencilBuffer?: boolean;
  67359. /** Defines texture type (int by default) */
  67360. type?: number;
  67361. /** Defines sampling mode (trilinear by default) */
  67362. samplingMode?: number;
  67363. /** Defines format (RGBA by default) */
  67364. format?: number;
  67365. }
  67366. }
  67367. declare module BABYLON {
  67368. /**
  67369. * @hidden
  67370. **/
  67371. export class _TimeToken {
  67372. _startTimeQuery: Nullable<WebGLQuery>;
  67373. _endTimeQuery: Nullable<WebGLQuery>;
  67374. _timeElapsedQuery: Nullable<WebGLQuery>;
  67375. _timeElapsedQueryEnded: boolean;
  67376. }
  67377. }
  67378. declare module BABYLON {
  67379. /** Defines the cross module used constants to avoid circular dependncies */
  67380. export class Constants {
  67381. /** Defines that alpha blending is disabled */
  67382. static readonly ALPHA_DISABLE: number;
  67383. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  67384. static readonly ALPHA_ADD: number;
  67385. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  67386. static readonly ALPHA_COMBINE: number;
  67387. /** Defines that alpha blending to DEST - SRC * DEST */
  67388. static readonly ALPHA_SUBTRACT: number;
  67389. /** Defines that alpha blending to SRC * DEST */
  67390. static readonly ALPHA_MULTIPLY: number;
  67391. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  67392. static readonly ALPHA_MAXIMIZED: number;
  67393. /** Defines that alpha blending to SRC + DEST */
  67394. static readonly ALPHA_ONEONE: number;
  67395. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  67396. static readonly ALPHA_PREMULTIPLIED: number;
  67397. /**
  67398. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  67399. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  67400. */
  67401. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  67402. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  67403. static readonly ALPHA_INTERPOLATE: number;
  67404. /**
  67405. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  67406. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  67407. */
  67408. static readonly ALPHA_SCREENMODE: number;
  67409. /**
  67410. * Defines that alpha blending to SRC + DST
  67411. * Alpha will be set to SRC ALPHA + DST ALPHA
  67412. */
  67413. static readonly ALPHA_ONEONE_ONEONE: number;
  67414. /**
  67415. * Defines that alpha blending to SRC * DST ALPHA + DST
  67416. * Alpha will be set to 0
  67417. */
  67418. static readonly ALPHA_ALPHATOCOLOR: number;
  67419. /**
  67420. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  67421. */
  67422. static readonly ALPHA_REVERSEONEMINUS: number;
  67423. /**
  67424. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  67425. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  67426. */
  67427. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  67428. /**
  67429. * Defines that alpha blending to SRC + DST
  67430. * Alpha will be set to SRC ALPHA
  67431. */
  67432. static readonly ALPHA_ONEONE_ONEZERO: number;
  67433. /** Defines that alpha blending equation a SUM */
  67434. static readonly ALPHA_EQUATION_ADD: number;
  67435. /** Defines that alpha blending equation a SUBSTRACTION */
  67436. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  67437. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  67438. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  67439. /** Defines that alpha blending equation a MAX operation */
  67440. static readonly ALPHA_EQUATION_MAX: number;
  67441. /** Defines that alpha blending equation a MIN operation */
  67442. static readonly ALPHA_EQUATION_MIN: number;
  67443. /**
  67444. * Defines that alpha blending equation a DARKEN operation:
  67445. * It takes the min of the src and sums the alpha channels.
  67446. */
  67447. static readonly ALPHA_EQUATION_DARKEN: number;
  67448. /** Defines that the ressource is not delayed*/
  67449. static readonly DELAYLOADSTATE_NONE: number;
  67450. /** Defines that the ressource was successfully delay loaded */
  67451. static readonly DELAYLOADSTATE_LOADED: number;
  67452. /** Defines that the ressource is currently delay loading */
  67453. static readonly DELAYLOADSTATE_LOADING: number;
  67454. /** Defines that the ressource is delayed and has not started loading */
  67455. static readonly DELAYLOADSTATE_NOTLOADED: number;
  67456. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  67457. static readonly NEVER: number;
  67458. /** 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 */
  67459. static readonly ALWAYS: number;
  67460. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  67461. static readonly LESS: number;
  67462. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  67463. static readonly EQUAL: number;
  67464. /** 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 */
  67465. static readonly LEQUAL: number;
  67466. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  67467. static readonly GREATER: number;
  67468. /** 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 */
  67469. static readonly GEQUAL: number;
  67470. /** 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 */
  67471. static readonly NOTEQUAL: number;
  67472. /** Passed to stencilOperation to specify that stencil value must be kept */
  67473. static readonly KEEP: number;
  67474. /** Passed to stencilOperation to specify that stencil value must be replaced */
  67475. static readonly REPLACE: number;
  67476. /** Passed to stencilOperation to specify that stencil value must be incremented */
  67477. static readonly INCR: number;
  67478. /** Passed to stencilOperation to specify that stencil value must be decremented */
  67479. static readonly DECR: number;
  67480. /** Passed to stencilOperation to specify that stencil value must be inverted */
  67481. static readonly INVERT: number;
  67482. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  67483. static readonly INCR_WRAP: number;
  67484. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  67485. static readonly DECR_WRAP: number;
  67486. /** Texture is not repeating outside of 0..1 UVs */
  67487. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  67488. /** Texture is repeating outside of 0..1 UVs */
  67489. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  67490. /** Texture is repeating and mirrored */
  67491. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  67492. /** ALPHA */
  67493. static readonly TEXTUREFORMAT_ALPHA: number;
  67494. /** LUMINANCE */
  67495. static readonly TEXTUREFORMAT_LUMINANCE: number;
  67496. /** LUMINANCE_ALPHA */
  67497. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  67498. /** RGB */
  67499. static readonly TEXTUREFORMAT_RGB: number;
  67500. /** RGBA */
  67501. static readonly TEXTUREFORMAT_RGBA: number;
  67502. /** RED */
  67503. static readonly TEXTUREFORMAT_RED: number;
  67504. /** RED (2nd reference) */
  67505. static readonly TEXTUREFORMAT_R: number;
  67506. /** RG */
  67507. static readonly TEXTUREFORMAT_RG: number;
  67508. /** RED_INTEGER */
  67509. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  67510. /** RED_INTEGER (2nd reference) */
  67511. static readonly TEXTUREFORMAT_R_INTEGER: number;
  67512. /** RG_INTEGER */
  67513. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  67514. /** RGB_INTEGER */
  67515. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  67516. /** RGBA_INTEGER */
  67517. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  67518. /** UNSIGNED_BYTE */
  67519. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  67520. /** UNSIGNED_BYTE (2nd reference) */
  67521. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  67522. /** FLOAT */
  67523. static readonly TEXTURETYPE_FLOAT: number;
  67524. /** HALF_FLOAT */
  67525. static readonly TEXTURETYPE_HALF_FLOAT: number;
  67526. /** BYTE */
  67527. static readonly TEXTURETYPE_BYTE: number;
  67528. /** SHORT */
  67529. static readonly TEXTURETYPE_SHORT: number;
  67530. /** UNSIGNED_SHORT */
  67531. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  67532. /** INT */
  67533. static readonly TEXTURETYPE_INT: number;
  67534. /** UNSIGNED_INT */
  67535. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  67536. /** UNSIGNED_SHORT_4_4_4_4 */
  67537. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  67538. /** UNSIGNED_SHORT_5_5_5_1 */
  67539. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  67540. /** UNSIGNED_SHORT_5_6_5 */
  67541. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  67542. /** UNSIGNED_INT_2_10_10_10_REV */
  67543. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  67544. /** UNSIGNED_INT_24_8 */
  67545. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  67546. /** UNSIGNED_INT_10F_11F_11F_REV */
  67547. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  67548. /** UNSIGNED_INT_5_9_9_9_REV */
  67549. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  67550. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  67551. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  67552. /** nearest is mag = nearest and min = nearest and mip = linear */
  67553. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  67554. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67555. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  67556. /** Trilinear is mag = linear and min = linear and mip = linear */
  67557. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  67558. /** nearest is mag = nearest and min = nearest and mip = linear */
  67559. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  67560. /** Bilinear is mag = linear and min = linear and mip = nearest */
  67561. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  67562. /** Trilinear is mag = linear and min = linear and mip = linear */
  67563. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  67564. /** mag = nearest and min = nearest and mip = nearest */
  67565. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  67566. /** mag = nearest and min = linear and mip = nearest */
  67567. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  67568. /** mag = nearest and min = linear and mip = linear */
  67569. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  67570. /** mag = nearest and min = linear and mip = none */
  67571. static readonly TEXTURE_NEAREST_LINEAR: number;
  67572. /** mag = nearest and min = nearest and mip = none */
  67573. static readonly TEXTURE_NEAREST_NEAREST: number;
  67574. /** mag = linear and min = nearest and mip = nearest */
  67575. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  67576. /** mag = linear and min = nearest and mip = linear */
  67577. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  67578. /** mag = linear and min = linear and mip = none */
  67579. static readonly TEXTURE_LINEAR_LINEAR: number;
  67580. /** mag = linear and min = nearest and mip = none */
  67581. static readonly TEXTURE_LINEAR_NEAREST: number;
  67582. /** Explicit coordinates mode */
  67583. static readonly TEXTURE_EXPLICIT_MODE: number;
  67584. /** Spherical coordinates mode */
  67585. static readonly TEXTURE_SPHERICAL_MODE: number;
  67586. /** Planar coordinates mode */
  67587. static readonly TEXTURE_PLANAR_MODE: number;
  67588. /** Cubic coordinates mode */
  67589. static readonly TEXTURE_CUBIC_MODE: number;
  67590. /** Projection coordinates mode */
  67591. static readonly TEXTURE_PROJECTION_MODE: number;
  67592. /** Skybox coordinates mode */
  67593. static readonly TEXTURE_SKYBOX_MODE: number;
  67594. /** Inverse Cubic coordinates mode */
  67595. static readonly TEXTURE_INVCUBIC_MODE: number;
  67596. /** Equirectangular coordinates mode */
  67597. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  67598. /** Equirectangular Fixed coordinates mode */
  67599. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  67600. /** Equirectangular Fixed Mirrored coordinates mode */
  67601. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  67602. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  67603. static readonly SCALEMODE_FLOOR: number;
  67604. /** Defines that texture rescaling will look for the nearest power of 2 size */
  67605. static readonly SCALEMODE_NEAREST: number;
  67606. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  67607. static readonly SCALEMODE_CEILING: number;
  67608. /**
  67609. * The dirty texture flag value
  67610. */
  67611. static readonly MATERIAL_TextureDirtyFlag: number;
  67612. /**
  67613. * The dirty light flag value
  67614. */
  67615. static readonly MATERIAL_LightDirtyFlag: number;
  67616. /**
  67617. * The dirty fresnel flag value
  67618. */
  67619. static readonly MATERIAL_FresnelDirtyFlag: number;
  67620. /**
  67621. * The dirty attribute flag value
  67622. */
  67623. static readonly MATERIAL_AttributesDirtyFlag: number;
  67624. /**
  67625. * The dirty misc flag value
  67626. */
  67627. static readonly MATERIAL_MiscDirtyFlag: number;
  67628. /**
  67629. * The all dirty flag value
  67630. */
  67631. static readonly MATERIAL_AllDirtyFlag: number;
  67632. /**
  67633. * Returns the triangle fill mode
  67634. */
  67635. static readonly MATERIAL_TriangleFillMode: number;
  67636. /**
  67637. * Returns the wireframe mode
  67638. */
  67639. static readonly MATERIAL_WireFrameFillMode: number;
  67640. /**
  67641. * Returns the point fill mode
  67642. */
  67643. static readonly MATERIAL_PointFillMode: number;
  67644. /**
  67645. * Returns the point list draw mode
  67646. */
  67647. static readonly MATERIAL_PointListDrawMode: number;
  67648. /**
  67649. * Returns the line list draw mode
  67650. */
  67651. static readonly MATERIAL_LineListDrawMode: number;
  67652. /**
  67653. * Returns the line loop draw mode
  67654. */
  67655. static readonly MATERIAL_LineLoopDrawMode: number;
  67656. /**
  67657. * Returns the line strip draw mode
  67658. */
  67659. static readonly MATERIAL_LineStripDrawMode: number;
  67660. /**
  67661. * Returns the triangle strip draw mode
  67662. */
  67663. static readonly MATERIAL_TriangleStripDrawMode: number;
  67664. /**
  67665. * Returns the triangle fan draw mode
  67666. */
  67667. static readonly MATERIAL_TriangleFanDrawMode: number;
  67668. /**
  67669. * Stores the clock-wise side orientation
  67670. */
  67671. static readonly MATERIAL_ClockWiseSideOrientation: number;
  67672. /**
  67673. * Stores the counter clock-wise side orientation
  67674. */
  67675. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  67676. /**
  67677. * Nothing
  67678. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67679. */
  67680. static readonly ACTION_NothingTrigger: number;
  67681. /**
  67682. * On pick
  67683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67684. */
  67685. static readonly ACTION_OnPickTrigger: number;
  67686. /**
  67687. * On left pick
  67688. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67689. */
  67690. static readonly ACTION_OnLeftPickTrigger: number;
  67691. /**
  67692. * On right pick
  67693. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67694. */
  67695. static readonly ACTION_OnRightPickTrigger: number;
  67696. /**
  67697. * On center pick
  67698. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67699. */
  67700. static readonly ACTION_OnCenterPickTrigger: number;
  67701. /**
  67702. * On pick down
  67703. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67704. */
  67705. static readonly ACTION_OnPickDownTrigger: number;
  67706. /**
  67707. * On double pick
  67708. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67709. */
  67710. static readonly ACTION_OnDoublePickTrigger: number;
  67711. /**
  67712. * On pick up
  67713. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67714. */
  67715. static readonly ACTION_OnPickUpTrigger: number;
  67716. /**
  67717. * On pick out.
  67718. * This trigger will only be raised if you also declared a OnPickDown
  67719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67720. */
  67721. static readonly ACTION_OnPickOutTrigger: number;
  67722. /**
  67723. * On long press
  67724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67725. */
  67726. static readonly ACTION_OnLongPressTrigger: number;
  67727. /**
  67728. * On pointer over
  67729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67730. */
  67731. static readonly ACTION_OnPointerOverTrigger: number;
  67732. /**
  67733. * On pointer out
  67734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67735. */
  67736. static readonly ACTION_OnPointerOutTrigger: number;
  67737. /**
  67738. * On every frame
  67739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67740. */
  67741. static readonly ACTION_OnEveryFrameTrigger: number;
  67742. /**
  67743. * On intersection enter
  67744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67745. */
  67746. static readonly ACTION_OnIntersectionEnterTrigger: number;
  67747. /**
  67748. * On intersection exit
  67749. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67750. */
  67751. static readonly ACTION_OnIntersectionExitTrigger: number;
  67752. /**
  67753. * On key down
  67754. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67755. */
  67756. static readonly ACTION_OnKeyDownTrigger: number;
  67757. /**
  67758. * On key up
  67759. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  67760. */
  67761. static readonly ACTION_OnKeyUpTrigger: number;
  67762. /**
  67763. * Billboard mode will only apply to Y axis
  67764. */
  67765. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  67766. /**
  67767. * Billboard mode will apply to all axes
  67768. */
  67769. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  67770. /**
  67771. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  67772. */
  67773. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  67774. /**
  67775. * Gets or sets base Assets URL
  67776. */
  67777. static PARTICLES_BaseAssetsUrl: string;
  67778. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  67779. * Test order :
  67780. * Is the bounding sphere outside the frustum ?
  67781. * If not, are the bounding box vertices outside the frustum ?
  67782. * It not, then the cullable object is in the frustum.
  67783. */
  67784. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  67785. /** Culling strategy : Bounding Sphere Only.
  67786. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  67787. * It's also less accurate than the standard because some not visible objects can still be selected.
  67788. * Test : is the bounding sphere outside the frustum ?
  67789. * If not, then the cullable object is in the frustum.
  67790. */
  67791. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  67792. /** Culling strategy : Optimistic Inclusion.
  67793. * This in an inclusion test first, then the standard exclusion test.
  67794. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  67795. * 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.
  67796. * Anyway, it's as accurate as the standard strategy.
  67797. * Test :
  67798. * Is the cullable object bounding sphere center in the frustum ?
  67799. * If not, apply the default culling strategy.
  67800. */
  67801. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  67802. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  67803. * This in an inclusion test first, then the bounding sphere only exclusion test.
  67804. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  67805. * 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.
  67806. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  67807. * Test :
  67808. * Is the cullable object bounding sphere center in the frustum ?
  67809. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  67810. */
  67811. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  67812. /**
  67813. * No logging while loading
  67814. */
  67815. static readonly SCENELOADER_NO_LOGGING: number;
  67816. /**
  67817. * Minimal logging while loading
  67818. */
  67819. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  67820. /**
  67821. * Summary logging while loading
  67822. */
  67823. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  67824. /**
  67825. * Detailled logging while loading
  67826. */
  67827. static readonly SCENELOADER_DETAILED_LOGGING: number;
  67828. }
  67829. }
  67830. declare module BABYLON {
  67831. /**
  67832. * This represents the required contract to create a new type of texture loader.
  67833. */
  67834. export interface IInternalTextureLoader {
  67835. /**
  67836. * Defines wether the loader supports cascade loading the different faces.
  67837. */
  67838. supportCascades: boolean;
  67839. /**
  67840. * This returns if the loader support the current file information.
  67841. * @param extension defines the file extension of the file being loaded
  67842. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67843. * @param fallback defines the fallback internal texture if any
  67844. * @param isBase64 defines whether the texture is encoded as a base64
  67845. * @param isBuffer defines whether the texture data are stored as a buffer
  67846. * @returns true if the loader can load the specified file
  67847. */
  67848. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  67849. /**
  67850. * Transform the url before loading if required.
  67851. * @param rootUrl the url of the texture
  67852. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67853. * @returns the transformed texture
  67854. */
  67855. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  67856. /**
  67857. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  67858. * @param rootUrl the url of the texture
  67859. * @param textureFormatInUse defines the current compressed format in use iun the engine
  67860. * @returns the fallback texture
  67861. */
  67862. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  67863. /**
  67864. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  67865. * @param data contains the texture data
  67866. * @param texture defines the BabylonJS internal texture
  67867. * @param createPolynomials will be true if polynomials have been requested
  67868. * @param onLoad defines the callback to trigger once the texture is ready
  67869. * @param onError defines the callback to trigger in case of error
  67870. */
  67871. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  67872. /**
  67873. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  67874. * @param data contains the texture data
  67875. * @param texture defines the BabylonJS internal texture
  67876. * @param callback defines the method to call once ready to upload
  67877. */
  67878. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  67879. }
  67880. }
  67881. declare module BABYLON {
  67882. /**
  67883. * Class used to store and describe the pipeline context associated with an effect
  67884. */
  67885. export interface IPipelineContext {
  67886. /**
  67887. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67888. */
  67889. isAsync: boolean;
  67890. /**
  67891. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67892. */
  67893. isReady: boolean;
  67894. /** @hidden */
  67895. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67896. }
  67897. }
  67898. declare module BABYLON {
  67899. /**
  67900. * Class used to store gfx data (like WebGLBuffer)
  67901. */
  67902. export class DataBuffer {
  67903. /**
  67904. * Gets or sets the number of objects referencing this buffer
  67905. */
  67906. references: number;
  67907. /** Gets or sets the size of the underlying buffer */
  67908. capacity: number;
  67909. /**
  67910. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67911. */
  67912. is32Bits: boolean;
  67913. /**
  67914. * Gets the underlying buffer
  67915. */
  67916. readonly underlyingResource: any;
  67917. }
  67918. }
  67919. declare module BABYLON {
  67920. /** @hidden */
  67921. export interface IShaderProcessor {
  67922. attributeProcessor?: (attribute: string) => string;
  67923. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  67924. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  67925. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  67926. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  67927. lineProcessor?: (line: string, isFragment: boolean) => string;
  67928. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67929. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  67930. }
  67931. }
  67932. declare module BABYLON {
  67933. /** @hidden */
  67934. export interface ProcessingOptions {
  67935. defines: string[];
  67936. indexParameters: any;
  67937. isFragment: boolean;
  67938. shouldUseHighPrecisionShader: boolean;
  67939. supportsUniformBuffers: boolean;
  67940. shadersRepository: string;
  67941. includesShadersStore: {
  67942. [key: string]: string;
  67943. };
  67944. processor?: IShaderProcessor;
  67945. version: string;
  67946. platformName: string;
  67947. lookForClosingBracketForUniformBuffer?: boolean;
  67948. }
  67949. }
  67950. declare module BABYLON {
  67951. /**
  67952. * Helper to manipulate strings
  67953. */
  67954. export class StringTools {
  67955. /**
  67956. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  67957. * @param str Source string
  67958. * @param suffix Suffix to search for in the source string
  67959. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67960. */
  67961. static EndsWith(str: string, suffix: string): boolean;
  67962. /**
  67963. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  67964. * @param str Source string
  67965. * @param suffix Suffix to search for in the source string
  67966. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  67967. */
  67968. static StartsWith(str: string, suffix: string): boolean;
  67969. }
  67970. }
  67971. declare module BABYLON {
  67972. /** @hidden */
  67973. export class ShaderCodeNode {
  67974. line: string;
  67975. children: ShaderCodeNode[];
  67976. additionalDefineKey?: string;
  67977. additionalDefineValue?: string;
  67978. isValid(preprocessors: {
  67979. [key: string]: string;
  67980. }): boolean;
  67981. process(preprocessors: {
  67982. [key: string]: string;
  67983. }, options: ProcessingOptions): string;
  67984. }
  67985. }
  67986. declare module BABYLON {
  67987. /** @hidden */
  67988. export class ShaderCodeCursor {
  67989. private _lines;
  67990. lineIndex: number;
  67991. readonly currentLine: string;
  67992. readonly canRead: boolean;
  67993. lines: string[];
  67994. }
  67995. }
  67996. declare module BABYLON {
  67997. /** @hidden */
  67998. export class ShaderCodeConditionNode extends ShaderCodeNode {
  67999. process(preprocessors: {
  68000. [key: string]: string;
  68001. }, options: ProcessingOptions): string;
  68002. }
  68003. }
  68004. declare module BABYLON {
  68005. /** @hidden */
  68006. export class ShaderDefineExpression {
  68007. isTrue(preprocessors: {
  68008. [key: string]: string;
  68009. }): boolean;
  68010. }
  68011. }
  68012. declare module BABYLON {
  68013. /** @hidden */
  68014. export class ShaderCodeTestNode extends ShaderCodeNode {
  68015. testExpression: ShaderDefineExpression;
  68016. isValid(preprocessors: {
  68017. [key: string]: string;
  68018. }): boolean;
  68019. }
  68020. }
  68021. declare module BABYLON {
  68022. /** @hidden */
  68023. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  68024. define: string;
  68025. not: boolean;
  68026. constructor(define: string, not?: boolean);
  68027. isTrue(preprocessors: {
  68028. [key: string]: string;
  68029. }): boolean;
  68030. }
  68031. }
  68032. declare module BABYLON {
  68033. /** @hidden */
  68034. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  68035. leftOperand: ShaderDefineExpression;
  68036. rightOperand: ShaderDefineExpression;
  68037. isTrue(preprocessors: {
  68038. [key: string]: string;
  68039. }): boolean;
  68040. }
  68041. }
  68042. declare module BABYLON {
  68043. /** @hidden */
  68044. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  68045. leftOperand: ShaderDefineExpression;
  68046. rightOperand: ShaderDefineExpression;
  68047. isTrue(preprocessors: {
  68048. [key: string]: string;
  68049. }): boolean;
  68050. }
  68051. }
  68052. declare module BABYLON {
  68053. /** @hidden */
  68054. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  68055. define: string;
  68056. operand: string;
  68057. testValue: string;
  68058. constructor(define: string, operand: string, testValue: string);
  68059. isTrue(preprocessors: {
  68060. [key: string]: string;
  68061. }): boolean;
  68062. }
  68063. }
  68064. declare module BABYLON {
  68065. /**
  68066. * @ignore
  68067. * Application error to support additional information when loading a file
  68068. */
  68069. export class LoadFileError extends Error {
  68070. /** defines the optional web request */
  68071. request?: WebRequest | undefined;
  68072. private static _setPrototypeOf;
  68073. /**
  68074. * Creates a new LoadFileError
  68075. * @param message defines the message of the error
  68076. * @param request defines the optional web request
  68077. */
  68078. constructor(message: string,
  68079. /** defines the optional web request */
  68080. request?: WebRequest | undefined);
  68081. }
  68082. }
  68083. declare module BABYLON {
  68084. /**
  68085. * Class used to enable access to offline support
  68086. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  68087. */
  68088. export interface IOfflineProvider {
  68089. /**
  68090. * Gets a boolean indicating if scene must be saved in the database
  68091. */
  68092. enableSceneOffline: boolean;
  68093. /**
  68094. * Gets a boolean indicating if textures must be saved in the database
  68095. */
  68096. enableTexturesOffline: boolean;
  68097. /**
  68098. * Open the offline support and make it available
  68099. * @param successCallback defines the callback to call on success
  68100. * @param errorCallback defines the callback to call on error
  68101. */
  68102. open(successCallback: () => void, errorCallback: () => void): void;
  68103. /**
  68104. * Loads an image from the offline support
  68105. * @param url defines the url to load from
  68106. * @param image defines the target DOM image
  68107. */
  68108. loadImage(url: string, image: HTMLImageElement): void;
  68109. /**
  68110. * Loads a file from offline support
  68111. * @param url defines the URL to load from
  68112. * @param sceneLoaded defines a callback to call on success
  68113. * @param progressCallBack defines a callback to call when progress changed
  68114. * @param errorCallback defines a callback to call on error
  68115. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68116. */
  68117. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68118. }
  68119. }
  68120. declare module BABYLON {
  68121. /**
  68122. * Class used to help managing file picking and drag'n'drop
  68123. * File Storage
  68124. */
  68125. export class FilesInputStore {
  68126. /**
  68127. * List of files ready to be loaded
  68128. */
  68129. static FilesToLoad: {
  68130. [key: string]: File;
  68131. };
  68132. }
  68133. }
  68134. declare module BABYLON {
  68135. /**
  68136. * Class used to define a retry strategy when error happens while loading assets
  68137. */
  68138. export class RetryStrategy {
  68139. /**
  68140. * Function used to defines an exponential back off strategy
  68141. * @param maxRetries defines the maximum number of retries (3 by default)
  68142. * @param baseInterval defines the interval between retries
  68143. * @returns the strategy function to use
  68144. */
  68145. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  68146. }
  68147. }
  68148. declare module BABYLON {
  68149. /**
  68150. * @hidden
  68151. */
  68152. export class FileTools {
  68153. /**
  68154. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  68155. */
  68156. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  68157. /**
  68158. * Gets or sets the base URL to use to load assets
  68159. */
  68160. static BaseUrl: string;
  68161. /**
  68162. * Default behaviour for cors in the application.
  68163. * It can be a string if the expected behavior is identical in the entire app.
  68164. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  68165. */
  68166. static CorsBehavior: string | ((url: string | string[]) => string);
  68167. /**
  68168. * Gets or sets a function used to pre-process url before using them to load assets
  68169. */
  68170. static PreprocessUrl: (url: string) => string;
  68171. /**
  68172. * Removes unwanted characters from an url
  68173. * @param url defines the url to clean
  68174. * @returns the cleaned url
  68175. */
  68176. private static _CleanUrl;
  68177. /**
  68178. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  68179. * @param url define the url we are trying
  68180. * @param element define the dom element where to configure the cors policy
  68181. */
  68182. static SetCorsBehavior(url: string | string[], element: {
  68183. crossOrigin: string | null;
  68184. }): void;
  68185. private static _ArrayBufferToBase64;
  68186. /**
  68187. * Loads an image as an HTMLImageElement.
  68188. * @param input url string, ArrayBuffer, or Blob to load
  68189. * @param onLoad callback called when the image successfully loads
  68190. * @param onError callback called when the image fails to load
  68191. * @param offlineProvider offline provider for caching
  68192. * @param mimeType optional mime type
  68193. * @returns the HTMLImageElement of the loaded image
  68194. */
  68195. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): HTMLImageElement;
  68196. /**
  68197. * Loads a file
  68198. * @param fileToLoad defines the file to load
  68199. * @param callback defines the callback to call when data is loaded
  68200. * @param progressCallBack defines the callback to call during loading process
  68201. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  68202. * @returns a file request object
  68203. */
  68204. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  68205. /**
  68206. * Loads a file
  68207. * @param url url string, ArrayBuffer, or Blob to load
  68208. * @param onSuccess callback called when the file successfully loads
  68209. * @param onProgress callback called while file is loading (if the server supports this mode)
  68210. * @param offlineProvider defines the offline provider for caching
  68211. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  68212. * @param onError callback called when the file fails to load
  68213. * @returns a file request object
  68214. */
  68215. 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;
  68216. /**
  68217. * Checks if the loaded document was accessed via `file:`-Protocol.
  68218. * @returns boolean
  68219. */
  68220. static IsFileURL(): boolean;
  68221. }
  68222. }
  68223. declare module BABYLON {
  68224. /** @hidden */
  68225. export class ShaderProcessor {
  68226. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  68227. private static _ProcessPrecision;
  68228. private static _ExtractOperation;
  68229. private static _BuildSubExpression;
  68230. private static _BuildExpression;
  68231. private static _MoveCursorWithinIf;
  68232. private static _MoveCursor;
  68233. private static _EvaluatePreProcessors;
  68234. private static _PreparePreProcessors;
  68235. private static _ProcessShaderConversion;
  68236. private static _ProcessIncludes;
  68237. }
  68238. }
  68239. declare module BABYLON {
  68240. /**
  68241. * @hidden
  68242. */
  68243. export interface IColor4Like {
  68244. r: float;
  68245. g: float;
  68246. b: float;
  68247. a: float;
  68248. }
  68249. /**
  68250. * @hidden
  68251. */
  68252. export interface IColor3Like {
  68253. r: float;
  68254. g: float;
  68255. b: float;
  68256. }
  68257. /**
  68258. * @hidden
  68259. */
  68260. export interface IVector4Like {
  68261. x: float;
  68262. y: float;
  68263. z: float;
  68264. w: float;
  68265. }
  68266. /**
  68267. * @hidden
  68268. */
  68269. export interface IVector3Like {
  68270. x: float;
  68271. y: float;
  68272. z: float;
  68273. }
  68274. /**
  68275. * @hidden
  68276. */
  68277. export interface IVector2Like {
  68278. x: float;
  68279. y: float;
  68280. }
  68281. /**
  68282. * @hidden
  68283. */
  68284. export interface IMatrixLike {
  68285. toArray(): DeepImmutable<Float32Array>;
  68286. updateFlag: int;
  68287. }
  68288. /**
  68289. * @hidden
  68290. */
  68291. export interface IViewportLike {
  68292. x: float;
  68293. y: float;
  68294. width: float;
  68295. height: float;
  68296. }
  68297. /**
  68298. * @hidden
  68299. */
  68300. export interface IPlaneLike {
  68301. normal: IVector3Like;
  68302. d: float;
  68303. normalize(): void;
  68304. }
  68305. }
  68306. declare module BABYLON {
  68307. /**
  68308. * Interface used to define common properties for effect fallbacks
  68309. */
  68310. export interface IEffectFallbacks {
  68311. /**
  68312. * Removes the defines that should be removed when falling back.
  68313. * @param currentDefines defines the current define statements for the shader.
  68314. * @param effect defines the current effect we try to compile
  68315. * @returns The resulting defines with defines of the current rank removed.
  68316. */
  68317. reduce(currentDefines: string, effect: Effect): string;
  68318. /**
  68319. * Removes the fallback from the bound mesh.
  68320. */
  68321. unBindMesh(): void;
  68322. /**
  68323. * Checks to see if more fallbacks are still availible.
  68324. */
  68325. hasMoreFallbacks: boolean;
  68326. }
  68327. }
  68328. declare module BABYLON {
  68329. /**
  68330. * Class used to evalaute queries containing `and` and `or` operators
  68331. */
  68332. export class AndOrNotEvaluator {
  68333. /**
  68334. * Evaluate a query
  68335. * @param query defines the query to evaluate
  68336. * @param evaluateCallback defines the callback used to filter result
  68337. * @returns true if the query matches
  68338. */
  68339. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  68340. private static _HandleParenthesisContent;
  68341. private static _SimplifyNegation;
  68342. }
  68343. }
  68344. declare module BABYLON {
  68345. /**
  68346. * Class used to store custom tags
  68347. */
  68348. export class Tags {
  68349. /**
  68350. * Adds support for tags on the given object
  68351. * @param obj defines the object to use
  68352. */
  68353. static EnableFor(obj: any): void;
  68354. /**
  68355. * Removes tags support
  68356. * @param obj defines the object to use
  68357. */
  68358. static DisableFor(obj: any): void;
  68359. /**
  68360. * Gets a boolean indicating if the given object has tags
  68361. * @param obj defines the object to use
  68362. * @returns a boolean
  68363. */
  68364. static HasTags(obj: any): boolean;
  68365. /**
  68366. * Gets the tags available on a given object
  68367. * @param obj defines the object to use
  68368. * @param asString defines if the tags must be returned as a string instead of an array of strings
  68369. * @returns the tags
  68370. */
  68371. static GetTags(obj: any, asString?: boolean): any;
  68372. /**
  68373. * Adds tags to an object
  68374. * @param obj defines the object to use
  68375. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  68376. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  68377. */
  68378. static AddTagsTo(obj: any, tagsString: string): void;
  68379. /**
  68380. * @hidden
  68381. */
  68382. static _AddTagTo(obj: any, tag: string): void;
  68383. /**
  68384. * Removes specific tags from a specific object
  68385. * @param obj defines the object to use
  68386. * @param tagsString defines the tags to remove
  68387. */
  68388. static RemoveTagsFrom(obj: any, tagsString: string): void;
  68389. /**
  68390. * @hidden
  68391. */
  68392. static _RemoveTagFrom(obj: any, tag: string): void;
  68393. /**
  68394. * Defines if tags hosted on an object match a given query
  68395. * @param obj defines the object to use
  68396. * @param tagsQuery defines the tag query
  68397. * @returns a boolean
  68398. */
  68399. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  68400. }
  68401. }
  68402. declare module BABYLON {
  68403. /**
  68404. * Scalar computation library
  68405. */
  68406. export class Scalar {
  68407. /**
  68408. * Two pi constants convenient for computation.
  68409. */
  68410. static TwoPi: number;
  68411. /**
  68412. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68413. * @param a number
  68414. * @param b number
  68415. * @param epsilon (default = 1.401298E-45)
  68416. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  68417. */
  68418. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  68419. /**
  68420. * Returns a string : the upper case translation of the number i to hexadecimal.
  68421. * @param i number
  68422. * @returns the upper case translation of the number i to hexadecimal.
  68423. */
  68424. static ToHex(i: number): string;
  68425. /**
  68426. * Returns -1 if value is negative and +1 is value is positive.
  68427. * @param value the value
  68428. * @returns the value itself if it's equal to zero.
  68429. */
  68430. static Sign(value: number): number;
  68431. /**
  68432. * Returns the value itself if it's between min and max.
  68433. * Returns min if the value is lower than min.
  68434. * Returns max if the value is greater than max.
  68435. * @param value the value to clmap
  68436. * @param min the min value to clamp to (default: 0)
  68437. * @param max the max value to clamp to (default: 1)
  68438. * @returns the clamped value
  68439. */
  68440. static Clamp(value: number, min?: number, max?: number): number;
  68441. /**
  68442. * the log2 of value.
  68443. * @param value the value to compute log2 of
  68444. * @returns the log2 of value.
  68445. */
  68446. static Log2(value: number): number;
  68447. /**
  68448. * Loops the value, so that it is never larger than length and never smaller than 0.
  68449. *
  68450. * This is similar to the modulo operator but it works with floating point numbers.
  68451. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  68452. * With t = 5 and length = 2.5, the result would be 0.0.
  68453. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68454. * @param value the value
  68455. * @param length the length
  68456. * @returns the looped value
  68457. */
  68458. static Repeat(value: number, length: number): number;
  68459. /**
  68460. * Normalize the value between 0.0 and 1.0 using min and max values
  68461. * @param value value to normalize
  68462. * @param min max to normalize between
  68463. * @param max min to normalize between
  68464. * @returns the normalized value
  68465. */
  68466. static Normalize(value: number, min: number, max: number): number;
  68467. /**
  68468. * Denormalize the value from 0.0 and 1.0 using min and max values
  68469. * @param normalized value to denormalize
  68470. * @param min max to denormalize between
  68471. * @param max min to denormalize between
  68472. * @returns the denormalized value
  68473. */
  68474. static Denormalize(normalized: number, min: number, max: number): number;
  68475. /**
  68476. * Calculates the shortest difference between two given angles given in degrees.
  68477. * @param current current angle in degrees
  68478. * @param target target angle in degrees
  68479. * @returns the delta
  68480. */
  68481. static DeltaAngle(current: number, target: number): number;
  68482. /**
  68483. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  68484. * @param tx value
  68485. * @param length length
  68486. * @returns The returned value will move back and forth between 0 and length
  68487. */
  68488. static PingPong(tx: number, length: number): number;
  68489. /**
  68490. * Interpolates between min and max with smoothing at the limits.
  68491. *
  68492. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  68493. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  68494. * @param from from
  68495. * @param to to
  68496. * @param tx value
  68497. * @returns the smooth stepped value
  68498. */
  68499. static SmoothStep(from: number, to: number, tx: number): number;
  68500. /**
  68501. * Moves a value current towards target.
  68502. *
  68503. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  68504. * Negative values of maxDelta pushes the value away from target.
  68505. * @param current current value
  68506. * @param target target value
  68507. * @param maxDelta max distance to move
  68508. * @returns resulting value
  68509. */
  68510. static MoveTowards(current: number, target: number, maxDelta: number): number;
  68511. /**
  68512. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68513. *
  68514. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  68515. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  68516. * @param current current value
  68517. * @param target target value
  68518. * @param maxDelta max distance to move
  68519. * @returns resulting angle
  68520. */
  68521. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  68522. /**
  68523. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  68524. * @param start start value
  68525. * @param end target value
  68526. * @param amount amount to lerp between
  68527. * @returns the lerped value
  68528. */
  68529. static Lerp(start: number, end: number, amount: number): number;
  68530. /**
  68531. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68532. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  68533. * @param start start value
  68534. * @param end target value
  68535. * @param amount amount to lerp between
  68536. * @returns the lerped value
  68537. */
  68538. static LerpAngle(start: number, end: number, amount: number): number;
  68539. /**
  68540. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  68541. * @param a start value
  68542. * @param b target value
  68543. * @param value value between a and b
  68544. * @returns the inverseLerp value
  68545. */
  68546. static InverseLerp(a: number, b: number, value: number): number;
  68547. /**
  68548. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  68549. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  68550. * @param value1 spline value
  68551. * @param tangent1 spline value
  68552. * @param value2 spline value
  68553. * @param tangent2 spline value
  68554. * @param amount input value
  68555. * @returns hermite result
  68556. */
  68557. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  68558. /**
  68559. * Returns a random float number between and min and max values
  68560. * @param min min value of random
  68561. * @param max max value of random
  68562. * @returns random value
  68563. */
  68564. static RandomRange(min: number, max: number): number;
  68565. /**
  68566. * This function returns percentage of a number in a given range.
  68567. *
  68568. * RangeToPercent(40,20,60) will return 0.5 (50%)
  68569. * RangeToPercent(34,0,100) will return 0.34 (34%)
  68570. * @param number to convert to percentage
  68571. * @param min min range
  68572. * @param max max range
  68573. * @returns the percentage
  68574. */
  68575. static RangeToPercent(number: number, min: number, max: number): number;
  68576. /**
  68577. * This function returns number that corresponds to the percentage in a given range.
  68578. *
  68579. * PercentToRange(0.34,0,100) will return 34.
  68580. * @param percent to convert to number
  68581. * @param min min range
  68582. * @param max max range
  68583. * @returns the number
  68584. */
  68585. static PercentToRange(percent: number, min: number, max: number): number;
  68586. /**
  68587. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  68588. * @param angle The angle to normalize in radian.
  68589. * @return The converted angle.
  68590. */
  68591. static NormalizeRadians(angle: number): number;
  68592. }
  68593. }
  68594. declare module BABYLON {
  68595. /**
  68596. * Constant used to convert a value to gamma space
  68597. * @ignorenaming
  68598. */
  68599. export const ToGammaSpace: number;
  68600. /**
  68601. * Constant used to convert a value to linear space
  68602. * @ignorenaming
  68603. */
  68604. export const ToLinearSpace = 2.2;
  68605. /**
  68606. * Constant used to define the minimal number value in Babylon.js
  68607. * @ignorenaming
  68608. */
  68609. let Epsilon: number;
  68610. }
  68611. declare module BABYLON {
  68612. /**
  68613. * Class used to represent a viewport on screen
  68614. */
  68615. export class Viewport {
  68616. /** viewport left coordinate */
  68617. x: number;
  68618. /** viewport top coordinate */
  68619. y: number;
  68620. /**viewport width */
  68621. width: number;
  68622. /** viewport height */
  68623. height: number;
  68624. /**
  68625. * Creates a Viewport object located at (x, y) and sized (width, height)
  68626. * @param x defines viewport left coordinate
  68627. * @param y defines viewport top coordinate
  68628. * @param width defines the viewport width
  68629. * @param height defines the viewport height
  68630. */
  68631. constructor(
  68632. /** viewport left coordinate */
  68633. x: number,
  68634. /** viewport top coordinate */
  68635. y: number,
  68636. /**viewport width */
  68637. width: number,
  68638. /** viewport height */
  68639. height: number);
  68640. /**
  68641. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  68642. * @param renderWidth defines the rendering width
  68643. * @param renderHeight defines the rendering height
  68644. * @returns a new Viewport
  68645. */
  68646. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  68647. /**
  68648. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  68649. * @param renderWidth defines the rendering width
  68650. * @param renderHeight defines the rendering height
  68651. * @param ref defines the target viewport
  68652. * @returns the current viewport
  68653. */
  68654. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  68655. /**
  68656. * Returns a new Viewport copied from the current one
  68657. * @returns a new Viewport
  68658. */
  68659. clone(): Viewport;
  68660. }
  68661. }
  68662. declare module BABYLON {
  68663. /**
  68664. * Class containing a set of static utilities functions for arrays.
  68665. */
  68666. export class ArrayTools {
  68667. /**
  68668. * Returns an array of the given size filled with element built from the given constructor and the paramters
  68669. * @param size the number of element to construct and put in the array
  68670. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  68671. * @returns a new array filled with new objects
  68672. */
  68673. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  68674. }
  68675. }
  68676. declare module BABYLON {
  68677. /**
  68678. * Class representing a vector containing 2 coordinates
  68679. */
  68680. export class Vector2 {
  68681. /** defines the first coordinate */
  68682. x: number;
  68683. /** defines the second coordinate */
  68684. y: number;
  68685. /**
  68686. * Creates a new Vector2 from the given x and y coordinates
  68687. * @param x defines the first coordinate
  68688. * @param y defines the second coordinate
  68689. */
  68690. constructor(
  68691. /** defines the first coordinate */
  68692. x?: number,
  68693. /** defines the second coordinate */
  68694. y?: number);
  68695. /**
  68696. * Gets a string with the Vector2 coordinates
  68697. * @returns a string with the Vector2 coordinates
  68698. */
  68699. toString(): string;
  68700. /**
  68701. * Gets class name
  68702. * @returns the string "Vector2"
  68703. */
  68704. getClassName(): string;
  68705. /**
  68706. * Gets current vector hash code
  68707. * @returns the Vector2 hash code as a number
  68708. */
  68709. getHashCode(): number;
  68710. /**
  68711. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  68712. * @param array defines the source array
  68713. * @param index defines the offset in source array
  68714. * @returns the current Vector2
  68715. */
  68716. toArray(array: FloatArray, index?: number): Vector2;
  68717. /**
  68718. * Copy the current vector to an array
  68719. * @returns a new array with 2 elements: the Vector2 coordinates.
  68720. */
  68721. asArray(): number[];
  68722. /**
  68723. * Sets the Vector2 coordinates with the given Vector2 coordinates
  68724. * @param source defines the source Vector2
  68725. * @returns the current updated Vector2
  68726. */
  68727. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  68728. /**
  68729. * Sets the Vector2 coordinates with the given floats
  68730. * @param x defines the first coordinate
  68731. * @param y defines the second coordinate
  68732. * @returns the current updated Vector2
  68733. */
  68734. copyFromFloats(x: number, y: number): Vector2;
  68735. /**
  68736. * Sets the Vector2 coordinates with the given floats
  68737. * @param x defines the first coordinate
  68738. * @param y defines the second coordinate
  68739. * @returns the current updated Vector2
  68740. */
  68741. set(x: number, y: number): Vector2;
  68742. /**
  68743. * Add another vector with the current one
  68744. * @param otherVector defines the other vector
  68745. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  68746. */
  68747. add(otherVector: DeepImmutable<Vector2>): Vector2;
  68748. /**
  68749. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  68750. * @param otherVector defines the other vector
  68751. * @param result defines the target vector
  68752. * @returns the unmodified current Vector2
  68753. */
  68754. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68755. /**
  68756. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  68757. * @param otherVector defines the other vector
  68758. * @returns the current updated Vector2
  68759. */
  68760. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68761. /**
  68762. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  68763. * @param otherVector defines the other vector
  68764. * @returns a new Vector2
  68765. */
  68766. addVector3(otherVector: Vector3): Vector2;
  68767. /**
  68768. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  68769. * @param otherVector defines the other vector
  68770. * @returns a new Vector2
  68771. */
  68772. subtract(otherVector: Vector2): Vector2;
  68773. /**
  68774. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  68775. * @param otherVector defines the other vector
  68776. * @param result defines the target vector
  68777. * @returns the unmodified current Vector2
  68778. */
  68779. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68780. /**
  68781. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  68782. * @param otherVector defines the other vector
  68783. * @returns the current updated Vector2
  68784. */
  68785. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68786. /**
  68787. * Multiplies in place the current Vector2 coordinates by the given ones
  68788. * @param otherVector defines the other vector
  68789. * @returns the current updated Vector2
  68790. */
  68791. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68792. /**
  68793. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  68794. * @param otherVector defines the other vector
  68795. * @returns a new Vector2
  68796. */
  68797. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  68798. /**
  68799. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  68800. * @param otherVector defines the other vector
  68801. * @param result defines the target vector
  68802. * @returns the unmodified current Vector2
  68803. */
  68804. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68805. /**
  68806. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  68807. * @param x defines the first coordinate
  68808. * @param y defines the second coordinate
  68809. * @returns a new Vector2
  68810. */
  68811. multiplyByFloats(x: number, y: number): Vector2;
  68812. /**
  68813. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  68814. * @param otherVector defines the other vector
  68815. * @returns a new Vector2
  68816. */
  68817. divide(otherVector: Vector2): Vector2;
  68818. /**
  68819. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  68820. * @param otherVector defines the other vector
  68821. * @param result defines the target vector
  68822. * @returns the unmodified current Vector2
  68823. */
  68824. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  68825. /**
  68826. * Divides the current Vector2 coordinates by the given ones
  68827. * @param otherVector defines the other vector
  68828. * @returns the current updated Vector2
  68829. */
  68830. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  68831. /**
  68832. * Gets a new Vector2 with current Vector2 negated coordinates
  68833. * @returns a new Vector2
  68834. */
  68835. negate(): Vector2;
  68836. /**
  68837. * Multiply the Vector2 coordinates by scale
  68838. * @param scale defines the scaling factor
  68839. * @returns the current updated Vector2
  68840. */
  68841. scaleInPlace(scale: number): Vector2;
  68842. /**
  68843. * Returns a new Vector2 scaled by "scale" from the current Vector2
  68844. * @param scale defines the scaling factor
  68845. * @returns a new Vector2
  68846. */
  68847. scale(scale: number): Vector2;
  68848. /**
  68849. * Scale the current Vector2 values by a factor to a given Vector2
  68850. * @param scale defines the scale factor
  68851. * @param result defines the Vector2 object where to store the result
  68852. * @returns the unmodified current Vector2
  68853. */
  68854. scaleToRef(scale: number, result: Vector2): Vector2;
  68855. /**
  68856. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  68857. * @param scale defines the scale factor
  68858. * @param result defines the Vector2 object where to store the result
  68859. * @returns the unmodified current Vector2
  68860. */
  68861. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  68862. /**
  68863. * Gets a boolean if two vectors are equals
  68864. * @param otherVector defines the other vector
  68865. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  68866. */
  68867. equals(otherVector: DeepImmutable<Vector2>): boolean;
  68868. /**
  68869. * Gets a boolean if two vectors are equals (using an epsilon value)
  68870. * @param otherVector defines the other vector
  68871. * @param epsilon defines the minimal distance to consider equality
  68872. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  68873. */
  68874. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  68875. /**
  68876. * Gets a new Vector2 from current Vector2 floored values
  68877. * @returns a new Vector2
  68878. */
  68879. floor(): Vector2;
  68880. /**
  68881. * Gets a new Vector2 from current Vector2 floored values
  68882. * @returns a new Vector2
  68883. */
  68884. fract(): Vector2;
  68885. /**
  68886. * Gets the length of the vector
  68887. * @returns the vector length (float)
  68888. */
  68889. length(): number;
  68890. /**
  68891. * Gets the vector squared length
  68892. * @returns the vector squared length (float)
  68893. */
  68894. lengthSquared(): number;
  68895. /**
  68896. * Normalize the vector
  68897. * @returns the current updated Vector2
  68898. */
  68899. normalize(): Vector2;
  68900. /**
  68901. * Gets a new Vector2 copied from the Vector2
  68902. * @returns a new Vector2
  68903. */
  68904. clone(): Vector2;
  68905. /**
  68906. * Gets a new Vector2(0, 0)
  68907. * @returns a new Vector2
  68908. */
  68909. static Zero(): Vector2;
  68910. /**
  68911. * Gets a new Vector2(1, 1)
  68912. * @returns a new Vector2
  68913. */
  68914. static One(): Vector2;
  68915. /**
  68916. * Gets a new Vector2 set from the given index element of the given array
  68917. * @param array defines the data source
  68918. * @param offset defines the offset in the data source
  68919. * @returns a new Vector2
  68920. */
  68921. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  68922. /**
  68923. * Sets "result" from the given index element of the given array
  68924. * @param array defines the data source
  68925. * @param offset defines the offset in the data source
  68926. * @param result defines the target vector
  68927. */
  68928. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  68929. /**
  68930. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  68931. * @param value1 defines 1st point of control
  68932. * @param value2 defines 2nd point of control
  68933. * @param value3 defines 3rd point of control
  68934. * @param value4 defines 4th point of control
  68935. * @param amount defines the interpolation factor
  68936. * @returns a new Vector2
  68937. */
  68938. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  68939. /**
  68940. * 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".
  68941. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  68942. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  68943. * @param value defines the value to clamp
  68944. * @param min defines the lower limit
  68945. * @param max defines the upper limit
  68946. * @returns a new Vector2
  68947. */
  68948. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  68949. /**
  68950. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  68951. * @param value1 defines the 1st control point
  68952. * @param tangent1 defines the outgoing tangent
  68953. * @param value2 defines the 2nd control point
  68954. * @param tangent2 defines the incoming tangent
  68955. * @param amount defines the interpolation factor
  68956. * @returns a new Vector2
  68957. */
  68958. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  68959. /**
  68960. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  68961. * @param start defines the start vector
  68962. * @param end defines the end vector
  68963. * @param amount defines the interpolation factor
  68964. * @returns a new Vector2
  68965. */
  68966. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  68967. /**
  68968. * Gets the dot product of the vector "left" and the vector "right"
  68969. * @param left defines first vector
  68970. * @param right defines second vector
  68971. * @returns the dot product (float)
  68972. */
  68973. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  68974. /**
  68975. * Returns a new Vector2 equal to the normalized given vector
  68976. * @param vector defines the vector to normalize
  68977. * @returns a new Vector2
  68978. */
  68979. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  68980. /**
  68981. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  68982. * @param left defines 1st vector
  68983. * @param right defines 2nd vector
  68984. * @returns a new Vector2
  68985. */
  68986. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68987. /**
  68988. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  68989. * @param left defines 1st vector
  68990. * @param right defines 2nd vector
  68991. * @returns a new Vector2
  68992. */
  68993. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  68994. /**
  68995. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  68996. * @param vector defines the vector to transform
  68997. * @param transformation defines the matrix to apply
  68998. * @returns a new Vector2
  68999. */
  69000. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  69001. /**
  69002. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69003. * @param vector defines the vector to transform
  69004. * @param transformation defines the matrix to apply
  69005. * @param result defines the target vector
  69006. */
  69007. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  69008. /**
  69009. * Determines if a given vector is included in a triangle
  69010. * @param p defines the vector to test
  69011. * @param p0 defines 1st triangle point
  69012. * @param p1 defines 2nd triangle point
  69013. * @param p2 defines 3rd triangle point
  69014. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69015. */
  69016. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  69017. /**
  69018. * Gets the distance between the vectors "value1" and "value2"
  69019. * @param value1 defines first vector
  69020. * @param value2 defines second vector
  69021. * @returns the distance between vectors
  69022. */
  69023. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69024. /**
  69025. * Returns the squared distance between the vectors "value1" and "value2"
  69026. * @param value1 defines first vector
  69027. * @param value2 defines second vector
  69028. * @returns the squared distance between vectors
  69029. */
  69030. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  69031. /**
  69032. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69033. * @param value1 defines first vector
  69034. * @param value2 defines second vector
  69035. * @returns a new Vector2
  69036. */
  69037. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  69038. /**
  69039. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69040. * @param p defines the middle point
  69041. * @param segA defines one point of the segment
  69042. * @param segB defines the other point of the segment
  69043. * @returns the shortest distance
  69044. */
  69045. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  69046. }
  69047. /**
  69048. * Classed used to store (x,y,z) vector representation
  69049. * A Vector3 is the main object used in 3D geometry
  69050. * It can represent etiher the coordinates of a point the space, either a direction
  69051. * Reminder: js uses a left handed forward facing system
  69052. */
  69053. export class Vector3 {
  69054. /**
  69055. * Defines the first coordinates (on X axis)
  69056. */
  69057. x: number;
  69058. /**
  69059. * Defines the second coordinates (on Y axis)
  69060. */
  69061. y: number;
  69062. /**
  69063. * Defines the third coordinates (on Z axis)
  69064. */
  69065. z: number;
  69066. private static _UpReadOnly;
  69067. private static _ZeroReadOnly;
  69068. /**
  69069. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69070. * @param x defines the first coordinates (on X axis)
  69071. * @param y defines the second coordinates (on Y axis)
  69072. * @param z defines the third coordinates (on Z axis)
  69073. */
  69074. constructor(
  69075. /**
  69076. * Defines the first coordinates (on X axis)
  69077. */
  69078. x?: number,
  69079. /**
  69080. * Defines the second coordinates (on Y axis)
  69081. */
  69082. y?: number,
  69083. /**
  69084. * Defines the third coordinates (on Z axis)
  69085. */
  69086. z?: number);
  69087. /**
  69088. * Creates a string representation of the Vector3
  69089. * @returns a string with the Vector3 coordinates.
  69090. */
  69091. toString(): string;
  69092. /**
  69093. * Gets the class name
  69094. * @returns the string "Vector3"
  69095. */
  69096. getClassName(): string;
  69097. /**
  69098. * Creates the Vector3 hash code
  69099. * @returns a number which tends to be unique between Vector3 instances
  69100. */
  69101. getHashCode(): number;
  69102. /**
  69103. * Creates an array containing three elements : the coordinates of the Vector3
  69104. * @returns a new array of numbers
  69105. */
  69106. asArray(): number[];
  69107. /**
  69108. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69109. * @param array defines the destination array
  69110. * @param index defines the offset in the destination array
  69111. * @returns the current Vector3
  69112. */
  69113. toArray(array: FloatArray, index?: number): Vector3;
  69114. /**
  69115. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69116. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69117. */
  69118. toQuaternion(): Quaternion;
  69119. /**
  69120. * Adds the given vector to the current Vector3
  69121. * @param otherVector defines the second operand
  69122. * @returns the current updated Vector3
  69123. */
  69124. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69125. /**
  69126. * Adds the given coordinates to the current Vector3
  69127. * @param x defines the x coordinate of the operand
  69128. * @param y defines the y coordinate of the operand
  69129. * @param z defines the z coordinate of the operand
  69130. * @returns the current updated Vector3
  69131. */
  69132. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69133. /**
  69134. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69135. * @param otherVector defines the second operand
  69136. * @returns the resulting Vector3
  69137. */
  69138. add(otherVector: DeepImmutable<Vector3>): Vector3;
  69139. /**
  69140. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69141. * @param otherVector defines the second operand
  69142. * @param result defines the Vector3 object where to store the result
  69143. * @returns the current Vector3
  69144. */
  69145. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69146. /**
  69147. * Subtract the given vector from the current Vector3
  69148. * @param otherVector defines the second operand
  69149. * @returns the current updated Vector3
  69150. */
  69151. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69152. /**
  69153. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69154. * @param otherVector defines the second operand
  69155. * @returns the resulting Vector3
  69156. */
  69157. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  69158. /**
  69159. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69160. * @param otherVector defines the second operand
  69161. * @param result defines the Vector3 object where to store the result
  69162. * @returns the current Vector3
  69163. */
  69164. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69165. /**
  69166. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69167. * @param x defines the x coordinate of the operand
  69168. * @param y defines the y coordinate of the operand
  69169. * @param z defines the z coordinate of the operand
  69170. * @returns the resulting Vector3
  69171. */
  69172. subtractFromFloats(x: number, y: number, z: number): Vector3;
  69173. /**
  69174. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69175. * @param x defines the x coordinate of the operand
  69176. * @param y defines the y coordinate of the operand
  69177. * @param z defines the z coordinate of the operand
  69178. * @param result defines the Vector3 object where to store the result
  69179. * @returns the current Vector3
  69180. */
  69181. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  69182. /**
  69183. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69184. * @returns a new Vector3
  69185. */
  69186. negate(): Vector3;
  69187. /**
  69188. * Multiplies the Vector3 coordinates by the float "scale"
  69189. * @param scale defines the multiplier factor
  69190. * @returns the current updated Vector3
  69191. */
  69192. scaleInPlace(scale: number): Vector3;
  69193. /**
  69194. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69195. * @param scale defines the multiplier factor
  69196. * @returns a new Vector3
  69197. */
  69198. scale(scale: number): Vector3;
  69199. /**
  69200. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69201. * @param scale defines the multiplier factor
  69202. * @param result defines the Vector3 object where to store the result
  69203. * @returns the current Vector3
  69204. */
  69205. scaleToRef(scale: number, result: Vector3): Vector3;
  69206. /**
  69207. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69208. * @param scale defines the scale factor
  69209. * @param result defines the Vector3 object where to store the result
  69210. * @returns the unmodified current Vector3
  69211. */
  69212. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  69213. /**
  69214. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69215. * @param otherVector defines the second operand
  69216. * @returns true if both vectors are equals
  69217. */
  69218. equals(otherVector: DeepImmutable<Vector3>): boolean;
  69219. /**
  69220. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69221. * @param otherVector defines the second operand
  69222. * @param epsilon defines the minimal distance to define values as equals
  69223. * @returns true if both vectors are distant less than epsilon
  69224. */
  69225. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  69226. /**
  69227. * Returns true if the current Vector3 coordinates equals the given floats
  69228. * @param x defines the x coordinate of the operand
  69229. * @param y defines the y coordinate of the operand
  69230. * @param z defines the z coordinate of the operand
  69231. * @returns true if both vectors are equals
  69232. */
  69233. equalsToFloats(x: number, y: number, z: number): boolean;
  69234. /**
  69235. * Multiplies the current Vector3 coordinates by the given ones
  69236. * @param otherVector defines the second operand
  69237. * @returns the current updated Vector3
  69238. */
  69239. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  69240. /**
  69241. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69242. * @param otherVector defines the second operand
  69243. * @returns the new Vector3
  69244. */
  69245. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  69246. /**
  69247. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69248. * @param otherVector defines the second operand
  69249. * @param result defines the Vector3 object where to store the result
  69250. * @returns the current Vector3
  69251. */
  69252. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69253. /**
  69254. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69255. * @param x defines the x coordinate of the operand
  69256. * @param y defines the y coordinate of the operand
  69257. * @param z defines the z coordinate of the operand
  69258. * @returns the new Vector3
  69259. */
  69260. multiplyByFloats(x: number, y: number, z: number): Vector3;
  69261. /**
  69262. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69263. * @param otherVector defines the second operand
  69264. * @returns the new Vector3
  69265. */
  69266. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  69267. /**
  69268. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69269. * @param otherVector defines the second operand
  69270. * @param result defines the Vector3 object where to store the result
  69271. * @returns the current Vector3
  69272. */
  69273. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  69274. /**
  69275. * Divides the current Vector3 coordinates by the given ones.
  69276. * @param otherVector defines the second operand
  69277. * @returns the current updated Vector3
  69278. */
  69279. divideInPlace(otherVector: Vector3): Vector3;
  69280. /**
  69281. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  69282. * @param other defines the second operand
  69283. * @returns the current updated Vector3
  69284. */
  69285. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69286. /**
  69287. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  69288. * @param other defines the second operand
  69289. * @returns the current updated Vector3
  69290. */
  69291. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  69292. /**
  69293. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  69294. * @param x defines the x coordinate of the operand
  69295. * @param y defines the y coordinate of the operand
  69296. * @param z defines the z coordinate of the operand
  69297. * @returns the current updated Vector3
  69298. */
  69299. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69300. /**
  69301. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  69302. * @param x defines the x coordinate of the operand
  69303. * @param y defines the y coordinate of the operand
  69304. * @param z defines the z coordinate of the operand
  69305. * @returns the current updated Vector3
  69306. */
  69307. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  69308. /**
  69309. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  69310. * Check if is non uniform within a certain amount of decimal places to account for this
  69311. * @param epsilon the amount the values can differ
  69312. * @returns if the the vector is non uniform to a certain number of decimal places
  69313. */
  69314. isNonUniformWithinEpsilon(epsilon: number): boolean;
  69315. /**
  69316. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  69317. */
  69318. readonly isNonUniform: boolean;
  69319. /**
  69320. * Gets a new Vector3 from current Vector3 floored values
  69321. * @returns a new Vector3
  69322. */
  69323. floor(): Vector3;
  69324. /**
  69325. * Gets a new Vector3 from current Vector3 floored values
  69326. * @returns a new Vector3
  69327. */
  69328. fract(): Vector3;
  69329. /**
  69330. * Gets the length of the Vector3
  69331. * @returns the length of the Vector3
  69332. */
  69333. length(): number;
  69334. /**
  69335. * Gets the squared length of the Vector3
  69336. * @returns squared length of the Vector3
  69337. */
  69338. lengthSquared(): number;
  69339. /**
  69340. * Normalize the current Vector3.
  69341. * Please note that this is an in place operation.
  69342. * @returns the current updated Vector3
  69343. */
  69344. normalize(): Vector3;
  69345. /**
  69346. * Reorders the x y z properties of the vector in place
  69347. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  69348. * @returns the current updated vector
  69349. */
  69350. reorderInPlace(order: string): this;
  69351. /**
  69352. * Rotates the vector around 0,0,0 by a quaternion
  69353. * @param quaternion the rotation quaternion
  69354. * @param result vector to store the result
  69355. * @returns the resulting vector
  69356. */
  69357. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  69358. /**
  69359. * Rotates a vector around a given point
  69360. * @param quaternion the rotation quaternion
  69361. * @param point the point to rotate around
  69362. * @param result vector to store the result
  69363. * @returns the resulting vector
  69364. */
  69365. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  69366. /**
  69367. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  69368. * The cross product is then orthogonal to both current and "other"
  69369. * @param other defines the right operand
  69370. * @returns the cross product
  69371. */
  69372. cross(other: Vector3): Vector3;
  69373. /**
  69374. * Normalize the current Vector3 with the given input length.
  69375. * Please note that this is an in place operation.
  69376. * @param len the length of the vector
  69377. * @returns the current updated Vector3
  69378. */
  69379. normalizeFromLength(len: number): Vector3;
  69380. /**
  69381. * Normalize the current Vector3 to a new vector
  69382. * @returns the new Vector3
  69383. */
  69384. normalizeToNew(): Vector3;
  69385. /**
  69386. * Normalize the current Vector3 to the reference
  69387. * @param reference define the Vector3 to update
  69388. * @returns the updated Vector3
  69389. */
  69390. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  69391. /**
  69392. * Creates a new Vector3 copied from the current Vector3
  69393. * @returns the new Vector3
  69394. */
  69395. clone(): Vector3;
  69396. /**
  69397. * Copies the given vector coordinates to the current Vector3 ones
  69398. * @param source defines the source Vector3
  69399. * @returns the current updated Vector3
  69400. */
  69401. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  69402. /**
  69403. * Copies the given floats to the current Vector3 coordinates
  69404. * @param x defines the x coordinate of the operand
  69405. * @param y defines the y coordinate of the operand
  69406. * @param z defines the z coordinate of the operand
  69407. * @returns the current updated Vector3
  69408. */
  69409. copyFromFloats(x: number, y: number, z: number): Vector3;
  69410. /**
  69411. * Copies the given floats to the current Vector3 coordinates
  69412. * @param x defines the x coordinate of the operand
  69413. * @param y defines the y coordinate of the operand
  69414. * @param z defines the z coordinate of the operand
  69415. * @returns the current updated Vector3
  69416. */
  69417. set(x: number, y: number, z: number): Vector3;
  69418. /**
  69419. * Copies the given float to the current Vector3 coordinates
  69420. * @param v defines the x, y and z coordinates of the operand
  69421. * @returns the current updated Vector3
  69422. */
  69423. setAll(v: number): Vector3;
  69424. /**
  69425. * Get the clip factor between two vectors
  69426. * @param vector0 defines the first operand
  69427. * @param vector1 defines the second operand
  69428. * @param axis defines the axis to use
  69429. * @param size defines the size along the axis
  69430. * @returns the clip factor
  69431. */
  69432. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  69433. /**
  69434. * Get angle between two vectors
  69435. * @param vector0 angle between vector0 and vector1
  69436. * @param vector1 angle between vector0 and vector1
  69437. * @param normal direction of the normal
  69438. * @return the angle between vector0 and vector1
  69439. */
  69440. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  69441. /**
  69442. * Returns a new Vector3 set from the index "offset" of the given array
  69443. * @param array defines the source array
  69444. * @param offset defines the offset in the source array
  69445. * @returns the new Vector3
  69446. */
  69447. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  69448. /**
  69449. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  69450. * This function is deprecated. Use FromArray instead
  69451. * @param array defines the source array
  69452. * @param offset defines the offset in the source array
  69453. * @returns the new Vector3
  69454. */
  69455. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  69456. /**
  69457. * Sets the given vector "result" with the element values from the index "offset" of the given array
  69458. * @param array defines the source array
  69459. * @param offset defines the offset in the source array
  69460. * @param result defines the Vector3 where to store the result
  69461. */
  69462. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  69463. /**
  69464. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  69465. * This function is deprecated. Use FromArrayToRef instead.
  69466. * @param array defines the source array
  69467. * @param offset defines the offset in the source array
  69468. * @param result defines the Vector3 where to store the result
  69469. */
  69470. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  69471. /**
  69472. * Sets the given vector "result" with the given floats.
  69473. * @param x defines the x coordinate of the source
  69474. * @param y defines the y coordinate of the source
  69475. * @param z defines the z coordinate of the source
  69476. * @param result defines the Vector3 where to store the result
  69477. */
  69478. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  69479. /**
  69480. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  69481. * @returns a new empty Vector3
  69482. */
  69483. static Zero(): Vector3;
  69484. /**
  69485. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  69486. * @returns a new unit Vector3
  69487. */
  69488. static One(): Vector3;
  69489. /**
  69490. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  69491. * @returns a new up Vector3
  69492. */
  69493. static Up(): Vector3;
  69494. /**
  69495. * Gets a up Vector3 that must not be updated
  69496. */
  69497. static readonly UpReadOnly: DeepImmutable<Vector3>;
  69498. /**
  69499. * Gets a zero Vector3 that must not be updated
  69500. */
  69501. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  69502. /**
  69503. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  69504. * @returns a new down Vector3
  69505. */
  69506. static Down(): Vector3;
  69507. /**
  69508. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  69509. * @returns a new forward Vector3
  69510. */
  69511. static Forward(): Vector3;
  69512. /**
  69513. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  69514. * @returns a new forward Vector3
  69515. */
  69516. static Backward(): Vector3;
  69517. /**
  69518. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  69519. * @returns a new right Vector3
  69520. */
  69521. static Right(): Vector3;
  69522. /**
  69523. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  69524. * @returns a new left Vector3
  69525. */
  69526. static Left(): Vector3;
  69527. /**
  69528. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  69529. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69530. * @param vector defines the Vector3 to transform
  69531. * @param transformation defines the transformation matrix
  69532. * @returns the transformed Vector3
  69533. */
  69534. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69535. /**
  69536. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  69537. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  69538. * @param vector defines the Vector3 to transform
  69539. * @param transformation defines the transformation matrix
  69540. * @param result defines the Vector3 where to store the result
  69541. */
  69542. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69543. /**
  69544. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  69545. * This method computes tranformed coordinates only, not transformed direction vectors
  69546. * @param x define the x coordinate of the source vector
  69547. * @param y define the y coordinate of the source vector
  69548. * @param z define the z coordinate of the source vector
  69549. * @param transformation defines the transformation matrix
  69550. * @param result defines the Vector3 where to store the result
  69551. */
  69552. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69553. /**
  69554. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  69555. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69556. * @param vector defines the Vector3 to transform
  69557. * @param transformation defines the transformation matrix
  69558. * @returns the new Vector3
  69559. */
  69560. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  69561. /**
  69562. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  69563. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69564. * @param vector defines the Vector3 to transform
  69565. * @param transformation defines the transformation matrix
  69566. * @param result defines the Vector3 where to store the result
  69567. */
  69568. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69569. /**
  69570. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  69571. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  69572. * @param x define the x coordinate of the source vector
  69573. * @param y define the y coordinate of the source vector
  69574. * @param z define the z coordinate of the source vector
  69575. * @param transformation defines the transformation matrix
  69576. * @param result defines the Vector3 where to store the result
  69577. */
  69578. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  69579. /**
  69580. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  69581. * @param value1 defines the first control point
  69582. * @param value2 defines the second control point
  69583. * @param value3 defines the third control point
  69584. * @param value4 defines the fourth control point
  69585. * @param amount defines the amount on the spline to use
  69586. * @returns the new Vector3
  69587. */
  69588. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  69589. /**
  69590. * 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"
  69591. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69592. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69593. * @param value defines the current value
  69594. * @param min defines the lower range value
  69595. * @param max defines the upper range value
  69596. * @returns the new Vector3
  69597. */
  69598. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  69599. /**
  69600. * 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"
  69601. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  69602. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  69603. * @param value defines the current value
  69604. * @param min defines the lower range value
  69605. * @param max defines the upper range value
  69606. * @param result defines the Vector3 where to store the result
  69607. */
  69608. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  69609. /**
  69610. * Checks if a given vector is inside a specific range
  69611. * @param v defines the vector to test
  69612. * @param min defines the minimum range
  69613. * @param max defines the maximum range
  69614. */
  69615. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  69616. /**
  69617. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  69618. * @param value1 defines the first control point
  69619. * @param tangent1 defines the first tangent vector
  69620. * @param value2 defines the second control point
  69621. * @param tangent2 defines the second tangent vector
  69622. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  69623. * @returns the new Vector3
  69624. */
  69625. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  69626. /**
  69627. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  69628. * @param start defines the start value
  69629. * @param end defines the end value
  69630. * @param amount max defines amount between both (between 0 and 1)
  69631. * @returns the new Vector3
  69632. */
  69633. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  69634. /**
  69635. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  69636. * @param start defines the start value
  69637. * @param end defines the end value
  69638. * @param amount max defines amount between both (between 0 and 1)
  69639. * @param result defines the Vector3 where to store the result
  69640. */
  69641. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  69642. /**
  69643. * Returns the dot product (float) between the vectors "left" and "right"
  69644. * @param left defines the left operand
  69645. * @param right defines the right operand
  69646. * @returns the dot product
  69647. */
  69648. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  69649. /**
  69650. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  69651. * The cross product is then orthogonal to both "left" and "right"
  69652. * @param left defines the left operand
  69653. * @param right defines the right operand
  69654. * @returns the cross product
  69655. */
  69656. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69657. /**
  69658. * Sets the given vector "result" with the cross product of "left" and "right"
  69659. * The cross product is then orthogonal to both "left" and "right"
  69660. * @param left defines the left operand
  69661. * @param right defines the right operand
  69662. * @param result defines the Vector3 where to store the result
  69663. */
  69664. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  69665. /**
  69666. * Returns a new Vector3 as the normalization of the given vector
  69667. * @param vector defines the Vector3 to normalize
  69668. * @returns the new Vector3
  69669. */
  69670. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  69671. /**
  69672. * Sets the given vector "result" with the normalization of the given first vector
  69673. * @param vector defines the Vector3 to normalize
  69674. * @param result defines the Vector3 where to store the result
  69675. */
  69676. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  69677. /**
  69678. * Project a Vector3 onto screen space
  69679. * @param vector defines the Vector3 to project
  69680. * @param world defines the world matrix to use
  69681. * @param transform defines the transform (view x projection) matrix to use
  69682. * @param viewport defines the screen viewport to use
  69683. * @returns the new Vector3
  69684. */
  69685. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  69686. /** @hidden */
  69687. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  69688. /**
  69689. * Unproject from screen space to object space
  69690. * @param source defines the screen space Vector3 to use
  69691. * @param viewportWidth defines the current width of the viewport
  69692. * @param viewportHeight defines the current height of the viewport
  69693. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69694. * @param transform defines the transform (view x projection) matrix to use
  69695. * @returns the new Vector3
  69696. */
  69697. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  69698. /**
  69699. * Unproject from screen space to object space
  69700. * @param source defines the screen space Vector3 to use
  69701. * @param viewportWidth defines the current width of the viewport
  69702. * @param viewportHeight defines the current height of the viewport
  69703. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69704. * @param view defines the view matrix to use
  69705. * @param projection defines the projection matrix to use
  69706. * @returns the new Vector3
  69707. */
  69708. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  69709. /**
  69710. * Unproject from screen space to object space
  69711. * @param source defines the screen space Vector3 to use
  69712. * @param viewportWidth defines the current width of the viewport
  69713. * @param viewportHeight defines the current height of the viewport
  69714. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69715. * @param view defines the view matrix to use
  69716. * @param projection defines the projection matrix to use
  69717. * @param result defines the Vector3 where to store the result
  69718. */
  69719. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69720. /**
  69721. * Unproject from screen space to object space
  69722. * @param sourceX defines the screen space x coordinate to use
  69723. * @param sourceY defines the screen space y coordinate to use
  69724. * @param sourceZ defines the screen space z coordinate to use
  69725. * @param viewportWidth defines the current width of the viewport
  69726. * @param viewportHeight defines the current height of the viewport
  69727. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  69728. * @param view defines the view matrix to use
  69729. * @param projection defines the projection matrix to use
  69730. * @param result defines the Vector3 where to store the result
  69731. */
  69732. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  69733. /**
  69734. * Gets the minimal coordinate values between two Vector3
  69735. * @param left defines the first operand
  69736. * @param right defines the second operand
  69737. * @returns the new Vector3
  69738. */
  69739. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69740. /**
  69741. * Gets the maximal coordinate values between two Vector3
  69742. * @param left defines the first operand
  69743. * @param right defines the second operand
  69744. * @returns the new Vector3
  69745. */
  69746. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  69747. /**
  69748. * Returns the distance between the vectors "value1" and "value2"
  69749. * @param value1 defines the first operand
  69750. * @param value2 defines the second operand
  69751. * @returns the distance
  69752. */
  69753. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69754. /**
  69755. * Returns the squared distance between the vectors "value1" and "value2"
  69756. * @param value1 defines the first operand
  69757. * @param value2 defines the second operand
  69758. * @returns the squared distance
  69759. */
  69760. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  69761. /**
  69762. * Returns a new Vector3 located at the center between "value1" and "value2"
  69763. * @param value1 defines the first operand
  69764. * @param value2 defines the second operand
  69765. * @returns the new Vector3
  69766. */
  69767. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  69768. /**
  69769. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  69770. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  69771. * to something in order to rotate it from its local system to the given target system
  69772. * Note: axis1, axis2 and axis3 are normalized during this operation
  69773. * @param axis1 defines the first axis
  69774. * @param axis2 defines the second axis
  69775. * @param axis3 defines the third axis
  69776. * @returns a new Vector3
  69777. */
  69778. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  69779. /**
  69780. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  69781. * @param axis1 defines the first axis
  69782. * @param axis2 defines the second axis
  69783. * @param axis3 defines the third axis
  69784. * @param ref defines the Vector3 where to store the result
  69785. */
  69786. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  69787. }
  69788. /**
  69789. * Vector4 class created for EulerAngle class conversion to Quaternion
  69790. */
  69791. export class Vector4 {
  69792. /** x value of the vector */
  69793. x: number;
  69794. /** y value of the vector */
  69795. y: number;
  69796. /** z value of the vector */
  69797. z: number;
  69798. /** w value of the vector */
  69799. w: number;
  69800. /**
  69801. * Creates a Vector4 object from the given floats.
  69802. * @param x x value of the vector
  69803. * @param y y value of the vector
  69804. * @param z z value of the vector
  69805. * @param w w value of the vector
  69806. */
  69807. constructor(
  69808. /** x value of the vector */
  69809. x: number,
  69810. /** y value of the vector */
  69811. y: number,
  69812. /** z value of the vector */
  69813. z: number,
  69814. /** w value of the vector */
  69815. w: number);
  69816. /**
  69817. * Returns the string with the Vector4 coordinates.
  69818. * @returns a string containing all the vector values
  69819. */
  69820. toString(): string;
  69821. /**
  69822. * Returns the string "Vector4".
  69823. * @returns "Vector4"
  69824. */
  69825. getClassName(): string;
  69826. /**
  69827. * Returns the Vector4 hash code.
  69828. * @returns a unique hash code
  69829. */
  69830. getHashCode(): number;
  69831. /**
  69832. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  69833. * @returns the resulting array
  69834. */
  69835. asArray(): number[];
  69836. /**
  69837. * Populates the given array from the given index with the Vector4 coordinates.
  69838. * @param array array to populate
  69839. * @param index index of the array to start at (default: 0)
  69840. * @returns the Vector4.
  69841. */
  69842. toArray(array: FloatArray, index?: number): Vector4;
  69843. /**
  69844. * Adds the given vector to the current Vector4.
  69845. * @param otherVector the vector to add
  69846. * @returns the updated Vector4.
  69847. */
  69848. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69849. /**
  69850. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  69851. * @param otherVector the vector to add
  69852. * @returns the resulting vector
  69853. */
  69854. add(otherVector: DeepImmutable<Vector4>): Vector4;
  69855. /**
  69856. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  69857. * @param otherVector the vector to add
  69858. * @param result the vector to store the result
  69859. * @returns the current Vector4.
  69860. */
  69861. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69862. /**
  69863. * Subtract in place the given vector from the current Vector4.
  69864. * @param otherVector the vector to subtract
  69865. * @returns the updated Vector4.
  69866. */
  69867. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  69868. /**
  69869. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  69870. * @param otherVector the vector to add
  69871. * @returns the new vector with the result
  69872. */
  69873. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  69874. /**
  69875. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  69876. * @param otherVector the vector to subtract
  69877. * @param result the vector to store the result
  69878. * @returns the current Vector4.
  69879. */
  69880. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69881. /**
  69882. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69883. */
  69884. /**
  69885. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69886. * @param x value to subtract
  69887. * @param y value to subtract
  69888. * @param z value to subtract
  69889. * @param w value to subtract
  69890. * @returns new vector containing the result
  69891. */
  69892. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  69893. /**
  69894. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  69895. * @param x value to subtract
  69896. * @param y value to subtract
  69897. * @param z value to subtract
  69898. * @param w value to subtract
  69899. * @param result the vector to store the result in
  69900. * @returns the current Vector4.
  69901. */
  69902. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  69903. /**
  69904. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  69905. * @returns a new vector with the negated values
  69906. */
  69907. negate(): Vector4;
  69908. /**
  69909. * Multiplies the current Vector4 coordinates by scale (float).
  69910. * @param scale the number to scale with
  69911. * @returns the updated Vector4.
  69912. */
  69913. scaleInPlace(scale: number): Vector4;
  69914. /**
  69915. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  69916. * @param scale the number to scale with
  69917. * @returns a new vector with the result
  69918. */
  69919. scale(scale: number): Vector4;
  69920. /**
  69921. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  69922. * @param scale the number to scale with
  69923. * @param result a vector to store the result in
  69924. * @returns the current Vector4.
  69925. */
  69926. scaleToRef(scale: number, result: Vector4): Vector4;
  69927. /**
  69928. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  69929. * @param scale defines the scale factor
  69930. * @param result defines the Vector4 object where to store the result
  69931. * @returns the unmodified current Vector4
  69932. */
  69933. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  69934. /**
  69935. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  69936. * @param otherVector the vector to compare against
  69937. * @returns true if they are equal
  69938. */
  69939. equals(otherVector: DeepImmutable<Vector4>): boolean;
  69940. /**
  69941. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  69942. * @param otherVector vector to compare against
  69943. * @param epsilon (Default: very small number)
  69944. * @returns true if they are equal
  69945. */
  69946. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  69947. /**
  69948. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  69949. * @param x x value to compare against
  69950. * @param y y value to compare against
  69951. * @param z z value to compare against
  69952. * @param w w value to compare against
  69953. * @returns true if equal
  69954. */
  69955. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  69956. /**
  69957. * Multiplies in place the current Vector4 by the given one.
  69958. * @param otherVector vector to multiple with
  69959. * @returns the updated Vector4.
  69960. */
  69961. multiplyInPlace(otherVector: Vector4): Vector4;
  69962. /**
  69963. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  69964. * @param otherVector vector to multiple with
  69965. * @returns resulting new vector
  69966. */
  69967. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  69968. /**
  69969. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  69970. * @param otherVector vector to multiple with
  69971. * @param result vector to store the result
  69972. * @returns the current Vector4.
  69973. */
  69974. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69975. /**
  69976. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  69977. * @param x x value multiply with
  69978. * @param y y value multiply with
  69979. * @param z z value multiply with
  69980. * @param w w value multiply with
  69981. * @returns resulting new vector
  69982. */
  69983. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  69984. /**
  69985. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  69986. * @param otherVector vector to devide with
  69987. * @returns resulting new vector
  69988. */
  69989. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  69990. /**
  69991. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  69992. * @param otherVector vector to devide with
  69993. * @param result vector to store the result
  69994. * @returns the current Vector4.
  69995. */
  69996. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  69997. /**
  69998. * Divides the current Vector3 coordinates by the given ones.
  69999. * @param otherVector vector to devide with
  70000. * @returns the updated Vector3.
  70001. */
  70002. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  70003. /**
  70004. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  70005. * @param other defines the second operand
  70006. * @returns the current updated Vector4
  70007. */
  70008. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70009. /**
  70010. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  70011. * @param other defines the second operand
  70012. * @returns the current updated Vector4
  70013. */
  70014. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  70015. /**
  70016. * Gets a new Vector4 from current Vector4 floored values
  70017. * @returns a new Vector4
  70018. */
  70019. floor(): Vector4;
  70020. /**
  70021. * Gets a new Vector4 from current Vector3 floored values
  70022. * @returns a new Vector4
  70023. */
  70024. fract(): Vector4;
  70025. /**
  70026. * Returns the Vector4 length (float).
  70027. * @returns the length
  70028. */
  70029. length(): number;
  70030. /**
  70031. * Returns the Vector4 squared length (float).
  70032. * @returns the length squared
  70033. */
  70034. lengthSquared(): number;
  70035. /**
  70036. * Normalizes in place the Vector4.
  70037. * @returns the updated Vector4.
  70038. */
  70039. normalize(): Vector4;
  70040. /**
  70041. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  70042. * @returns this converted to a new vector3
  70043. */
  70044. toVector3(): Vector3;
  70045. /**
  70046. * Returns a new Vector4 copied from the current one.
  70047. * @returns the new cloned vector
  70048. */
  70049. clone(): Vector4;
  70050. /**
  70051. * Updates the current Vector4 with the given one coordinates.
  70052. * @param source the source vector to copy from
  70053. * @returns the updated Vector4.
  70054. */
  70055. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  70056. /**
  70057. * Updates the current Vector4 coordinates with the given floats.
  70058. * @param x float to copy from
  70059. * @param y float to copy from
  70060. * @param z float to copy from
  70061. * @param w float to copy from
  70062. * @returns the updated Vector4.
  70063. */
  70064. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  70065. /**
  70066. * Updates the current Vector4 coordinates with the given floats.
  70067. * @param x float to set from
  70068. * @param y float to set from
  70069. * @param z float to set from
  70070. * @param w float to set from
  70071. * @returns the updated Vector4.
  70072. */
  70073. set(x: number, y: number, z: number, w: number): Vector4;
  70074. /**
  70075. * Copies the given float to the current Vector3 coordinates
  70076. * @param v defines the x, y, z and w coordinates of the operand
  70077. * @returns the current updated Vector3
  70078. */
  70079. setAll(v: number): Vector4;
  70080. /**
  70081. * Returns a new Vector4 set from the starting index of the given array.
  70082. * @param array the array to pull values from
  70083. * @param offset the offset into the array to start at
  70084. * @returns the new vector
  70085. */
  70086. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  70087. /**
  70088. * Updates the given vector "result" from the starting index of the given array.
  70089. * @param array the array to pull values from
  70090. * @param offset the offset into the array to start at
  70091. * @param result the vector to store the result in
  70092. */
  70093. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  70094. /**
  70095. * Updates the given vector "result" from the starting index of the given Float32Array.
  70096. * @param array the array to pull values from
  70097. * @param offset the offset into the array to start at
  70098. * @param result the vector to store the result in
  70099. */
  70100. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  70101. /**
  70102. * Updates the given vector "result" coordinates from the given floats.
  70103. * @param x float to set from
  70104. * @param y float to set from
  70105. * @param z float to set from
  70106. * @param w float to set from
  70107. * @param result the vector to the floats in
  70108. */
  70109. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  70110. /**
  70111. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  70112. * @returns the new vector
  70113. */
  70114. static Zero(): Vector4;
  70115. /**
  70116. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  70117. * @returns the new vector
  70118. */
  70119. static One(): Vector4;
  70120. /**
  70121. * Returns a new normalized Vector4 from the given one.
  70122. * @param vector the vector to normalize
  70123. * @returns the vector
  70124. */
  70125. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  70126. /**
  70127. * Updates the given vector "result" from the normalization of the given one.
  70128. * @param vector the vector to normalize
  70129. * @param result the vector to store the result in
  70130. */
  70131. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  70132. /**
  70133. * Returns a vector with the minimum values from the left and right vectors
  70134. * @param left left vector to minimize
  70135. * @param right right vector to minimize
  70136. * @returns a new vector with the minimum of the left and right vector values
  70137. */
  70138. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70139. /**
  70140. * Returns a vector with the maximum values from the left and right vectors
  70141. * @param left left vector to maximize
  70142. * @param right right vector to maximize
  70143. * @returns a new vector with the maximum of the left and right vector values
  70144. */
  70145. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  70146. /**
  70147. * Returns the distance (float) between the vectors "value1" and "value2".
  70148. * @param value1 value to calulate the distance between
  70149. * @param value2 value to calulate the distance between
  70150. * @return the distance between the two vectors
  70151. */
  70152. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70153. /**
  70154. * Returns the squared distance (float) between the vectors "value1" and "value2".
  70155. * @param value1 value to calulate the distance between
  70156. * @param value2 value to calulate the distance between
  70157. * @return the distance between the two vectors squared
  70158. */
  70159. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  70160. /**
  70161. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  70162. * @param value1 value to calulate the center between
  70163. * @param value2 value to calulate the center between
  70164. * @return the center between the two vectors
  70165. */
  70166. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  70167. /**
  70168. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  70169. * This methods computes transformed normalized direction vectors only.
  70170. * @param vector the vector to transform
  70171. * @param transformation the transformation matrix to apply
  70172. * @returns the new vector
  70173. */
  70174. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  70175. /**
  70176. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  70177. * This methods computes transformed normalized direction vectors only.
  70178. * @param vector the vector to transform
  70179. * @param transformation the transformation matrix to apply
  70180. * @param result the vector to store the result in
  70181. */
  70182. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70183. /**
  70184. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  70185. * This methods computes transformed normalized direction vectors only.
  70186. * @param x value to transform
  70187. * @param y value to transform
  70188. * @param z value to transform
  70189. * @param w value to transform
  70190. * @param transformation the transformation matrix to apply
  70191. * @param result the vector to store the results in
  70192. */
  70193. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  70194. /**
  70195. * Creates a new Vector4 from a Vector3
  70196. * @param source defines the source data
  70197. * @param w defines the 4th component (default is 0)
  70198. * @returns a new Vector4
  70199. */
  70200. static FromVector3(source: Vector3, w?: number): Vector4;
  70201. }
  70202. /**
  70203. * Class used to store quaternion data
  70204. * @see https://en.wikipedia.org/wiki/Quaternion
  70205. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  70206. */
  70207. export class Quaternion {
  70208. /** defines the first component (0 by default) */
  70209. x: number;
  70210. /** defines the second component (0 by default) */
  70211. y: number;
  70212. /** defines the third component (0 by default) */
  70213. z: number;
  70214. /** defines the fourth component (1.0 by default) */
  70215. w: number;
  70216. /**
  70217. * Creates a new Quaternion from the given floats
  70218. * @param x defines the first component (0 by default)
  70219. * @param y defines the second component (0 by default)
  70220. * @param z defines the third component (0 by default)
  70221. * @param w defines the fourth component (1.0 by default)
  70222. */
  70223. constructor(
  70224. /** defines the first component (0 by default) */
  70225. x?: number,
  70226. /** defines the second component (0 by default) */
  70227. y?: number,
  70228. /** defines the third component (0 by default) */
  70229. z?: number,
  70230. /** defines the fourth component (1.0 by default) */
  70231. w?: number);
  70232. /**
  70233. * Gets a string representation for the current quaternion
  70234. * @returns a string with the Quaternion coordinates
  70235. */
  70236. toString(): string;
  70237. /**
  70238. * Gets the class name of the quaternion
  70239. * @returns the string "Quaternion"
  70240. */
  70241. getClassName(): string;
  70242. /**
  70243. * Gets a hash code for this quaternion
  70244. * @returns the quaternion hash code
  70245. */
  70246. getHashCode(): number;
  70247. /**
  70248. * Copy the quaternion to an array
  70249. * @returns a new array populated with 4 elements from the quaternion coordinates
  70250. */
  70251. asArray(): number[];
  70252. /**
  70253. * Check if two quaternions are equals
  70254. * @param otherQuaternion defines the second operand
  70255. * @return true if the current quaternion and the given one coordinates are strictly equals
  70256. */
  70257. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  70258. /**
  70259. * Clone the current quaternion
  70260. * @returns a new quaternion copied from the current one
  70261. */
  70262. clone(): Quaternion;
  70263. /**
  70264. * Copy a quaternion to the current one
  70265. * @param other defines the other quaternion
  70266. * @returns the updated current quaternion
  70267. */
  70268. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  70269. /**
  70270. * Updates the current quaternion with the given float coordinates
  70271. * @param x defines the x coordinate
  70272. * @param y defines the y coordinate
  70273. * @param z defines the z coordinate
  70274. * @param w defines the w coordinate
  70275. * @returns the updated current quaternion
  70276. */
  70277. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  70278. /**
  70279. * Updates the current quaternion from the given float coordinates
  70280. * @param x defines the x coordinate
  70281. * @param y defines the y coordinate
  70282. * @param z defines the z coordinate
  70283. * @param w defines the w coordinate
  70284. * @returns the updated current quaternion
  70285. */
  70286. set(x: number, y: number, z: number, w: number): Quaternion;
  70287. /**
  70288. * Adds two quaternions
  70289. * @param other defines the second operand
  70290. * @returns a new quaternion as the addition result of the given one and the current quaternion
  70291. */
  70292. add(other: DeepImmutable<Quaternion>): Quaternion;
  70293. /**
  70294. * Add a quaternion to the current one
  70295. * @param other defines the quaternion to add
  70296. * @returns the current quaternion
  70297. */
  70298. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  70299. /**
  70300. * Subtract two quaternions
  70301. * @param other defines the second operand
  70302. * @returns a new quaternion as the subtraction result of the given one from the current one
  70303. */
  70304. subtract(other: Quaternion): Quaternion;
  70305. /**
  70306. * Multiplies the current quaternion by a scale factor
  70307. * @param value defines the scale factor
  70308. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  70309. */
  70310. scale(value: number): Quaternion;
  70311. /**
  70312. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  70313. * @param scale defines the scale factor
  70314. * @param result defines the Quaternion object where to store the result
  70315. * @returns the unmodified current quaternion
  70316. */
  70317. scaleToRef(scale: number, result: Quaternion): Quaternion;
  70318. /**
  70319. * Multiplies in place the current quaternion by a scale factor
  70320. * @param value defines the scale factor
  70321. * @returns the current modified quaternion
  70322. */
  70323. scaleInPlace(value: number): Quaternion;
  70324. /**
  70325. * Scale the current quaternion values by a factor and add the result to a given quaternion
  70326. * @param scale defines the scale factor
  70327. * @param result defines the Quaternion object where to store the result
  70328. * @returns the unmodified current quaternion
  70329. */
  70330. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  70331. /**
  70332. * Multiplies two quaternions
  70333. * @param q1 defines the second operand
  70334. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  70335. */
  70336. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  70337. /**
  70338. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  70339. * @param q1 defines the second operand
  70340. * @param result defines the target quaternion
  70341. * @returns the current quaternion
  70342. */
  70343. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  70344. /**
  70345. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  70346. * @param q1 defines the second operand
  70347. * @returns the currentupdated quaternion
  70348. */
  70349. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  70350. /**
  70351. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  70352. * @param ref defines the target quaternion
  70353. * @returns the current quaternion
  70354. */
  70355. conjugateToRef(ref: Quaternion): Quaternion;
  70356. /**
  70357. * Conjugates in place (1-q) the current quaternion
  70358. * @returns the current updated quaternion
  70359. */
  70360. conjugateInPlace(): Quaternion;
  70361. /**
  70362. * Conjugates in place (1-q) the current quaternion
  70363. * @returns a new quaternion
  70364. */
  70365. conjugate(): Quaternion;
  70366. /**
  70367. * Gets length of current quaternion
  70368. * @returns the quaternion length (float)
  70369. */
  70370. length(): number;
  70371. /**
  70372. * Normalize in place the current quaternion
  70373. * @returns the current updated quaternion
  70374. */
  70375. normalize(): Quaternion;
  70376. /**
  70377. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  70378. * @param order is a reserved parameter and is ignore for now
  70379. * @returns a new Vector3 containing the Euler angles
  70380. */
  70381. toEulerAngles(order?: string): Vector3;
  70382. /**
  70383. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  70384. * @param result defines the vector which will be filled with the Euler angles
  70385. * @param order is a reserved parameter and is ignore for now
  70386. * @returns the current unchanged quaternion
  70387. */
  70388. toEulerAnglesToRef(result: Vector3): Quaternion;
  70389. /**
  70390. * Updates the given rotation matrix with the current quaternion values
  70391. * @param result defines the target matrix
  70392. * @returns the current unchanged quaternion
  70393. */
  70394. toRotationMatrix(result: Matrix): Quaternion;
  70395. /**
  70396. * Updates the current quaternion from the given rotation matrix values
  70397. * @param matrix defines the source matrix
  70398. * @returns the current updated quaternion
  70399. */
  70400. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70401. /**
  70402. * Creates a new quaternion from a rotation matrix
  70403. * @param matrix defines the source matrix
  70404. * @returns a new quaternion created from the given rotation matrix values
  70405. */
  70406. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  70407. /**
  70408. * Updates the given quaternion with the given rotation matrix values
  70409. * @param matrix defines the source matrix
  70410. * @param result defines the target quaternion
  70411. */
  70412. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  70413. /**
  70414. * Returns the dot product (float) between the quaternions "left" and "right"
  70415. * @param left defines the left operand
  70416. * @param right defines the right operand
  70417. * @returns the dot product
  70418. */
  70419. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  70420. /**
  70421. * Checks if the two quaternions are close to each other
  70422. * @param quat0 defines the first quaternion to check
  70423. * @param quat1 defines the second quaternion to check
  70424. * @returns true if the two quaternions are close to each other
  70425. */
  70426. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  70427. /**
  70428. * Creates an empty quaternion
  70429. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  70430. */
  70431. static Zero(): Quaternion;
  70432. /**
  70433. * Inverse a given quaternion
  70434. * @param q defines the source quaternion
  70435. * @returns a new quaternion as the inverted current quaternion
  70436. */
  70437. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  70438. /**
  70439. * Inverse a given quaternion
  70440. * @param q defines the source quaternion
  70441. * @param result the quaternion the result will be stored in
  70442. * @returns the result quaternion
  70443. */
  70444. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  70445. /**
  70446. * Creates an identity quaternion
  70447. * @returns the identity quaternion
  70448. */
  70449. static Identity(): Quaternion;
  70450. /**
  70451. * Gets a boolean indicating if the given quaternion is identity
  70452. * @param quaternion defines the quaternion to check
  70453. * @returns true if the quaternion is identity
  70454. */
  70455. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  70456. /**
  70457. * Creates a quaternion from a rotation around an axis
  70458. * @param axis defines the axis to use
  70459. * @param angle defines the angle to use
  70460. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  70461. */
  70462. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  70463. /**
  70464. * Creates a rotation around an axis and stores it into the given quaternion
  70465. * @param axis defines the axis to use
  70466. * @param angle defines the angle to use
  70467. * @param result defines the target quaternion
  70468. * @returns the target quaternion
  70469. */
  70470. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  70471. /**
  70472. * Creates a new quaternion from data stored into an array
  70473. * @param array defines the data source
  70474. * @param offset defines the offset in the source array where the data starts
  70475. * @returns a new quaternion
  70476. */
  70477. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  70478. /**
  70479. * Create a quaternion from Euler rotation angles
  70480. * @param x Pitch
  70481. * @param y Yaw
  70482. * @param z Roll
  70483. * @returns the new Quaternion
  70484. */
  70485. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  70486. /**
  70487. * Updates a quaternion from Euler rotation angles
  70488. * @param x Pitch
  70489. * @param y Yaw
  70490. * @param z Roll
  70491. * @param result the quaternion to store the result
  70492. * @returns the updated quaternion
  70493. */
  70494. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  70495. /**
  70496. * Create a quaternion from Euler rotation vector
  70497. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70498. * @returns the new Quaternion
  70499. */
  70500. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  70501. /**
  70502. * Updates a quaternion from Euler rotation vector
  70503. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  70504. * @param result the quaternion to store the result
  70505. * @returns the updated quaternion
  70506. */
  70507. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  70508. /**
  70509. * Creates a new quaternion from the given Euler float angles (y, x, z)
  70510. * @param yaw defines the rotation around Y axis
  70511. * @param pitch defines the rotation around X axis
  70512. * @param roll defines the rotation around Z axis
  70513. * @returns the new quaternion
  70514. */
  70515. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  70516. /**
  70517. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  70518. * @param yaw defines the rotation around Y axis
  70519. * @param pitch defines the rotation around X axis
  70520. * @param roll defines the rotation around Z axis
  70521. * @param result defines the target quaternion
  70522. */
  70523. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  70524. /**
  70525. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  70526. * @param alpha defines the rotation around first axis
  70527. * @param beta defines the rotation around second axis
  70528. * @param gamma defines the rotation around third axis
  70529. * @returns the new quaternion
  70530. */
  70531. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  70532. /**
  70533. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  70534. * @param alpha defines the rotation around first axis
  70535. * @param beta defines the rotation around second axis
  70536. * @param gamma defines the rotation around third axis
  70537. * @param result defines the target quaternion
  70538. */
  70539. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  70540. /**
  70541. * 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)
  70542. * @param axis1 defines the first axis
  70543. * @param axis2 defines the second axis
  70544. * @param axis3 defines the third axis
  70545. * @returns the new quaternion
  70546. */
  70547. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  70548. /**
  70549. * 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
  70550. * @param axis1 defines the first axis
  70551. * @param axis2 defines the second axis
  70552. * @param axis3 defines the third axis
  70553. * @param ref defines the target quaternion
  70554. */
  70555. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  70556. /**
  70557. * Interpolates between two quaternions
  70558. * @param left defines first quaternion
  70559. * @param right defines second quaternion
  70560. * @param amount defines the gradient to use
  70561. * @returns the new interpolated quaternion
  70562. */
  70563. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70564. /**
  70565. * Interpolates between two quaternions and stores it into a target quaternion
  70566. * @param left defines first quaternion
  70567. * @param right defines second quaternion
  70568. * @param amount defines the gradient to use
  70569. * @param result defines the target quaternion
  70570. */
  70571. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  70572. /**
  70573. * Interpolate between two quaternions using Hermite interpolation
  70574. * @param value1 defines first quaternion
  70575. * @param tangent1 defines the incoming tangent
  70576. * @param value2 defines second quaternion
  70577. * @param tangent2 defines the outgoing tangent
  70578. * @param amount defines the target quaternion
  70579. * @returns the new interpolated quaternion
  70580. */
  70581. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  70582. }
  70583. /**
  70584. * Class used to store matrix data (4x4)
  70585. */
  70586. export class Matrix {
  70587. private static _updateFlagSeed;
  70588. private static _identityReadOnly;
  70589. private _isIdentity;
  70590. private _isIdentityDirty;
  70591. private _isIdentity3x2;
  70592. private _isIdentity3x2Dirty;
  70593. /**
  70594. * Gets the update flag of the matrix which is an unique number for the matrix.
  70595. * It will be incremented every time the matrix data change.
  70596. * You can use it to speed the comparison between two versions of the same matrix.
  70597. */
  70598. updateFlag: number;
  70599. private readonly _m;
  70600. /**
  70601. * Gets the internal data of the matrix
  70602. */
  70603. readonly m: DeepImmutable<Float32Array>;
  70604. /** @hidden */
  70605. _markAsUpdated(): void;
  70606. /** @hidden */
  70607. private _updateIdentityStatus;
  70608. /**
  70609. * Creates an empty matrix (filled with zeros)
  70610. */
  70611. constructor();
  70612. /**
  70613. * Check if the current matrix is identity
  70614. * @returns true is the matrix is the identity matrix
  70615. */
  70616. isIdentity(): boolean;
  70617. /**
  70618. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  70619. * @returns true is the matrix is the identity matrix
  70620. */
  70621. isIdentityAs3x2(): boolean;
  70622. /**
  70623. * Gets the determinant of the matrix
  70624. * @returns the matrix determinant
  70625. */
  70626. determinant(): number;
  70627. /**
  70628. * Returns the matrix as a Float32Array
  70629. * @returns the matrix underlying array
  70630. */
  70631. toArray(): DeepImmutable<Float32Array>;
  70632. /**
  70633. * Returns the matrix as a Float32Array
  70634. * @returns the matrix underlying array.
  70635. */
  70636. asArray(): DeepImmutable<Float32Array>;
  70637. /**
  70638. * Inverts the current matrix in place
  70639. * @returns the current inverted matrix
  70640. */
  70641. invert(): Matrix;
  70642. /**
  70643. * Sets all the matrix elements to zero
  70644. * @returns the current matrix
  70645. */
  70646. reset(): Matrix;
  70647. /**
  70648. * Adds the current matrix with a second one
  70649. * @param other defines the matrix to add
  70650. * @returns a new matrix as the addition of the current matrix and the given one
  70651. */
  70652. add(other: DeepImmutable<Matrix>): Matrix;
  70653. /**
  70654. * Sets the given matrix "result" to the addition of the current matrix and the given one
  70655. * @param other defines the matrix to add
  70656. * @param result defines the target matrix
  70657. * @returns the current matrix
  70658. */
  70659. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70660. /**
  70661. * Adds in place the given matrix to the current matrix
  70662. * @param other defines the second operand
  70663. * @returns the current updated matrix
  70664. */
  70665. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  70666. /**
  70667. * Sets the given matrix to the current inverted Matrix
  70668. * @param other defines the target matrix
  70669. * @returns the unmodified current matrix
  70670. */
  70671. invertToRef(other: Matrix): Matrix;
  70672. /**
  70673. * add a value at the specified position in the current Matrix
  70674. * @param index the index of the value within the matrix. between 0 and 15.
  70675. * @param value the value to be added
  70676. * @returns the current updated matrix
  70677. */
  70678. addAtIndex(index: number, value: number): Matrix;
  70679. /**
  70680. * mutiply the specified position in the current Matrix by a value
  70681. * @param index the index of the value within the matrix. between 0 and 15.
  70682. * @param value the value to be added
  70683. * @returns the current updated matrix
  70684. */
  70685. multiplyAtIndex(index: number, value: number): Matrix;
  70686. /**
  70687. * Inserts the translation vector (using 3 floats) in the current matrix
  70688. * @param x defines the 1st component of the translation
  70689. * @param y defines the 2nd component of the translation
  70690. * @param z defines the 3rd component of the translation
  70691. * @returns the current updated matrix
  70692. */
  70693. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70694. /**
  70695. * Adds the translation vector (using 3 floats) in the current matrix
  70696. * @param x defines the 1st component of the translation
  70697. * @param y defines the 2nd component of the translation
  70698. * @param z defines the 3rd component of the translation
  70699. * @returns the current updated matrix
  70700. */
  70701. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  70702. /**
  70703. * Inserts the translation vector in the current matrix
  70704. * @param vector3 defines the translation to insert
  70705. * @returns the current updated matrix
  70706. */
  70707. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  70708. /**
  70709. * Gets the translation value of the current matrix
  70710. * @returns a new Vector3 as the extracted translation from the matrix
  70711. */
  70712. getTranslation(): Vector3;
  70713. /**
  70714. * Fill a Vector3 with the extracted translation from the matrix
  70715. * @param result defines the Vector3 where to store the translation
  70716. * @returns the current matrix
  70717. */
  70718. getTranslationToRef(result: Vector3): Matrix;
  70719. /**
  70720. * Remove rotation and scaling part from the matrix
  70721. * @returns the updated matrix
  70722. */
  70723. removeRotationAndScaling(): Matrix;
  70724. /**
  70725. * Multiply two matrices
  70726. * @param other defines the second operand
  70727. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  70728. */
  70729. multiply(other: DeepImmutable<Matrix>): Matrix;
  70730. /**
  70731. * Copy the current matrix from the given one
  70732. * @param other defines the source matrix
  70733. * @returns the current updated matrix
  70734. */
  70735. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  70736. /**
  70737. * Populates the given array from the starting index with the current matrix values
  70738. * @param array defines the target array
  70739. * @param offset defines the offset in the target array where to start storing values
  70740. * @returns the current matrix
  70741. */
  70742. copyToArray(array: Float32Array, offset?: number): Matrix;
  70743. /**
  70744. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  70745. * @param other defines the second operand
  70746. * @param result defines the matrix where to store the multiplication
  70747. * @returns the current matrix
  70748. */
  70749. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  70750. /**
  70751. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  70752. * @param other defines the second operand
  70753. * @param result defines the array where to store the multiplication
  70754. * @param offset defines the offset in the target array where to start storing values
  70755. * @returns the current matrix
  70756. */
  70757. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  70758. /**
  70759. * Check equality between this matrix and a second one
  70760. * @param value defines the second matrix to compare
  70761. * @returns true is the current matrix and the given one values are strictly equal
  70762. */
  70763. equals(value: DeepImmutable<Matrix>): boolean;
  70764. /**
  70765. * Clone the current matrix
  70766. * @returns a new matrix from the current matrix
  70767. */
  70768. clone(): Matrix;
  70769. /**
  70770. * Returns the name of the current matrix class
  70771. * @returns the string "Matrix"
  70772. */
  70773. getClassName(): string;
  70774. /**
  70775. * Gets the hash code of the current matrix
  70776. * @returns the hash code
  70777. */
  70778. getHashCode(): number;
  70779. /**
  70780. * Decomposes the current Matrix into a translation, rotation and scaling components
  70781. * @param scale defines the scale vector3 given as a reference to update
  70782. * @param rotation defines the rotation quaternion given as a reference to update
  70783. * @param translation defines the translation vector3 given as a reference to update
  70784. * @returns true if operation was successful
  70785. */
  70786. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  70787. /**
  70788. * Gets specific row of the matrix
  70789. * @param index defines the number of the row to get
  70790. * @returns the index-th row of the current matrix as a new Vector4
  70791. */
  70792. getRow(index: number): Nullable<Vector4>;
  70793. /**
  70794. * Sets the index-th row of the current matrix to the vector4 values
  70795. * @param index defines the number of the row to set
  70796. * @param row defines the target vector4
  70797. * @returns the updated current matrix
  70798. */
  70799. setRow(index: number, row: Vector4): Matrix;
  70800. /**
  70801. * Compute the transpose of the matrix
  70802. * @returns the new transposed matrix
  70803. */
  70804. transpose(): Matrix;
  70805. /**
  70806. * Compute the transpose of the matrix and store it in a given matrix
  70807. * @param result defines the target matrix
  70808. * @returns the current matrix
  70809. */
  70810. transposeToRef(result: Matrix): Matrix;
  70811. /**
  70812. * Sets the index-th row of the current matrix with the given 4 x float values
  70813. * @param index defines the row index
  70814. * @param x defines the x component to set
  70815. * @param y defines the y component to set
  70816. * @param z defines the z component to set
  70817. * @param w defines the w component to set
  70818. * @returns the updated current matrix
  70819. */
  70820. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  70821. /**
  70822. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  70823. * @param scale defines the scale factor
  70824. * @returns a new matrix
  70825. */
  70826. scale(scale: number): Matrix;
  70827. /**
  70828. * Scale the current matrix values by a factor to a given result matrix
  70829. * @param scale defines the scale factor
  70830. * @param result defines the matrix to store the result
  70831. * @returns the current matrix
  70832. */
  70833. scaleToRef(scale: number, result: Matrix): Matrix;
  70834. /**
  70835. * Scale the current matrix values by a factor and add the result to a given matrix
  70836. * @param scale defines the scale factor
  70837. * @param result defines the Matrix to store the result
  70838. * @returns the current matrix
  70839. */
  70840. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  70841. /**
  70842. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  70843. * @param ref matrix to store the result
  70844. */
  70845. toNormalMatrix(ref: Matrix): void;
  70846. /**
  70847. * Gets only rotation part of the current matrix
  70848. * @returns a new matrix sets to the extracted rotation matrix from the current one
  70849. */
  70850. getRotationMatrix(): Matrix;
  70851. /**
  70852. * Extracts the rotation matrix from the current one and sets it as the given "result"
  70853. * @param result defines the target matrix to store data to
  70854. * @returns the current matrix
  70855. */
  70856. getRotationMatrixToRef(result: Matrix): Matrix;
  70857. /**
  70858. * Toggles model matrix from being right handed to left handed in place and vice versa
  70859. */
  70860. toggleModelMatrixHandInPlace(): void;
  70861. /**
  70862. * Toggles projection matrix from being right handed to left handed in place and vice versa
  70863. */
  70864. toggleProjectionMatrixHandInPlace(): void;
  70865. /**
  70866. * Creates a matrix from an array
  70867. * @param array defines the source array
  70868. * @param offset defines an offset in the source array
  70869. * @returns a new Matrix set from the starting index of the given array
  70870. */
  70871. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  70872. /**
  70873. * Copy the content of an array into a given matrix
  70874. * @param array defines the source array
  70875. * @param offset defines an offset in the source array
  70876. * @param result defines the target matrix
  70877. */
  70878. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  70879. /**
  70880. * Stores an array into a matrix after having multiplied each component by a given factor
  70881. * @param array defines the source array
  70882. * @param offset defines the offset in the source array
  70883. * @param scale defines the scaling factor
  70884. * @param result defines the target matrix
  70885. */
  70886. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  70887. /**
  70888. * Gets an identity matrix that must not be updated
  70889. */
  70890. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  70891. /**
  70892. * Stores a list of values (16) inside a given matrix
  70893. * @param initialM11 defines 1st value of 1st row
  70894. * @param initialM12 defines 2nd value of 1st row
  70895. * @param initialM13 defines 3rd value of 1st row
  70896. * @param initialM14 defines 4th value of 1st row
  70897. * @param initialM21 defines 1st value of 2nd row
  70898. * @param initialM22 defines 2nd value of 2nd row
  70899. * @param initialM23 defines 3rd value of 2nd row
  70900. * @param initialM24 defines 4th value of 2nd row
  70901. * @param initialM31 defines 1st value of 3rd row
  70902. * @param initialM32 defines 2nd value of 3rd row
  70903. * @param initialM33 defines 3rd value of 3rd row
  70904. * @param initialM34 defines 4th value of 3rd row
  70905. * @param initialM41 defines 1st value of 4th row
  70906. * @param initialM42 defines 2nd value of 4th row
  70907. * @param initialM43 defines 3rd value of 4th row
  70908. * @param initialM44 defines 4th value of 4th row
  70909. * @param result defines the target matrix
  70910. */
  70911. 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;
  70912. /**
  70913. * Creates new matrix from a list of values (16)
  70914. * @param initialM11 defines 1st value of 1st row
  70915. * @param initialM12 defines 2nd value of 1st row
  70916. * @param initialM13 defines 3rd value of 1st row
  70917. * @param initialM14 defines 4th value of 1st row
  70918. * @param initialM21 defines 1st value of 2nd row
  70919. * @param initialM22 defines 2nd value of 2nd row
  70920. * @param initialM23 defines 3rd value of 2nd row
  70921. * @param initialM24 defines 4th value of 2nd row
  70922. * @param initialM31 defines 1st value of 3rd row
  70923. * @param initialM32 defines 2nd value of 3rd row
  70924. * @param initialM33 defines 3rd value of 3rd row
  70925. * @param initialM34 defines 4th value of 3rd row
  70926. * @param initialM41 defines 1st value of 4th row
  70927. * @param initialM42 defines 2nd value of 4th row
  70928. * @param initialM43 defines 3rd value of 4th row
  70929. * @param initialM44 defines 4th value of 4th row
  70930. * @returns the new matrix
  70931. */
  70932. 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;
  70933. /**
  70934. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70935. * @param scale defines the scale vector3
  70936. * @param rotation defines the rotation quaternion
  70937. * @param translation defines the translation vector3
  70938. * @returns a new matrix
  70939. */
  70940. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  70941. /**
  70942. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  70943. * @param scale defines the scale vector3
  70944. * @param rotation defines the rotation quaternion
  70945. * @param translation defines the translation vector3
  70946. * @param result defines the target matrix
  70947. */
  70948. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  70949. /**
  70950. * Creates a new identity matrix
  70951. * @returns a new identity matrix
  70952. */
  70953. static Identity(): Matrix;
  70954. /**
  70955. * Creates a new identity matrix and stores the result in a given matrix
  70956. * @param result defines the target matrix
  70957. */
  70958. static IdentityToRef(result: Matrix): void;
  70959. /**
  70960. * Creates a new zero matrix
  70961. * @returns a new zero matrix
  70962. */
  70963. static Zero(): Matrix;
  70964. /**
  70965. * Creates a new rotation matrix for "angle" radians around the X axis
  70966. * @param angle defines the angle (in radians) to use
  70967. * @return the new matrix
  70968. */
  70969. static RotationX(angle: number): Matrix;
  70970. /**
  70971. * Creates a new matrix as the invert of a given matrix
  70972. * @param source defines the source matrix
  70973. * @returns the new matrix
  70974. */
  70975. static Invert(source: DeepImmutable<Matrix>): Matrix;
  70976. /**
  70977. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  70978. * @param angle defines the angle (in radians) to use
  70979. * @param result defines the target matrix
  70980. */
  70981. static RotationXToRef(angle: number, result: Matrix): void;
  70982. /**
  70983. * Creates a new rotation matrix for "angle" radians around the Y axis
  70984. * @param angle defines the angle (in radians) to use
  70985. * @return the new matrix
  70986. */
  70987. static RotationY(angle: number): Matrix;
  70988. /**
  70989. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  70990. * @param angle defines the angle (in radians) to use
  70991. * @param result defines the target matrix
  70992. */
  70993. static RotationYToRef(angle: number, result: Matrix): void;
  70994. /**
  70995. * Creates a new rotation matrix for "angle" radians around the Z axis
  70996. * @param angle defines the angle (in radians) to use
  70997. * @return the new matrix
  70998. */
  70999. static RotationZ(angle: number): Matrix;
  71000. /**
  71001. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  71002. * @param angle defines the angle (in radians) to use
  71003. * @param result defines the target matrix
  71004. */
  71005. static RotationZToRef(angle: number, result: Matrix): void;
  71006. /**
  71007. * Creates a new rotation matrix for "angle" radians around the given axis
  71008. * @param axis defines the axis to use
  71009. * @param angle defines the angle (in radians) to use
  71010. * @return the new matrix
  71011. */
  71012. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  71013. /**
  71014. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  71015. * @param axis defines the axis to use
  71016. * @param angle defines the angle (in radians) to use
  71017. * @param result defines the target matrix
  71018. */
  71019. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  71020. /**
  71021. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  71022. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  71023. * @param from defines the vector to align
  71024. * @param to defines the vector to align to
  71025. * @param result defines the target matrix
  71026. */
  71027. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  71028. /**
  71029. * Creates a rotation matrix
  71030. * @param yaw defines the yaw angle in radians (Y axis)
  71031. * @param pitch defines the pitch angle in radians (X axis)
  71032. * @param roll defines the roll angle in radians (X axis)
  71033. * @returns the new rotation matrix
  71034. */
  71035. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  71036. /**
  71037. * Creates a rotation matrix and stores it in a given matrix
  71038. * @param yaw defines the yaw angle in radians (Y axis)
  71039. * @param pitch defines the pitch angle in radians (X axis)
  71040. * @param roll defines the roll angle in radians (X axis)
  71041. * @param result defines the target matrix
  71042. */
  71043. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  71044. /**
  71045. * Creates a scaling matrix
  71046. * @param x defines the scale factor on X axis
  71047. * @param y defines the scale factor on Y axis
  71048. * @param z defines the scale factor on Z axis
  71049. * @returns the new matrix
  71050. */
  71051. static Scaling(x: number, y: number, z: number): Matrix;
  71052. /**
  71053. * Creates a scaling matrix and stores it in a given matrix
  71054. * @param x defines the scale factor on X axis
  71055. * @param y defines the scale factor on Y axis
  71056. * @param z defines the scale factor on Z axis
  71057. * @param result defines the target matrix
  71058. */
  71059. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  71060. /**
  71061. * Creates a translation matrix
  71062. * @param x defines the translation on X axis
  71063. * @param y defines the translation on Y axis
  71064. * @param z defines the translationon Z axis
  71065. * @returns the new matrix
  71066. */
  71067. static Translation(x: number, y: number, z: number): Matrix;
  71068. /**
  71069. * Creates a translation matrix and stores it in a given matrix
  71070. * @param x defines the translation on X axis
  71071. * @param y defines the translation on Y axis
  71072. * @param z defines the translationon Z axis
  71073. * @param result defines the target matrix
  71074. */
  71075. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  71076. /**
  71077. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71078. * @param startValue defines the start value
  71079. * @param endValue defines the end value
  71080. * @param gradient defines the gradient factor
  71081. * @returns the new matrix
  71082. */
  71083. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71084. /**
  71085. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  71086. * @param startValue defines the start value
  71087. * @param endValue defines the end value
  71088. * @param gradient defines the gradient factor
  71089. * @param result defines the Matrix object where to store data
  71090. */
  71091. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71092. /**
  71093. * Builds a new matrix whose values are computed by:
  71094. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71095. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71096. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71097. * @param startValue defines the first matrix
  71098. * @param endValue defines the second matrix
  71099. * @param gradient defines the gradient between the two matrices
  71100. * @returns the new matrix
  71101. */
  71102. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  71103. /**
  71104. * Update a matrix to values which are computed by:
  71105. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  71106. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  71107. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  71108. * @param startValue defines the first matrix
  71109. * @param endValue defines the second matrix
  71110. * @param gradient defines the gradient between the two matrices
  71111. * @param result defines the target matrix
  71112. */
  71113. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  71114. /**
  71115. * 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"
  71116. * This function works in left handed mode
  71117. * @param eye defines the final position of the entity
  71118. * @param target defines where the entity should look at
  71119. * @param up defines the up vector for the entity
  71120. * @returns the new matrix
  71121. */
  71122. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71123. /**
  71124. * 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".
  71125. * This function works in left handed mode
  71126. * @param eye defines the final position of the entity
  71127. * @param target defines where the entity should look at
  71128. * @param up defines the up vector for the entity
  71129. * @param result defines the target matrix
  71130. */
  71131. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71132. /**
  71133. * 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"
  71134. * This function works in right handed mode
  71135. * @param eye defines the final position of the entity
  71136. * @param target defines where the entity should look at
  71137. * @param up defines the up vector for the entity
  71138. * @returns the new matrix
  71139. */
  71140. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  71141. /**
  71142. * 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".
  71143. * This function works in right handed mode
  71144. * @param eye defines the final position of the entity
  71145. * @param target defines where the entity should look at
  71146. * @param up defines the up vector for the entity
  71147. * @param result defines the target matrix
  71148. */
  71149. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  71150. /**
  71151. * Create a left-handed orthographic projection matrix
  71152. * @param width defines the viewport width
  71153. * @param height defines the viewport height
  71154. * @param znear defines the near clip plane
  71155. * @param zfar defines the far clip plane
  71156. * @returns a new matrix as a left-handed orthographic projection matrix
  71157. */
  71158. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71159. /**
  71160. * Store a left-handed orthographic projection to a given matrix
  71161. * @param width defines the viewport width
  71162. * @param height defines the viewport height
  71163. * @param znear defines the near clip plane
  71164. * @param zfar defines the far clip plane
  71165. * @param result defines the target matrix
  71166. */
  71167. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  71168. /**
  71169. * Create a left-handed orthographic projection matrix
  71170. * @param left defines the viewport left coordinate
  71171. * @param right defines the viewport right coordinate
  71172. * @param bottom defines the viewport bottom coordinate
  71173. * @param top defines the viewport top coordinate
  71174. * @param znear defines the near clip plane
  71175. * @param zfar defines the far clip plane
  71176. * @returns a new matrix as a left-handed orthographic projection matrix
  71177. */
  71178. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71179. /**
  71180. * Stores a left-handed orthographic projection into a given matrix
  71181. * @param left defines the viewport left coordinate
  71182. * @param right defines the viewport right coordinate
  71183. * @param bottom defines the viewport bottom coordinate
  71184. * @param top defines the viewport top coordinate
  71185. * @param znear defines the near clip plane
  71186. * @param zfar defines the far clip plane
  71187. * @param result defines the target matrix
  71188. */
  71189. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71190. /**
  71191. * Creates a right-handed orthographic projection matrix
  71192. * @param left defines the viewport left coordinate
  71193. * @param right defines the viewport right coordinate
  71194. * @param bottom defines the viewport bottom coordinate
  71195. * @param top defines the viewport top coordinate
  71196. * @param znear defines the near clip plane
  71197. * @param zfar defines the far clip plane
  71198. * @returns a new matrix as a right-handed orthographic projection matrix
  71199. */
  71200. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  71201. /**
  71202. * Stores a right-handed orthographic projection into a given matrix
  71203. * @param left defines the viewport left coordinate
  71204. * @param right defines the viewport right coordinate
  71205. * @param bottom defines the viewport bottom coordinate
  71206. * @param top defines the viewport top coordinate
  71207. * @param znear defines the near clip plane
  71208. * @param zfar defines the far clip plane
  71209. * @param result defines the target matrix
  71210. */
  71211. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  71212. /**
  71213. * Creates a left-handed perspective projection matrix
  71214. * @param width defines the viewport width
  71215. * @param height defines the viewport height
  71216. * @param znear defines the near clip plane
  71217. * @param zfar defines the far clip plane
  71218. * @returns a new matrix as a left-handed perspective projection matrix
  71219. */
  71220. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  71221. /**
  71222. * Creates a left-handed perspective projection matrix
  71223. * @param fov defines the horizontal field of view
  71224. * @param aspect defines the aspect ratio
  71225. * @param znear defines the near clip plane
  71226. * @param zfar defines the far clip plane
  71227. * @returns a new matrix as a left-handed perspective projection matrix
  71228. */
  71229. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71230. /**
  71231. * Stores a left-handed perspective projection into a given matrix
  71232. * @param fov defines the horizontal field of view
  71233. * @param aspect defines the aspect ratio
  71234. * @param znear defines the near clip plane
  71235. * @param zfar defines the far clip plane
  71236. * @param result defines the target matrix
  71237. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71238. */
  71239. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71240. /**
  71241. * Creates a right-handed perspective projection matrix
  71242. * @param fov defines the horizontal field of view
  71243. * @param aspect defines the aspect ratio
  71244. * @param znear defines the near clip plane
  71245. * @param zfar defines the far clip plane
  71246. * @returns a new matrix as a right-handed perspective projection matrix
  71247. */
  71248. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  71249. /**
  71250. * Stores a right-handed perspective projection into a given matrix
  71251. * @param fov defines the horizontal field of view
  71252. * @param aspect defines the aspect ratio
  71253. * @param znear defines the near clip plane
  71254. * @param zfar defines the far clip plane
  71255. * @param result defines the target matrix
  71256. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  71257. */
  71258. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  71259. /**
  71260. * Stores a perspective projection for WebVR info a given matrix
  71261. * @param fov defines the field of view
  71262. * @param znear defines the near clip plane
  71263. * @param zfar defines the far clip plane
  71264. * @param result defines the target matrix
  71265. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  71266. */
  71267. static PerspectiveFovWebVRToRef(fov: {
  71268. upDegrees: number;
  71269. downDegrees: number;
  71270. leftDegrees: number;
  71271. rightDegrees: number;
  71272. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  71273. /**
  71274. * Computes a complete transformation matrix
  71275. * @param viewport defines the viewport to use
  71276. * @param world defines the world matrix
  71277. * @param view defines the view matrix
  71278. * @param projection defines the projection matrix
  71279. * @param zmin defines the near clip plane
  71280. * @param zmax defines the far clip plane
  71281. * @returns the transformation matrix
  71282. */
  71283. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  71284. /**
  71285. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  71286. * @param matrix defines the matrix to use
  71287. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  71288. */
  71289. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  71290. /**
  71291. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  71292. * @param matrix defines the matrix to use
  71293. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  71294. */
  71295. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  71296. /**
  71297. * Compute the transpose of a given matrix
  71298. * @param matrix defines the matrix to transpose
  71299. * @returns the new matrix
  71300. */
  71301. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  71302. /**
  71303. * Compute the transpose of a matrix and store it in a target matrix
  71304. * @param matrix defines the matrix to transpose
  71305. * @param result defines the target matrix
  71306. */
  71307. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  71308. /**
  71309. * Computes a reflection matrix from a plane
  71310. * @param plane defines the reflection plane
  71311. * @returns a new matrix
  71312. */
  71313. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  71314. /**
  71315. * Computes a reflection matrix from a plane
  71316. * @param plane defines the reflection plane
  71317. * @param result defines the target matrix
  71318. */
  71319. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  71320. /**
  71321. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  71322. * @param xaxis defines the value of the 1st axis
  71323. * @param yaxis defines the value of the 2nd axis
  71324. * @param zaxis defines the value of the 3rd axis
  71325. * @param result defines the target matrix
  71326. */
  71327. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  71328. /**
  71329. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  71330. * @param quat defines the quaternion to use
  71331. * @param result defines the target matrix
  71332. */
  71333. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  71334. }
  71335. /**
  71336. * @hidden
  71337. */
  71338. export class TmpVectors {
  71339. static Vector2: Vector2[];
  71340. static Vector3: Vector3[];
  71341. static Vector4: Vector4[];
  71342. static Quaternion: Quaternion[];
  71343. static Matrix: Matrix[];
  71344. }
  71345. }
  71346. declare module BABYLON {
  71347. /**
  71348. * Defines potential orientation for back face culling
  71349. */
  71350. export enum Orientation {
  71351. /**
  71352. * Clockwise
  71353. */
  71354. CW = 0,
  71355. /** Counter clockwise */
  71356. CCW = 1
  71357. }
  71358. /** Class used to represent a Bezier curve */
  71359. export class BezierCurve {
  71360. /**
  71361. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  71362. * @param t defines the time
  71363. * @param x1 defines the left coordinate on X axis
  71364. * @param y1 defines the left coordinate on Y axis
  71365. * @param x2 defines the right coordinate on X axis
  71366. * @param y2 defines the right coordinate on Y axis
  71367. * @returns the interpolated value
  71368. */
  71369. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  71370. }
  71371. /**
  71372. * Defines angle representation
  71373. */
  71374. export class Angle {
  71375. private _radians;
  71376. /**
  71377. * Creates an Angle object of "radians" radians (float).
  71378. * @param radians the angle in radians
  71379. */
  71380. constructor(radians: number);
  71381. /**
  71382. * Get value in degrees
  71383. * @returns the Angle value in degrees (float)
  71384. */
  71385. degrees(): number;
  71386. /**
  71387. * Get value in radians
  71388. * @returns the Angle value in radians (float)
  71389. */
  71390. radians(): number;
  71391. /**
  71392. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  71393. * @param a defines first vector
  71394. * @param b defines second vector
  71395. * @returns a new Angle
  71396. */
  71397. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  71398. /**
  71399. * Gets a new Angle object from the given float in radians
  71400. * @param radians defines the angle value in radians
  71401. * @returns a new Angle
  71402. */
  71403. static FromRadians(radians: number): Angle;
  71404. /**
  71405. * Gets a new Angle object from the given float in degrees
  71406. * @param degrees defines the angle value in degrees
  71407. * @returns a new Angle
  71408. */
  71409. static FromDegrees(degrees: number): Angle;
  71410. }
  71411. /**
  71412. * This represents an arc in a 2d space.
  71413. */
  71414. export class Arc2 {
  71415. /** Defines the start point of the arc */
  71416. startPoint: Vector2;
  71417. /** Defines the mid point of the arc */
  71418. midPoint: Vector2;
  71419. /** Defines the end point of the arc */
  71420. endPoint: Vector2;
  71421. /**
  71422. * Defines the center point of the arc.
  71423. */
  71424. centerPoint: Vector2;
  71425. /**
  71426. * Defines the radius of the arc.
  71427. */
  71428. radius: number;
  71429. /**
  71430. * Defines the angle of the arc (from mid point to end point).
  71431. */
  71432. angle: Angle;
  71433. /**
  71434. * Defines the start angle of the arc (from start point to middle point).
  71435. */
  71436. startAngle: Angle;
  71437. /**
  71438. * Defines the orientation of the arc (clock wise/counter clock wise).
  71439. */
  71440. orientation: Orientation;
  71441. /**
  71442. * Creates an Arc object from the three given points : start, middle and end.
  71443. * @param startPoint Defines the start point of the arc
  71444. * @param midPoint Defines the midlle point of the arc
  71445. * @param endPoint Defines the end point of the arc
  71446. */
  71447. constructor(
  71448. /** Defines the start point of the arc */
  71449. startPoint: Vector2,
  71450. /** Defines the mid point of the arc */
  71451. midPoint: Vector2,
  71452. /** Defines the end point of the arc */
  71453. endPoint: Vector2);
  71454. }
  71455. /**
  71456. * Represents a 2D path made up of multiple 2D points
  71457. */
  71458. export class Path2 {
  71459. private _points;
  71460. private _length;
  71461. /**
  71462. * If the path start and end point are the same
  71463. */
  71464. closed: boolean;
  71465. /**
  71466. * Creates a Path2 object from the starting 2D coordinates x and y.
  71467. * @param x the starting points x value
  71468. * @param y the starting points y value
  71469. */
  71470. constructor(x: number, y: number);
  71471. /**
  71472. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  71473. * @param x the added points x value
  71474. * @param y the added points y value
  71475. * @returns the updated Path2.
  71476. */
  71477. addLineTo(x: number, y: number): Path2;
  71478. /**
  71479. * 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.
  71480. * @param midX middle point x value
  71481. * @param midY middle point y value
  71482. * @param endX end point x value
  71483. * @param endY end point y value
  71484. * @param numberOfSegments (default: 36)
  71485. * @returns the updated Path2.
  71486. */
  71487. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  71488. /**
  71489. * Closes the Path2.
  71490. * @returns the Path2.
  71491. */
  71492. close(): Path2;
  71493. /**
  71494. * Gets the sum of the distance between each sequential point in the path
  71495. * @returns the Path2 total length (float).
  71496. */
  71497. length(): number;
  71498. /**
  71499. * Gets the points which construct the path
  71500. * @returns the Path2 internal array of points.
  71501. */
  71502. getPoints(): Vector2[];
  71503. /**
  71504. * Retreives the point at the distance aways from the starting point
  71505. * @param normalizedLengthPosition the length along the path to retreive the point from
  71506. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  71507. */
  71508. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  71509. /**
  71510. * Creates a new path starting from an x and y position
  71511. * @param x starting x value
  71512. * @param y starting y value
  71513. * @returns a new Path2 starting at the coordinates (x, y).
  71514. */
  71515. static StartingAt(x: number, y: number): Path2;
  71516. }
  71517. /**
  71518. * Represents a 3D path made up of multiple 3D points
  71519. */
  71520. export class Path3D {
  71521. /**
  71522. * an array of Vector3, the curve axis of the Path3D
  71523. */
  71524. path: Vector3[];
  71525. private _curve;
  71526. private _distances;
  71527. private _tangents;
  71528. private _normals;
  71529. private _binormals;
  71530. private _raw;
  71531. /**
  71532. * new Path3D(path, normal, raw)
  71533. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  71534. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  71535. * @param path an array of Vector3, the curve axis of the Path3D
  71536. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  71537. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  71538. */
  71539. constructor(
  71540. /**
  71541. * an array of Vector3, the curve axis of the Path3D
  71542. */
  71543. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  71544. /**
  71545. * Returns the Path3D array of successive Vector3 designing its curve.
  71546. * @returns the Path3D array of successive Vector3 designing its curve.
  71547. */
  71548. getCurve(): Vector3[];
  71549. /**
  71550. * Returns an array populated with tangent vectors on each Path3D curve point.
  71551. * @returns an array populated with tangent vectors on each Path3D curve point.
  71552. */
  71553. getTangents(): Vector3[];
  71554. /**
  71555. * Returns an array populated with normal vectors on each Path3D curve point.
  71556. * @returns an array populated with normal vectors on each Path3D curve point.
  71557. */
  71558. getNormals(): Vector3[];
  71559. /**
  71560. * Returns an array populated with binormal vectors on each Path3D curve point.
  71561. * @returns an array populated with binormal vectors on each Path3D curve point.
  71562. */
  71563. getBinormals(): Vector3[];
  71564. /**
  71565. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  71566. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  71567. */
  71568. getDistances(): number[];
  71569. /**
  71570. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  71571. * @param path path which all values are copied into the curves points
  71572. * @param firstNormal which should be projected onto the curve
  71573. * @returns the same object updated.
  71574. */
  71575. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  71576. private _compute;
  71577. private _getFirstNonNullVector;
  71578. private _getLastNonNullVector;
  71579. private _normalVector;
  71580. }
  71581. /**
  71582. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71583. * A Curve3 is designed from a series of successive Vector3.
  71584. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  71585. */
  71586. export class Curve3 {
  71587. private _points;
  71588. private _length;
  71589. /**
  71590. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  71591. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  71592. * @param v1 (Vector3) the control point
  71593. * @param v2 (Vector3) the end point of the Quadratic Bezier
  71594. * @param nbPoints (integer) the wanted number of points in the curve
  71595. * @returns the created Curve3
  71596. */
  71597. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71598. /**
  71599. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  71600. * @param v0 (Vector3) the origin point of the Cubic Bezier
  71601. * @param v1 (Vector3) the first control point
  71602. * @param v2 (Vector3) the second control point
  71603. * @param v3 (Vector3) the end point of the Cubic Bezier
  71604. * @param nbPoints (integer) the wanted number of points in the curve
  71605. * @returns the created Curve3
  71606. */
  71607. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71608. /**
  71609. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  71610. * @param p1 (Vector3) the origin point of the Hermite Spline
  71611. * @param t1 (Vector3) the tangent vector at the origin point
  71612. * @param p2 (Vector3) the end point of the Hermite Spline
  71613. * @param t2 (Vector3) the tangent vector at the end point
  71614. * @param nbPoints (integer) the wanted number of points in the curve
  71615. * @returns the created Curve3
  71616. */
  71617. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  71618. /**
  71619. * Returns a Curve3 object along a CatmullRom Spline curve :
  71620. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  71621. * @param nbPoints (integer) the wanted number of points between each curve control points
  71622. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  71623. * @returns the created Curve3
  71624. */
  71625. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  71626. /**
  71627. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  71628. * A Curve3 is designed from a series of successive Vector3.
  71629. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  71630. * @param points points which make up the curve
  71631. */
  71632. constructor(points: Vector3[]);
  71633. /**
  71634. * @returns the Curve3 stored array of successive Vector3
  71635. */
  71636. getPoints(): Vector3[];
  71637. /**
  71638. * @returns the computed length (float) of the curve.
  71639. */
  71640. length(): number;
  71641. /**
  71642. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  71643. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  71644. * curveA and curveB keep unchanged.
  71645. * @param curve the curve to continue from this curve
  71646. * @returns the newly constructed curve
  71647. */
  71648. continue(curve: DeepImmutable<Curve3>): Curve3;
  71649. private _computeLength;
  71650. }
  71651. }
  71652. declare module BABYLON {
  71653. /**
  71654. * This represents the main contract an easing function should follow.
  71655. * Easing functions are used throughout the animation system.
  71656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71657. */
  71658. export interface IEasingFunction {
  71659. /**
  71660. * Given an input gradient between 0 and 1, this returns the corrseponding value
  71661. * of the easing function.
  71662. * The link below provides some of the most common examples of easing functions.
  71663. * @see https://easings.net/
  71664. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71665. * @returns the corresponding value on the curve defined by the easing function
  71666. */
  71667. ease(gradient: number): number;
  71668. }
  71669. /**
  71670. * Base class used for every default easing function.
  71671. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71672. */
  71673. export class EasingFunction implements IEasingFunction {
  71674. /**
  71675. * Interpolation follows the mathematical formula associated with the easing function.
  71676. */
  71677. static readonly EASINGMODE_EASEIN: number;
  71678. /**
  71679. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  71680. */
  71681. static readonly EASINGMODE_EASEOUT: number;
  71682. /**
  71683. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  71684. */
  71685. static readonly EASINGMODE_EASEINOUT: number;
  71686. private _easingMode;
  71687. /**
  71688. * Sets the easing mode of the current function.
  71689. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  71690. */
  71691. setEasingMode(easingMode: number): void;
  71692. /**
  71693. * Gets the current easing mode.
  71694. * @returns the easing mode
  71695. */
  71696. getEasingMode(): number;
  71697. /**
  71698. * @hidden
  71699. */
  71700. easeInCore(gradient: number): number;
  71701. /**
  71702. * Given an input gradient between 0 and 1, this returns the corresponding value
  71703. * of the easing function.
  71704. * @param gradient Defines the value between 0 and 1 we want the easing value for
  71705. * @returns the corresponding value on the curve defined by the easing function
  71706. */
  71707. ease(gradient: number): number;
  71708. }
  71709. /**
  71710. * Easing function with a circle shape (see link below).
  71711. * @see https://easings.net/#easeInCirc
  71712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71713. */
  71714. export class CircleEase extends EasingFunction implements IEasingFunction {
  71715. /** @hidden */
  71716. easeInCore(gradient: number): number;
  71717. }
  71718. /**
  71719. * Easing function with a ease back shape (see link below).
  71720. * @see https://easings.net/#easeInBack
  71721. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71722. */
  71723. export class BackEase extends EasingFunction implements IEasingFunction {
  71724. /** Defines the amplitude of the function */
  71725. amplitude: number;
  71726. /**
  71727. * Instantiates a back ease easing
  71728. * @see https://easings.net/#easeInBack
  71729. * @param amplitude Defines the amplitude of the function
  71730. */
  71731. constructor(
  71732. /** Defines the amplitude of the function */
  71733. amplitude?: number);
  71734. /** @hidden */
  71735. easeInCore(gradient: number): number;
  71736. }
  71737. /**
  71738. * Easing function with a bouncing shape (see link below).
  71739. * @see https://easings.net/#easeInBounce
  71740. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71741. */
  71742. export class BounceEase extends EasingFunction implements IEasingFunction {
  71743. /** Defines the number of bounces */
  71744. bounces: number;
  71745. /** Defines the amplitude of the bounce */
  71746. bounciness: number;
  71747. /**
  71748. * Instantiates a bounce easing
  71749. * @see https://easings.net/#easeInBounce
  71750. * @param bounces Defines the number of bounces
  71751. * @param bounciness Defines the amplitude of the bounce
  71752. */
  71753. constructor(
  71754. /** Defines the number of bounces */
  71755. bounces?: number,
  71756. /** Defines the amplitude of the bounce */
  71757. bounciness?: number);
  71758. /** @hidden */
  71759. easeInCore(gradient: number): number;
  71760. }
  71761. /**
  71762. * Easing function with a power of 3 shape (see link below).
  71763. * @see https://easings.net/#easeInCubic
  71764. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71765. */
  71766. export class CubicEase extends EasingFunction implements IEasingFunction {
  71767. /** @hidden */
  71768. easeInCore(gradient: number): number;
  71769. }
  71770. /**
  71771. * Easing function with an elastic shape (see link below).
  71772. * @see https://easings.net/#easeInElastic
  71773. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71774. */
  71775. export class ElasticEase extends EasingFunction implements IEasingFunction {
  71776. /** Defines the number of oscillations*/
  71777. oscillations: number;
  71778. /** Defines the amplitude of the oscillations*/
  71779. springiness: number;
  71780. /**
  71781. * Instantiates an elastic easing function
  71782. * @see https://easings.net/#easeInElastic
  71783. * @param oscillations Defines the number of oscillations
  71784. * @param springiness Defines the amplitude of the oscillations
  71785. */
  71786. constructor(
  71787. /** Defines the number of oscillations*/
  71788. oscillations?: number,
  71789. /** Defines the amplitude of the oscillations*/
  71790. springiness?: number);
  71791. /** @hidden */
  71792. easeInCore(gradient: number): number;
  71793. }
  71794. /**
  71795. * Easing function with an exponential shape (see link below).
  71796. * @see https://easings.net/#easeInExpo
  71797. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71798. */
  71799. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  71800. /** Defines the exponent of the function */
  71801. exponent: number;
  71802. /**
  71803. * Instantiates an exponential easing function
  71804. * @see https://easings.net/#easeInExpo
  71805. * @param exponent Defines the exponent of the function
  71806. */
  71807. constructor(
  71808. /** Defines the exponent of the function */
  71809. exponent?: number);
  71810. /** @hidden */
  71811. easeInCore(gradient: number): number;
  71812. }
  71813. /**
  71814. * Easing function with a power shape (see link below).
  71815. * @see https://easings.net/#easeInQuad
  71816. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71817. */
  71818. export class PowerEase extends EasingFunction implements IEasingFunction {
  71819. /** Defines the power of the function */
  71820. power: number;
  71821. /**
  71822. * Instantiates an power base easing function
  71823. * @see https://easings.net/#easeInQuad
  71824. * @param power Defines the power of the function
  71825. */
  71826. constructor(
  71827. /** Defines the power of the function */
  71828. power?: number);
  71829. /** @hidden */
  71830. easeInCore(gradient: number): number;
  71831. }
  71832. /**
  71833. * Easing function with a power of 2 shape (see link below).
  71834. * @see https://easings.net/#easeInQuad
  71835. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71836. */
  71837. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  71838. /** @hidden */
  71839. easeInCore(gradient: number): number;
  71840. }
  71841. /**
  71842. * Easing function with a power of 4 shape (see link below).
  71843. * @see https://easings.net/#easeInQuart
  71844. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71845. */
  71846. export class QuarticEase extends EasingFunction implements IEasingFunction {
  71847. /** @hidden */
  71848. easeInCore(gradient: number): number;
  71849. }
  71850. /**
  71851. * Easing function with a power of 5 shape (see link below).
  71852. * @see https://easings.net/#easeInQuint
  71853. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71854. */
  71855. export class QuinticEase extends EasingFunction implements IEasingFunction {
  71856. /** @hidden */
  71857. easeInCore(gradient: number): number;
  71858. }
  71859. /**
  71860. * Easing function with a sin shape (see link below).
  71861. * @see https://easings.net/#easeInSine
  71862. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71863. */
  71864. export class SineEase extends EasingFunction implements IEasingFunction {
  71865. /** @hidden */
  71866. easeInCore(gradient: number): number;
  71867. }
  71868. /**
  71869. * Easing function with a bezier shape (see link below).
  71870. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71871. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  71872. */
  71873. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  71874. /** Defines the x component of the start tangent in the bezier curve */
  71875. x1: number;
  71876. /** Defines the y component of the start tangent in the bezier curve */
  71877. y1: number;
  71878. /** Defines the x component of the end tangent in the bezier curve */
  71879. x2: number;
  71880. /** Defines the y component of the end tangent in the bezier curve */
  71881. y2: number;
  71882. /**
  71883. * Instantiates a bezier function
  71884. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  71885. * @param x1 Defines the x component of the start tangent in the bezier curve
  71886. * @param y1 Defines the y component of the start tangent in the bezier curve
  71887. * @param x2 Defines the x component of the end tangent in the bezier curve
  71888. * @param y2 Defines the y component of the end tangent in the bezier curve
  71889. */
  71890. constructor(
  71891. /** Defines the x component of the start tangent in the bezier curve */
  71892. x1?: number,
  71893. /** Defines the y component of the start tangent in the bezier curve */
  71894. y1?: number,
  71895. /** Defines the x component of the end tangent in the bezier curve */
  71896. x2?: number,
  71897. /** Defines the y component of the end tangent in the bezier curve */
  71898. y2?: number);
  71899. /** @hidden */
  71900. easeInCore(gradient: number): number;
  71901. }
  71902. }
  71903. declare module BABYLON {
  71904. /**
  71905. * Class used to hold a RBG color
  71906. */
  71907. export class Color3 {
  71908. /**
  71909. * Defines the red component (between 0 and 1, default is 0)
  71910. */
  71911. r: number;
  71912. /**
  71913. * Defines the green component (between 0 and 1, default is 0)
  71914. */
  71915. g: number;
  71916. /**
  71917. * Defines the blue component (between 0 and 1, default is 0)
  71918. */
  71919. b: number;
  71920. /**
  71921. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  71922. * @param r defines the red component (between 0 and 1, default is 0)
  71923. * @param g defines the green component (between 0 and 1, default is 0)
  71924. * @param b defines the blue component (between 0 and 1, default is 0)
  71925. */
  71926. constructor(
  71927. /**
  71928. * Defines the red component (between 0 and 1, default is 0)
  71929. */
  71930. r?: number,
  71931. /**
  71932. * Defines the green component (between 0 and 1, default is 0)
  71933. */
  71934. g?: number,
  71935. /**
  71936. * Defines the blue component (between 0 and 1, default is 0)
  71937. */
  71938. b?: number);
  71939. /**
  71940. * Creates a string with the Color3 current values
  71941. * @returns the string representation of the Color3 object
  71942. */
  71943. toString(): string;
  71944. /**
  71945. * Returns the string "Color3"
  71946. * @returns "Color3"
  71947. */
  71948. getClassName(): string;
  71949. /**
  71950. * Compute the Color3 hash code
  71951. * @returns an unique number that can be used to hash Color3 objects
  71952. */
  71953. getHashCode(): number;
  71954. /**
  71955. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  71956. * @param array defines the array where to store the r,g,b components
  71957. * @param index defines an optional index in the target array to define where to start storing values
  71958. * @returns the current Color3 object
  71959. */
  71960. toArray(array: FloatArray, index?: number): Color3;
  71961. /**
  71962. * Returns a new Color4 object from the current Color3 and the given alpha
  71963. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  71964. * @returns a new Color4 object
  71965. */
  71966. toColor4(alpha?: number): Color4;
  71967. /**
  71968. * Returns a new array populated with 3 numeric elements : red, green and blue values
  71969. * @returns the new array
  71970. */
  71971. asArray(): number[];
  71972. /**
  71973. * Returns the luminance value
  71974. * @returns a float value
  71975. */
  71976. toLuminance(): number;
  71977. /**
  71978. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  71979. * @param otherColor defines the second operand
  71980. * @returns the new Color3 object
  71981. */
  71982. multiply(otherColor: DeepImmutable<Color3>): Color3;
  71983. /**
  71984. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  71985. * @param otherColor defines the second operand
  71986. * @param result defines the Color3 object where to store the result
  71987. * @returns the current Color3
  71988. */
  71989. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  71990. /**
  71991. * Determines equality between Color3 objects
  71992. * @param otherColor defines the second operand
  71993. * @returns true if the rgb values are equal to the given ones
  71994. */
  71995. equals(otherColor: DeepImmutable<Color3>): boolean;
  71996. /**
  71997. * Determines equality between the current Color3 object and a set of r,b,g values
  71998. * @param r defines the red component to check
  71999. * @param g defines the green component to check
  72000. * @param b defines the blue component to check
  72001. * @returns true if the rgb values are equal to the given ones
  72002. */
  72003. equalsFloats(r: number, g: number, b: number): boolean;
  72004. /**
  72005. * Multiplies in place each rgb value by scale
  72006. * @param scale defines the scaling factor
  72007. * @returns the updated Color3
  72008. */
  72009. scale(scale: number): Color3;
  72010. /**
  72011. * Multiplies the rgb values by scale and stores the result into "result"
  72012. * @param scale defines the scaling factor
  72013. * @param result defines the Color3 object where to store the result
  72014. * @returns the unmodified current Color3
  72015. */
  72016. scaleToRef(scale: number, result: Color3): Color3;
  72017. /**
  72018. * Scale the current Color3 values by a factor and add the result to a given Color3
  72019. * @param scale defines the scale factor
  72020. * @param result defines color to store the result into
  72021. * @returns the unmodified current Color3
  72022. */
  72023. scaleAndAddToRef(scale: number, result: Color3): Color3;
  72024. /**
  72025. * Clamps the rgb values by the min and max values and stores the result into "result"
  72026. * @param min defines minimum clamping value (default is 0)
  72027. * @param max defines maximum clamping value (default is 1)
  72028. * @param result defines color to store the result into
  72029. * @returns the original Color3
  72030. */
  72031. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  72032. /**
  72033. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  72034. * @param otherColor defines the second operand
  72035. * @returns the new Color3
  72036. */
  72037. add(otherColor: DeepImmutable<Color3>): Color3;
  72038. /**
  72039. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  72040. * @param otherColor defines the second operand
  72041. * @param result defines Color3 object to store the result into
  72042. * @returns the unmodified current Color3
  72043. */
  72044. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72045. /**
  72046. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  72047. * @param otherColor defines the second operand
  72048. * @returns the new Color3
  72049. */
  72050. subtract(otherColor: DeepImmutable<Color3>): Color3;
  72051. /**
  72052. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  72053. * @param otherColor defines the second operand
  72054. * @param result defines Color3 object to store the result into
  72055. * @returns the unmodified current Color3
  72056. */
  72057. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  72058. /**
  72059. * Copy the current object
  72060. * @returns a new Color3 copied the current one
  72061. */
  72062. clone(): Color3;
  72063. /**
  72064. * Copies the rgb values from the source in the current Color3
  72065. * @param source defines the source Color3 object
  72066. * @returns the updated Color3 object
  72067. */
  72068. copyFrom(source: DeepImmutable<Color3>): Color3;
  72069. /**
  72070. * Updates the Color3 rgb values from the given floats
  72071. * @param r defines the red component to read from
  72072. * @param g defines the green component to read from
  72073. * @param b defines the blue component to read from
  72074. * @returns the current Color3 object
  72075. */
  72076. copyFromFloats(r: number, g: number, b: number): Color3;
  72077. /**
  72078. * Updates the Color3 rgb values from the given floats
  72079. * @param r defines the red component to read from
  72080. * @param g defines the green component to read from
  72081. * @param b defines the blue component to read from
  72082. * @returns the current Color3 object
  72083. */
  72084. set(r: number, g: number, b: number): Color3;
  72085. /**
  72086. * Compute the Color3 hexadecimal code as a string
  72087. * @returns a string containing the hexadecimal representation of the Color3 object
  72088. */
  72089. toHexString(): string;
  72090. /**
  72091. * Computes a new Color3 converted from the current one to linear space
  72092. * @returns a new Color3 object
  72093. */
  72094. toLinearSpace(): Color3;
  72095. /**
  72096. * Converts current color in rgb space to HSV values
  72097. * @returns a new color3 representing the HSV values
  72098. */
  72099. toHSV(): Color3;
  72100. /**
  72101. * Converts current color in rgb space to HSV values
  72102. * @param result defines the Color3 where to store the HSV values
  72103. */
  72104. toHSVToRef(result: Color3): void;
  72105. /**
  72106. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  72107. * @param convertedColor defines the Color3 object where to store the linear space version
  72108. * @returns the unmodified Color3
  72109. */
  72110. toLinearSpaceToRef(convertedColor: Color3): Color3;
  72111. /**
  72112. * Computes a new Color3 converted from the current one to gamma space
  72113. * @returns a new Color3 object
  72114. */
  72115. toGammaSpace(): Color3;
  72116. /**
  72117. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  72118. * @param convertedColor defines the Color3 object where to store the gamma space version
  72119. * @returns the unmodified Color3
  72120. */
  72121. toGammaSpaceToRef(convertedColor: Color3): Color3;
  72122. private static _BlackReadOnly;
  72123. /**
  72124. * Convert Hue, saturation and value to a Color3 (RGB)
  72125. * @param hue defines the hue
  72126. * @param saturation defines the saturation
  72127. * @param value defines the value
  72128. * @param result defines the Color3 where to store the RGB values
  72129. */
  72130. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  72131. /**
  72132. * Creates a new Color3 from the string containing valid hexadecimal values
  72133. * @param hex defines a string containing valid hexadecimal values
  72134. * @returns a new Color3 object
  72135. */
  72136. static FromHexString(hex: string): Color3;
  72137. /**
  72138. * Creates a new Color3 from the starting index of the given array
  72139. * @param array defines the source array
  72140. * @param offset defines an offset in the source array
  72141. * @returns a new Color3 object
  72142. */
  72143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  72144. /**
  72145. * Creates a new Color3 from integer values (< 256)
  72146. * @param r defines the red component to read from (value between 0 and 255)
  72147. * @param g defines the green component to read from (value between 0 and 255)
  72148. * @param b defines the blue component to read from (value between 0 and 255)
  72149. * @returns a new Color3 object
  72150. */
  72151. static FromInts(r: number, g: number, b: number): Color3;
  72152. /**
  72153. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72154. * @param start defines the start Color3 value
  72155. * @param end defines the end Color3 value
  72156. * @param amount defines the gradient value between start and end
  72157. * @returns a new Color3 object
  72158. */
  72159. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  72160. /**
  72161. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  72162. * @param left defines the start value
  72163. * @param right defines the end value
  72164. * @param amount defines the gradient factor
  72165. * @param result defines the Color3 object where to store the result
  72166. */
  72167. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  72168. /**
  72169. * Returns a Color3 value containing a red color
  72170. * @returns a new Color3 object
  72171. */
  72172. static Red(): Color3;
  72173. /**
  72174. * Returns a Color3 value containing a green color
  72175. * @returns a new Color3 object
  72176. */
  72177. static Green(): Color3;
  72178. /**
  72179. * Returns a Color3 value containing a blue color
  72180. * @returns a new Color3 object
  72181. */
  72182. static Blue(): Color3;
  72183. /**
  72184. * Returns a Color3 value containing a black color
  72185. * @returns a new Color3 object
  72186. */
  72187. static Black(): Color3;
  72188. /**
  72189. * Gets a Color3 value containing a black color that must not be updated
  72190. */
  72191. static readonly BlackReadOnly: DeepImmutable<Color3>;
  72192. /**
  72193. * Returns a Color3 value containing a white color
  72194. * @returns a new Color3 object
  72195. */
  72196. static White(): Color3;
  72197. /**
  72198. * Returns a Color3 value containing a purple color
  72199. * @returns a new Color3 object
  72200. */
  72201. static Purple(): Color3;
  72202. /**
  72203. * Returns a Color3 value containing a magenta color
  72204. * @returns a new Color3 object
  72205. */
  72206. static Magenta(): Color3;
  72207. /**
  72208. * Returns a Color3 value containing a yellow color
  72209. * @returns a new Color3 object
  72210. */
  72211. static Yellow(): Color3;
  72212. /**
  72213. * Returns a Color3 value containing a gray color
  72214. * @returns a new Color3 object
  72215. */
  72216. static Gray(): Color3;
  72217. /**
  72218. * Returns a Color3 value containing a teal color
  72219. * @returns a new Color3 object
  72220. */
  72221. static Teal(): Color3;
  72222. /**
  72223. * Returns a Color3 value containing a random color
  72224. * @returns a new Color3 object
  72225. */
  72226. static Random(): Color3;
  72227. }
  72228. /**
  72229. * Class used to hold a RBGA color
  72230. */
  72231. export class Color4 {
  72232. /**
  72233. * Defines the red component (between 0 and 1, default is 0)
  72234. */
  72235. r: number;
  72236. /**
  72237. * Defines the green component (between 0 and 1, default is 0)
  72238. */
  72239. g: number;
  72240. /**
  72241. * Defines the blue component (between 0 and 1, default is 0)
  72242. */
  72243. b: number;
  72244. /**
  72245. * Defines the alpha component (between 0 and 1, default is 1)
  72246. */
  72247. a: number;
  72248. /**
  72249. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  72250. * @param r defines the red component (between 0 and 1, default is 0)
  72251. * @param g defines the green component (between 0 and 1, default is 0)
  72252. * @param b defines the blue component (between 0 and 1, default is 0)
  72253. * @param a defines the alpha component (between 0 and 1, default is 1)
  72254. */
  72255. constructor(
  72256. /**
  72257. * Defines the red component (between 0 and 1, default is 0)
  72258. */
  72259. r?: number,
  72260. /**
  72261. * Defines the green component (between 0 and 1, default is 0)
  72262. */
  72263. g?: number,
  72264. /**
  72265. * Defines the blue component (between 0 and 1, default is 0)
  72266. */
  72267. b?: number,
  72268. /**
  72269. * Defines the alpha component (between 0 and 1, default is 1)
  72270. */
  72271. a?: number);
  72272. /**
  72273. * Adds in place the given Color4 values to the current Color4 object
  72274. * @param right defines the second operand
  72275. * @returns the current updated Color4 object
  72276. */
  72277. addInPlace(right: DeepImmutable<Color4>): Color4;
  72278. /**
  72279. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  72280. * @returns the new array
  72281. */
  72282. asArray(): number[];
  72283. /**
  72284. * Stores from the starting index in the given array the Color4 successive values
  72285. * @param array defines the array where to store the r,g,b components
  72286. * @param index defines an optional index in the target array to define where to start storing values
  72287. * @returns the current Color4 object
  72288. */
  72289. toArray(array: number[], index?: number): Color4;
  72290. /**
  72291. * Determines equality between Color4 objects
  72292. * @param otherColor defines the second operand
  72293. * @returns true if the rgba values are equal to the given ones
  72294. */
  72295. equals(otherColor: DeepImmutable<Color4>): boolean;
  72296. /**
  72297. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  72298. * @param right defines the second operand
  72299. * @returns a new Color4 object
  72300. */
  72301. add(right: DeepImmutable<Color4>): Color4;
  72302. /**
  72303. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  72304. * @param right defines the second operand
  72305. * @returns a new Color4 object
  72306. */
  72307. subtract(right: DeepImmutable<Color4>): Color4;
  72308. /**
  72309. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  72310. * @param right defines the second operand
  72311. * @param result defines the Color4 object where to store the result
  72312. * @returns the current Color4 object
  72313. */
  72314. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  72315. /**
  72316. * Creates a new Color4 with the current Color4 values multiplied by scale
  72317. * @param scale defines the scaling factor to apply
  72318. * @returns a new Color4 object
  72319. */
  72320. scale(scale: number): Color4;
  72321. /**
  72322. * Multiplies the current Color4 values by scale and stores the result in "result"
  72323. * @param scale defines the scaling factor to apply
  72324. * @param result defines the Color4 object where to store the result
  72325. * @returns the current unmodified Color4
  72326. */
  72327. scaleToRef(scale: number, result: Color4): Color4;
  72328. /**
  72329. * Scale the current Color4 values by a factor and add the result to a given Color4
  72330. * @param scale defines the scale factor
  72331. * @param result defines the Color4 object where to store the result
  72332. * @returns the unmodified current Color4
  72333. */
  72334. scaleAndAddToRef(scale: number, result: Color4): Color4;
  72335. /**
  72336. * Clamps the rgb values by the min and max values and stores the result into "result"
  72337. * @param min defines minimum clamping value (default is 0)
  72338. * @param max defines maximum clamping value (default is 1)
  72339. * @param result defines color to store the result into.
  72340. * @returns the cuurent Color4
  72341. */
  72342. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  72343. /**
  72344. * Multipy an Color4 value by another and return a new Color4 object
  72345. * @param color defines the Color4 value to multiply by
  72346. * @returns a new Color4 object
  72347. */
  72348. multiply(color: Color4): Color4;
  72349. /**
  72350. * Multipy a Color4 value by another and push the result in a reference value
  72351. * @param color defines the Color4 value to multiply by
  72352. * @param result defines the Color4 to fill the result in
  72353. * @returns the result Color4
  72354. */
  72355. multiplyToRef(color: Color4, result: Color4): Color4;
  72356. /**
  72357. * Creates a string with the Color4 current values
  72358. * @returns the string representation of the Color4 object
  72359. */
  72360. toString(): string;
  72361. /**
  72362. * Returns the string "Color4"
  72363. * @returns "Color4"
  72364. */
  72365. getClassName(): string;
  72366. /**
  72367. * Compute the Color4 hash code
  72368. * @returns an unique number that can be used to hash Color4 objects
  72369. */
  72370. getHashCode(): number;
  72371. /**
  72372. * Creates a new Color4 copied from the current one
  72373. * @returns a new Color4 object
  72374. */
  72375. clone(): Color4;
  72376. /**
  72377. * Copies the given Color4 values into the current one
  72378. * @param source defines the source Color4 object
  72379. * @returns the current updated Color4 object
  72380. */
  72381. copyFrom(source: Color4): Color4;
  72382. /**
  72383. * Copies the given float values into the current one
  72384. * @param r defines the red component to read from
  72385. * @param g defines the green component to read from
  72386. * @param b defines the blue component to read from
  72387. * @param a defines the alpha component to read from
  72388. * @returns the current updated Color4 object
  72389. */
  72390. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  72391. /**
  72392. * Copies the given float values into the current one
  72393. * @param r defines the red component to read from
  72394. * @param g defines the green component to read from
  72395. * @param b defines the blue component to read from
  72396. * @param a defines the alpha component to read from
  72397. * @returns the current updated Color4 object
  72398. */
  72399. set(r: number, g: number, b: number, a: number): Color4;
  72400. /**
  72401. * Compute the Color4 hexadecimal code as a string
  72402. * @returns a string containing the hexadecimal representation of the Color4 object
  72403. */
  72404. toHexString(): string;
  72405. /**
  72406. * Computes a new Color4 converted from the current one to linear space
  72407. * @returns a new Color4 object
  72408. */
  72409. toLinearSpace(): Color4;
  72410. /**
  72411. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  72412. * @param convertedColor defines the Color4 object where to store the linear space version
  72413. * @returns the unmodified Color4
  72414. */
  72415. toLinearSpaceToRef(convertedColor: Color4): Color4;
  72416. /**
  72417. * Computes a new Color4 converted from the current one to gamma space
  72418. * @returns a new Color4 object
  72419. */
  72420. toGammaSpace(): Color4;
  72421. /**
  72422. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  72423. * @param convertedColor defines the Color4 object where to store the gamma space version
  72424. * @returns the unmodified Color4
  72425. */
  72426. toGammaSpaceToRef(convertedColor: Color4): Color4;
  72427. /**
  72428. * Creates a new Color4 from the string containing valid hexadecimal values
  72429. * @param hex defines a string containing valid hexadecimal values
  72430. * @returns a new Color4 object
  72431. */
  72432. static FromHexString(hex: string): Color4;
  72433. /**
  72434. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72435. * @param left defines the start value
  72436. * @param right defines the end value
  72437. * @param amount defines the gradient factor
  72438. * @returns a new Color4 object
  72439. */
  72440. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  72441. /**
  72442. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  72443. * @param left defines the start value
  72444. * @param right defines the end value
  72445. * @param amount defines the gradient factor
  72446. * @param result defines the Color4 object where to store data
  72447. */
  72448. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  72449. /**
  72450. * Creates a new Color4 from a Color3 and an alpha value
  72451. * @param color3 defines the source Color3 to read from
  72452. * @param alpha defines the alpha component (1.0 by default)
  72453. * @returns a new Color4 object
  72454. */
  72455. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  72456. /**
  72457. * Creates a new Color4 from the starting index element of the given array
  72458. * @param array defines the source array to read from
  72459. * @param offset defines the offset in the source array
  72460. * @returns a new Color4 object
  72461. */
  72462. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  72463. /**
  72464. * Creates a new Color3 from integer values (< 256)
  72465. * @param r defines the red component to read from (value between 0 and 255)
  72466. * @param g defines the green component to read from (value between 0 and 255)
  72467. * @param b defines the blue component to read from (value between 0 and 255)
  72468. * @param a defines the alpha component to read from (value between 0 and 255)
  72469. * @returns a new Color3 object
  72470. */
  72471. static FromInts(r: number, g: number, b: number, a: number): Color4;
  72472. /**
  72473. * Check the content of a given array and convert it to an array containing RGBA data
  72474. * If the original array was already containing count * 4 values then it is returned directly
  72475. * @param colors defines the array to check
  72476. * @param count defines the number of RGBA data to expect
  72477. * @returns an array containing count * 4 values (RGBA)
  72478. */
  72479. static CheckColors4(colors: number[], count: number): number[];
  72480. }
  72481. /**
  72482. * @hidden
  72483. */
  72484. export class TmpColors {
  72485. static Color3: Color3[];
  72486. static Color4: Color4[];
  72487. }
  72488. }
  72489. declare module BABYLON {
  72490. /**
  72491. * Defines an interface which represents an animation key frame
  72492. */
  72493. export interface IAnimationKey {
  72494. /**
  72495. * Frame of the key frame
  72496. */
  72497. frame: number;
  72498. /**
  72499. * Value at the specifies key frame
  72500. */
  72501. value: any;
  72502. /**
  72503. * The input tangent for the cubic hermite spline
  72504. */
  72505. inTangent?: any;
  72506. /**
  72507. * The output tangent for the cubic hermite spline
  72508. */
  72509. outTangent?: any;
  72510. /**
  72511. * The animation interpolation type
  72512. */
  72513. interpolation?: AnimationKeyInterpolation;
  72514. }
  72515. /**
  72516. * Enum for the animation key frame interpolation type
  72517. */
  72518. export enum AnimationKeyInterpolation {
  72519. /**
  72520. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72521. */
  72522. STEP = 1
  72523. }
  72524. }
  72525. declare module BABYLON {
  72526. /**
  72527. * Represents the range of an animation
  72528. */
  72529. export class AnimationRange {
  72530. /**The name of the animation range**/
  72531. name: string;
  72532. /**The starting frame of the animation */
  72533. from: number;
  72534. /**The ending frame of the animation*/
  72535. to: number;
  72536. /**
  72537. * Initializes the range of an animation
  72538. * @param name The name of the animation range
  72539. * @param from The starting frame of the animation
  72540. * @param to The ending frame of the animation
  72541. */
  72542. constructor(
  72543. /**The name of the animation range**/
  72544. name: string,
  72545. /**The starting frame of the animation */
  72546. from: number,
  72547. /**The ending frame of the animation*/
  72548. to: number);
  72549. /**
  72550. * Makes a copy of the animation range
  72551. * @returns A copy of the animation range
  72552. */
  72553. clone(): AnimationRange;
  72554. }
  72555. }
  72556. declare module BABYLON {
  72557. /**
  72558. * Composed of a frame, and an action function
  72559. */
  72560. export class AnimationEvent {
  72561. /** The frame for which the event is triggered **/
  72562. frame: number;
  72563. /** The event to perform when triggered **/
  72564. action: (currentFrame: number) => void;
  72565. /** Specifies if the event should be triggered only once**/
  72566. onlyOnce?: boolean | undefined;
  72567. /**
  72568. * Specifies if the animation event is done
  72569. */
  72570. isDone: boolean;
  72571. /**
  72572. * Initializes the animation event
  72573. * @param frame The frame for which the event is triggered
  72574. * @param action The event to perform when triggered
  72575. * @param onlyOnce Specifies if the event should be triggered only once
  72576. */
  72577. constructor(
  72578. /** The frame for which the event is triggered **/
  72579. frame: number,
  72580. /** The event to perform when triggered **/
  72581. action: (currentFrame: number) => void,
  72582. /** Specifies if the event should be triggered only once**/
  72583. onlyOnce?: boolean | undefined);
  72584. /** @hidden */
  72585. _clone(): AnimationEvent;
  72586. }
  72587. }
  72588. declare module BABYLON {
  72589. /**
  72590. * Interface used to define a behavior
  72591. */
  72592. export interface Behavior<T> {
  72593. /** gets or sets behavior's name */
  72594. name: string;
  72595. /**
  72596. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72597. */
  72598. init(): void;
  72599. /**
  72600. * Called when the behavior is attached to a target
  72601. * @param target defines the target where the behavior is attached to
  72602. */
  72603. attach(target: T): void;
  72604. /**
  72605. * Called when the behavior is detached from its target
  72606. */
  72607. detach(): void;
  72608. }
  72609. /**
  72610. * Interface implemented by classes supporting behaviors
  72611. */
  72612. export interface IBehaviorAware<T> {
  72613. /**
  72614. * Attach a behavior
  72615. * @param behavior defines the behavior to attach
  72616. * @returns the current host
  72617. */
  72618. addBehavior(behavior: Behavior<T>): T;
  72619. /**
  72620. * Remove a behavior from the current object
  72621. * @param behavior defines the behavior to detach
  72622. * @returns the current host
  72623. */
  72624. removeBehavior(behavior: Behavior<T>): T;
  72625. /**
  72626. * Gets a behavior using its name to search
  72627. * @param name defines the name to search
  72628. * @returns the behavior or null if not found
  72629. */
  72630. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72631. }
  72632. }
  72633. declare module BABYLON {
  72634. /**
  72635. * Defines an array and its length.
  72636. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72637. */
  72638. export interface ISmartArrayLike<T> {
  72639. /**
  72640. * The data of the array.
  72641. */
  72642. data: Array<T>;
  72643. /**
  72644. * The active length of the array.
  72645. */
  72646. length: number;
  72647. }
  72648. /**
  72649. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72650. */
  72651. export class SmartArray<T> implements ISmartArrayLike<T> {
  72652. /**
  72653. * The full set of data from the array.
  72654. */
  72655. data: Array<T>;
  72656. /**
  72657. * The active length of the array.
  72658. */
  72659. length: number;
  72660. protected _id: number;
  72661. /**
  72662. * Instantiates a Smart Array.
  72663. * @param capacity defines the default capacity of the array.
  72664. */
  72665. constructor(capacity: number);
  72666. /**
  72667. * Pushes a value at the end of the active data.
  72668. * @param value defines the object to push in the array.
  72669. */
  72670. push(value: T): void;
  72671. /**
  72672. * Iterates over the active data and apply the lambda to them.
  72673. * @param func defines the action to apply on each value.
  72674. */
  72675. forEach(func: (content: T) => void): void;
  72676. /**
  72677. * Sorts the full sets of data.
  72678. * @param compareFn defines the comparison function to apply.
  72679. */
  72680. sort(compareFn: (a: T, b: T) => number): void;
  72681. /**
  72682. * Resets the active data to an empty array.
  72683. */
  72684. reset(): void;
  72685. /**
  72686. * Releases all the data from the array as well as the array.
  72687. */
  72688. dispose(): void;
  72689. /**
  72690. * Concats the active data with a given array.
  72691. * @param array defines the data to concatenate with.
  72692. */
  72693. concat(array: any): void;
  72694. /**
  72695. * Returns the position of a value in the active data.
  72696. * @param value defines the value to find the index for
  72697. * @returns the index if found in the active data otherwise -1
  72698. */
  72699. indexOf(value: T): number;
  72700. /**
  72701. * Returns whether an element is part of the active data.
  72702. * @param value defines the value to look for
  72703. * @returns true if found in the active data otherwise false
  72704. */
  72705. contains(value: T): boolean;
  72706. private static _GlobalId;
  72707. }
  72708. /**
  72709. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72710. * The data in this array can only be present once
  72711. */
  72712. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72713. private _duplicateId;
  72714. /**
  72715. * Pushes a value at the end of the active data.
  72716. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72717. * @param value defines the object to push in the array.
  72718. */
  72719. push(value: T): void;
  72720. /**
  72721. * Pushes a value at the end of the active data.
  72722. * If the data is already present, it won t be added again
  72723. * @param value defines the object to push in the array.
  72724. * @returns true if added false if it was already present
  72725. */
  72726. pushNoDuplicate(value: T): boolean;
  72727. /**
  72728. * Resets the active data to an empty array.
  72729. */
  72730. reset(): void;
  72731. /**
  72732. * Concats the active data with a given array.
  72733. * This ensures no dupplicate will be present in the result.
  72734. * @param array defines the data to concatenate with.
  72735. */
  72736. concatWithNoDuplicate(array: any): void;
  72737. }
  72738. }
  72739. declare module BABYLON {
  72740. /**
  72741. * @ignore
  72742. * This is a list of all the different input types that are available in the application.
  72743. * Fo instance: ArcRotateCameraGamepadInput...
  72744. */
  72745. export var CameraInputTypes: {};
  72746. /**
  72747. * This is the contract to implement in order to create a new input class.
  72748. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72749. */
  72750. export interface ICameraInput<TCamera extends Camera> {
  72751. /**
  72752. * Defines the camera the input is attached to.
  72753. */
  72754. camera: Nullable<TCamera>;
  72755. /**
  72756. * Gets the class name of the current intput.
  72757. * @returns the class name
  72758. */
  72759. getClassName(): string;
  72760. /**
  72761. * Get the friendly name associated with the input class.
  72762. * @returns the input friendly name
  72763. */
  72764. getSimpleName(): string;
  72765. /**
  72766. * Attach the input controls to a specific dom element to get the input from.
  72767. * @param element Defines the element the controls should be listened from
  72768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72769. */
  72770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72771. /**
  72772. * Detach the current controls from the specified dom element.
  72773. * @param element Defines the element to stop listening the inputs from
  72774. */
  72775. detachControl(element: Nullable<HTMLElement>): void;
  72776. /**
  72777. * Update the current camera state depending on the inputs that have been used this frame.
  72778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72779. */
  72780. checkInputs?: () => void;
  72781. }
  72782. /**
  72783. * Represents a map of input types to input instance or input index to input instance.
  72784. */
  72785. export interface CameraInputsMap<TCamera extends Camera> {
  72786. /**
  72787. * Accessor to the input by input type.
  72788. */
  72789. [name: string]: ICameraInput<TCamera>;
  72790. /**
  72791. * Accessor to the input by input index.
  72792. */
  72793. [idx: number]: ICameraInput<TCamera>;
  72794. }
  72795. /**
  72796. * This represents the input manager used within a camera.
  72797. * It helps dealing with all the different kind of input attached to a camera.
  72798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72799. */
  72800. export class CameraInputsManager<TCamera extends Camera> {
  72801. /**
  72802. * Defines the list of inputs attahed to the camera.
  72803. */
  72804. attached: CameraInputsMap<TCamera>;
  72805. /**
  72806. * Defines the dom element the camera is collecting inputs from.
  72807. * This is null if the controls have not been attached.
  72808. */
  72809. attachedElement: Nullable<HTMLElement>;
  72810. /**
  72811. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72812. */
  72813. noPreventDefault: boolean;
  72814. /**
  72815. * Defined the camera the input manager belongs to.
  72816. */
  72817. camera: TCamera;
  72818. /**
  72819. * Update the current camera state depending on the inputs that have been used this frame.
  72820. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72821. */
  72822. checkInputs: () => void;
  72823. /**
  72824. * Instantiate a new Camera Input Manager.
  72825. * @param camera Defines the camera the input manager blongs to
  72826. */
  72827. constructor(camera: TCamera);
  72828. /**
  72829. * Add an input method to a camera
  72830. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72831. * @param input camera input method
  72832. */
  72833. add(input: ICameraInput<TCamera>): void;
  72834. /**
  72835. * Remove a specific input method from a camera
  72836. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72837. * @param inputToRemove camera input method
  72838. */
  72839. remove(inputToRemove: ICameraInput<TCamera>): void;
  72840. /**
  72841. * Remove a specific input type from a camera
  72842. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72843. * @param inputType the type of the input to remove
  72844. */
  72845. removeByType(inputType: string): void;
  72846. private _addCheckInputs;
  72847. /**
  72848. * Attach the input controls to the currently attached dom element to listen the events from.
  72849. * @param input Defines the input to attach
  72850. */
  72851. attachInput(input: ICameraInput<TCamera>): void;
  72852. /**
  72853. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72854. * @param element Defines the dom element to collect the events from
  72855. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72856. */
  72857. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72858. /**
  72859. * Detach the current manager inputs controls from a specific dom element.
  72860. * @param element Defines the dom element to collect the events from
  72861. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72862. */
  72863. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72864. /**
  72865. * Rebuild the dynamic inputCheck function from the current list of
  72866. * defined inputs in the manager.
  72867. */
  72868. rebuildInputCheck(): void;
  72869. /**
  72870. * Remove all attached input methods from a camera
  72871. */
  72872. clear(): void;
  72873. /**
  72874. * Serialize the current input manager attached to a camera.
  72875. * This ensures than once parsed,
  72876. * the input associated to the camera will be identical to the current ones
  72877. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72878. */
  72879. serialize(serializedCamera: any): void;
  72880. /**
  72881. * Parses an input manager serialized JSON to restore the previous list of inputs
  72882. * and states associated to a camera.
  72883. * @param parsedCamera Defines the JSON to parse
  72884. */
  72885. parse(parsedCamera: any): void;
  72886. }
  72887. }
  72888. declare module BABYLON {
  72889. /**
  72890. * Class used to store data that will be store in GPU memory
  72891. */
  72892. export class Buffer {
  72893. private _engine;
  72894. private _buffer;
  72895. /** @hidden */
  72896. _data: Nullable<DataArray>;
  72897. private _updatable;
  72898. private _instanced;
  72899. /**
  72900. * Gets the byte stride.
  72901. */
  72902. readonly byteStride: number;
  72903. /**
  72904. * Constructor
  72905. * @param engine the engine
  72906. * @param data the data to use for this buffer
  72907. * @param updatable whether the data is updatable
  72908. * @param stride the stride (optional)
  72909. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  72910. * @param instanced whether the buffer is instanced (optional)
  72911. * @param useBytes set to true if the stride in in bytes (optional)
  72912. */
  72913. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  72914. /**
  72915. * Create a new VertexBuffer based on the current buffer
  72916. * @param kind defines the vertex buffer kind (position, normal, etc.)
  72917. * @param offset defines offset in the buffer (0 by default)
  72918. * @param size defines the size in floats of attributes (position is 3 for instance)
  72919. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  72920. * @param instanced defines if the vertex buffer contains indexed data
  72921. * @param useBytes defines if the offset and stride are in bytes
  72922. * @returns the new vertex buffer
  72923. */
  72924. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  72925. /**
  72926. * Gets a boolean indicating if the Buffer is updatable?
  72927. * @returns true if the buffer is updatable
  72928. */
  72929. isUpdatable(): boolean;
  72930. /**
  72931. * Gets current buffer's data
  72932. * @returns a DataArray or null
  72933. */
  72934. getData(): Nullable<DataArray>;
  72935. /**
  72936. * Gets underlying native buffer
  72937. * @returns underlying native buffer
  72938. */
  72939. getBuffer(): Nullable<DataBuffer>;
  72940. /**
  72941. * Gets the stride in float32 units (i.e. byte stride / 4).
  72942. * May not be an integer if the byte stride is not divisible by 4.
  72943. * DEPRECATED. Use byteStride instead.
  72944. * @returns the stride in float32 units
  72945. */
  72946. getStrideSize(): number;
  72947. /**
  72948. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  72949. * @param data defines the data to store
  72950. */
  72951. create(data?: Nullable<DataArray>): void;
  72952. /** @hidden */
  72953. _rebuild(): void;
  72954. /**
  72955. * Update current buffer data
  72956. * @param data defines the data to store
  72957. */
  72958. update(data: DataArray): void;
  72959. /**
  72960. * Updates the data directly.
  72961. * @param data the new data
  72962. * @param offset the new offset
  72963. * @param vertexCount the vertex count (optional)
  72964. * @param useBytes set to true if the offset is in bytes
  72965. */
  72966. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  72967. /**
  72968. * Release all resources
  72969. */
  72970. dispose(): void;
  72971. }
  72972. /**
  72973. * Specialized buffer used to store vertex data
  72974. */
  72975. export class VertexBuffer {
  72976. /** @hidden */
  72977. _buffer: Buffer;
  72978. private _kind;
  72979. private _size;
  72980. private _ownsBuffer;
  72981. private _instanced;
  72982. private _instanceDivisor;
  72983. /**
  72984. * The byte type.
  72985. */
  72986. static readonly BYTE: number;
  72987. /**
  72988. * The unsigned byte type.
  72989. */
  72990. static readonly UNSIGNED_BYTE: number;
  72991. /**
  72992. * The short type.
  72993. */
  72994. static readonly SHORT: number;
  72995. /**
  72996. * The unsigned short type.
  72997. */
  72998. static readonly UNSIGNED_SHORT: number;
  72999. /**
  73000. * The integer type.
  73001. */
  73002. static readonly INT: number;
  73003. /**
  73004. * The unsigned integer type.
  73005. */
  73006. static readonly UNSIGNED_INT: number;
  73007. /**
  73008. * The float type.
  73009. */
  73010. static readonly FLOAT: number;
  73011. /**
  73012. * Gets or sets the instance divisor when in instanced mode
  73013. */
  73014. instanceDivisor: number;
  73015. /**
  73016. * Gets the byte stride.
  73017. */
  73018. readonly byteStride: number;
  73019. /**
  73020. * Gets the byte offset.
  73021. */
  73022. readonly byteOffset: number;
  73023. /**
  73024. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73025. */
  73026. readonly normalized: boolean;
  73027. /**
  73028. * Gets the data type of each component in the array.
  73029. */
  73030. readonly type: number;
  73031. /**
  73032. * Constructor
  73033. * @param engine the engine
  73034. * @param data the data to use for this vertex buffer
  73035. * @param kind the vertex buffer kind
  73036. * @param updatable whether the data is updatable
  73037. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73038. * @param stride the stride (optional)
  73039. * @param instanced whether the buffer is instanced (optional)
  73040. * @param offset the offset of the data (optional)
  73041. * @param size the number of components (optional)
  73042. * @param type the type of the component (optional)
  73043. * @param normalized whether the data contains normalized data (optional)
  73044. * @param useBytes set to true if stride and offset are in bytes (optional)
  73045. */
  73046. 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);
  73047. /** @hidden */
  73048. _rebuild(): void;
  73049. /**
  73050. * Returns the kind of the VertexBuffer (string)
  73051. * @returns a string
  73052. */
  73053. getKind(): string;
  73054. /**
  73055. * Gets a boolean indicating if the VertexBuffer is updatable?
  73056. * @returns true if the buffer is updatable
  73057. */
  73058. isUpdatable(): boolean;
  73059. /**
  73060. * Gets current buffer's data
  73061. * @returns a DataArray or null
  73062. */
  73063. getData(): Nullable<DataArray>;
  73064. /**
  73065. * Gets underlying native buffer
  73066. * @returns underlying native buffer
  73067. */
  73068. getBuffer(): Nullable<DataBuffer>;
  73069. /**
  73070. * Gets the stride in float32 units (i.e. byte stride / 4).
  73071. * May not be an integer if the byte stride is not divisible by 4.
  73072. * DEPRECATED. Use byteStride instead.
  73073. * @returns the stride in float32 units
  73074. */
  73075. getStrideSize(): number;
  73076. /**
  73077. * Returns the offset as a multiple of the type byte length.
  73078. * DEPRECATED. Use byteOffset instead.
  73079. * @returns the offset in bytes
  73080. */
  73081. getOffset(): number;
  73082. /**
  73083. * Returns the number of components per vertex attribute (integer)
  73084. * @returns the size in float
  73085. */
  73086. getSize(): number;
  73087. /**
  73088. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73089. * @returns true if this buffer is instanced
  73090. */
  73091. getIsInstanced(): boolean;
  73092. /**
  73093. * Returns the instancing divisor, zero for non-instanced (integer).
  73094. * @returns a number
  73095. */
  73096. getInstanceDivisor(): number;
  73097. /**
  73098. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73099. * @param data defines the data to store
  73100. */
  73101. create(data?: DataArray): void;
  73102. /**
  73103. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73104. * This function will create a new buffer if the current one is not updatable
  73105. * @param data defines the data to store
  73106. */
  73107. update(data: DataArray): void;
  73108. /**
  73109. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73110. * Returns the directly updated WebGLBuffer.
  73111. * @param data the new data
  73112. * @param offset the new offset
  73113. * @param useBytes set to true if the offset is in bytes
  73114. */
  73115. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73116. /**
  73117. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73118. */
  73119. dispose(): void;
  73120. /**
  73121. * Enumerates each value of this vertex buffer as numbers.
  73122. * @param count the number of values to enumerate
  73123. * @param callback the callback function called for each value
  73124. */
  73125. forEach(count: number, callback: (value: number, index: number) => void): void;
  73126. /**
  73127. * Positions
  73128. */
  73129. static readonly PositionKind: string;
  73130. /**
  73131. * Normals
  73132. */
  73133. static readonly NormalKind: string;
  73134. /**
  73135. * Tangents
  73136. */
  73137. static readonly TangentKind: string;
  73138. /**
  73139. * Texture coordinates
  73140. */
  73141. static readonly UVKind: string;
  73142. /**
  73143. * Texture coordinates 2
  73144. */
  73145. static readonly UV2Kind: string;
  73146. /**
  73147. * Texture coordinates 3
  73148. */
  73149. static readonly UV3Kind: string;
  73150. /**
  73151. * Texture coordinates 4
  73152. */
  73153. static readonly UV4Kind: string;
  73154. /**
  73155. * Texture coordinates 5
  73156. */
  73157. static readonly UV5Kind: string;
  73158. /**
  73159. * Texture coordinates 6
  73160. */
  73161. static readonly UV6Kind: string;
  73162. /**
  73163. * Colors
  73164. */
  73165. static readonly ColorKind: string;
  73166. /**
  73167. * Matrix indices (for bones)
  73168. */
  73169. static readonly MatricesIndicesKind: string;
  73170. /**
  73171. * Matrix weights (for bones)
  73172. */
  73173. static readonly MatricesWeightsKind: string;
  73174. /**
  73175. * Additional matrix indices (for bones)
  73176. */
  73177. static readonly MatricesIndicesExtraKind: string;
  73178. /**
  73179. * Additional matrix weights (for bones)
  73180. */
  73181. static readonly MatricesWeightsExtraKind: string;
  73182. /**
  73183. * Deduces the stride given a kind.
  73184. * @param kind The kind string to deduce
  73185. * @returns The deduced stride
  73186. */
  73187. static DeduceStride(kind: string): number;
  73188. /**
  73189. * Gets the byte length of the given type.
  73190. * @param type the type
  73191. * @returns the number of bytes
  73192. */
  73193. static GetTypeByteLength(type: number): number;
  73194. /**
  73195. * Enumerates each value of the given parameters as numbers.
  73196. * @param data the data to enumerate
  73197. * @param byteOffset the byte offset of the data
  73198. * @param byteStride the byte stride of the data
  73199. * @param componentCount the number of components per element
  73200. * @param componentType the type of the component
  73201. * @param count the number of values to enumerate
  73202. * @param normalized whether the data is normalized
  73203. * @param callback the callback function called for each value
  73204. */
  73205. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73206. private static _GetFloatValue;
  73207. }
  73208. }
  73209. declare module BABYLON {
  73210. /**
  73211. * @hidden
  73212. */
  73213. export class IntersectionInfo {
  73214. bu: Nullable<number>;
  73215. bv: Nullable<number>;
  73216. distance: number;
  73217. faceId: number;
  73218. subMeshId: number;
  73219. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73220. }
  73221. }
  73222. declare module BABYLON {
  73223. /**
  73224. * Represens a plane by the equation ax + by + cz + d = 0
  73225. */
  73226. export class Plane {
  73227. private static _TmpMatrix;
  73228. /**
  73229. * Normal of the plane (a,b,c)
  73230. */
  73231. normal: Vector3;
  73232. /**
  73233. * d component of the plane
  73234. */
  73235. d: number;
  73236. /**
  73237. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73238. * @param a a component of the plane
  73239. * @param b b component of the plane
  73240. * @param c c component of the plane
  73241. * @param d d component of the plane
  73242. */
  73243. constructor(a: number, b: number, c: number, d: number);
  73244. /**
  73245. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73246. */
  73247. asArray(): number[];
  73248. /**
  73249. * @returns a new plane copied from the current Plane.
  73250. */
  73251. clone(): Plane;
  73252. /**
  73253. * @returns the string "Plane".
  73254. */
  73255. getClassName(): string;
  73256. /**
  73257. * @returns the Plane hash code.
  73258. */
  73259. getHashCode(): number;
  73260. /**
  73261. * Normalize the current Plane in place.
  73262. * @returns the updated Plane.
  73263. */
  73264. normalize(): Plane;
  73265. /**
  73266. * Applies a transformation the plane and returns the result
  73267. * @param transformation the transformation matrix to be applied to the plane
  73268. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73269. */
  73270. transform(transformation: DeepImmutable<Matrix>): Plane;
  73271. /**
  73272. * Calcualtte the dot product between the point and the plane normal
  73273. * @param point point to calculate the dot product with
  73274. * @returns the dot product (float) of the point coordinates and the plane normal.
  73275. */
  73276. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73277. /**
  73278. * Updates the current Plane from the plane defined by the three given points.
  73279. * @param point1 one of the points used to contruct the plane
  73280. * @param point2 one of the points used to contruct the plane
  73281. * @param point3 one of the points used to contruct the plane
  73282. * @returns the updated Plane.
  73283. */
  73284. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73285. /**
  73286. * Checks if the plane is facing a given direction
  73287. * @param direction the direction to check if the plane is facing
  73288. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73289. * @returns True is the vector "direction" is the same side than the plane normal.
  73290. */
  73291. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73292. /**
  73293. * Calculates the distance to a point
  73294. * @param point point to calculate distance to
  73295. * @returns the signed distance (float) from the given point to the Plane.
  73296. */
  73297. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73298. /**
  73299. * Creates a plane from an array
  73300. * @param array the array to create a plane from
  73301. * @returns a new Plane from the given array.
  73302. */
  73303. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73304. /**
  73305. * Creates a plane from three points
  73306. * @param point1 point used to create the plane
  73307. * @param point2 point used to create the plane
  73308. * @param point3 point used to create the plane
  73309. * @returns a new Plane defined by the three given points.
  73310. */
  73311. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73312. /**
  73313. * Creates a plane from an origin point and a normal
  73314. * @param origin origin of the plane to be constructed
  73315. * @param normal normal of the plane to be constructed
  73316. * @returns a new Plane the normal vector to this plane at the given origin point.
  73317. * Note : the vector "normal" is updated because normalized.
  73318. */
  73319. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73320. /**
  73321. * Calculates the distance from a plane and a point
  73322. * @param origin origin of the plane to be constructed
  73323. * @param normal normal of the plane to be constructed
  73324. * @param point point to calculate distance to
  73325. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73326. */
  73327. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73328. }
  73329. }
  73330. declare module BABYLON {
  73331. /**
  73332. * Class used to store bounding sphere information
  73333. */
  73334. export class BoundingSphere {
  73335. /**
  73336. * Gets the center of the bounding sphere in local space
  73337. */
  73338. readonly center: Vector3;
  73339. /**
  73340. * Radius of the bounding sphere in local space
  73341. */
  73342. radius: number;
  73343. /**
  73344. * Gets the center of the bounding sphere in world space
  73345. */
  73346. readonly centerWorld: Vector3;
  73347. /**
  73348. * Radius of the bounding sphere in world space
  73349. */
  73350. radiusWorld: number;
  73351. /**
  73352. * Gets the minimum vector in local space
  73353. */
  73354. readonly minimum: Vector3;
  73355. /**
  73356. * Gets the maximum vector in local space
  73357. */
  73358. readonly maximum: Vector3;
  73359. private _worldMatrix;
  73360. private static readonly TmpVector3;
  73361. /**
  73362. * Creates a new bounding sphere
  73363. * @param min defines the minimum vector (in local space)
  73364. * @param max defines the maximum vector (in local space)
  73365. * @param worldMatrix defines the new world matrix
  73366. */
  73367. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73368. /**
  73369. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73370. * @param min defines the new minimum vector (in local space)
  73371. * @param max defines the new maximum vector (in local space)
  73372. * @param worldMatrix defines the new world matrix
  73373. */
  73374. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73375. /**
  73376. * Scale the current bounding sphere by applying a scale factor
  73377. * @param factor defines the scale factor to apply
  73378. * @returns the current bounding box
  73379. */
  73380. scale(factor: number): BoundingSphere;
  73381. /**
  73382. * Gets the world matrix of the bounding box
  73383. * @returns a matrix
  73384. */
  73385. getWorldMatrix(): DeepImmutable<Matrix>;
  73386. /** @hidden */
  73387. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73388. /**
  73389. * Tests if the bounding sphere is intersecting the frustum planes
  73390. * @param frustumPlanes defines the frustum planes to test
  73391. * @returns true if there is an intersection
  73392. */
  73393. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73394. /**
  73395. * Tests if the bounding sphere center is in between the frustum planes.
  73396. * Used for optimistic fast inclusion.
  73397. * @param frustumPlanes defines the frustum planes to test
  73398. * @returns true if the sphere center is in between the frustum planes
  73399. */
  73400. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73401. /**
  73402. * Tests if a point is inside the bounding sphere
  73403. * @param point defines the point to test
  73404. * @returns true if the point is inside the bounding sphere
  73405. */
  73406. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73407. /**
  73408. * Checks if two sphere intersct
  73409. * @param sphere0 sphere 0
  73410. * @param sphere1 sphere 1
  73411. * @returns true if the speres intersect
  73412. */
  73413. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73414. }
  73415. }
  73416. declare module BABYLON {
  73417. /**
  73418. * Class used to store bounding box information
  73419. */
  73420. export class BoundingBox implements ICullable {
  73421. /**
  73422. * Gets the 8 vectors representing the bounding box in local space
  73423. */
  73424. readonly vectors: Vector3[];
  73425. /**
  73426. * Gets the center of the bounding box in local space
  73427. */
  73428. readonly center: Vector3;
  73429. /**
  73430. * Gets the center of the bounding box in world space
  73431. */
  73432. readonly centerWorld: Vector3;
  73433. /**
  73434. * Gets the extend size in local space
  73435. */
  73436. readonly extendSize: Vector3;
  73437. /**
  73438. * Gets the extend size in world space
  73439. */
  73440. readonly extendSizeWorld: Vector3;
  73441. /**
  73442. * Gets the OBB (object bounding box) directions
  73443. */
  73444. readonly directions: Vector3[];
  73445. /**
  73446. * Gets the 8 vectors representing the bounding box in world space
  73447. */
  73448. readonly vectorsWorld: Vector3[];
  73449. /**
  73450. * Gets the minimum vector in world space
  73451. */
  73452. readonly minimumWorld: Vector3;
  73453. /**
  73454. * Gets the maximum vector in world space
  73455. */
  73456. readonly maximumWorld: Vector3;
  73457. /**
  73458. * Gets the minimum vector in local space
  73459. */
  73460. readonly minimum: Vector3;
  73461. /**
  73462. * Gets the maximum vector in local space
  73463. */
  73464. readonly maximum: Vector3;
  73465. private _worldMatrix;
  73466. private static readonly TmpVector3;
  73467. /**
  73468. * @hidden
  73469. */
  73470. _tag: number;
  73471. /**
  73472. * Creates a new bounding box
  73473. * @param min defines the minimum vector (in local space)
  73474. * @param max defines the maximum vector (in local space)
  73475. * @param worldMatrix defines the new world matrix
  73476. */
  73477. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73478. /**
  73479. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73480. * @param min defines the new minimum vector (in local space)
  73481. * @param max defines the new maximum vector (in local space)
  73482. * @param worldMatrix defines the new world matrix
  73483. */
  73484. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73485. /**
  73486. * Scale the current bounding box by applying a scale factor
  73487. * @param factor defines the scale factor to apply
  73488. * @returns the current bounding box
  73489. */
  73490. scale(factor: number): BoundingBox;
  73491. /**
  73492. * Gets the world matrix of the bounding box
  73493. * @returns a matrix
  73494. */
  73495. getWorldMatrix(): DeepImmutable<Matrix>;
  73496. /** @hidden */
  73497. _update(world: DeepImmutable<Matrix>): void;
  73498. /**
  73499. * Tests if the bounding box is intersecting the frustum planes
  73500. * @param frustumPlanes defines the frustum planes to test
  73501. * @returns true if there is an intersection
  73502. */
  73503. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73504. /**
  73505. * Tests if the bounding box is entirely inside the frustum planes
  73506. * @param frustumPlanes defines the frustum planes to test
  73507. * @returns true if there is an inclusion
  73508. */
  73509. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73510. /**
  73511. * Tests if a point is inside the bounding box
  73512. * @param point defines the point to test
  73513. * @returns true if the point is inside the bounding box
  73514. */
  73515. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73516. /**
  73517. * Tests if the bounding box intersects with a bounding sphere
  73518. * @param sphere defines the sphere to test
  73519. * @returns true if there is an intersection
  73520. */
  73521. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73522. /**
  73523. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73524. * @param min defines the min vector to use
  73525. * @param max defines the max vector to use
  73526. * @returns true if there is an intersection
  73527. */
  73528. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73529. /**
  73530. * Tests if two bounding boxes are intersections
  73531. * @param box0 defines the first box to test
  73532. * @param box1 defines the second box to test
  73533. * @returns true if there is an intersection
  73534. */
  73535. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73536. /**
  73537. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73538. * @param minPoint defines the minimum vector of the bounding box
  73539. * @param maxPoint defines the maximum vector of the bounding box
  73540. * @param sphereCenter defines the sphere center
  73541. * @param sphereRadius defines the sphere radius
  73542. * @returns true if there is an intersection
  73543. */
  73544. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73545. /**
  73546. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73547. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73548. * @param frustumPlanes defines the frustum planes to test
  73549. * @return true if there is an inclusion
  73550. */
  73551. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73552. /**
  73553. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73554. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73555. * @param frustumPlanes defines the frustum planes to test
  73556. * @return true if there is an intersection
  73557. */
  73558. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73559. }
  73560. }
  73561. declare module BABYLON {
  73562. /** @hidden */
  73563. export class Collider {
  73564. /** Define if a collision was found */
  73565. collisionFound: boolean;
  73566. /**
  73567. * Define last intersection point in local space
  73568. */
  73569. intersectionPoint: Vector3;
  73570. /**
  73571. * Define last collided mesh
  73572. */
  73573. collidedMesh: Nullable<AbstractMesh>;
  73574. private _collisionPoint;
  73575. private _planeIntersectionPoint;
  73576. private _tempVector;
  73577. private _tempVector2;
  73578. private _tempVector3;
  73579. private _tempVector4;
  73580. private _edge;
  73581. private _baseToVertex;
  73582. private _destinationPoint;
  73583. private _slidePlaneNormal;
  73584. private _displacementVector;
  73585. /** @hidden */
  73586. _radius: Vector3;
  73587. /** @hidden */
  73588. _retry: number;
  73589. private _velocity;
  73590. private _basePoint;
  73591. private _epsilon;
  73592. /** @hidden */
  73593. _velocityWorldLength: number;
  73594. /** @hidden */
  73595. _basePointWorld: Vector3;
  73596. private _velocityWorld;
  73597. private _normalizedVelocity;
  73598. /** @hidden */
  73599. _initialVelocity: Vector3;
  73600. /** @hidden */
  73601. _initialPosition: Vector3;
  73602. private _nearestDistance;
  73603. private _collisionMask;
  73604. collisionMask: number;
  73605. /**
  73606. * Gets the plane normal used to compute the sliding response (in local space)
  73607. */
  73608. readonly slidePlaneNormal: Vector3;
  73609. /** @hidden */
  73610. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73611. /** @hidden */
  73612. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73613. /** @hidden */
  73614. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73615. /** @hidden */
  73616. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73617. /** @hidden */
  73618. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73619. /** @hidden */
  73620. _getResponse(pos: Vector3, vel: Vector3): void;
  73621. }
  73622. }
  73623. declare module BABYLON {
  73624. /**
  73625. * Interface for cullable objects
  73626. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73627. */
  73628. export interface ICullable {
  73629. /**
  73630. * Checks if the object or part of the object is in the frustum
  73631. * @param frustumPlanes Camera near/planes
  73632. * @returns true if the object is in frustum otherwise false
  73633. */
  73634. isInFrustum(frustumPlanes: Plane[]): boolean;
  73635. /**
  73636. * Checks if a cullable object (mesh...) is in the camera frustum
  73637. * Unlike isInFrustum this cheks the full bounding box
  73638. * @param frustumPlanes Camera near/planes
  73639. * @returns true if the object is in frustum otherwise false
  73640. */
  73641. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73642. }
  73643. /**
  73644. * Info for a bounding data of a mesh
  73645. */
  73646. export class BoundingInfo implements ICullable {
  73647. /**
  73648. * Bounding box for the mesh
  73649. */
  73650. readonly boundingBox: BoundingBox;
  73651. /**
  73652. * Bounding sphere for the mesh
  73653. */
  73654. readonly boundingSphere: BoundingSphere;
  73655. private _isLocked;
  73656. private static readonly TmpVector3;
  73657. /**
  73658. * Constructs bounding info
  73659. * @param minimum min vector of the bounding box/sphere
  73660. * @param maximum max vector of the bounding box/sphere
  73661. * @param worldMatrix defines the new world matrix
  73662. */
  73663. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73664. /**
  73665. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73666. * @param min defines the new minimum vector (in local space)
  73667. * @param max defines the new maximum vector (in local space)
  73668. * @param worldMatrix defines the new world matrix
  73669. */
  73670. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73671. /**
  73672. * min vector of the bounding box/sphere
  73673. */
  73674. readonly minimum: Vector3;
  73675. /**
  73676. * max vector of the bounding box/sphere
  73677. */
  73678. readonly maximum: Vector3;
  73679. /**
  73680. * If the info is locked and won't be updated to avoid perf overhead
  73681. */
  73682. isLocked: boolean;
  73683. /**
  73684. * Updates the bounding sphere and box
  73685. * @param world world matrix to be used to update
  73686. */
  73687. update(world: DeepImmutable<Matrix>): void;
  73688. /**
  73689. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73690. * @param center New center of the bounding info
  73691. * @param extend New extend of the bounding info
  73692. * @returns the current bounding info
  73693. */
  73694. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73695. /**
  73696. * Scale the current bounding info by applying a scale factor
  73697. * @param factor defines the scale factor to apply
  73698. * @returns the current bounding info
  73699. */
  73700. scale(factor: number): BoundingInfo;
  73701. /**
  73702. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73703. * @param frustumPlanes defines the frustum to test
  73704. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73705. * @returns true if the bounding info is in the frustum planes
  73706. */
  73707. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73708. /**
  73709. * Gets the world distance between the min and max points of the bounding box
  73710. */
  73711. readonly diagonalLength: number;
  73712. /**
  73713. * Checks if a cullable object (mesh...) is in the camera frustum
  73714. * Unlike isInFrustum this cheks the full bounding box
  73715. * @param frustumPlanes Camera near/planes
  73716. * @returns true if the object is in frustum otherwise false
  73717. */
  73718. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73719. /** @hidden */
  73720. _checkCollision(collider: Collider): boolean;
  73721. /**
  73722. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73723. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73724. * @param point the point to check intersection with
  73725. * @returns if the point intersects
  73726. */
  73727. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73728. /**
  73729. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73730. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73731. * @param boundingInfo the bounding info to check intersection with
  73732. * @param precise if the intersection should be done using OBB
  73733. * @returns if the bounding info intersects
  73734. */
  73735. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73736. }
  73737. }
  73738. declare module BABYLON {
  73739. /**
  73740. * Extracts minimum and maximum values from a list of indexed positions
  73741. * @param positions defines the positions to use
  73742. * @param indices defines the indices to the positions
  73743. * @param indexStart defines the start index
  73744. * @param indexCount defines the end index
  73745. * @param bias defines bias value to add to the result
  73746. * @return minimum and maximum values
  73747. */
  73748. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73749. minimum: Vector3;
  73750. maximum: Vector3;
  73751. };
  73752. /**
  73753. * Extracts minimum and maximum values from a list of positions
  73754. * @param positions defines the positions to use
  73755. * @param start defines the start index in the positions array
  73756. * @param count defines the number of positions to handle
  73757. * @param bias defines bias value to add to the result
  73758. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73759. * @return minimum and maximum values
  73760. */
  73761. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73762. minimum: Vector3;
  73763. maximum: Vector3;
  73764. };
  73765. }
  73766. declare module BABYLON {
  73767. /** @hidden */
  73768. export class WebGLDataBuffer extends DataBuffer {
  73769. private _buffer;
  73770. constructor(resource: WebGLBuffer);
  73771. readonly underlyingResource: any;
  73772. }
  73773. }
  73774. declare module BABYLON {
  73775. /** @hidden */
  73776. export class WebGLPipelineContext implements IPipelineContext {
  73777. engine: ThinEngine;
  73778. program: Nullable<WebGLProgram>;
  73779. context?: WebGLRenderingContext;
  73780. vertexShader?: WebGLShader;
  73781. fragmentShader?: WebGLShader;
  73782. isParallelCompiled: boolean;
  73783. onCompiled?: () => void;
  73784. transformFeedback?: WebGLTransformFeedback | null;
  73785. readonly isAsync: boolean;
  73786. readonly isReady: boolean;
  73787. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73788. }
  73789. }
  73790. declare module BABYLON {
  73791. interface ThinEngine {
  73792. /**
  73793. * Create an uniform buffer
  73794. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73795. * @param elements defines the content of the uniform buffer
  73796. * @returns the webGL uniform buffer
  73797. */
  73798. createUniformBuffer(elements: FloatArray): DataBuffer;
  73799. /**
  73800. * Create a dynamic uniform buffer
  73801. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73802. * @param elements defines the content of the uniform buffer
  73803. * @returns the webGL uniform buffer
  73804. */
  73805. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73806. /**
  73807. * Update an existing uniform buffer
  73808. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73809. * @param uniformBuffer defines the target uniform buffer
  73810. * @param elements defines the content to update
  73811. * @param offset defines the offset in the uniform buffer where update should start
  73812. * @param count defines the size of the data to update
  73813. */
  73814. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73815. /**
  73816. * Bind an uniform buffer to the current webGL context
  73817. * @param buffer defines the buffer to bind
  73818. */
  73819. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73820. /**
  73821. * Bind a buffer to the current webGL context at a given location
  73822. * @param buffer defines the buffer to bind
  73823. * @param location defines the index where to bind the buffer
  73824. */
  73825. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73826. /**
  73827. * Bind a specific block at a given index in a specific shader program
  73828. * @param pipelineContext defines the pipeline context to use
  73829. * @param blockName defines the block name
  73830. * @param index defines the index where to bind the block
  73831. */
  73832. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73833. }
  73834. }
  73835. declare module BABYLON {
  73836. /**
  73837. * Uniform buffer objects.
  73838. *
  73839. * Handles blocks of uniform on the GPU.
  73840. *
  73841. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73842. *
  73843. * For more information, please refer to :
  73844. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73845. */
  73846. export class UniformBuffer {
  73847. private _engine;
  73848. private _buffer;
  73849. private _data;
  73850. private _bufferData;
  73851. private _dynamic?;
  73852. private _uniformLocations;
  73853. private _uniformSizes;
  73854. private _uniformLocationPointer;
  73855. private _needSync;
  73856. private _noUBO;
  73857. private _currentEffect;
  73858. private static _MAX_UNIFORM_SIZE;
  73859. private static _tempBuffer;
  73860. /**
  73861. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73862. * This is dynamic to allow compat with webgl 1 and 2.
  73863. * You will need to pass the name of the uniform as well as the value.
  73864. */
  73865. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73866. /**
  73867. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73868. * This is dynamic to allow compat with webgl 1 and 2.
  73869. * You will need to pass the name of the uniform as well as the value.
  73870. */
  73871. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73872. /**
  73873. * Lambda to Update a single float in a uniform buffer.
  73874. * This is dynamic to allow compat with webgl 1 and 2.
  73875. * You will need to pass the name of the uniform as well as the value.
  73876. */
  73877. updateFloat: (name: string, x: number) => void;
  73878. /**
  73879. * Lambda to Update a vec2 of float in a uniform buffer.
  73880. * This is dynamic to allow compat with webgl 1 and 2.
  73881. * You will need to pass the name of the uniform as well as the value.
  73882. */
  73883. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73884. /**
  73885. * Lambda to Update a vec3 of float in a uniform buffer.
  73886. * This is dynamic to allow compat with webgl 1 and 2.
  73887. * You will need to pass the name of the uniform as well as the value.
  73888. */
  73889. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73890. /**
  73891. * Lambda to Update a vec4 of float in a uniform buffer.
  73892. * This is dynamic to allow compat with webgl 1 and 2.
  73893. * You will need to pass the name of the uniform as well as the value.
  73894. */
  73895. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  73896. /**
  73897. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  73898. * This is dynamic to allow compat with webgl 1 and 2.
  73899. * You will need to pass the name of the uniform as well as the value.
  73900. */
  73901. updateMatrix: (name: string, mat: Matrix) => void;
  73902. /**
  73903. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  73904. * This is dynamic to allow compat with webgl 1 and 2.
  73905. * You will need to pass the name of the uniform as well as the value.
  73906. */
  73907. updateVector3: (name: string, vector: Vector3) => void;
  73908. /**
  73909. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  73910. * This is dynamic to allow compat with webgl 1 and 2.
  73911. * You will need to pass the name of the uniform as well as the value.
  73912. */
  73913. updateVector4: (name: string, vector: Vector4) => void;
  73914. /**
  73915. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  73916. * This is dynamic to allow compat with webgl 1 and 2.
  73917. * You will need to pass the name of the uniform as well as the value.
  73918. */
  73919. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  73920. /**
  73921. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  73922. * This is dynamic to allow compat with webgl 1 and 2.
  73923. * You will need to pass the name of the uniform as well as the value.
  73924. */
  73925. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  73926. /**
  73927. * Instantiates a new Uniform buffer objects.
  73928. *
  73929. * Handles blocks of uniform on the GPU.
  73930. *
  73931. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73932. *
  73933. * For more information, please refer to :
  73934. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73935. * @param engine Define the engine the buffer is associated with
  73936. * @param data Define the data contained in the buffer
  73937. * @param dynamic Define if the buffer is updatable
  73938. */
  73939. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  73940. /**
  73941. * Indicates if the buffer is using the WebGL2 UBO implementation,
  73942. * or just falling back on setUniformXXX calls.
  73943. */
  73944. readonly useUbo: boolean;
  73945. /**
  73946. * Indicates if the WebGL underlying uniform buffer is in sync
  73947. * with the javascript cache data.
  73948. */
  73949. readonly isSync: boolean;
  73950. /**
  73951. * Indicates if the WebGL underlying uniform buffer is dynamic.
  73952. * Also, a dynamic UniformBuffer will disable cache verification and always
  73953. * update the underlying WebGL uniform buffer to the GPU.
  73954. * @returns if Dynamic, otherwise false
  73955. */
  73956. isDynamic(): boolean;
  73957. /**
  73958. * The data cache on JS side.
  73959. * @returns the underlying data as a float array
  73960. */
  73961. getData(): Float32Array;
  73962. /**
  73963. * The underlying WebGL Uniform buffer.
  73964. * @returns the webgl buffer
  73965. */
  73966. getBuffer(): Nullable<DataBuffer>;
  73967. /**
  73968. * std140 layout specifies how to align data within an UBO structure.
  73969. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  73970. * for specs.
  73971. */
  73972. private _fillAlignment;
  73973. /**
  73974. * Adds an uniform in the buffer.
  73975. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  73976. * for the layout to be correct !
  73977. * @param name Name of the uniform, as used in the uniform block in the shader.
  73978. * @param size Data size, or data directly.
  73979. */
  73980. addUniform(name: string, size: number | number[]): void;
  73981. /**
  73982. * Adds a Matrix 4x4 to the uniform buffer.
  73983. * @param name Name of the uniform, as used in the uniform block in the shader.
  73984. * @param mat A 4x4 matrix.
  73985. */
  73986. addMatrix(name: string, mat: Matrix): void;
  73987. /**
  73988. * Adds a vec2 to the uniform buffer.
  73989. * @param name Name of the uniform, as used in the uniform block in the shader.
  73990. * @param x Define the x component value of the vec2
  73991. * @param y Define the y component value of the vec2
  73992. */
  73993. addFloat2(name: string, x: number, y: number): void;
  73994. /**
  73995. * Adds a vec3 to the uniform buffer.
  73996. * @param name Name of the uniform, as used in the uniform block in the shader.
  73997. * @param x Define the x component value of the vec3
  73998. * @param y Define the y component value of the vec3
  73999. * @param z Define the z component value of the vec3
  74000. */
  74001. addFloat3(name: string, x: number, y: number, z: number): void;
  74002. /**
  74003. * Adds a vec3 to the uniform buffer.
  74004. * @param name Name of the uniform, as used in the uniform block in the shader.
  74005. * @param color Define the vec3 from a Color
  74006. */
  74007. addColor3(name: string, color: Color3): void;
  74008. /**
  74009. * Adds a vec4 to the uniform buffer.
  74010. * @param name Name of the uniform, as used in the uniform block in the shader.
  74011. * @param color Define the rgb components from a Color
  74012. * @param alpha Define the a component of the vec4
  74013. */
  74014. addColor4(name: string, color: Color3, alpha: number): void;
  74015. /**
  74016. * Adds a vec3 to the uniform buffer.
  74017. * @param name Name of the uniform, as used in the uniform block in the shader.
  74018. * @param vector Define the vec3 components from a Vector
  74019. */
  74020. addVector3(name: string, vector: Vector3): void;
  74021. /**
  74022. * Adds a Matrix 3x3 to the uniform buffer.
  74023. * @param name Name of the uniform, as used in the uniform block in the shader.
  74024. */
  74025. addMatrix3x3(name: string): void;
  74026. /**
  74027. * Adds a Matrix 2x2 to the uniform buffer.
  74028. * @param name Name of the uniform, as used in the uniform block in the shader.
  74029. */
  74030. addMatrix2x2(name: string): void;
  74031. /**
  74032. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74033. */
  74034. create(): void;
  74035. /** @hidden */
  74036. _rebuild(): void;
  74037. /**
  74038. * Updates the WebGL Uniform Buffer on the GPU.
  74039. * If the `dynamic` flag is set to true, no cache comparison is done.
  74040. * Otherwise, the buffer will be updated only if the cache differs.
  74041. */
  74042. update(): void;
  74043. /**
  74044. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74045. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74046. * @param data Define the flattened data
  74047. * @param size Define the size of the data.
  74048. */
  74049. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74050. private _valueCache;
  74051. private _cacheMatrix;
  74052. private _updateMatrix3x3ForUniform;
  74053. private _updateMatrix3x3ForEffect;
  74054. private _updateMatrix2x2ForEffect;
  74055. private _updateMatrix2x2ForUniform;
  74056. private _updateFloatForEffect;
  74057. private _updateFloatForUniform;
  74058. private _updateFloat2ForEffect;
  74059. private _updateFloat2ForUniform;
  74060. private _updateFloat3ForEffect;
  74061. private _updateFloat3ForUniform;
  74062. private _updateFloat4ForEffect;
  74063. private _updateFloat4ForUniform;
  74064. private _updateMatrixForEffect;
  74065. private _updateMatrixForUniform;
  74066. private _updateVector3ForEffect;
  74067. private _updateVector3ForUniform;
  74068. private _updateVector4ForEffect;
  74069. private _updateVector4ForUniform;
  74070. private _updateColor3ForEffect;
  74071. private _updateColor3ForUniform;
  74072. private _updateColor4ForEffect;
  74073. private _updateColor4ForUniform;
  74074. /**
  74075. * Sets a sampler uniform on the effect.
  74076. * @param name Define the name of the sampler.
  74077. * @param texture Define the texture to set in the sampler
  74078. */
  74079. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74080. /**
  74081. * Directly updates the value of the uniform in the cache AND on the GPU.
  74082. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74083. * @param data Define the flattened data
  74084. */
  74085. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74086. /**
  74087. * Binds this uniform buffer to an effect.
  74088. * @param effect Define the effect to bind the buffer to
  74089. * @param name Name of the uniform block in the shader.
  74090. */
  74091. bindToEffect(effect: Effect, name: string): void;
  74092. /**
  74093. * Disposes the uniform buffer.
  74094. */
  74095. dispose(): void;
  74096. }
  74097. }
  74098. declare module BABYLON {
  74099. /**
  74100. * Enum that determines the text-wrapping mode to use.
  74101. */
  74102. export enum InspectableType {
  74103. /**
  74104. * Checkbox for booleans
  74105. */
  74106. Checkbox = 0,
  74107. /**
  74108. * Sliders for numbers
  74109. */
  74110. Slider = 1,
  74111. /**
  74112. * Vector3
  74113. */
  74114. Vector3 = 2,
  74115. /**
  74116. * Quaternions
  74117. */
  74118. Quaternion = 3,
  74119. /**
  74120. * Color3
  74121. */
  74122. Color3 = 4,
  74123. /**
  74124. * String
  74125. */
  74126. String = 5
  74127. }
  74128. /**
  74129. * Interface used to define custom inspectable properties.
  74130. * This interface is used by the inspector to display custom property grids
  74131. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74132. */
  74133. export interface IInspectable {
  74134. /**
  74135. * Gets the label to display
  74136. */
  74137. label: string;
  74138. /**
  74139. * Gets the name of the property to edit
  74140. */
  74141. propertyName: string;
  74142. /**
  74143. * Gets the type of the editor to use
  74144. */
  74145. type: InspectableType;
  74146. /**
  74147. * Gets the minimum value of the property when using in "slider" mode
  74148. */
  74149. min?: number;
  74150. /**
  74151. * Gets the maximum value of the property when using in "slider" mode
  74152. */
  74153. max?: number;
  74154. /**
  74155. * Gets the setp to use when using in "slider" mode
  74156. */
  74157. step?: number;
  74158. }
  74159. }
  74160. declare module BABYLON {
  74161. /**
  74162. * Class used to provide helper for timing
  74163. */
  74164. export class TimingTools {
  74165. /**
  74166. * Polyfill for setImmediate
  74167. * @param action defines the action to execute after the current execution block
  74168. */
  74169. static SetImmediate(action: () => void): void;
  74170. }
  74171. }
  74172. declare module BABYLON {
  74173. /**
  74174. * Class used to enable instatition of objects by class name
  74175. */
  74176. export class InstantiationTools {
  74177. /**
  74178. * Use this object to register external classes like custom textures or material
  74179. * to allow the laoders to instantiate them
  74180. */
  74181. static RegisteredExternalClasses: {
  74182. [key: string]: Object;
  74183. };
  74184. /**
  74185. * Tries to instantiate a new object from a given class name
  74186. * @param className defines the class name to instantiate
  74187. * @returns the new object or null if the system was not able to do the instantiation
  74188. */
  74189. static Instantiate(className: string): any;
  74190. }
  74191. }
  74192. declare module BABYLON {
  74193. /**
  74194. * Define options used to create a depth texture
  74195. */
  74196. export class DepthTextureCreationOptions {
  74197. /** Specifies whether or not a stencil should be allocated in the texture */
  74198. generateStencil?: boolean;
  74199. /** Specifies whether or not bilinear filtering is enable on the texture */
  74200. bilinearFiltering?: boolean;
  74201. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74202. comparisonFunction?: number;
  74203. /** Specifies if the created texture is a cube texture */
  74204. isCube?: boolean;
  74205. }
  74206. }
  74207. declare module BABYLON {
  74208. interface ThinEngine {
  74209. /**
  74210. * Creates a depth stencil cube texture.
  74211. * This is only available in WebGL 2.
  74212. * @param size The size of face edge in the cube texture.
  74213. * @param options The options defining the cube texture.
  74214. * @returns The cube texture
  74215. */
  74216. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74217. /**
  74218. * Creates a cube texture
  74219. * @param rootUrl defines the url where the files to load is located
  74220. * @param scene defines the current scene
  74221. * @param files defines the list of files to load (1 per face)
  74222. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74223. * @param onLoad defines an optional callback raised when the texture is loaded
  74224. * @param onError defines an optional callback raised if there is an issue to load the texture
  74225. * @param format defines the format of the data
  74226. * @param forcedExtension defines the extension to use to pick the right loader
  74227. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74228. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74229. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74230. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74231. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74232. * @returns the cube texture as an InternalTexture
  74233. */
  74234. 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;
  74235. /**
  74236. * Creates a cube texture
  74237. * @param rootUrl defines the url where the files to load is located
  74238. * @param scene defines the current scene
  74239. * @param files defines the list of files to load (1 per face)
  74240. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74241. * @param onLoad defines an optional callback raised when the texture is loaded
  74242. * @param onError defines an optional callback raised if there is an issue to load the texture
  74243. * @param format defines the format of the data
  74244. * @param forcedExtension defines the extension to use to pick the right loader
  74245. * @returns the cube texture as an InternalTexture
  74246. */
  74247. 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;
  74248. /**
  74249. * Creates a cube texture
  74250. * @param rootUrl defines the url where the files to load is located
  74251. * @param scene defines the current scene
  74252. * @param files defines the list of files to load (1 per face)
  74253. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74254. * @param onLoad defines an optional callback raised when the texture is loaded
  74255. * @param onError defines an optional callback raised if there is an issue to load the texture
  74256. * @param format defines the format of the data
  74257. * @param forcedExtension defines the extension to use to pick the right loader
  74258. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74259. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74260. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74261. * @returns the cube texture as an InternalTexture
  74262. */
  74263. 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;
  74264. /** @hidden */
  74265. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74266. /** @hidden */
  74267. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74268. /** @hidden */
  74269. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74270. /** @hidden */
  74271. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  74272. }
  74273. }
  74274. declare module BABYLON {
  74275. /**
  74276. * Class for creating a cube texture
  74277. */
  74278. export class CubeTexture extends BaseTexture {
  74279. private _delayedOnLoad;
  74280. /**
  74281. * The url of the texture
  74282. */
  74283. url: string;
  74284. /**
  74285. * Gets or sets the center of the bounding box associated with the cube texture.
  74286. * It must define where the camera used to render the texture was set
  74287. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74288. */
  74289. boundingBoxPosition: Vector3;
  74290. private _boundingBoxSize;
  74291. /**
  74292. * Gets or sets the size of the bounding box associated with the cube texture
  74293. * When defined, the cubemap will switch to local mode
  74294. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74295. * @example https://www.babylonjs-playground.com/#RNASML
  74296. */
  74297. /**
  74298. * Returns the bounding box size
  74299. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74300. */
  74301. boundingBoxSize: Vector3;
  74302. protected _rotationY: number;
  74303. /**
  74304. * Sets texture matrix rotation angle around Y axis in radians.
  74305. */
  74306. /**
  74307. * Gets texture matrix rotation angle around Y axis radians.
  74308. */
  74309. rotationY: number;
  74310. /**
  74311. * Are mip maps generated for this texture or not.
  74312. */
  74313. readonly noMipmap: boolean;
  74314. private _noMipmap;
  74315. private _files;
  74316. protected _forcedExtension: Nullable<string>;
  74317. private _extensions;
  74318. private _textureMatrix;
  74319. private _format;
  74320. private _createPolynomials;
  74321. /** @hidden */
  74322. _prefiltered: boolean;
  74323. /**
  74324. * Creates a cube texture from an array of image urls
  74325. * @param files defines an array of image urls
  74326. * @param scene defines the hosting scene
  74327. * @param noMipmap specifies if mip maps are not used
  74328. * @returns a cube texture
  74329. */
  74330. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74331. /**
  74332. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74333. * @param url defines the url of the prefiltered texture
  74334. * @param scene defines the scene the texture is attached to
  74335. * @param forcedExtension defines the extension of the file if different from the url
  74336. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74337. * @return the prefiltered texture
  74338. */
  74339. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74340. /**
  74341. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74342. * as prefiltered data.
  74343. * @param rootUrl defines the url of the texture or the root name of the six images
  74344. * @param scene defines the scene the texture is attached to
  74345. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74346. * @param noMipmap defines if mipmaps should be created or not
  74347. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74348. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74349. * @param onError defines a callback triggered in case of error during load
  74350. * @param format defines the internal format to use for the texture once loaded
  74351. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74352. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74353. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74354. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74355. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74356. * @return the cube texture
  74357. */
  74358. 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);
  74359. /**
  74360. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74361. */
  74362. readonly isPrefiltered: boolean;
  74363. /**
  74364. * Get the current class name of the texture useful for serialization or dynamic coding.
  74365. * @returns "CubeTexture"
  74366. */
  74367. getClassName(): string;
  74368. /**
  74369. * Update the url (and optional buffer) of this texture if url was null during construction.
  74370. * @param url the url of the texture
  74371. * @param forcedExtension defines the extension to use
  74372. * @param onLoad callback called when the texture is loaded (defaults to null)
  74373. */
  74374. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74375. /**
  74376. * Delays loading of the cube texture
  74377. * @param forcedExtension defines the extension to use
  74378. */
  74379. delayLoad(forcedExtension?: string): void;
  74380. /**
  74381. * Returns the reflection texture matrix
  74382. * @returns the reflection texture matrix
  74383. */
  74384. getReflectionTextureMatrix(): Matrix;
  74385. /**
  74386. * Sets the reflection texture matrix
  74387. * @param value Reflection texture matrix
  74388. */
  74389. setReflectionTextureMatrix(value: Matrix): void;
  74390. /**
  74391. * Parses text to create a cube texture
  74392. * @param parsedTexture define the serialized text to read from
  74393. * @param scene defines the hosting scene
  74394. * @param rootUrl defines the root url of the cube texture
  74395. * @returns a cube texture
  74396. */
  74397. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74398. /**
  74399. * Makes a clone, or deep copy, of the cube texture
  74400. * @returns a new cube texture
  74401. */
  74402. clone(): CubeTexture;
  74403. }
  74404. }
  74405. declare module BABYLON {
  74406. /**
  74407. * Manages the defines for the Material
  74408. */
  74409. export class MaterialDefines {
  74410. /** @hidden */
  74411. protected _keys: string[];
  74412. private _isDirty;
  74413. /** @hidden */
  74414. _renderId: number;
  74415. /** @hidden */
  74416. _areLightsDirty: boolean;
  74417. /** @hidden */
  74418. _areLightsDisposed: boolean;
  74419. /** @hidden */
  74420. _areAttributesDirty: boolean;
  74421. /** @hidden */
  74422. _areTexturesDirty: boolean;
  74423. /** @hidden */
  74424. _areFresnelDirty: boolean;
  74425. /** @hidden */
  74426. _areMiscDirty: boolean;
  74427. /** @hidden */
  74428. _areImageProcessingDirty: boolean;
  74429. /** @hidden */
  74430. _normals: boolean;
  74431. /** @hidden */
  74432. _uvs: boolean;
  74433. /** @hidden */
  74434. _needNormals: boolean;
  74435. /** @hidden */
  74436. _needUVs: boolean;
  74437. [id: string]: any;
  74438. /**
  74439. * Specifies if the material needs to be re-calculated
  74440. */
  74441. readonly isDirty: boolean;
  74442. /**
  74443. * Marks the material to indicate that it has been re-calculated
  74444. */
  74445. markAsProcessed(): void;
  74446. /**
  74447. * Marks the material to indicate that it needs to be re-calculated
  74448. */
  74449. markAsUnprocessed(): void;
  74450. /**
  74451. * Marks the material to indicate all of its defines need to be re-calculated
  74452. */
  74453. markAllAsDirty(): void;
  74454. /**
  74455. * Marks the material to indicate that image processing needs to be re-calculated
  74456. */
  74457. markAsImageProcessingDirty(): void;
  74458. /**
  74459. * Marks the material to indicate the lights need to be re-calculated
  74460. * @param disposed Defines whether the light is dirty due to dispose or not
  74461. */
  74462. markAsLightDirty(disposed?: boolean): void;
  74463. /**
  74464. * Marks the attribute state as changed
  74465. */
  74466. markAsAttributesDirty(): void;
  74467. /**
  74468. * Marks the texture state as changed
  74469. */
  74470. markAsTexturesDirty(): void;
  74471. /**
  74472. * Marks the fresnel state as changed
  74473. */
  74474. markAsFresnelDirty(): void;
  74475. /**
  74476. * Marks the misc state as changed
  74477. */
  74478. markAsMiscDirty(): void;
  74479. /**
  74480. * Rebuilds the material defines
  74481. */
  74482. rebuild(): void;
  74483. /**
  74484. * Specifies if two material defines are equal
  74485. * @param other - A material define instance to compare to
  74486. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74487. */
  74488. isEqual(other: MaterialDefines): boolean;
  74489. /**
  74490. * Clones this instance's defines to another instance
  74491. * @param other - material defines to clone values to
  74492. */
  74493. cloneTo(other: MaterialDefines): void;
  74494. /**
  74495. * Resets the material define values
  74496. */
  74497. reset(): void;
  74498. /**
  74499. * Converts the material define values to a string
  74500. * @returns - String of material define information
  74501. */
  74502. toString(): string;
  74503. }
  74504. }
  74505. declare module BABYLON {
  74506. /**
  74507. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74508. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74509. * 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;
  74510. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74511. */
  74512. export class ColorCurves {
  74513. private _dirty;
  74514. private _tempColor;
  74515. private _globalCurve;
  74516. private _highlightsCurve;
  74517. private _midtonesCurve;
  74518. private _shadowsCurve;
  74519. private _positiveCurve;
  74520. private _negativeCurve;
  74521. private _globalHue;
  74522. private _globalDensity;
  74523. private _globalSaturation;
  74524. private _globalExposure;
  74525. /**
  74526. * Gets the global Hue value.
  74527. * 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).
  74528. */
  74529. /**
  74530. * Sets the global Hue value.
  74531. * 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).
  74532. */
  74533. globalHue: number;
  74534. /**
  74535. * Gets the global Density value.
  74536. * 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.
  74537. * Values less than zero provide a filter of opposite hue.
  74538. */
  74539. /**
  74540. * Sets the global Density value.
  74541. * 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.
  74542. * Values less than zero provide a filter of opposite hue.
  74543. */
  74544. globalDensity: number;
  74545. /**
  74546. * Gets the global Saturation value.
  74547. * 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.
  74548. */
  74549. /**
  74550. * Sets the global Saturation value.
  74551. * 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.
  74552. */
  74553. globalSaturation: number;
  74554. /**
  74555. * Gets the global Exposure value.
  74556. * 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.
  74557. */
  74558. /**
  74559. * Sets the global Exposure value.
  74560. * 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.
  74561. */
  74562. globalExposure: number;
  74563. private _highlightsHue;
  74564. private _highlightsDensity;
  74565. private _highlightsSaturation;
  74566. private _highlightsExposure;
  74567. /**
  74568. * Gets the highlights Hue value.
  74569. * 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).
  74570. */
  74571. /**
  74572. * Sets the highlights Hue value.
  74573. * 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).
  74574. */
  74575. highlightsHue: number;
  74576. /**
  74577. * Gets the highlights Density value.
  74578. * 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.
  74579. * Values less than zero provide a filter of opposite hue.
  74580. */
  74581. /**
  74582. * Sets the highlights Density value.
  74583. * 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.
  74584. * Values less than zero provide a filter of opposite hue.
  74585. */
  74586. highlightsDensity: number;
  74587. /**
  74588. * Gets the highlights Saturation value.
  74589. * 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.
  74590. */
  74591. /**
  74592. * Sets the highlights Saturation value.
  74593. * 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.
  74594. */
  74595. highlightsSaturation: number;
  74596. /**
  74597. * Gets the highlights Exposure value.
  74598. * 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.
  74599. */
  74600. /**
  74601. * Sets the highlights Exposure value.
  74602. * 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.
  74603. */
  74604. highlightsExposure: number;
  74605. private _midtonesHue;
  74606. private _midtonesDensity;
  74607. private _midtonesSaturation;
  74608. private _midtonesExposure;
  74609. /**
  74610. * Gets the midtones Hue value.
  74611. * 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).
  74612. */
  74613. /**
  74614. * Sets the midtones Hue value.
  74615. * 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).
  74616. */
  74617. midtonesHue: number;
  74618. /**
  74619. * Gets the midtones Density value.
  74620. * 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.
  74621. * Values less than zero provide a filter of opposite hue.
  74622. */
  74623. /**
  74624. * Sets the midtones Density value.
  74625. * 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.
  74626. * Values less than zero provide a filter of opposite hue.
  74627. */
  74628. midtonesDensity: number;
  74629. /**
  74630. * Gets the midtones Saturation value.
  74631. * 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.
  74632. */
  74633. /**
  74634. * Sets the midtones Saturation value.
  74635. * 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.
  74636. */
  74637. midtonesSaturation: number;
  74638. /**
  74639. * Gets the midtones Exposure value.
  74640. * 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.
  74641. */
  74642. /**
  74643. * Sets the midtones Exposure value.
  74644. * 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.
  74645. */
  74646. midtonesExposure: number;
  74647. private _shadowsHue;
  74648. private _shadowsDensity;
  74649. private _shadowsSaturation;
  74650. private _shadowsExposure;
  74651. /**
  74652. * Gets the shadows Hue value.
  74653. * 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).
  74654. */
  74655. /**
  74656. * Sets the shadows Hue value.
  74657. * 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).
  74658. */
  74659. shadowsHue: number;
  74660. /**
  74661. * Gets the shadows Density value.
  74662. * 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.
  74663. * Values less than zero provide a filter of opposite hue.
  74664. */
  74665. /**
  74666. * Sets the shadows Density value.
  74667. * 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.
  74668. * Values less than zero provide a filter of opposite hue.
  74669. */
  74670. shadowsDensity: number;
  74671. /**
  74672. * Gets the shadows Saturation value.
  74673. * 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.
  74674. */
  74675. /**
  74676. * Sets the shadows Saturation value.
  74677. * 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.
  74678. */
  74679. shadowsSaturation: number;
  74680. /**
  74681. * Gets the shadows Exposure value.
  74682. * 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.
  74683. */
  74684. /**
  74685. * Sets the shadows Exposure value.
  74686. * 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.
  74687. */
  74688. shadowsExposure: number;
  74689. /**
  74690. * Returns the class name
  74691. * @returns The class name
  74692. */
  74693. getClassName(): string;
  74694. /**
  74695. * Binds the color curves to the shader.
  74696. * @param colorCurves The color curve to bind
  74697. * @param effect The effect to bind to
  74698. * @param positiveUniform The positive uniform shader parameter
  74699. * @param neutralUniform The neutral uniform shader parameter
  74700. * @param negativeUniform The negative uniform shader parameter
  74701. */
  74702. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74703. /**
  74704. * Prepare the list of uniforms associated with the ColorCurves effects.
  74705. * @param uniformsList The list of uniforms used in the effect
  74706. */
  74707. static PrepareUniforms(uniformsList: string[]): void;
  74708. /**
  74709. * Returns color grading data based on a hue, density, saturation and exposure value.
  74710. * @param filterHue The hue of the color filter.
  74711. * @param filterDensity The density of the color filter.
  74712. * @param saturation The saturation.
  74713. * @param exposure The exposure.
  74714. * @param result The result data container.
  74715. */
  74716. private getColorGradingDataToRef;
  74717. /**
  74718. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74719. * @param value The input slider value in range [-100,100].
  74720. * @returns Adjusted value.
  74721. */
  74722. private static applyColorGradingSliderNonlinear;
  74723. /**
  74724. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74725. * @param hue The hue (H) input.
  74726. * @param saturation The saturation (S) input.
  74727. * @param brightness The brightness (B) input.
  74728. * @result An RGBA color represented as Vector4.
  74729. */
  74730. private static fromHSBToRef;
  74731. /**
  74732. * Returns a value clamped between min and max
  74733. * @param value The value to clamp
  74734. * @param min The minimum of value
  74735. * @param max The maximum of value
  74736. * @returns The clamped value.
  74737. */
  74738. private static clamp;
  74739. /**
  74740. * Clones the current color curve instance.
  74741. * @return The cloned curves
  74742. */
  74743. clone(): ColorCurves;
  74744. /**
  74745. * Serializes the current color curve instance to a json representation.
  74746. * @return a JSON representation
  74747. */
  74748. serialize(): any;
  74749. /**
  74750. * Parses the color curve from a json representation.
  74751. * @param source the JSON source to parse
  74752. * @return The parsed curves
  74753. */
  74754. static Parse(source: any): ColorCurves;
  74755. }
  74756. }
  74757. declare module BABYLON {
  74758. /**
  74759. * Interface to follow in your material defines to integrate easily the
  74760. * Image proccessing functions.
  74761. * @hidden
  74762. */
  74763. export interface IImageProcessingConfigurationDefines {
  74764. IMAGEPROCESSING: boolean;
  74765. VIGNETTE: boolean;
  74766. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74767. VIGNETTEBLENDMODEOPAQUE: boolean;
  74768. TONEMAPPING: boolean;
  74769. TONEMAPPING_ACES: boolean;
  74770. CONTRAST: boolean;
  74771. EXPOSURE: boolean;
  74772. COLORCURVES: boolean;
  74773. COLORGRADING: boolean;
  74774. COLORGRADING3D: boolean;
  74775. SAMPLER3DGREENDEPTH: boolean;
  74776. SAMPLER3DBGRMAP: boolean;
  74777. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74778. }
  74779. /**
  74780. * @hidden
  74781. */
  74782. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74783. IMAGEPROCESSING: boolean;
  74784. VIGNETTE: boolean;
  74785. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74786. VIGNETTEBLENDMODEOPAQUE: boolean;
  74787. TONEMAPPING: boolean;
  74788. TONEMAPPING_ACES: boolean;
  74789. CONTRAST: boolean;
  74790. COLORCURVES: boolean;
  74791. COLORGRADING: boolean;
  74792. COLORGRADING3D: boolean;
  74793. SAMPLER3DGREENDEPTH: boolean;
  74794. SAMPLER3DBGRMAP: boolean;
  74795. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74796. EXPOSURE: boolean;
  74797. constructor();
  74798. }
  74799. /**
  74800. * This groups together the common properties used for image processing either in direct forward pass
  74801. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74802. * or not.
  74803. */
  74804. export class ImageProcessingConfiguration {
  74805. /**
  74806. * Default tone mapping applied in BabylonJS.
  74807. */
  74808. static readonly TONEMAPPING_STANDARD: number;
  74809. /**
  74810. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74811. * to other engines rendering to increase portability.
  74812. */
  74813. static readonly TONEMAPPING_ACES: number;
  74814. /**
  74815. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74816. */
  74817. colorCurves: Nullable<ColorCurves>;
  74818. private _colorCurvesEnabled;
  74819. /**
  74820. * Gets wether the color curves effect is enabled.
  74821. */
  74822. /**
  74823. * Sets wether the color curves effect is enabled.
  74824. */
  74825. colorCurvesEnabled: boolean;
  74826. private _colorGradingTexture;
  74827. /**
  74828. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74829. */
  74830. /**
  74831. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74832. */
  74833. colorGradingTexture: Nullable<BaseTexture>;
  74834. private _colorGradingEnabled;
  74835. /**
  74836. * Gets wether the color grading effect is enabled.
  74837. */
  74838. /**
  74839. * Sets wether the color grading effect is enabled.
  74840. */
  74841. colorGradingEnabled: boolean;
  74842. private _colorGradingWithGreenDepth;
  74843. /**
  74844. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74845. */
  74846. /**
  74847. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74848. */
  74849. colorGradingWithGreenDepth: boolean;
  74850. private _colorGradingBGR;
  74851. /**
  74852. * Gets wether the color grading texture contains BGR values.
  74853. */
  74854. /**
  74855. * Sets wether the color grading texture contains BGR values.
  74856. */
  74857. colorGradingBGR: boolean;
  74858. /** @hidden */
  74859. _exposure: number;
  74860. /**
  74861. * Gets the Exposure used in the effect.
  74862. */
  74863. /**
  74864. * Sets the Exposure used in the effect.
  74865. */
  74866. exposure: number;
  74867. private _toneMappingEnabled;
  74868. /**
  74869. * Gets wether the tone mapping effect is enabled.
  74870. */
  74871. /**
  74872. * Sets wether the tone mapping effect is enabled.
  74873. */
  74874. toneMappingEnabled: boolean;
  74875. private _toneMappingType;
  74876. /**
  74877. * Gets the type of tone mapping effect.
  74878. */
  74879. /**
  74880. * Sets the type of tone mapping effect used in BabylonJS.
  74881. */
  74882. toneMappingType: number;
  74883. protected _contrast: number;
  74884. /**
  74885. * Gets the contrast used in the effect.
  74886. */
  74887. /**
  74888. * Sets the contrast used in the effect.
  74889. */
  74890. contrast: number;
  74891. /**
  74892. * Vignette stretch size.
  74893. */
  74894. vignetteStretch: number;
  74895. /**
  74896. * Vignette centre X Offset.
  74897. */
  74898. vignetteCentreX: number;
  74899. /**
  74900. * Vignette centre Y Offset.
  74901. */
  74902. vignetteCentreY: number;
  74903. /**
  74904. * Vignette weight or intensity of the vignette effect.
  74905. */
  74906. vignetteWeight: number;
  74907. /**
  74908. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  74909. * if vignetteEnabled is set to true.
  74910. */
  74911. vignetteColor: Color4;
  74912. /**
  74913. * Camera field of view used by the Vignette effect.
  74914. */
  74915. vignetteCameraFov: number;
  74916. private _vignetteBlendMode;
  74917. /**
  74918. * Gets the vignette blend mode allowing different kind of effect.
  74919. */
  74920. /**
  74921. * Sets the vignette blend mode allowing different kind of effect.
  74922. */
  74923. vignetteBlendMode: number;
  74924. private _vignetteEnabled;
  74925. /**
  74926. * Gets wether the vignette effect is enabled.
  74927. */
  74928. /**
  74929. * Sets wether the vignette effect is enabled.
  74930. */
  74931. vignetteEnabled: boolean;
  74932. private _applyByPostProcess;
  74933. /**
  74934. * Gets wether the image processing is applied through a post process or not.
  74935. */
  74936. /**
  74937. * Sets wether the image processing is applied through a post process or not.
  74938. */
  74939. applyByPostProcess: boolean;
  74940. private _isEnabled;
  74941. /**
  74942. * Gets wether the image processing is enabled or not.
  74943. */
  74944. /**
  74945. * Sets wether the image processing is enabled or not.
  74946. */
  74947. isEnabled: boolean;
  74948. /**
  74949. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  74950. */
  74951. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  74952. /**
  74953. * Method called each time the image processing information changes requires to recompile the effect.
  74954. */
  74955. protected _updateParameters(): void;
  74956. /**
  74957. * Gets the current class name.
  74958. * @return "ImageProcessingConfiguration"
  74959. */
  74960. getClassName(): string;
  74961. /**
  74962. * Prepare the list of uniforms associated with the Image Processing effects.
  74963. * @param uniforms The list of uniforms used in the effect
  74964. * @param defines the list of defines currently in use
  74965. */
  74966. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  74967. /**
  74968. * Prepare the list of samplers associated with the Image Processing effects.
  74969. * @param samplersList The list of uniforms used in the effect
  74970. * @param defines the list of defines currently in use
  74971. */
  74972. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  74973. /**
  74974. * Prepare the list of defines associated to the shader.
  74975. * @param defines the list of defines to complete
  74976. * @param forPostProcess Define if we are currently in post process mode or not
  74977. */
  74978. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  74979. /**
  74980. * Returns true if all the image processing information are ready.
  74981. * @returns True if ready, otherwise, false
  74982. */
  74983. isReady(): boolean;
  74984. /**
  74985. * Binds the image processing to the shader.
  74986. * @param effect The effect to bind to
  74987. * @param aspectRatio Define the current aspect ratio of the effect
  74988. */
  74989. bind(effect: Effect, aspectRatio?: number): void;
  74990. /**
  74991. * Clones the current image processing instance.
  74992. * @return The cloned image processing
  74993. */
  74994. clone(): ImageProcessingConfiguration;
  74995. /**
  74996. * Serializes the current image processing instance to a json representation.
  74997. * @return a JSON representation
  74998. */
  74999. serialize(): any;
  75000. /**
  75001. * Parses the image processing from a json representation.
  75002. * @param source the JSON source to parse
  75003. * @return The parsed image processing
  75004. */
  75005. static Parse(source: any): ImageProcessingConfiguration;
  75006. private static _VIGNETTEMODE_MULTIPLY;
  75007. private static _VIGNETTEMODE_OPAQUE;
  75008. /**
  75009. * Used to apply the vignette as a mix with the pixel color.
  75010. */
  75011. static readonly VIGNETTEMODE_MULTIPLY: number;
  75012. /**
  75013. * Used to apply the vignette as a replacement of the pixel color.
  75014. */
  75015. static readonly VIGNETTEMODE_OPAQUE: number;
  75016. }
  75017. }
  75018. declare module BABYLON {
  75019. /** @hidden */
  75020. export var postprocessVertexShader: {
  75021. name: string;
  75022. shader: string;
  75023. };
  75024. }
  75025. declare module BABYLON {
  75026. interface ThinEngine {
  75027. /**
  75028. * Creates a new render target texture
  75029. * @param size defines the size of the texture
  75030. * @param options defines the options used to create the texture
  75031. * @returns a new render target texture stored in an InternalTexture
  75032. */
  75033. createRenderTargetTexture(size: number | {
  75034. width: number;
  75035. height: number;
  75036. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  75037. }
  75038. }
  75039. declare module BABYLON {
  75040. /** Defines supported spaces */
  75041. export enum Space {
  75042. /** Local (object) space */
  75043. LOCAL = 0,
  75044. /** World space */
  75045. WORLD = 1,
  75046. /** Bone space */
  75047. BONE = 2
  75048. }
  75049. /** Defines the 3 main axes */
  75050. export class Axis {
  75051. /** X axis */
  75052. static X: Vector3;
  75053. /** Y axis */
  75054. static Y: Vector3;
  75055. /** Z axis */
  75056. static Z: Vector3;
  75057. }
  75058. }
  75059. declare module BABYLON {
  75060. /**
  75061. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75062. * This is the base of the follow, arc rotate cameras and Free camera
  75063. * @see http://doc.babylonjs.com/features/cameras
  75064. */
  75065. export class TargetCamera extends Camera {
  75066. private static _RigCamTransformMatrix;
  75067. private static _TargetTransformMatrix;
  75068. private static _TargetFocalPoint;
  75069. /**
  75070. * Define the current direction the camera is moving to
  75071. */
  75072. cameraDirection: Vector3;
  75073. /**
  75074. * Define the current rotation the camera is rotating to
  75075. */
  75076. cameraRotation: Vector2;
  75077. /**
  75078. * When set, the up vector of the camera will be updated by the rotation of the camera
  75079. */
  75080. updateUpVectorFromRotation: boolean;
  75081. private _tmpQuaternion;
  75082. /**
  75083. * Define the current rotation of the camera
  75084. */
  75085. rotation: Vector3;
  75086. /**
  75087. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75088. */
  75089. rotationQuaternion: Quaternion;
  75090. /**
  75091. * Define the current speed of the camera
  75092. */
  75093. speed: number;
  75094. /**
  75095. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75096. * around all axis.
  75097. */
  75098. noRotationConstraint: boolean;
  75099. /**
  75100. * Define the current target of the camera as an object or a position.
  75101. */
  75102. lockedTarget: any;
  75103. /** @hidden */
  75104. _currentTarget: Vector3;
  75105. /** @hidden */
  75106. _initialFocalDistance: number;
  75107. /** @hidden */
  75108. _viewMatrix: Matrix;
  75109. /** @hidden */
  75110. _camMatrix: Matrix;
  75111. /** @hidden */
  75112. _cameraTransformMatrix: Matrix;
  75113. /** @hidden */
  75114. _cameraRotationMatrix: Matrix;
  75115. /** @hidden */
  75116. _referencePoint: Vector3;
  75117. /** @hidden */
  75118. _transformedReferencePoint: Vector3;
  75119. protected _globalCurrentTarget: Vector3;
  75120. protected _globalCurrentUpVector: Vector3;
  75121. /** @hidden */
  75122. _reset: () => void;
  75123. private _defaultUp;
  75124. /**
  75125. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75126. * This is the base of the follow, arc rotate cameras and Free camera
  75127. * @see http://doc.babylonjs.com/features/cameras
  75128. * @param name Defines the name of the camera in the scene
  75129. * @param position Defines the start position of the camera in the scene
  75130. * @param scene Defines the scene the camera belongs to
  75131. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75132. */
  75133. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75134. /**
  75135. * Gets the position in front of the camera at a given distance.
  75136. * @param distance The distance from the camera we want the position to be
  75137. * @returns the position
  75138. */
  75139. getFrontPosition(distance: number): Vector3;
  75140. /** @hidden */
  75141. _getLockedTargetPosition(): Nullable<Vector3>;
  75142. private _storedPosition;
  75143. private _storedRotation;
  75144. private _storedRotationQuaternion;
  75145. /**
  75146. * Store current camera state of the camera (fov, position, rotation, etc..)
  75147. * @returns the camera
  75148. */
  75149. storeState(): Camera;
  75150. /**
  75151. * Restored camera state. You must call storeState() first
  75152. * @returns whether it was successful or not
  75153. * @hidden
  75154. */
  75155. _restoreStateValues(): boolean;
  75156. /** @hidden */
  75157. _initCache(): void;
  75158. /** @hidden */
  75159. _updateCache(ignoreParentClass?: boolean): void;
  75160. /** @hidden */
  75161. _isSynchronizedViewMatrix(): boolean;
  75162. /** @hidden */
  75163. _computeLocalCameraSpeed(): number;
  75164. /**
  75165. * Defines the target the camera should look at.
  75166. * @param target Defines the new target as a Vector or a mesh
  75167. */
  75168. setTarget(target: Vector3): void;
  75169. /**
  75170. * Return the current target position of the camera. This value is expressed in local space.
  75171. * @returns the target position
  75172. */
  75173. getTarget(): Vector3;
  75174. /** @hidden */
  75175. _decideIfNeedsToMove(): boolean;
  75176. /** @hidden */
  75177. _updatePosition(): void;
  75178. /** @hidden */
  75179. _checkInputs(): void;
  75180. protected _updateCameraRotationMatrix(): void;
  75181. /**
  75182. * 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)
  75183. * @returns the current camera
  75184. */
  75185. private _rotateUpVectorWithCameraRotationMatrix;
  75186. private _cachedRotationZ;
  75187. private _cachedQuaternionRotationZ;
  75188. /** @hidden */
  75189. _getViewMatrix(): Matrix;
  75190. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75191. /**
  75192. * @hidden
  75193. */
  75194. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75195. /**
  75196. * @hidden
  75197. */
  75198. _updateRigCameras(): void;
  75199. private _getRigCamPositionAndTarget;
  75200. /**
  75201. * Gets the current object class name.
  75202. * @return the class name
  75203. */
  75204. getClassName(): string;
  75205. }
  75206. }
  75207. declare module BABYLON {
  75208. /**
  75209. * Gather the list of keyboard event types as constants.
  75210. */
  75211. export class KeyboardEventTypes {
  75212. /**
  75213. * The keydown event is fired when a key becomes active (pressed).
  75214. */
  75215. static readonly KEYDOWN: number;
  75216. /**
  75217. * The keyup event is fired when a key has been released.
  75218. */
  75219. static readonly KEYUP: number;
  75220. }
  75221. /**
  75222. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75223. */
  75224. export class KeyboardInfo {
  75225. /**
  75226. * Defines the type of event (KeyboardEventTypes)
  75227. */
  75228. type: number;
  75229. /**
  75230. * Defines the related dom event
  75231. */
  75232. event: KeyboardEvent;
  75233. /**
  75234. * Instantiates a new keyboard info.
  75235. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75236. * @param type Defines the type of event (KeyboardEventTypes)
  75237. * @param event Defines the related dom event
  75238. */
  75239. constructor(
  75240. /**
  75241. * Defines the type of event (KeyboardEventTypes)
  75242. */
  75243. type: number,
  75244. /**
  75245. * Defines the related dom event
  75246. */
  75247. event: KeyboardEvent);
  75248. }
  75249. /**
  75250. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75251. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75252. */
  75253. export class KeyboardInfoPre extends KeyboardInfo {
  75254. /**
  75255. * Defines the type of event (KeyboardEventTypes)
  75256. */
  75257. type: number;
  75258. /**
  75259. * Defines the related dom event
  75260. */
  75261. event: KeyboardEvent;
  75262. /**
  75263. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75264. */
  75265. skipOnPointerObservable: boolean;
  75266. /**
  75267. * Instantiates a new keyboard pre info.
  75268. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75269. * @param type Defines the type of event (KeyboardEventTypes)
  75270. * @param event Defines the related dom event
  75271. */
  75272. constructor(
  75273. /**
  75274. * Defines the type of event (KeyboardEventTypes)
  75275. */
  75276. type: number,
  75277. /**
  75278. * Defines the related dom event
  75279. */
  75280. event: KeyboardEvent);
  75281. }
  75282. }
  75283. declare module BABYLON {
  75284. /**
  75285. * Manage the keyboard inputs to control the movement of a free camera.
  75286. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75287. */
  75288. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75289. /**
  75290. * Defines the camera the input is attached to.
  75291. */
  75292. camera: FreeCamera;
  75293. /**
  75294. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75295. */
  75296. keysUp: number[];
  75297. /**
  75298. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75299. */
  75300. keysDown: number[];
  75301. /**
  75302. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75303. */
  75304. keysLeft: number[];
  75305. /**
  75306. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75307. */
  75308. keysRight: number[];
  75309. private _keys;
  75310. private _onCanvasBlurObserver;
  75311. private _onKeyboardObserver;
  75312. private _engine;
  75313. private _scene;
  75314. /**
  75315. * Attach the input controls to a specific dom element to get the input from.
  75316. * @param element Defines the element the controls should be listened from
  75317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75318. */
  75319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75320. /**
  75321. * Detach the current controls from the specified dom element.
  75322. * @param element Defines the element to stop listening the inputs from
  75323. */
  75324. detachControl(element: Nullable<HTMLElement>): void;
  75325. /**
  75326. * Update the current camera state depending on the inputs that have been used this frame.
  75327. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75328. */
  75329. checkInputs(): void;
  75330. /**
  75331. * Gets the class name of the current intput.
  75332. * @returns the class name
  75333. */
  75334. getClassName(): string;
  75335. /** @hidden */
  75336. _onLostFocus(): void;
  75337. /**
  75338. * Get the friendly name associated with the input class.
  75339. * @returns the input friendly name
  75340. */
  75341. getSimpleName(): string;
  75342. }
  75343. }
  75344. declare module BABYLON {
  75345. /**
  75346. * Interface describing all the common properties and methods a shadow light needs to implement.
  75347. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75348. * as well as binding the different shadow properties to the effects.
  75349. */
  75350. export interface IShadowLight extends Light {
  75351. /**
  75352. * The light id in the scene (used in scene.findLighById for instance)
  75353. */
  75354. id: string;
  75355. /**
  75356. * The position the shdow will be casted from.
  75357. */
  75358. position: Vector3;
  75359. /**
  75360. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75361. */
  75362. direction: Vector3;
  75363. /**
  75364. * The transformed position. Position of the light in world space taking parenting in account.
  75365. */
  75366. transformedPosition: Vector3;
  75367. /**
  75368. * The transformed direction. Direction of the light in world space taking parenting in account.
  75369. */
  75370. transformedDirection: Vector3;
  75371. /**
  75372. * The friendly name of the light in the scene.
  75373. */
  75374. name: string;
  75375. /**
  75376. * Defines the shadow projection clipping minimum z value.
  75377. */
  75378. shadowMinZ: number;
  75379. /**
  75380. * Defines the shadow projection clipping maximum z value.
  75381. */
  75382. shadowMaxZ: number;
  75383. /**
  75384. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75385. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75386. */
  75387. computeTransformedInformation(): boolean;
  75388. /**
  75389. * Gets the scene the light belongs to.
  75390. * @returns The scene
  75391. */
  75392. getScene(): Scene;
  75393. /**
  75394. * Callback defining a custom Projection Matrix Builder.
  75395. * This can be used to override the default projection matrix computation.
  75396. */
  75397. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75398. /**
  75399. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75400. * @param matrix The materix to updated with the projection information
  75401. * @param viewMatrix The transform matrix of the light
  75402. * @param renderList The list of mesh to render in the map
  75403. * @returns The current light
  75404. */
  75405. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75406. /**
  75407. * Gets the current depth scale used in ESM.
  75408. * @returns The scale
  75409. */
  75410. getDepthScale(): number;
  75411. /**
  75412. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75413. * @returns true if a cube texture needs to be use
  75414. */
  75415. needCube(): boolean;
  75416. /**
  75417. * Detects if the projection matrix requires to be recomputed this frame.
  75418. * @returns true if it requires to be recomputed otherwise, false.
  75419. */
  75420. needProjectionMatrixCompute(): boolean;
  75421. /**
  75422. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75423. */
  75424. forceProjectionMatrixCompute(): void;
  75425. /**
  75426. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75427. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75428. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75429. */
  75430. getShadowDirection(faceIndex?: number): Vector3;
  75431. /**
  75432. * Gets the minZ used for shadow according to both the scene and the light.
  75433. * @param activeCamera The camera we are returning the min for
  75434. * @returns the depth min z
  75435. */
  75436. getDepthMinZ(activeCamera: Camera): number;
  75437. /**
  75438. * Gets the maxZ used for shadow according to both the scene and the light.
  75439. * @param activeCamera The camera we are returning the max for
  75440. * @returns the depth max z
  75441. */
  75442. getDepthMaxZ(activeCamera: Camera): number;
  75443. }
  75444. /**
  75445. * Base implementation IShadowLight
  75446. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75447. */
  75448. export abstract class ShadowLight extends Light implements IShadowLight {
  75449. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75450. protected _position: Vector3;
  75451. protected _setPosition(value: Vector3): void;
  75452. /**
  75453. * Sets the position the shadow will be casted from. Also use as the light position for both
  75454. * point and spot lights.
  75455. */
  75456. /**
  75457. * Sets the position the shadow will be casted from. Also use as the light position for both
  75458. * point and spot lights.
  75459. */
  75460. position: Vector3;
  75461. protected _direction: Vector3;
  75462. protected _setDirection(value: Vector3): void;
  75463. /**
  75464. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75465. * Also use as the light direction on spot and directional lights.
  75466. */
  75467. /**
  75468. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75469. * Also use as the light direction on spot and directional lights.
  75470. */
  75471. direction: Vector3;
  75472. private _shadowMinZ;
  75473. /**
  75474. * Gets the shadow projection clipping minimum z value.
  75475. */
  75476. /**
  75477. * Sets the shadow projection clipping minimum z value.
  75478. */
  75479. shadowMinZ: number;
  75480. private _shadowMaxZ;
  75481. /**
  75482. * Sets the shadow projection clipping maximum z value.
  75483. */
  75484. /**
  75485. * Gets the shadow projection clipping maximum z value.
  75486. */
  75487. shadowMaxZ: number;
  75488. /**
  75489. * Callback defining a custom Projection Matrix Builder.
  75490. * This can be used to override the default projection matrix computation.
  75491. */
  75492. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75493. /**
  75494. * The transformed position. Position of the light in world space taking parenting in account.
  75495. */
  75496. transformedPosition: Vector3;
  75497. /**
  75498. * The transformed direction. Direction of the light in world space taking parenting in account.
  75499. */
  75500. transformedDirection: Vector3;
  75501. private _needProjectionMatrixCompute;
  75502. /**
  75503. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75504. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75505. */
  75506. computeTransformedInformation(): boolean;
  75507. /**
  75508. * Return the depth scale used for the shadow map.
  75509. * @returns the depth scale.
  75510. */
  75511. getDepthScale(): number;
  75512. /**
  75513. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75514. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75515. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75516. */
  75517. getShadowDirection(faceIndex?: number): Vector3;
  75518. /**
  75519. * Returns the ShadowLight absolute position in the World.
  75520. * @returns the position vector in world space
  75521. */
  75522. getAbsolutePosition(): Vector3;
  75523. /**
  75524. * Sets the ShadowLight direction toward the passed target.
  75525. * @param target The point to target in local space
  75526. * @returns the updated ShadowLight direction
  75527. */
  75528. setDirectionToTarget(target: Vector3): Vector3;
  75529. /**
  75530. * Returns the light rotation in euler definition.
  75531. * @returns the x y z rotation in local space.
  75532. */
  75533. getRotation(): Vector3;
  75534. /**
  75535. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75536. * @returns true if a cube texture needs to be use
  75537. */
  75538. needCube(): boolean;
  75539. /**
  75540. * Detects if the projection matrix requires to be recomputed this frame.
  75541. * @returns true if it requires to be recomputed otherwise, false.
  75542. */
  75543. needProjectionMatrixCompute(): boolean;
  75544. /**
  75545. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75546. */
  75547. forceProjectionMatrixCompute(): void;
  75548. /** @hidden */
  75549. _initCache(): void;
  75550. /** @hidden */
  75551. _isSynchronized(): boolean;
  75552. /**
  75553. * Computes the world matrix of the node
  75554. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75555. * @returns the world matrix
  75556. */
  75557. computeWorldMatrix(force?: boolean): Matrix;
  75558. /**
  75559. * Gets the minZ used for shadow according to both the scene and the light.
  75560. * @param activeCamera The camera we are returning the min for
  75561. * @returns the depth min z
  75562. */
  75563. getDepthMinZ(activeCamera: Camera): number;
  75564. /**
  75565. * Gets the maxZ used for shadow according to both the scene and the light.
  75566. * @param activeCamera The camera we are returning the max for
  75567. * @returns the depth max z
  75568. */
  75569. getDepthMaxZ(activeCamera: Camera): number;
  75570. /**
  75571. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75572. * @param matrix The materix to updated with the projection information
  75573. * @param viewMatrix The transform matrix of the light
  75574. * @param renderList The list of mesh to render in the map
  75575. * @returns The current light
  75576. */
  75577. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75578. }
  75579. }
  75580. declare module BABYLON {
  75581. /**
  75582. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75583. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75584. */
  75585. export class EffectFallbacks implements IEffectFallbacks {
  75586. private _defines;
  75587. private _currentRank;
  75588. private _maxRank;
  75589. private _mesh;
  75590. /**
  75591. * Removes the fallback from the bound mesh.
  75592. */
  75593. unBindMesh(): void;
  75594. /**
  75595. * Adds a fallback on the specified property.
  75596. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75597. * @param define The name of the define in the shader
  75598. */
  75599. addFallback(rank: number, define: string): void;
  75600. /**
  75601. * Sets the mesh to use CPU skinning when needing to fallback.
  75602. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75603. * @param mesh The mesh to use the fallbacks.
  75604. */
  75605. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75606. /**
  75607. * Checks to see if more fallbacks are still availible.
  75608. */
  75609. readonly hasMoreFallbacks: boolean;
  75610. /**
  75611. * Removes the defines that should be removed when falling back.
  75612. * @param currentDefines defines the current define statements for the shader.
  75613. * @param effect defines the current effect we try to compile
  75614. * @returns The resulting defines with defines of the current rank removed.
  75615. */
  75616. reduce(currentDefines: string, effect: Effect): string;
  75617. }
  75618. }
  75619. declare module BABYLON {
  75620. /**
  75621. * "Static Class" containing the most commonly used helper while dealing with material for
  75622. * rendering purpose.
  75623. *
  75624. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75625. *
  75626. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75627. */
  75628. export class MaterialHelper {
  75629. /**
  75630. * Bind the current view position to an effect.
  75631. * @param effect The effect to be bound
  75632. * @param scene The scene the eyes position is used from
  75633. */
  75634. static BindEyePosition(effect: Effect, scene: Scene): void;
  75635. /**
  75636. * Helps preparing the defines values about the UVs in used in the effect.
  75637. * UVs are shared as much as we can accross channels in the shaders.
  75638. * @param texture The texture we are preparing the UVs for
  75639. * @param defines The defines to update
  75640. * @param key The channel key "diffuse", "specular"... used in the shader
  75641. */
  75642. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75643. /**
  75644. * Binds a texture matrix value to its corrsponding uniform
  75645. * @param texture The texture to bind the matrix for
  75646. * @param uniformBuffer The uniform buffer receivin the data
  75647. * @param key The channel key "diffuse", "specular"... used in the shader
  75648. */
  75649. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75650. /**
  75651. * Gets the current status of the fog (should it be enabled?)
  75652. * @param mesh defines the mesh to evaluate for fog support
  75653. * @param scene defines the hosting scene
  75654. * @returns true if fog must be enabled
  75655. */
  75656. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75657. /**
  75658. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75659. * @param mesh defines the current mesh
  75660. * @param scene defines the current scene
  75661. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75662. * @param pointsCloud defines if point cloud rendering has to be turned on
  75663. * @param fogEnabled defines if fog has to be turned on
  75664. * @param alphaTest defines if alpha testing has to be turned on
  75665. * @param defines defines the current list of defines
  75666. */
  75667. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75668. /**
  75669. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75670. * @param scene defines the current scene
  75671. * @param engine defines the current engine
  75672. * @param defines specifies the list of active defines
  75673. * @param useInstances defines if instances have to be turned on
  75674. * @param useClipPlane defines if clip plane have to be turned on
  75675. */
  75676. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75677. /**
  75678. * Prepares the defines for bones
  75679. * @param mesh The mesh containing the geometry data we will draw
  75680. * @param defines The defines to update
  75681. */
  75682. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75683. /**
  75684. * Prepares the defines for morph targets
  75685. * @param mesh The mesh containing the geometry data we will draw
  75686. * @param defines The defines to update
  75687. */
  75688. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75689. /**
  75690. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75691. * @param mesh The mesh containing the geometry data we will draw
  75692. * @param defines The defines to update
  75693. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75694. * @param useBones Precise whether bones should be used or not (override mesh info)
  75695. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75696. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75697. * @returns false if defines are considered not dirty and have not been checked
  75698. */
  75699. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75700. /**
  75701. * Prepares the defines related to multiview
  75702. * @param scene The scene we are intending to draw
  75703. * @param defines The defines to update
  75704. */
  75705. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75706. /**
  75707. * Prepares the defines related to the light information passed in parameter
  75708. * @param scene The scene we are intending to draw
  75709. * @param mesh The mesh the effect is compiling for
  75710. * @param light The light the effect is compiling for
  75711. * @param lightIndex The index of the light
  75712. * @param defines The defines to update
  75713. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75714. * @param state Defines the current state regarding what is needed (normals, etc...)
  75715. */
  75716. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75717. needNormals: boolean;
  75718. needRebuild: boolean;
  75719. shadowEnabled: boolean;
  75720. specularEnabled: boolean;
  75721. lightmapMode: boolean;
  75722. }): void;
  75723. /**
  75724. * Prepares the defines related to the light information passed in parameter
  75725. * @param scene The scene we are intending to draw
  75726. * @param mesh The mesh the effect is compiling for
  75727. * @param defines The defines to update
  75728. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75729. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75730. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75731. * @returns true if normals will be required for the rest of the effect
  75732. */
  75733. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75734. /**
  75735. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75736. * @param lightIndex defines the light index
  75737. * @param uniformsList The uniform list
  75738. * @param samplersList The sampler list
  75739. * @param projectedLightTexture defines if projected texture must be used
  75740. * @param uniformBuffersList defines an optional list of uniform buffers
  75741. */
  75742. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75743. /**
  75744. * Prepares the uniforms and samplers list to be used in the effect
  75745. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75746. * @param samplersList The sampler list
  75747. * @param defines The defines helping in the list generation
  75748. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75749. */
  75750. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75751. /**
  75752. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75753. * @param defines The defines to update while falling back
  75754. * @param fallbacks The authorized effect fallbacks
  75755. * @param maxSimultaneousLights The maximum number of lights allowed
  75756. * @param rank the current rank of the Effect
  75757. * @returns The newly affected rank
  75758. */
  75759. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75760. private static _TmpMorphInfluencers;
  75761. /**
  75762. * Prepares the list of attributes required for morph targets according to the effect defines.
  75763. * @param attribs The current list of supported attribs
  75764. * @param mesh The mesh to prepare the morph targets attributes for
  75765. * @param influencers The number of influencers
  75766. */
  75767. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75768. /**
  75769. * Prepares the list of attributes required for morph targets according to the effect defines.
  75770. * @param attribs The current list of supported attribs
  75771. * @param mesh The mesh to prepare the morph targets attributes for
  75772. * @param defines The current Defines of the effect
  75773. */
  75774. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75775. /**
  75776. * Prepares the list of attributes required for bones according to the effect defines.
  75777. * @param attribs The current list of supported attribs
  75778. * @param mesh The mesh to prepare the bones attributes for
  75779. * @param defines The current Defines of the effect
  75780. * @param fallbacks The current efffect fallback strategy
  75781. */
  75782. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75783. /**
  75784. * Check and prepare the list of attributes required for instances according to the effect defines.
  75785. * @param attribs The current list of supported attribs
  75786. * @param defines The current MaterialDefines of the effect
  75787. */
  75788. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75789. /**
  75790. * Add the list of attributes required for instances to the attribs array.
  75791. * @param attribs The current list of supported attribs
  75792. */
  75793. static PushAttributesForInstances(attribs: string[]): void;
  75794. /**
  75795. * Binds the light shadow information to the effect for the given mesh.
  75796. * @param light The light containing the generator
  75797. * @param scene The scene the lights belongs to
  75798. * @param mesh The mesh we are binding the information to render
  75799. * @param lightIndex The light index in the effect used to render the mesh
  75800. * @param effect The effect we are binding the data to
  75801. */
  75802. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75803. /**
  75804. * Binds the light information to the effect.
  75805. * @param light The light containing the generator
  75806. * @param effect The effect we are binding the data to
  75807. * @param lightIndex The light index in the effect used to render
  75808. */
  75809. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75810. /**
  75811. * Binds the lights information from the scene to the effect for the given mesh.
  75812. * @param light Light to bind
  75813. * @param lightIndex Light index
  75814. * @param scene The scene where the light belongs to
  75815. * @param mesh The mesh we are binding the information to render
  75816. * @param effect The effect we are binding the data to
  75817. * @param useSpecular Defines if specular is supported
  75818. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75819. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75820. */
  75821. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75822. /**
  75823. * Binds the lights information from the scene to the effect for the given mesh.
  75824. * @param scene The scene the lights belongs to
  75825. * @param mesh The mesh we are binding the information to render
  75826. * @param effect The effect we are binding the data to
  75827. * @param defines The generated defines for the effect
  75828. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75829. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75830. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75831. */
  75832. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75833. private static _tempFogColor;
  75834. /**
  75835. * Binds the fog information from the scene to the effect for the given mesh.
  75836. * @param scene The scene the lights belongs to
  75837. * @param mesh The mesh we are binding the information to render
  75838. * @param effect The effect we are binding the data to
  75839. * @param linearSpace Defines if the fog effect is applied in linear space
  75840. */
  75841. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75842. /**
  75843. * Binds the bones information from the mesh to the effect.
  75844. * @param mesh The mesh we are binding the information to render
  75845. * @param effect The effect we are binding the data to
  75846. */
  75847. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75848. /**
  75849. * Binds the morph targets information from the mesh to the effect.
  75850. * @param abstractMesh The mesh we are binding the information to render
  75851. * @param effect The effect we are binding the data to
  75852. */
  75853. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75854. /**
  75855. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75856. * @param defines The generated defines used in the effect
  75857. * @param effect The effect we are binding the data to
  75858. * @param scene The scene we are willing to render with logarithmic scale for
  75859. */
  75860. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75861. /**
  75862. * Binds the clip plane information from the scene to the effect.
  75863. * @param scene The scene the clip plane information are extracted from
  75864. * @param effect The effect we are binding the data to
  75865. */
  75866. static BindClipPlane(effect: Effect, scene: Scene): void;
  75867. }
  75868. }
  75869. declare module BABYLON {
  75870. /** @hidden */
  75871. export var packingFunctions: {
  75872. name: string;
  75873. shader: string;
  75874. };
  75875. }
  75876. declare module BABYLON {
  75877. /** @hidden */
  75878. export var shadowMapPixelShader: {
  75879. name: string;
  75880. shader: string;
  75881. };
  75882. }
  75883. declare module BABYLON {
  75884. /** @hidden */
  75885. export var bonesDeclaration: {
  75886. name: string;
  75887. shader: string;
  75888. };
  75889. }
  75890. declare module BABYLON {
  75891. /** @hidden */
  75892. export var morphTargetsVertexGlobalDeclaration: {
  75893. name: string;
  75894. shader: string;
  75895. };
  75896. }
  75897. declare module BABYLON {
  75898. /** @hidden */
  75899. export var morphTargetsVertexDeclaration: {
  75900. name: string;
  75901. shader: string;
  75902. };
  75903. }
  75904. declare module BABYLON {
  75905. /** @hidden */
  75906. export var instancesDeclaration: {
  75907. name: string;
  75908. shader: string;
  75909. };
  75910. }
  75911. declare module BABYLON {
  75912. /** @hidden */
  75913. export var helperFunctions: {
  75914. name: string;
  75915. shader: string;
  75916. };
  75917. }
  75918. declare module BABYLON {
  75919. /** @hidden */
  75920. export var morphTargetsVertex: {
  75921. name: string;
  75922. shader: string;
  75923. };
  75924. }
  75925. declare module BABYLON {
  75926. /** @hidden */
  75927. export var instancesVertex: {
  75928. name: string;
  75929. shader: string;
  75930. };
  75931. }
  75932. declare module BABYLON {
  75933. /** @hidden */
  75934. export var bonesVertex: {
  75935. name: string;
  75936. shader: string;
  75937. };
  75938. }
  75939. declare module BABYLON {
  75940. /** @hidden */
  75941. export var shadowMapVertexShader: {
  75942. name: string;
  75943. shader: string;
  75944. };
  75945. }
  75946. declare module BABYLON {
  75947. /** @hidden */
  75948. export var depthBoxBlurPixelShader: {
  75949. name: string;
  75950. shader: string;
  75951. };
  75952. }
  75953. declare module BABYLON {
  75954. /**
  75955. * Defines the options associated with the creation of a custom shader for a shadow generator.
  75956. */
  75957. export interface ICustomShaderOptions {
  75958. /**
  75959. * Gets or sets the custom shader name to use
  75960. */
  75961. shaderName: string;
  75962. /**
  75963. * The list of attribute names used in the shader
  75964. */
  75965. attributes?: string[];
  75966. /**
  75967. * The list of unifrom names used in the shader
  75968. */
  75969. uniforms?: string[];
  75970. /**
  75971. * The list of sampler names used in the shader
  75972. */
  75973. samplers?: string[];
  75974. /**
  75975. * The list of defines used in the shader
  75976. */
  75977. defines?: string[];
  75978. }
  75979. /**
  75980. * Interface to implement to create a shadow generator compatible with BJS.
  75981. */
  75982. export interface IShadowGenerator {
  75983. /**
  75984. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  75985. * @returns The render target texture if present otherwise, null
  75986. */
  75987. getShadowMap(): Nullable<RenderTargetTexture>;
  75988. /**
  75989. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  75990. * @returns The render target texture if the shadow map is present otherwise, null
  75991. */
  75992. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  75993. /**
  75994. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  75995. * @param subMesh The submesh we want to render in the shadow map
  75996. * @param useInstances Defines wether will draw in the map using instances
  75997. * @returns true if ready otherwise, false
  75998. */
  75999. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76000. /**
  76001. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76002. * @param defines Defines of the material we want to update
  76003. * @param lightIndex Index of the light in the enabled light list of the material
  76004. */
  76005. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76006. /**
  76007. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76008. * defined in the generator but impacting the effect).
  76009. * It implies the unifroms available on the materials are the standard BJS ones.
  76010. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76011. * @param effect The effect we are binfing the information for
  76012. */
  76013. bindShadowLight(lightIndex: string, effect: Effect): void;
  76014. /**
  76015. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76016. * (eq to shadow prjection matrix * light transform matrix)
  76017. * @returns The transform matrix used to create the shadow map
  76018. */
  76019. getTransformMatrix(): Matrix;
  76020. /**
  76021. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76022. * Cube and 2D textures for instance.
  76023. */
  76024. recreateShadowMap(): void;
  76025. /**
  76026. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76027. * @param onCompiled Callback triggered at the and of the effects compilation
  76028. * @param options Sets of optional options forcing the compilation with different modes
  76029. */
  76030. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76031. useInstances: boolean;
  76032. }>): void;
  76033. /**
  76034. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76035. * @param options Sets of optional options forcing the compilation with different modes
  76036. * @returns A promise that resolves when the compilation completes
  76037. */
  76038. forceCompilationAsync(options?: Partial<{
  76039. useInstances: boolean;
  76040. }>): Promise<void>;
  76041. /**
  76042. * Serializes the shadow generator setup to a json object.
  76043. * @returns The serialized JSON object
  76044. */
  76045. serialize(): any;
  76046. /**
  76047. * Disposes the Shadow map and related Textures and effects.
  76048. */
  76049. dispose(): void;
  76050. }
  76051. /**
  76052. * Default implementation IShadowGenerator.
  76053. * This is the main object responsible of generating shadows in the framework.
  76054. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76055. */
  76056. export class ShadowGenerator implements IShadowGenerator {
  76057. /**
  76058. * Shadow generator mode None: no filtering applied.
  76059. */
  76060. static readonly FILTER_NONE: number;
  76061. /**
  76062. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76063. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76064. */
  76065. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76066. /**
  76067. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76068. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76069. */
  76070. static readonly FILTER_POISSONSAMPLING: number;
  76071. /**
  76072. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76073. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76074. */
  76075. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76076. /**
  76077. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76078. * edge artifacts on steep falloff.
  76079. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76080. */
  76081. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76082. /**
  76083. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76084. * edge artifacts on steep falloff.
  76085. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76086. */
  76087. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76088. /**
  76089. * Shadow generator mode PCF: Percentage Closer Filtering
  76090. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76091. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76092. */
  76093. static readonly FILTER_PCF: number;
  76094. /**
  76095. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76096. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76097. * Contact Hardening
  76098. */
  76099. static readonly FILTER_PCSS: number;
  76100. /**
  76101. * Reserved for PCF and PCSS
  76102. * Highest Quality.
  76103. *
  76104. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76105. *
  76106. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76107. */
  76108. static readonly QUALITY_HIGH: number;
  76109. /**
  76110. * Reserved for PCF and PCSS
  76111. * Good tradeoff for quality/perf cross devices
  76112. *
  76113. * Execute PCF on a 3*3 kernel.
  76114. *
  76115. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76116. */
  76117. static readonly QUALITY_MEDIUM: number;
  76118. /**
  76119. * Reserved for PCF and PCSS
  76120. * The lowest quality but the fastest.
  76121. *
  76122. * Execute PCF on a 1*1 kernel.
  76123. *
  76124. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76125. */
  76126. static readonly QUALITY_LOW: number;
  76127. /** Gets or sets the custom shader name to use */
  76128. customShaderOptions: ICustomShaderOptions;
  76129. /**
  76130. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76131. */
  76132. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76133. /**
  76134. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76135. */
  76136. onAfterShadowMapRenderObservable: Observable<Effect>;
  76137. /**
  76138. * Observable triggered before a mesh is rendered in the shadow map.
  76139. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76140. */
  76141. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76142. /**
  76143. * Observable triggered after a mesh is rendered in the shadow map.
  76144. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76145. */
  76146. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76147. private _bias;
  76148. /**
  76149. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76150. */
  76151. /**
  76152. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76153. */
  76154. bias: number;
  76155. private _normalBias;
  76156. /**
  76157. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76158. */
  76159. /**
  76160. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76161. */
  76162. normalBias: number;
  76163. private _blurBoxOffset;
  76164. /**
  76165. * Gets the blur box offset: offset applied during the blur pass.
  76166. * Only useful if useKernelBlur = false
  76167. */
  76168. /**
  76169. * Sets the blur box offset: offset applied during the blur pass.
  76170. * Only useful if useKernelBlur = false
  76171. */
  76172. blurBoxOffset: number;
  76173. private _blurScale;
  76174. /**
  76175. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76176. * 2 means half of the size.
  76177. */
  76178. /**
  76179. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76180. * 2 means half of the size.
  76181. */
  76182. blurScale: number;
  76183. private _blurKernel;
  76184. /**
  76185. * Gets the blur kernel: kernel size of the blur pass.
  76186. * Only useful if useKernelBlur = true
  76187. */
  76188. /**
  76189. * Sets the blur kernel: kernel size of the blur pass.
  76190. * Only useful if useKernelBlur = true
  76191. */
  76192. blurKernel: number;
  76193. private _useKernelBlur;
  76194. /**
  76195. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76196. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76197. */
  76198. /**
  76199. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76200. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76201. */
  76202. useKernelBlur: boolean;
  76203. private _depthScale;
  76204. /**
  76205. * Gets the depth scale used in ESM mode.
  76206. */
  76207. /**
  76208. * Sets the depth scale used in ESM mode.
  76209. * This can override the scale stored on the light.
  76210. */
  76211. depthScale: number;
  76212. private _filter;
  76213. /**
  76214. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76215. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76216. */
  76217. /**
  76218. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76219. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76220. */
  76221. filter: number;
  76222. /**
  76223. * Gets if the current filter is set to Poisson Sampling.
  76224. */
  76225. /**
  76226. * Sets the current filter to Poisson Sampling.
  76227. */
  76228. usePoissonSampling: boolean;
  76229. /**
  76230. * Gets if the current filter is set to ESM.
  76231. */
  76232. /**
  76233. * Sets the current filter is to ESM.
  76234. */
  76235. useExponentialShadowMap: boolean;
  76236. /**
  76237. * Gets if the current filter is set to filtered ESM.
  76238. */
  76239. /**
  76240. * Gets if the current filter is set to filtered ESM.
  76241. */
  76242. useBlurExponentialShadowMap: boolean;
  76243. /**
  76244. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76245. * exponential to prevent steep falloff artifacts).
  76246. */
  76247. /**
  76248. * Sets the current filter to "close ESM" (using the inverse of the
  76249. * exponential to prevent steep falloff artifacts).
  76250. */
  76251. useCloseExponentialShadowMap: boolean;
  76252. /**
  76253. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76254. * exponential to prevent steep falloff artifacts).
  76255. */
  76256. /**
  76257. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76258. * exponential to prevent steep falloff artifacts).
  76259. */
  76260. useBlurCloseExponentialShadowMap: boolean;
  76261. /**
  76262. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76263. */
  76264. /**
  76265. * Sets the current filter to "PCF" (percentage closer filtering).
  76266. */
  76267. usePercentageCloserFiltering: boolean;
  76268. private _filteringQuality;
  76269. /**
  76270. * Gets the PCF or PCSS Quality.
  76271. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76272. */
  76273. /**
  76274. * Sets the PCF or PCSS Quality.
  76275. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76276. */
  76277. filteringQuality: number;
  76278. /**
  76279. * Gets if the current filter is set to "PCSS" (contact hardening).
  76280. */
  76281. /**
  76282. * Sets the current filter to "PCSS" (contact hardening).
  76283. */
  76284. useContactHardeningShadow: boolean;
  76285. private _contactHardeningLightSizeUVRatio;
  76286. /**
  76287. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76288. * Using a ratio helps keeping shape stability independently of the map size.
  76289. *
  76290. * It does not account for the light projection as it was having too much
  76291. * instability during the light setup or during light position changes.
  76292. *
  76293. * Only valid if useContactHardeningShadow is true.
  76294. */
  76295. /**
  76296. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76297. * Using a ratio helps keeping shape stability independently of the map size.
  76298. *
  76299. * It does not account for the light projection as it was having too much
  76300. * instability during the light setup or during light position changes.
  76301. *
  76302. * Only valid if useContactHardeningShadow is true.
  76303. */
  76304. contactHardeningLightSizeUVRatio: number;
  76305. private _darkness;
  76306. /** Gets or sets the actual darkness of a shadow */
  76307. darkness: number;
  76308. /**
  76309. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76310. * 0 means strongest and 1 would means no shadow.
  76311. * @returns the darkness.
  76312. */
  76313. getDarkness(): number;
  76314. /**
  76315. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76316. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76317. * @returns the shadow generator allowing fluent coding.
  76318. */
  76319. setDarkness(darkness: number): ShadowGenerator;
  76320. private _transparencyShadow;
  76321. /** Gets or sets the ability to have transparent shadow */
  76322. transparencyShadow: boolean;
  76323. /**
  76324. * Sets the ability to have transparent shadow (boolean).
  76325. * @param transparent True if transparent else False
  76326. * @returns the shadow generator allowing fluent coding
  76327. */
  76328. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76329. private _shadowMap;
  76330. private _shadowMap2;
  76331. /**
  76332. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76333. * @returns The render target texture if present otherwise, null
  76334. */
  76335. getShadowMap(): Nullable<RenderTargetTexture>;
  76336. /**
  76337. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76338. * @returns The render target texture if the shadow map is present otherwise, null
  76339. */
  76340. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76341. /**
  76342. * Gets the class name of that object
  76343. * @returns "ShadowGenerator"
  76344. */
  76345. getClassName(): string;
  76346. /**
  76347. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76348. * @param mesh Mesh to add
  76349. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76350. * @returns the Shadow Generator itself
  76351. */
  76352. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76353. /**
  76354. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76355. * @param mesh Mesh to remove
  76356. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76357. * @returns the Shadow Generator itself
  76358. */
  76359. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76360. /**
  76361. * Controls the extent to which the shadows fade out at the edge of the frustum
  76362. * Used only by directionals and spots
  76363. */
  76364. frustumEdgeFalloff: number;
  76365. private _light;
  76366. /**
  76367. * Returns the associated light object.
  76368. * @returns the light generating the shadow
  76369. */
  76370. getLight(): IShadowLight;
  76371. /**
  76372. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76373. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76374. * It might on the other hand introduce peter panning.
  76375. */
  76376. forceBackFacesOnly: boolean;
  76377. private _scene;
  76378. private _lightDirection;
  76379. private _effect;
  76380. private _viewMatrix;
  76381. private _projectionMatrix;
  76382. private _transformMatrix;
  76383. private _cachedPosition;
  76384. private _cachedDirection;
  76385. private _cachedDefines;
  76386. private _currentRenderID;
  76387. private _boxBlurPostprocess;
  76388. private _kernelBlurXPostprocess;
  76389. private _kernelBlurYPostprocess;
  76390. private _blurPostProcesses;
  76391. private _mapSize;
  76392. private _currentFaceIndex;
  76393. private _currentFaceIndexCache;
  76394. private _textureType;
  76395. private _defaultTextureMatrix;
  76396. private _storedUniqueId;
  76397. /** @hidden */
  76398. static _SceneComponentInitialization: (scene: Scene) => void;
  76399. /**
  76400. * Creates a ShadowGenerator object.
  76401. * A ShadowGenerator is the required tool to use the shadows.
  76402. * Each light casting shadows needs to use its own ShadowGenerator.
  76403. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76404. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76405. * @param light The light object generating the shadows.
  76406. * @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.
  76407. */
  76408. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76409. private _initializeGenerator;
  76410. private _initializeShadowMap;
  76411. private _initializeBlurRTTAndPostProcesses;
  76412. private _renderForShadowMap;
  76413. private _renderSubMeshForShadowMap;
  76414. private _applyFilterValues;
  76415. /**
  76416. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76417. * @param onCompiled Callback triggered at the and of the effects compilation
  76418. * @param options Sets of optional options forcing the compilation with different modes
  76419. */
  76420. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76421. useInstances: boolean;
  76422. }>): void;
  76423. /**
  76424. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76425. * @param options Sets of optional options forcing the compilation with different modes
  76426. * @returns A promise that resolves when the compilation completes
  76427. */
  76428. forceCompilationAsync(options?: Partial<{
  76429. useInstances: boolean;
  76430. }>): Promise<void>;
  76431. /**
  76432. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76433. * @param subMesh The submesh we want to render in the shadow map
  76434. * @param useInstances Defines wether will draw in the map using instances
  76435. * @returns true if ready otherwise, false
  76436. */
  76437. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76438. /**
  76439. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76440. * @param defines Defines of the material we want to update
  76441. * @param lightIndex Index of the light in the enabled light list of the material
  76442. */
  76443. prepareDefines(defines: any, lightIndex: number): void;
  76444. /**
  76445. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76446. * defined in the generator but impacting the effect).
  76447. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76448. * @param effect The effect we are binfing the information for
  76449. */
  76450. bindShadowLight(lightIndex: string, effect: Effect): void;
  76451. /**
  76452. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76453. * (eq to shadow prjection matrix * light transform matrix)
  76454. * @returns The transform matrix used to create the shadow map
  76455. */
  76456. getTransformMatrix(): Matrix;
  76457. /**
  76458. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76459. * Cube and 2D textures for instance.
  76460. */
  76461. recreateShadowMap(): void;
  76462. private _disposeBlurPostProcesses;
  76463. private _disposeRTTandPostProcesses;
  76464. /**
  76465. * Disposes the ShadowGenerator.
  76466. * Returns nothing.
  76467. */
  76468. dispose(): void;
  76469. /**
  76470. * Serializes the shadow generator setup to a json object.
  76471. * @returns The serialized JSON object
  76472. */
  76473. serialize(): any;
  76474. /**
  76475. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76476. * @param parsedShadowGenerator The JSON object to parse
  76477. * @param scene The scene to create the shadow map for
  76478. * @returns The parsed shadow generator
  76479. */
  76480. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76481. }
  76482. }
  76483. declare module BABYLON {
  76484. /**
  76485. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76486. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76487. * 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.
  76488. */
  76489. export abstract class Light extends Node {
  76490. /**
  76491. * Falloff Default: light is falling off following the material specification:
  76492. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76493. */
  76494. static readonly FALLOFF_DEFAULT: number;
  76495. /**
  76496. * Falloff Physical: light is falling off following the inverse squared distance law.
  76497. */
  76498. static readonly FALLOFF_PHYSICAL: number;
  76499. /**
  76500. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76501. * to enhance interoperability with other engines.
  76502. */
  76503. static readonly FALLOFF_GLTF: number;
  76504. /**
  76505. * Falloff Standard: light is falling off like in the standard material
  76506. * to enhance interoperability with other materials.
  76507. */
  76508. static readonly FALLOFF_STANDARD: number;
  76509. /**
  76510. * If every light affecting the material is in this lightmapMode,
  76511. * material.lightmapTexture adds or multiplies
  76512. * (depends on material.useLightmapAsShadowmap)
  76513. * after every other light calculations.
  76514. */
  76515. static readonly LIGHTMAP_DEFAULT: number;
  76516. /**
  76517. * material.lightmapTexture as only diffuse lighting from this light
  76518. * adds only specular lighting from this light
  76519. * adds dynamic shadows
  76520. */
  76521. static readonly LIGHTMAP_SPECULAR: number;
  76522. /**
  76523. * material.lightmapTexture as only lighting
  76524. * no light calculation from this light
  76525. * only adds dynamic shadows from this light
  76526. */
  76527. static readonly LIGHTMAP_SHADOWSONLY: number;
  76528. /**
  76529. * Each light type uses the default quantity according to its type:
  76530. * point/spot lights use luminous intensity
  76531. * directional lights use illuminance
  76532. */
  76533. static readonly INTENSITYMODE_AUTOMATIC: number;
  76534. /**
  76535. * lumen (lm)
  76536. */
  76537. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76538. /**
  76539. * candela (lm/sr)
  76540. */
  76541. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76542. /**
  76543. * lux (lm/m^2)
  76544. */
  76545. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76546. /**
  76547. * nit (cd/m^2)
  76548. */
  76549. static readonly INTENSITYMODE_LUMINANCE: number;
  76550. /**
  76551. * Light type const id of the point light.
  76552. */
  76553. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76554. /**
  76555. * Light type const id of the directional light.
  76556. */
  76557. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76558. /**
  76559. * Light type const id of the spot light.
  76560. */
  76561. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76562. /**
  76563. * Light type const id of the hemispheric light.
  76564. */
  76565. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76566. /**
  76567. * Diffuse gives the basic color to an object.
  76568. */
  76569. diffuse: Color3;
  76570. /**
  76571. * Specular produces a highlight color on an object.
  76572. * Note: This is note affecting PBR materials.
  76573. */
  76574. specular: Color3;
  76575. /**
  76576. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76577. * falling off base on range or angle.
  76578. * This can be set to any values in Light.FALLOFF_x.
  76579. *
  76580. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76581. * other types of materials.
  76582. */
  76583. falloffType: number;
  76584. /**
  76585. * Strength of the light.
  76586. * Note: By default it is define in the framework own unit.
  76587. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76588. */
  76589. intensity: number;
  76590. private _range;
  76591. protected _inverseSquaredRange: number;
  76592. /**
  76593. * Defines how far from the source the light is impacting in scene units.
  76594. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76595. */
  76596. /**
  76597. * Defines how far from the source the light is impacting in scene units.
  76598. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76599. */
  76600. range: number;
  76601. /**
  76602. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76603. * of light.
  76604. */
  76605. private _photometricScale;
  76606. private _intensityMode;
  76607. /**
  76608. * Gets the photometric scale used to interpret the intensity.
  76609. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76610. */
  76611. /**
  76612. * Sets the photometric scale used to interpret the intensity.
  76613. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76614. */
  76615. intensityMode: number;
  76616. private _radius;
  76617. /**
  76618. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76619. */
  76620. /**
  76621. * sets the light radius used by PBR Materials to simulate soft area lights.
  76622. */
  76623. radius: number;
  76624. private _renderPriority;
  76625. /**
  76626. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76627. * exceeding the number allowed of the materials.
  76628. */
  76629. renderPriority: number;
  76630. private _shadowEnabled;
  76631. /**
  76632. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76633. * the current shadow generator.
  76634. */
  76635. /**
  76636. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76637. * the current shadow generator.
  76638. */
  76639. shadowEnabled: boolean;
  76640. private _includedOnlyMeshes;
  76641. /**
  76642. * Gets the only meshes impacted by this light.
  76643. */
  76644. /**
  76645. * Sets the only meshes impacted by this light.
  76646. */
  76647. includedOnlyMeshes: AbstractMesh[];
  76648. private _excludedMeshes;
  76649. /**
  76650. * Gets the meshes not impacted by this light.
  76651. */
  76652. /**
  76653. * Sets the meshes not impacted by this light.
  76654. */
  76655. excludedMeshes: AbstractMesh[];
  76656. private _excludeWithLayerMask;
  76657. /**
  76658. * Gets the layer id use to find what meshes are not impacted by the light.
  76659. * Inactive if 0
  76660. */
  76661. /**
  76662. * Sets the layer id use to find what meshes are not impacted by the light.
  76663. * Inactive if 0
  76664. */
  76665. excludeWithLayerMask: number;
  76666. private _includeOnlyWithLayerMask;
  76667. /**
  76668. * Gets the layer id use to find what meshes are impacted by the light.
  76669. * Inactive if 0
  76670. */
  76671. /**
  76672. * Sets the layer id use to find what meshes are impacted by the light.
  76673. * Inactive if 0
  76674. */
  76675. includeOnlyWithLayerMask: number;
  76676. private _lightmapMode;
  76677. /**
  76678. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76679. */
  76680. /**
  76681. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76682. */
  76683. lightmapMode: number;
  76684. /**
  76685. * Shadow generator associted to the light.
  76686. * @hidden Internal use only.
  76687. */
  76688. _shadowGenerator: Nullable<IShadowGenerator>;
  76689. /**
  76690. * @hidden Internal use only.
  76691. */
  76692. _excludedMeshesIds: string[];
  76693. /**
  76694. * @hidden Internal use only.
  76695. */
  76696. _includedOnlyMeshesIds: string[];
  76697. /**
  76698. * The current light unifom buffer.
  76699. * @hidden Internal use only.
  76700. */
  76701. _uniformBuffer: UniformBuffer;
  76702. /**
  76703. * Creates a Light object in the scene.
  76704. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76705. * @param name The firendly name of the light
  76706. * @param scene The scene the light belongs too
  76707. */
  76708. constructor(name: string, scene: Scene);
  76709. protected abstract _buildUniformLayout(): void;
  76710. /**
  76711. * Sets the passed Effect "effect" with the Light information.
  76712. * @param effect The effect to update
  76713. * @param lightIndex The index of the light in the effect to update
  76714. * @returns The light
  76715. */
  76716. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76717. /**
  76718. * Sets the passed Effect "effect" with the Light information.
  76719. * @param effect The effect to update
  76720. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76721. * @returns The light
  76722. */
  76723. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76724. /**
  76725. * Returns the string "Light".
  76726. * @returns the class name
  76727. */
  76728. getClassName(): string;
  76729. /** @hidden */
  76730. readonly _isLight: boolean;
  76731. /**
  76732. * Converts the light information to a readable string for debug purpose.
  76733. * @param fullDetails Supports for multiple levels of logging within scene loading
  76734. * @returns the human readable light info
  76735. */
  76736. toString(fullDetails?: boolean): string;
  76737. /** @hidden */
  76738. protected _syncParentEnabledState(): void;
  76739. /**
  76740. * Set the enabled state of this node.
  76741. * @param value - the new enabled state
  76742. */
  76743. setEnabled(value: boolean): void;
  76744. /**
  76745. * Returns the Light associated shadow generator if any.
  76746. * @return the associated shadow generator.
  76747. */
  76748. getShadowGenerator(): Nullable<IShadowGenerator>;
  76749. /**
  76750. * Returns a Vector3, the absolute light position in the World.
  76751. * @returns the world space position of the light
  76752. */
  76753. getAbsolutePosition(): Vector3;
  76754. /**
  76755. * Specifies if the light will affect the passed mesh.
  76756. * @param mesh The mesh to test against the light
  76757. * @return true the mesh is affected otherwise, false.
  76758. */
  76759. canAffectMesh(mesh: AbstractMesh): boolean;
  76760. /**
  76761. * Sort function to order lights for rendering.
  76762. * @param a First Light object to compare to second.
  76763. * @param b Second Light object to compare first.
  76764. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76765. */
  76766. static CompareLightsPriority(a: Light, b: Light): number;
  76767. /**
  76768. * Releases resources associated with this node.
  76769. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76770. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76771. */
  76772. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76773. /**
  76774. * Returns the light type ID (integer).
  76775. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76776. */
  76777. getTypeID(): number;
  76778. /**
  76779. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76780. * @returns the scaled intensity in intensity mode unit
  76781. */
  76782. getScaledIntensity(): number;
  76783. /**
  76784. * Returns a new Light object, named "name", from the current one.
  76785. * @param name The name of the cloned light
  76786. * @returns the new created light
  76787. */
  76788. clone(name: string): Nullable<Light>;
  76789. /**
  76790. * Serializes the current light into a Serialization object.
  76791. * @returns the serialized object.
  76792. */
  76793. serialize(): any;
  76794. /**
  76795. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76796. * This new light is named "name" and added to the passed scene.
  76797. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76798. * @param name The friendly name of the light
  76799. * @param scene The scene the new light will belong to
  76800. * @returns the constructor function
  76801. */
  76802. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76803. /**
  76804. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76805. * @param parsedLight The JSON representation of the light
  76806. * @param scene The scene to create the parsed light in
  76807. * @returns the created light after parsing
  76808. */
  76809. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76810. private _hookArrayForExcluded;
  76811. private _hookArrayForIncludedOnly;
  76812. private _resyncMeshes;
  76813. /**
  76814. * Forces the meshes to update their light related information in their rendering used effects
  76815. * @hidden Internal Use Only
  76816. */
  76817. _markMeshesAsLightDirty(): void;
  76818. /**
  76819. * Recomputes the cached photometric scale if needed.
  76820. */
  76821. private _computePhotometricScale;
  76822. /**
  76823. * Returns the Photometric Scale according to the light type and intensity mode.
  76824. */
  76825. private _getPhotometricScale;
  76826. /**
  76827. * Reorder the light in the scene according to their defined priority.
  76828. * @hidden Internal Use Only
  76829. */
  76830. _reorderLightsInScene(): void;
  76831. /**
  76832. * Prepares the list of defines specific to the light type.
  76833. * @param defines the list of defines
  76834. * @param lightIndex defines the index of the light for the effect
  76835. */
  76836. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76837. }
  76838. }
  76839. declare module BABYLON {
  76840. /**
  76841. * Interface used to define Action
  76842. */
  76843. export interface IAction {
  76844. /**
  76845. * Trigger for the action
  76846. */
  76847. trigger: number;
  76848. /** Options of the trigger */
  76849. triggerOptions: any;
  76850. /**
  76851. * Gets the trigger parameters
  76852. * @returns the trigger parameters
  76853. */
  76854. getTriggerParameter(): any;
  76855. /**
  76856. * Internal only - executes current action event
  76857. * @hidden
  76858. */
  76859. _executeCurrent(evt?: ActionEvent): void;
  76860. /**
  76861. * Serialize placeholder for child classes
  76862. * @param parent of child
  76863. * @returns the serialized object
  76864. */
  76865. serialize(parent: any): any;
  76866. /**
  76867. * Internal only
  76868. * @hidden
  76869. */
  76870. _prepare(): void;
  76871. /**
  76872. * Internal only - manager for action
  76873. * @hidden
  76874. */
  76875. _actionManager: AbstractActionManager;
  76876. /**
  76877. * Adds action to chain of actions, may be a DoNothingAction
  76878. * @param action defines the next action to execute
  76879. * @returns The action passed in
  76880. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76881. */
  76882. then(action: IAction): IAction;
  76883. }
  76884. /**
  76885. * The action to be carried out following a trigger
  76886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76887. */
  76888. export class Action implements IAction {
  76889. /** the trigger, with or without parameters, for the action */
  76890. triggerOptions: any;
  76891. /**
  76892. * Trigger for the action
  76893. */
  76894. trigger: number;
  76895. /**
  76896. * Internal only - manager for action
  76897. * @hidden
  76898. */
  76899. _actionManager: ActionManager;
  76900. private _nextActiveAction;
  76901. private _child;
  76902. private _condition?;
  76903. private _triggerParameter;
  76904. /**
  76905. * An event triggered prior to action being executed.
  76906. */
  76907. onBeforeExecuteObservable: Observable<Action>;
  76908. /**
  76909. * Creates a new Action
  76910. * @param triggerOptions the trigger, with or without parameters, for the action
  76911. * @param condition an optional determinant of action
  76912. */
  76913. constructor(
  76914. /** the trigger, with or without parameters, for the action */
  76915. triggerOptions: any, condition?: Condition);
  76916. /**
  76917. * Internal only
  76918. * @hidden
  76919. */
  76920. _prepare(): void;
  76921. /**
  76922. * Gets the trigger parameters
  76923. * @returns the trigger parameters
  76924. */
  76925. getTriggerParameter(): any;
  76926. /**
  76927. * Internal only - executes current action event
  76928. * @hidden
  76929. */
  76930. _executeCurrent(evt?: ActionEvent): void;
  76931. /**
  76932. * Execute placeholder for child classes
  76933. * @param evt optional action event
  76934. */
  76935. execute(evt?: ActionEvent): void;
  76936. /**
  76937. * Skips to next active action
  76938. */
  76939. skipToNextActiveAction(): void;
  76940. /**
  76941. * Adds action to chain of actions, may be a DoNothingAction
  76942. * @param action defines the next action to execute
  76943. * @returns The action passed in
  76944. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76945. */
  76946. then(action: Action): Action;
  76947. /**
  76948. * Internal only
  76949. * @hidden
  76950. */
  76951. _getProperty(propertyPath: string): string;
  76952. /**
  76953. * Internal only
  76954. * @hidden
  76955. */
  76956. _getEffectiveTarget(target: any, propertyPath: string): any;
  76957. /**
  76958. * Serialize placeholder for child classes
  76959. * @param parent of child
  76960. * @returns the serialized object
  76961. */
  76962. serialize(parent: any): any;
  76963. /**
  76964. * Internal only called by serialize
  76965. * @hidden
  76966. */
  76967. protected _serialize(serializedAction: any, parent?: any): any;
  76968. /**
  76969. * Internal only
  76970. * @hidden
  76971. */
  76972. static _SerializeValueAsString: (value: any) => string;
  76973. /**
  76974. * Internal only
  76975. * @hidden
  76976. */
  76977. static _GetTargetProperty: (target: Node | Scene) => {
  76978. name: string;
  76979. targetType: string;
  76980. value: string;
  76981. };
  76982. }
  76983. }
  76984. declare module BABYLON {
  76985. /**
  76986. * A Condition applied to an Action
  76987. */
  76988. export class Condition {
  76989. /**
  76990. * Internal only - manager for action
  76991. * @hidden
  76992. */
  76993. _actionManager: ActionManager;
  76994. /**
  76995. * Internal only
  76996. * @hidden
  76997. */
  76998. _evaluationId: number;
  76999. /**
  77000. * Internal only
  77001. * @hidden
  77002. */
  77003. _currentResult: boolean;
  77004. /**
  77005. * Creates a new Condition
  77006. * @param actionManager the manager of the action the condition is applied to
  77007. */
  77008. constructor(actionManager: ActionManager);
  77009. /**
  77010. * Check if the current condition is valid
  77011. * @returns a boolean
  77012. */
  77013. isValid(): boolean;
  77014. /**
  77015. * Internal only
  77016. * @hidden
  77017. */
  77018. _getProperty(propertyPath: string): string;
  77019. /**
  77020. * Internal only
  77021. * @hidden
  77022. */
  77023. _getEffectiveTarget(target: any, propertyPath: string): any;
  77024. /**
  77025. * Serialize placeholder for child classes
  77026. * @returns the serialized object
  77027. */
  77028. serialize(): any;
  77029. /**
  77030. * Internal only
  77031. * @hidden
  77032. */
  77033. protected _serialize(serializedCondition: any): any;
  77034. }
  77035. /**
  77036. * Defines specific conditional operators as extensions of Condition
  77037. */
  77038. export class ValueCondition extends Condition {
  77039. /** path to specify the property of the target the conditional operator uses */
  77040. propertyPath: string;
  77041. /** the value compared by the conditional operator against the current value of the property */
  77042. value: any;
  77043. /** the conditional operator, default ValueCondition.IsEqual */
  77044. operator: number;
  77045. /**
  77046. * Internal only
  77047. * @hidden
  77048. */
  77049. private static _IsEqual;
  77050. /**
  77051. * Internal only
  77052. * @hidden
  77053. */
  77054. private static _IsDifferent;
  77055. /**
  77056. * Internal only
  77057. * @hidden
  77058. */
  77059. private static _IsGreater;
  77060. /**
  77061. * Internal only
  77062. * @hidden
  77063. */
  77064. private static _IsLesser;
  77065. /**
  77066. * returns the number for IsEqual
  77067. */
  77068. static readonly IsEqual: number;
  77069. /**
  77070. * Returns the number for IsDifferent
  77071. */
  77072. static readonly IsDifferent: number;
  77073. /**
  77074. * Returns the number for IsGreater
  77075. */
  77076. static readonly IsGreater: number;
  77077. /**
  77078. * Returns the number for IsLesser
  77079. */
  77080. static readonly IsLesser: number;
  77081. /**
  77082. * Internal only The action manager for the condition
  77083. * @hidden
  77084. */
  77085. _actionManager: ActionManager;
  77086. /**
  77087. * Internal only
  77088. * @hidden
  77089. */
  77090. private _target;
  77091. /**
  77092. * Internal only
  77093. * @hidden
  77094. */
  77095. private _effectiveTarget;
  77096. /**
  77097. * Internal only
  77098. * @hidden
  77099. */
  77100. private _property;
  77101. /**
  77102. * Creates a new ValueCondition
  77103. * @param actionManager manager for the action the condition applies to
  77104. * @param target for the action
  77105. * @param propertyPath path to specify the property of the target the conditional operator uses
  77106. * @param value the value compared by the conditional operator against the current value of the property
  77107. * @param operator the conditional operator, default ValueCondition.IsEqual
  77108. */
  77109. constructor(actionManager: ActionManager, target: any,
  77110. /** path to specify the property of the target the conditional operator uses */
  77111. propertyPath: string,
  77112. /** the value compared by the conditional operator against the current value of the property */
  77113. value: any,
  77114. /** the conditional operator, default ValueCondition.IsEqual */
  77115. operator?: number);
  77116. /**
  77117. * Compares the given value with the property value for the specified conditional operator
  77118. * @returns the result of the comparison
  77119. */
  77120. isValid(): boolean;
  77121. /**
  77122. * Serialize the ValueCondition into a JSON compatible object
  77123. * @returns serialization object
  77124. */
  77125. serialize(): any;
  77126. /**
  77127. * Gets the name of the conditional operator for the ValueCondition
  77128. * @param operator the conditional operator
  77129. * @returns the name
  77130. */
  77131. static GetOperatorName(operator: number): string;
  77132. }
  77133. /**
  77134. * Defines a predicate condition as an extension of Condition
  77135. */
  77136. export class PredicateCondition extends Condition {
  77137. /** defines the predicate function used to validate the condition */
  77138. predicate: () => boolean;
  77139. /**
  77140. * Internal only - manager for action
  77141. * @hidden
  77142. */
  77143. _actionManager: ActionManager;
  77144. /**
  77145. * Creates a new PredicateCondition
  77146. * @param actionManager manager for the action the condition applies to
  77147. * @param predicate defines the predicate function used to validate the condition
  77148. */
  77149. constructor(actionManager: ActionManager,
  77150. /** defines the predicate function used to validate the condition */
  77151. predicate: () => boolean);
  77152. /**
  77153. * @returns the validity of the predicate condition
  77154. */
  77155. isValid(): boolean;
  77156. }
  77157. /**
  77158. * Defines a state condition as an extension of Condition
  77159. */
  77160. export class StateCondition extends Condition {
  77161. /** Value to compare with target state */
  77162. value: string;
  77163. /**
  77164. * Internal only - manager for action
  77165. * @hidden
  77166. */
  77167. _actionManager: ActionManager;
  77168. /**
  77169. * Internal only
  77170. * @hidden
  77171. */
  77172. private _target;
  77173. /**
  77174. * Creates a new StateCondition
  77175. * @param actionManager manager for the action the condition applies to
  77176. * @param target of the condition
  77177. * @param value to compare with target state
  77178. */
  77179. constructor(actionManager: ActionManager, target: any,
  77180. /** Value to compare with target state */
  77181. value: string);
  77182. /**
  77183. * Gets a boolean indicating if the current condition is met
  77184. * @returns the validity of the state
  77185. */
  77186. isValid(): boolean;
  77187. /**
  77188. * Serialize the StateCondition into a JSON compatible object
  77189. * @returns serialization object
  77190. */
  77191. serialize(): any;
  77192. }
  77193. }
  77194. declare module BABYLON {
  77195. /**
  77196. * This defines an action responsible to toggle a boolean once triggered.
  77197. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77198. */
  77199. export class SwitchBooleanAction extends Action {
  77200. /**
  77201. * The path to the boolean property in the target object
  77202. */
  77203. propertyPath: string;
  77204. private _target;
  77205. private _effectiveTarget;
  77206. private _property;
  77207. /**
  77208. * Instantiate the action
  77209. * @param triggerOptions defines the trigger options
  77210. * @param target defines the object containing the boolean
  77211. * @param propertyPath defines the path to the boolean property in the target object
  77212. * @param condition defines the trigger related conditions
  77213. */
  77214. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77215. /** @hidden */
  77216. _prepare(): void;
  77217. /**
  77218. * Execute the action toggle the boolean value.
  77219. */
  77220. execute(): void;
  77221. /**
  77222. * Serializes the actions and its related information.
  77223. * @param parent defines the object to serialize in
  77224. * @returns the serialized object
  77225. */
  77226. serialize(parent: any): any;
  77227. }
  77228. /**
  77229. * This defines an action responsible to set a the state field of the target
  77230. * to a desired value once triggered.
  77231. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77232. */
  77233. export class SetStateAction extends Action {
  77234. /**
  77235. * The value to store in the state field.
  77236. */
  77237. value: string;
  77238. private _target;
  77239. /**
  77240. * Instantiate the action
  77241. * @param triggerOptions defines the trigger options
  77242. * @param target defines the object containing the state property
  77243. * @param value defines the value to store in the state field
  77244. * @param condition defines the trigger related conditions
  77245. */
  77246. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77247. /**
  77248. * Execute the action and store the value on the target state property.
  77249. */
  77250. execute(): void;
  77251. /**
  77252. * Serializes the actions and its related information.
  77253. * @param parent defines the object to serialize in
  77254. * @returns the serialized object
  77255. */
  77256. serialize(parent: any): any;
  77257. }
  77258. /**
  77259. * This defines an action responsible to set a property of the target
  77260. * to a desired value once triggered.
  77261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77262. */
  77263. export class SetValueAction extends Action {
  77264. /**
  77265. * The path of the property to set in the target.
  77266. */
  77267. propertyPath: string;
  77268. /**
  77269. * The value to set in the property
  77270. */
  77271. value: any;
  77272. private _target;
  77273. private _effectiveTarget;
  77274. private _property;
  77275. /**
  77276. * Instantiate the action
  77277. * @param triggerOptions defines the trigger options
  77278. * @param target defines the object containing the property
  77279. * @param propertyPath defines the path of the property to set in the target
  77280. * @param value defines the value to set in the property
  77281. * @param condition defines the trigger related conditions
  77282. */
  77283. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77284. /** @hidden */
  77285. _prepare(): void;
  77286. /**
  77287. * Execute the action and set the targetted property to the desired value.
  77288. */
  77289. execute(): void;
  77290. /**
  77291. * Serializes the actions and its related information.
  77292. * @param parent defines the object to serialize in
  77293. * @returns the serialized object
  77294. */
  77295. serialize(parent: any): any;
  77296. }
  77297. /**
  77298. * This defines an action responsible to increment the target value
  77299. * to a desired value once triggered.
  77300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77301. */
  77302. export class IncrementValueAction extends Action {
  77303. /**
  77304. * The path of the property to increment in the target.
  77305. */
  77306. propertyPath: string;
  77307. /**
  77308. * The value we should increment the property by.
  77309. */
  77310. value: any;
  77311. private _target;
  77312. private _effectiveTarget;
  77313. private _property;
  77314. /**
  77315. * Instantiate the action
  77316. * @param triggerOptions defines the trigger options
  77317. * @param target defines the object containing the property
  77318. * @param propertyPath defines the path of the property to increment in the target
  77319. * @param value defines the value value we should increment the property by
  77320. * @param condition defines the trigger related conditions
  77321. */
  77322. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77323. /** @hidden */
  77324. _prepare(): void;
  77325. /**
  77326. * Execute the action and increment the target of the value amount.
  77327. */
  77328. execute(): void;
  77329. /**
  77330. * Serializes the actions and its related information.
  77331. * @param parent defines the object to serialize in
  77332. * @returns the serialized object
  77333. */
  77334. serialize(parent: any): any;
  77335. }
  77336. /**
  77337. * This defines an action responsible to start an animation once triggered.
  77338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77339. */
  77340. export class PlayAnimationAction extends Action {
  77341. /**
  77342. * Where the animation should start (animation frame)
  77343. */
  77344. from: number;
  77345. /**
  77346. * Where the animation should stop (animation frame)
  77347. */
  77348. to: number;
  77349. /**
  77350. * Define if the animation should loop or stop after the first play.
  77351. */
  77352. loop?: boolean;
  77353. private _target;
  77354. /**
  77355. * Instantiate the action
  77356. * @param triggerOptions defines the trigger options
  77357. * @param target defines the target animation or animation name
  77358. * @param from defines from where the animation should start (animation frame)
  77359. * @param end defines where the animation should stop (animation frame)
  77360. * @param loop defines if the animation should loop or stop after the first play
  77361. * @param condition defines the trigger related conditions
  77362. */
  77363. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77364. /** @hidden */
  77365. _prepare(): void;
  77366. /**
  77367. * Execute the action and play the animation.
  77368. */
  77369. execute(): void;
  77370. /**
  77371. * Serializes the actions and its related information.
  77372. * @param parent defines the object to serialize in
  77373. * @returns the serialized object
  77374. */
  77375. serialize(parent: any): any;
  77376. }
  77377. /**
  77378. * This defines an action responsible to stop an animation once triggered.
  77379. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77380. */
  77381. export class StopAnimationAction extends Action {
  77382. private _target;
  77383. /**
  77384. * Instantiate the action
  77385. * @param triggerOptions defines the trigger options
  77386. * @param target defines the target animation or animation name
  77387. * @param condition defines the trigger related conditions
  77388. */
  77389. constructor(triggerOptions: any, target: any, condition?: Condition);
  77390. /** @hidden */
  77391. _prepare(): void;
  77392. /**
  77393. * Execute the action and stop the animation.
  77394. */
  77395. execute(): void;
  77396. /**
  77397. * Serializes the actions and its related information.
  77398. * @param parent defines the object to serialize in
  77399. * @returns the serialized object
  77400. */
  77401. serialize(parent: any): any;
  77402. }
  77403. /**
  77404. * This defines an action responsible that does nothing once triggered.
  77405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77406. */
  77407. export class DoNothingAction extends Action {
  77408. /**
  77409. * Instantiate the action
  77410. * @param triggerOptions defines the trigger options
  77411. * @param condition defines the trigger related conditions
  77412. */
  77413. constructor(triggerOptions?: any, condition?: Condition);
  77414. /**
  77415. * Execute the action and do nothing.
  77416. */
  77417. execute(): void;
  77418. /**
  77419. * Serializes the actions and its related information.
  77420. * @param parent defines the object to serialize in
  77421. * @returns the serialized object
  77422. */
  77423. serialize(parent: any): any;
  77424. }
  77425. /**
  77426. * This defines an action responsible to trigger several actions once triggered.
  77427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77428. */
  77429. export class CombineAction extends Action {
  77430. /**
  77431. * The list of aggregated animations to run.
  77432. */
  77433. children: Action[];
  77434. /**
  77435. * Instantiate the action
  77436. * @param triggerOptions defines the trigger options
  77437. * @param children defines the list of aggregated animations to run
  77438. * @param condition defines the trigger related conditions
  77439. */
  77440. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77441. /** @hidden */
  77442. _prepare(): void;
  77443. /**
  77444. * Execute the action and executes all the aggregated actions.
  77445. */
  77446. execute(evt: ActionEvent): void;
  77447. /**
  77448. * Serializes the actions and its related information.
  77449. * @param parent defines the object to serialize in
  77450. * @returns the serialized object
  77451. */
  77452. serialize(parent: any): any;
  77453. }
  77454. /**
  77455. * This defines an action responsible to run code (external event) once triggered.
  77456. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77457. */
  77458. export class ExecuteCodeAction extends Action {
  77459. /**
  77460. * The callback function to run.
  77461. */
  77462. func: (evt: ActionEvent) => void;
  77463. /**
  77464. * Instantiate the action
  77465. * @param triggerOptions defines the trigger options
  77466. * @param func defines the callback function to run
  77467. * @param condition defines the trigger related conditions
  77468. */
  77469. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77470. /**
  77471. * Execute the action and run the attached code.
  77472. */
  77473. execute(evt: ActionEvent): void;
  77474. }
  77475. /**
  77476. * This defines an action responsible to set the parent property of the target once triggered.
  77477. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77478. */
  77479. export class SetParentAction extends Action {
  77480. private _parent;
  77481. private _target;
  77482. /**
  77483. * Instantiate the action
  77484. * @param triggerOptions defines the trigger options
  77485. * @param target defines the target containing the parent property
  77486. * @param parent defines from where the animation should start (animation frame)
  77487. * @param condition defines the trigger related conditions
  77488. */
  77489. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77490. /** @hidden */
  77491. _prepare(): void;
  77492. /**
  77493. * Execute the action and set the parent property.
  77494. */
  77495. execute(): void;
  77496. /**
  77497. * Serializes the actions and its related information.
  77498. * @param parent defines the object to serialize in
  77499. * @returns the serialized object
  77500. */
  77501. serialize(parent: any): any;
  77502. }
  77503. }
  77504. declare module BABYLON {
  77505. /**
  77506. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77507. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77508. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77509. */
  77510. export class ActionManager extends AbstractActionManager {
  77511. /**
  77512. * Nothing
  77513. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77514. */
  77515. static readonly NothingTrigger: number;
  77516. /**
  77517. * On pick
  77518. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77519. */
  77520. static readonly OnPickTrigger: number;
  77521. /**
  77522. * On left pick
  77523. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77524. */
  77525. static readonly OnLeftPickTrigger: number;
  77526. /**
  77527. * On right pick
  77528. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77529. */
  77530. static readonly OnRightPickTrigger: number;
  77531. /**
  77532. * On center pick
  77533. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77534. */
  77535. static readonly OnCenterPickTrigger: number;
  77536. /**
  77537. * On pick down
  77538. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77539. */
  77540. static readonly OnPickDownTrigger: number;
  77541. /**
  77542. * On double pick
  77543. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77544. */
  77545. static readonly OnDoublePickTrigger: number;
  77546. /**
  77547. * On pick up
  77548. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77549. */
  77550. static readonly OnPickUpTrigger: number;
  77551. /**
  77552. * On pick out.
  77553. * This trigger will only be raised if you also declared a OnPickDown
  77554. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77555. */
  77556. static readonly OnPickOutTrigger: number;
  77557. /**
  77558. * On long press
  77559. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77560. */
  77561. static readonly OnLongPressTrigger: number;
  77562. /**
  77563. * On pointer over
  77564. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77565. */
  77566. static readonly OnPointerOverTrigger: number;
  77567. /**
  77568. * On pointer out
  77569. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77570. */
  77571. static readonly OnPointerOutTrigger: number;
  77572. /**
  77573. * On every frame
  77574. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77575. */
  77576. static readonly OnEveryFrameTrigger: number;
  77577. /**
  77578. * On intersection enter
  77579. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77580. */
  77581. static readonly OnIntersectionEnterTrigger: number;
  77582. /**
  77583. * On intersection exit
  77584. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77585. */
  77586. static readonly OnIntersectionExitTrigger: number;
  77587. /**
  77588. * On key down
  77589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77590. */
  77591. static readonly OnKeyDownTrigger: number;
  77592. /**
  77593. * On key up
  77594. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77595. */
  77596. static readonly OnKeyUpTrigger: number;
  77597. private _scene;
  77598. /**
  77599. * Creates a new action manager
  77600. * @param scene defines the hosting scene
  77601. */
  77602. constructor(scene: Scene);
  77603. /**
  77604. * Releases all associated resources
  77605. */
  77606. dispose(): void;
  77607. /**
  77608. * Gets hosting scene
  77609. * @returns the hosting scene
  77610. */
  77611. getScene(): Scene;
  77612. /**
  77613. * Does this action manager handles actions of any of the given triggers
  77614. * @param triggers defines the triggers to be tested
  77615. * @return a boolean indicating whether one (or more) of the triggers is handled
  77616. */
  77617. hasSpecificTriggers(triggers: number[]): boolean;
  77618. /**
  77619. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77620. * speed.
  77621. * @param triggerA defines the trigger to be tested
  77622. * @param triggerB defines the trigger to be tested
  77623. * @return a boolean indicating whether one (or more) of the triggers is handled
  77624. */
  77625. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77626. /**
  77627. * Does this action manager handles actions of a given trigger
  77628. * @param trigger defines the trigger to be tested
  77629. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77630. * @return whether the trigger is handled
  77631. */
  77632. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77633. /**
  77634. * Does this action manager has pointer triggers
  77635. */
  77636. readonly hasPointerTriggers: boolean;
  77637. /**
  77638. * Does this action manager has pick triggers
  77639. */
  77640. readonly hasPickTriggers: boolean;
  77641. /**
  77642. * Registers an action to this action manager
  77643. * @param action defines the action to be registered
  77644. * @return the action amended (prepared) after registration
  77645. */
  77646. registerAction(action: IAction): Nullable<IAction>;
  77647. /**
  77648. * Unregisters an action to this action manager
  77649. * @param action defines the action to be unregistered
  77650. * @return a boolean indicating whether the action has been unregistered
  77651. */
  77652. unregisterAction(action: IAction): Boolean;
  77653. /**
  77654. * Process a specific trigger
  77655. * @param trigger defines the trigger to process
  77656. * @param evt defines the event details to be processed
  77657. */
  77658. processTrigger(trigger: number, evt?: IActionEvent): void;
  77659. /** @hidden */
  77660. _getEffectiveTarget(target: any, propertyPath: string): any;
  77661. /** @hidden */
  77662. _getProperty(propertyPath: string): string;
  77663. /**
  77664. * Serialize this manager to a JSON object
  77665. * @param name defines the property name to store this manager
  77666. * @returns a JSON representation of this manager
  77667. */
  77668. serialize(name: string): any;
  77669. /**
  77670. * Creates a new ActionManager from a JSON data
  77671. * @param parsedActions defines the JSON data to read from
  77672. * @param object defines the hosting mesh
  77673. * @param scene defines the hosting scene
  77674. */
  77675. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77676. /**
  77677. * Get a trigger name by index
  77678. * @param trigger defines the trigger index
  77679. * @returns a trigger name
  77680. */
  77681. static GetTriggerName(trigger: number): string;
  77682. }
  77683. }
  77684. declare module BABYLON {
  77685. /**
  77686. * Class representing a ray with position and direction
  77687. */
  77688. export class Ray {
  77689. /** origin point */
  77690. origin: Vector3;
  77691. /** direction */
  77692. direction: Vector3;
  77693. /** length of the ray */
  77694. length: number;
  77695. private static readonly TmpVector3;
  77696. private _tmpRay;
  77697. /**
  77698. * Creates a new ray
  77699. * @param origin origin point
  77700. * @param direction direction
  77701. * @param length length of the ray
  77702. */
  77703. constructor(
  77704. /** origin point */
  77705. origin: Vector3,
  77706. /** direction */
  77707. direction: Vector3,
  77708. /** length of the ray */
  77709. length?: number);
  77710. /**
  77711. * Checks if the ray intersects a box
  77712. * @param minimum bound of the box
  77713. * @param maximum bound of the box
  77714. * @param intersectionTreshold extra extend to be added to the box in all direction
  77715. * @returns if the box was hit
  77716. */
  77717. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77718. /**
  77719. * Checks if the ray intersects a box
  77720. * @param box the bounding box to check
  77721. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77722. * @returns if the box was hit
  77723. */
  77724. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77725. /**
  77726. * If the ray hits a sphere
  77727. * @param sphere the bounding sphere to check
  77728. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77729. * @returns true if it hits the sphere
  77730. */
  77731. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77732. /**
  77733. * If the ray hits a triange
  77734. * @param vertex0 triangle vertex
  77735. * @param vertex1 triangle vertex
  77736. * @param vertex2 triangle vertex
  77737. * @returns intersection information if hit
  77738. */
  77739. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77740. /**
  77741. * Checks if ray intersects a plane
  77742. * @param plane the plane to check
  77743. * @returns the distance away it was hit
  77744. */
  77745. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77746. /**
  77747. * Calculate the intercept of a ray on a given axis
  77748. * @param axis to check 'x' | 'y' | 'z'
  77749. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77750. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77751. */
  77752. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77753. /**
  77754. * Checks if ray intersects a mesh
  77755. * @param mesh the mesh to check
  77756. * @param fastCheck if only the bounding box should checked
  77757. * @returns picking info of the intersecton
  77758. */
  77759. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77760. /**
  77761. * Checks if ray intersects a mesh
  77762. * @param meshes the meshes to check
  77763. * @param fastCheck if only the bounding box should checked
  77764. * @param results array to store result in
  77765. * @returns Array of picking infos
  77766. */
  77767. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77768. private _comparePickingInfo;
  77769. private static smallnum;
  77770. private static rayl;
  77771. /**
  77772. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77773. * @param sega the first point of the segment to test the intersection against
  77774. * @param segb the second point of the segment to test the intersection against
  77775. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77776. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77777. */
  77778. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77779. /**
  77780. * Update the ray from viewport position
  77781. * @param x position
  77782. * @param y y position
  77783. * @param viewportWidth viewport width
  77784. * @param viewportHeight viewport height
  77785. * @param world world matrix
  77786. * @param view view matrix
  77787. * @param projection projection matrix
  77788. * @returns this ray updated
  77789. */
  77790. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77791. /**
  77792. * Creates a ray with origin and direction of 0,0,0
  77793. * @returns the new ray
  77794. */
  77795. static Zero(): Ray;
  77796. /**
  77797. * Creates a new ray from screen space and viewport
  77798. * @param x position
  77799. * @param y y position
  77800. * @param viewportWidth viewport width
  77801. * @param viewportHeight viewport height
  77802. * @param world world matrix
  77803. * @param view view matrix
  77804. * @param projection projection matrix
  77805. * @returns new ray
  77806. */
  77807. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77808. /**
  77809. * 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
  77810. * transformed to the given world matrix.
  77811. * @param origin The origin point
  77812. * @param end The end point
  77813. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77814. * @returns the new ray
  77815. */
  77816. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77817. /**
  77818. * Transforms a ray by a matrix
  77819. * @param ray ray to transform
  77820. * @param matrix matrix to apply
  77821. * @returns the resulting new ray
  77822. */
  77823. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77824. /**
  77825. * Transforms a ray by a matrix
  77826. * @param ray ray to transform
  77827. * @param matrix matrix to apply
  77828. * @param result ray to store result in
  77829. */
  77830. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77831. /**
  77832. * Unproject a ray from screen space to object space
  77833. * @param sourceX defines the screen space x coordinate to use
  77834. * @param sourceY defines the screen space y coordinate to use
  77835. * @param viewportWidth defines the current width of the viewport
  77836. * @param viewportHeight defines the current height of the viewport
  77837. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77838. * @param view defines the view matrix to use
  77839. * @param projection defines the projection matrix to use
  77840. */
  77841. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77842. }
  77843. /**
  77844. * Type used to define predicate used to select faces when a mesh intersection is detected
  77845. */
  77846. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77847. interface Scene {
  77848. /** @hidden */
  77849. _tempPickingRay: Nullable<Ray>;
  77850. /** @hidden */
  77851. _cachedRayForTransform: Ray;
  77852. /** @hidden */
  77853. _pickWithRayInverseMatrix: Matrix;
  77854. /** @hidden */
  77855. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77856. /** @hidden */
  77857. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77858. }
  77859. }
  77860. declare module BABYLON {
  77861. /**
  77862. * Groups all the scene component constants in one place to ease maintenance.
  77863. * @hidden
  77864. */
  77865. export class SceneComponentConstants {
  77866. static readonly NAME_EFFECTLAYER: string;
  77867. static readonly NAME_LAYER: string;
  77868. static readonly NAME_LENSFLARESYSTEM: string;
  77869. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77870. static readonly NAME_PARTICLESYSTEM: string;
  77871. static readonly NAME_GAMEPAD: string;
  77872. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77873. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77874. static readonly NAME_DEPTHRENDERER: string;
  77875. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77876. static readonly NAME_SPRITE: string;
  77877. static readonly NAME_OUTLINERENDERER: string;
  77878. static readonly NAME_PROCEDURALTEXTURE: string;
  77879. static readonly NAME_SHADOWGENERATOR: string;
  77880. static readonly NAME_OCTREE: string;
  77881. static readonly NAME_PHYSICSENGINE: string;
  77882. static readonly NAME_AUDIO: string;
  77883. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77884. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77885. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77886. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77887. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77888. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77889. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77890. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77891. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77892. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77893. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77894. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77895. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77896. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77897. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77898. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77899. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77900. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77901. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77902. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77903. static readonly STEP_AFTERRENDER_AUDIO: number;
  77904. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  77905. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  77906. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  77907. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  77908. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  77909. static readonly STEP_POINTERMOVE_SPRITE: number;
  77910. static readonly STEP_POINTERDOWN_SPRITE: number;
  77911. static readonly STEP_POINTERUP_SPRITE: number;
  77912. }
  77913. /**
  77914. * This represents a scene component.
  77915. *
  77916. * This is used to decouple the dependency the scene is having on the different workloads like
  77917. * layers, post processes...
  77918. */
  77919. export interface ISceneComponent {
  77920. /**
  77921. * The name of the component. Each component must have a unique name.
  77922. */
  77923. name: string;
  77924. /**
  77925. * The scene the component belongs to.
  77926. */
  77927. scene: Scene;
  77928. /**
  77929. * Register the component to one instance of a scene.
  77930. */
  77931. register(): void;
  77932. /**
  77933. * Rebuilds the elements related to this component in case of
  77934. * context lost for instance.
  77935. */
  77936. rebuild(): void;
  77937. /**
  77938. * Disposes the component and the associated ressources.
  77939. */
  77940. dispose(): void;
  77941. }
  77942. /**
  77943. * This represents a SERIALIZABLE scene component.
  77944. *
  77945. * This extends Scene Component to add Serialization methods on top.
  77946. */
  77947. export interface ISceneSerializableComponent extends ISceneComponent {
  77948. /**
  77949. * Adds all the elements from the container to the scene
  77950. * @param container the container holding the elements
  77951. */
  77952. addFromContainer(container: AbstractScene): void;
  77953. /**
  77954. * Removes all the elements in the container from the scene
  77955. * @param container contains the elements to remove
  77956. * @param dispose if the removed element should be disposed (default: false)
  77957. */
  77958. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  77959. /**
  77960. * Serializes the component data to the specified json object
  77961. * @param serializationObject The object to serialize to
  77962. */
  77963. serialize(serializationObject: any): void;
  77964. }
  77965. /**
  77966. * Strong typing of a Mesh related stage step action
  77967. */
  77968. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  77969. /**
  77970. * Strong typing of a Evaluate Sub Mesh related stage step action
  77971. */
  77972. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  77973. /**
  77974. * Strong typing of a Active Mesh related stage step action
  77975. */
  77976. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  77977. /**
  77978. * Strong typing of a Camera related stage step action
  77979. */
  77980. export type CameraStageAction = (camera: Camera) => void;
  77981. /**
  77982. * Strong typing of a Camera Frame buffer related stage step action
  77983. */
  77984. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  77985. /**
  77986. * Strong typing of a Render Target related stage step action
  77987. */
  77988. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  77989. /**
  77990. * Strong typing of a RenderingGroup related stage step action
  77991. */
  77992. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  77993. /**
  77994. * Strong typing of a Mesh Render related stage step action
  77995. */
  77996. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  77997. /**
  77998. * Strong typing of a simple stage step action
  77999. */
  78000. export type SimpleStageAction = () => void;
  78001. /**
  78002. * Strong typing of a render target action.
  78003. */
  78004. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78005. /**
  78006. * Strong typing of a pointer move action.
  78007. */
  78008. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78009. /**
  78010. * Strong typing of a pointer up/down action.
  78011. */
  78012. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78013. /**
  78014. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78015. * @hidden
  78016. */
  78017. export class Stage<T extends Function> extends Array<{
  78018. index: number;
  78019. component: ISceneComponent;
  78020. action: T;
  78021. }> {
  78022. /**
  78023. * Hide ctor from the rest of the world.
  78024. * @param items The items to add.
  78025. */
  78026. private constructor();
  78027. /**
  78028. * Creates a new Stage.
  78029. * @returns A new instance of a Stage
  78030. */
  78031. static Create<T extends Function>(): Stage<T>;
  78032. /**
  78033. * Registers a step in an ordered way in the targeted stage.
  78034. * @param index Defines the position to register the step in
  78035. * @param component Defines the component attached to the step
  78036. * @param action Defines the action to launch during the step
  78037. */
  78038. registerStep(index: number, component: ISceneComponent, action: T): void;
  78039. /**
  78040. * Clears all the steps from the stage.
  78041. */
  78042. clear(): void;
  78043. }
  78044. }
  78045. declare module BABYLON {
  78046. interface Scene {
  78047. /** @hidden */
  78048. _pointerOverSprite: Nullable<Sprite>;
  78049. /** @hidden */
  78050. _pickedDownSprite: Nullable<Sprite>;
  78051. /** @hidden */
  78052. _tempSpritePickingRay: Nullable<Ray>;
  78053. /**
  78054. * All of the sprite managers added to this scene
  78055. * @see http://doc.babylonjs.com/babylon101/sprites
  78056. */
  78057. spriteManagers: Array<ISpriteManager>;
  78058. /**
  78059. * An event triggered when sprites rendering is about to start
  78060. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78061. */
  78062. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78063. /**
  78064. * An event triggered when sprites rendering is done
  78065. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78066. */
  78067. onAfterSpritesRenderingObservable: Observable<Scene>;
  78068. /** @hidden */
  78069. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78070. /** Launch a ray to try to pick a sprite in the scene
  78071. * @param x position on screen
  78072. * @param y position on screen
  78073. * @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
  78074. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78075. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78076. * @returns a PickingInfo
  78077. */
  78078. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78079. /** Use the given ray to pick a sprite in the scene
  78080. * @param ray The ray (in world space) to use to pick meshes
  78081. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  78082. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78083. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78084. * @returns a PickingInfo
  78085. */
  78086. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78087. /** @hidden */
  78088. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78089. /** Launch a ray to try to pick sprites in the scene
  78090. * @param x position on screen
  78091. * @param y position on screen
  78092. * @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
  78093. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78094. * @returns a PickingInfo array
  78095. */
  78096. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78097. /** Use the given ray to pick sprites in the scene
  78098. * @param ray The ray (in world space) to use to pick meshes
  78099. * @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
  78100. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78101. * @returns a PickingInfo array
  78102. */
  78103. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78104. /**
  78105. * Force the sprite under the pointer
  78106. * @param sprite defines the sprite to use
  78107. */
  78108. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78109. /**
  78110. * Gets the sprite under the pointer
  78111. * @returns a Sprite or null if no sprite is under the pointer
  78112. */
  78113. getPointerOverSprite(): Nullable<Sprite>;
  78114. }
  78115. /**
  78116. * Defines the sprite scene component responsible to manage sprites
  78117. * in a given scene.
  78118. */
  78119. export class SpriteSceneComponent implements ISceneComponent {
  78120. /**
  78121. * The component name helpfull to identify the component in the list of scene components.
  78122. */
  78123. readonly name: string;
  78124. /**
  78125. * The scene the component belongs to.
  78126. */
  78127. scene: Scene;
  78128. /** @hidden */
  78129. private _spritePredicate;
  78130. /**
  78131. * Creates a new instance of the component for the given scene
  78132. * @param scene Defines the scene to register the component in
  78133. */
  78134. constructor(scene: Scene);
  78135. /**
  78136. * Registers the component in a given scene
  78137. */
  78138. register(): void;
  78139. /**
  78140. * Rebuilds the elements related to this component in case of
  78141. * context lost for instance.
  78142. */
  78143. rebuild(): void;
  78144. /**
  78145. * Disposes the component and the associated ressources.
  78146. */
  78147. dispose(): void;
  78148. private _pickSpriteButKeepRay;
  78149. private _pointerMove;
  78150. private _pointerDown;
  78151. private _pointerUp;
  78152. }
  78153. }
  78154. declare module BABYLON {
  78155. /** @hidden */
  78156. export var fogFragmentDeclaration: {
  78157. name: string;
  78158. shader: string;
  78159. };
  78160. }
  78161. declare module BABYLON {
  78162. /** @hidden */
  78163. export var fogFragment: {
  78164. name: string;
  78165. shader: string;
  78166. };
  78167. }
  78168. declare module BABYLON {
  78169. /** @hidden */
  78170. export var spritesPixelShader: {
  78171. name: string;
  78172. shader: string;
  78173. };
  78174. }
  78175. declare module BABYLON {
  78176. /** @hidden */
  78177. export var fogVertexDeclaration: {
  78178. name: string;
  78179. shader: string;
  78180. };
  78181. }
  78182. declare module BABYLON {
  78183. /** @hidden */
  78184. export var spritesVertexShader: {
  78185. name: string;
  78186. shader: string;
  78187. };
  78188. }
  78189. declare module BABYLON {
  78190. /**
  78191. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78192. */
  78193. export interface ISpriteManager extends IDisposable {
  78194. /**
  78195. * Restricts the camera to viewing objects with the same layerMask.
  78196. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78197. */
  78198. layerMask: number;
  78199. /**
  78200. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78201. */
  78202. isPickable: boolean;
  78203. /**
  78204. * Specifies the rendering group id for this mesh (0 by default)
  78205. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78206. */
  78207. renderingGroupId: number;
  78208. /**
  78209. * Defines the list of sprites managed by the manager.
  78210. */
  78211. sprites: Array<Sprite>;
  78212. /**
  78213. * Tests the intersection of a sprite with a specific ray.
  78214. * @param ray The ray we are sending to test the collision
  78215. * @param camera The camera space we are sending rays in
  78216. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78217. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78218. * @returns picking info or null.
  78219. */
  78220. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78221. /**
  78222. * Intersects the sprites with a ray
  78223. * @param ray defines the ray to intersect with
  78224. * @param camera defines the current active camera
  78225. * @param predicate defines a predicate used to select candidate sprites
  78226. * @returns null if no hit or a PickingInfo array
  78227. */
  78228. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78229. /**
  78230. * Renders the list of sprites on screen.
  78231. */
  78232. render(): void;
  78233. }
  78234. /**
  78235. * Class used to manage multiple sprites on the same spritesheet
  78236. * @see http://doc.babylonjs.com/babylon101/sprites
  78237. */
  78238. export class SpriteManager implements ISpriteManager {
  78239. /** defines the manager's name */
  78240. name: string;
  78241. /** Gets the list of sprites */
  78242. sprites: Sprite[];
  78243. /** Gets or sets the rendering group id (0 by default) */
  78244. renderingGroupId: number;
  78245. /** Gets or sets camera layer mask */
  78246. layerMask: number;
  78247. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78248. fogEnabled: boolean;
  78249. /** Gets or sets a boolean indicating if the sprites are pickable */
  78250. isPickable: boolean;
  78251. /** Defines the default width of a cell in the spritesheet */
  78252. cellWidth: number;
  78253. /** Defines the default height of a cell in the spritesheet */
  78254. cellHeight: number;
  78255. /** Associative array from JSON sprite data file */
  78256. private _cellData;
  78257. /** Array of sprite names from JSON sprite data file */
  78258. private _spriteMap;
  78259. /** True when packed cell data from JSON file is ready*/
  78260. private _packedAndReady;
  78261. /**
  78262. * An event triggered when the manager is disposed.
  78263. */
  78264. onDisposeObservable: Observable<SpriteManager>;
  78265. private _onDisposeObserver;
  78266. /**
  78267. * Callback called when the manager is disposed
  78268. */
  78269. onDispose: () => void;
  78270. private _capacity;
  78271. private _fromPacked;
  78272. private _spriteTexture;
  78273. private _epsilon;
  78274. private _scene;
  78275. private _vertexData;
  78276. private _buffer;
  78277. private _vertexBuffers;
  78278. private _indexBuffer;
  78279. private _effectBase;
  78280. private _effectFog;
  78281. /**
  78282. * Gets or sets the spritesheet texture
  78283. */
  78284. texture: Texture;
  78285. /**
  78286. * Creates a new sprite manager
  78287. * @param name defines the manager's name
  78288. * @param imgUrl defines the sprite sheet url
  78289. * @param capacity defines the maximum allowed number of sprites
  78290. * @param cellSize defines the size of a sprite cell
  78291. * @param scene defines the hosting scene
  78292. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78293. * @param samplingMode defines the smapling mode to use with spritesheet
  78294. * @param fromPacked set to false; do not alter
  78295. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78296. */
  78297. constructor(
  78298. /** defines the manager's name */
  78299. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78300. private _makePacked;
  78301. private _appendSpriteVertex;
  78302. /**
  78303. * Intersects the sprites with a ray
  78304. * @param ray defines the ray to intersect with
  78305. * @param camera defines the current active camera
  78306. * @param predicate defines a predicate used to select candidate sprites
  78307. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78308. * @returns null if no hit or a PickingInfo
  78309. */
  78310. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78311. /**
  78312. * Intersects the sprites with a ray
  78313. * @param ray defines the ray to intersect with
  78314. * @param camera defines the current active camera
  78315. * @param predicate defines a predicate used to select candidate sprites
  78316. * @returns null if no hit or a PickingInfo array
  78317. */
  78318. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78319. /**
  78320. * Render all child sprites
  78321. */
  78322. render(): void;
  78323. /**
  78324. * Release associated resources
  78325. */
  78326. dispose(): void;
  78327. }
  78328. }
  78329. declare module BABYLON {
  78330. /**
  78331. * Class used to represent a sprite
  78332. * @see http://doc.babylonjs.com/babylon101/sprites
  78333. */
  78334. export class Sprite {
  78335. /** defines the name */
  78336. name: string;
  78337. /** Gets or sets the current world position */
  78338. position: Vector3;
  78339. /** Gets or sets the main color */
  78340. color: Color4;
  78341. /** Gets or sets the width */
  78342. width: number;
  78343. /** Gets or sets the height */
  78344. height: number;
  78345. /** Gets or sets rotation angle */
  78346. angle: number;
  78347. /** Gets or sets the cell index in the sprite sheet */
  78348. cellIndex: number;
  78349. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78350. cellRef: string;
  78351. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78352. invertU: number;
  78353. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78354. invertV: number;
  78355. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78356. disposeWhenFinishedAnimating: boolean;
  78357. /** Gets the list of attached animations */
  78358. animations: Animation[];
  78359. /** Gets or sets a boolean indicating if the sprite can be picked */
  78360. isPickable: boolean;
  78361. /**
  78362. * Gets or sets the associated action manager
  78363. */
  78364. actionManager: Nullable<ActionManager>;
  78365. private _animationStarted;
  78366. private _loopAnimation;
  78367. private _fromIndex;
  78368. private _toIndex;
  78369. private _delay;
  78370. private _direction;
  78371. private _manager;
  78372. private _time;
  78373. private _onAnimationEnd;
  78374. /**
  78375. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78376. */
  78377. isVisible: boolean;
  78378. /**
  78379. * Gets or sets the sprite size
  78380. */
  78381. size: number;
  78382. /**
  78383. * Creates a new Sprite
  78384. * @param name defines the name
  78385. * @param manager defines the manager
  78386. */
  78387. constructor(
  78388. /** defines the name */
  78389. name: string, manager: ISpriteManager);
  78390. /**
  78391. * Starts an animation
  78392. * @param from defines the initial key
  78393. * @param to defines the end key
  78394. * @param loop defines if the animation must loop
  78395. * @param delay defines the start delay (in ms)
  78396. * @param onAnimationEnd defines a callback to call when animation ends
  78397. */
  78398. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78399. /** Stops current animation (if any) */
  78400. stopAnimation(): void;
  78401. /** @hidden */
  78402. _animate(deltaTime: number): void;
  78403. /** Release associated resources */
  78404. dispose(): void;
  78405. }
  78406. }
  78407. declare module BABYLON {
  78408. /**
  78409. * Information about the result of picking within a scene
  78410. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78411. */
  78412. export class PickingInfo {
  78413. /** @hidden */
  78414. _pickingUnavailable: boolean;
  78415. /**
  78416. * If the pick collided with an object
  78417. */
  78418. hit: boolean;
  78419. /**
  78420. * Distance away where the pick collided
  78421. */
  78422. distance: number;
  78423. /**
  78424. * The location of pick collision
  78425. */
  78426. pickedPoint: Nullable<Vector3>;
  78427. /**
  78428. * The mesh corresponding the the pick collision
  78429. */
  78430. pickedMesh: Nullable<AbstractMesh>;
  78431. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78432. bu: number;
  78433. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78434. bv: number;
  78435. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78436. faceId: number;
  78437. /** Id of the the submesh that was picked */
  78438. subMeshId: number;
  78439. /** If a sprite was picked, this will be the sprite the pick collided with */
  78440. pickedSprite: Nullable<Sprite>;
  78441. /**
  78442. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78443. */
  78444. originMesh: Nullable<AbstractMesh>;
  78445. /**
  78446. * The ray that was used to perform the picking.
  78447. */
  78448. ray: Nullable<Ray>;
  78449. /**
  78450. * Gets the normal correspodning to the face the pick collided with
  78451. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78452. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78453. * @returns The normal correspodning to the face the pick collided with
  78454. */
  78455. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78456. /**
  78457. * Gets the texture coordinates of where the pick occured
  78458. * @returns the vector containing the coordnates of the texture
  78459. */
  78460. getTextureCoordinates(): Nullable<Vector2>;
  78461. }
  78462. }
  78463. declare module BABYLON {
  78464. /**
  78465. * Gather the list of pointer event types as constants.
  78466. */
  78467. export class PointerEventTypes {
  78468. /**
  78469. * 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.
  78470. */
  78471. static readonly POINTERDOWN: number;
  78472. /**
  78473. * The pointerup event is fired when a pointer is no longer active.
  78474. */
  78475. static readonly POINTERUP: number;
  78476. /**
  78477. * The pointermove event is fired when a pointer changes coordinates.
  78478. */
  78479. static readonly POINTERMOVE: number;
  78480. /**
  78481. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78482. */
  78483. static readonly POINTERWHEEL: number;
  78484. /**
  78485. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78486. */
  78487. static readonly POINTERPICK: number;
  78488. /**
  78489. * The pointertap event is fired when a the object has been touched and released without drag.
  78490. */
  78491. static readonly POINTERTAP: number;
  78492. /**
  78493. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78494. */
  78495. static readonly POINTERDOUBLETAP: number;
  78496. }
  78497. /**
  78498. * Base class of pointer info types.
  78499. */
  78500. export class PointerInfoBase {
  78501. /**
  78502. * Defines the type of event (PointerEventTypes)
  78503. */
  78504. type: number;
  78505. /**
  78506. * Defines the related dom event
  78507. */
  78508. event: PointerEvent | MouseWheelEvent;
  78509. /**
  78510. * Instantiates the base class of pointers info.
  78511. * @param type Defines the type of event (PointerEventTypes)
  78512. * @param event Defines the related dom event
  78513. */
  78514. constructor(
  78515. /**
  78516. * Defines the type of event (PointerEventTypes)
  78517. */
  78518. type: number,
  78519. /**
  78520. * Defines the related dom event
  78521. */
  78522. event: PointerEvent | MouseWheelEvent);
  78523. }
  78524. /**
  78525. * This class is used to store pointer related info for the onPrePointerObservable event.
  78526. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78527. */
  78528. export class PointerInfoPre extends PointerInfoBase {
  78529. /**
  78530. * Ray from a pointer if availible (eg. 6dof controller)
  78531. */
  78532. ray: Nullable<Ray>;
  78533. /**
  78534. * Defines the local position of the pointer on the canvas.
  78535. */
  78536. localPosition: Vector2;
  78537. /**
  78538. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78539. */
  78540. skipOnPointerObservable: boolean;
  78541. /**
  78542. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78543. * @param type Defines the type of event (PointerEventTypes)
  78544. * @param event Defines the related dom event
  78545. * @param localX Defines the local x coordinates of the pointer when the event occured
  78546. * @param localY Defines the local y coordinates of the pointer when the event occured
  78547. */
  78548. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78549. }
  78550. /**
  78551. * This type contains all the data related to a pointer event in Babylon.js.
  78552. * 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.
  78553. */
  78554. export class PointerInfo extends PointerInfoBase {
  78555. /**
  78556. * Defines the picking info associated to the info (if any)\
  78557. */
  78558. pickInfo: Nullable<PickingInfo>;
  78559. /**
  78560. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78561. * @param type Defines the type of event (PointerEventTypes)
  78562. * @param event Defines the related dom event
  78563. * @param pickInfo Defines the picking info associated to the info (if any)\
  78564. */
  78565. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78566. /**
  78567. * Defines the picking info associated to the info (if any)\
  78568. */
  78569. pickInfo: Nullable<PickingInfo>);
  78570. }
  78571. /**
  78572. * Data relating to a touch event on the screen.
  78573. */
  78574. export interface PointerTouch {
  78575. /**
  78576. * X coordinate of touch.
  78577. */
  78578. x: number;
  78579. /**
  78580. * Y coordinate of touch.
  78581. */
  78582. y: number;
  78583. /**
  78584. * Id of touch. Unique for each finger.
  78585. */
  78586. pointerId: number;
  78587. /**
  78588. * Event type passed from DOM.
  78589. */
  78590. type: any;
  78591. }
  78592. }
  78593. declare module BABYLON {
  78594. /**
  78595. * Manage the mouse inputs to control the movement of a free camera.
  78596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78597. */
  78598. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78599. /**
  78600. * Define if touch is enabled in the mouse input
  78601. */
  78602. touchEnabled: boolean;
  78603. /**
  78604. * Defines the camera the input is attached to.
  78605. */
  78606. camera: FreeCamera;
  78607. /**
  78608. * Defines the buttons associated with the input to handle camera move.
  78609. */
  78610. buttons: number[];
  78611. /**
  78612. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78613. */
  78614. angularSensibility: number;
  78615. private _pointerInput;
  78616. private _onMouseMove;
  78617. private _observer;
  78618. private previousPosition;
  78619. /**
  78620. * Observable for when a pointer move event occurs containing the move offset
  78621. */
  78622. onPointerMovedObservable: Observable<{
  78623. offsetX: number;
  78624. offsetY: number;
  78625. }>;
  78626. /**
  78627. * @hidden
  78628. * If the camera should be rotated automatically based on pointer movement
  78629. */
  78630. _allowCameraRotation: boolean;
  78631. /**
  78632. * Manage the mouse inputs to control the movement of a free camera.
  78633. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78634. * @param touchEnabled Defines if touch is enabled or not
  78635. */
  78636. constructor(
  78637. /**
  78638. * Define if touch is enabled in the mouse input
  78639. */
  78640. touchEnabled?: boolean);
  78641. /**
  78642. * Attach the input controls to a specific dom element to get the input from.
  78643. * @param element Defines the element the controls should be listened from
  78644. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78645. */
  78646. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78647. /**
  78648. * Called on JS contextmenu event.
  78649. * Override this method to provide functionality.
  78650. */
  78651. protected onContextMenu(evt: PointerEvent): void;
  78652. /**
  78653. * Detach the current controls from the specified dom element.
  78654. * @param element Defines the element to stop listening the inputs from
  78655. */
  78656. detachControl(element: Nullable<HTMLElement>): void;
  78657. /**
  78658. * Gets the class name of the current intput.
  78659. * @returns the class name
  78660. */
  78661. getClassName(): string;
  78662. /**
  78663. * Get the friendly name associated with the input class.
  78664. * @returns the input friendly name
  78665. */
  78666. getSimpleName(): string;
  78667. }
  78668. }
  78669. declare module BABYLON {
  78670. /**
  78671. * Manage the touch inputs to control the movement of a free camera.
  78672. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78673. */
  78674. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78675. /**
  78676. * Defines the camera the input is attached to.
  78677. */
  78678. camera: FreeCamera;
  78679. /**
  78680. * Defines the touch sensibility for rotation.
  78681. * The higher the faster.
  78682. */
  78683. touchAngularSensibility: number;
  78684. /**
  78685. * Defines the touch sensibility for move.
  78686. * The higher the faster.
  78687. */
  78688. touchMoveSensibility: number;
  78689. private _offsetX;
  78690. private _offsetY;
  78691. private _pointerPressed;
  78692. private _pointerInput;
  78693. private _observer;
  78694. private _onLostFocus;
  78695. /**
  78696. * Attach the input controls to a specific dom element to get the input from.
  78697. * @param element Defines the element the controls should be listened from
  78698. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78699. */
  78700. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78701. /**
  78702. * Detach the current controls from the specified dom element.
  78703. * @param element Defines the element to stop listening the inputs from
  78704. */
  78705. detachControl(element: Nullable<HTMLElement>): void;
  78706. /**
  78707. * Update the current camera state depending on the inputs that have been used this frame.
  78708. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78709. */
  78710. checkInputs(): void;
  78711. /**
  78712. * Gets the class name of the current intput.
  78713. * @returns the class name
  78714. */
  78715. getClassName(): string;
  78716. /**
  78717. * Get the friendly name associated with the input class.
  78718. * @returns the input friendly name
  78719. */
  78720. getSimpleName(): string;
  78721. }
  78722. }
  78723. declare module BABYLON {
  78724. /**
  78725. * Default Inputs manager for the FreeCamera.
  78726. * It groups all the default supported inputs for ease of use.
  78727. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78728. */
  78729. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78730. /**
  78731. * @hidden
  78732. */
  78733. _mouseInput: Nullable<FreeCameraMouseInput>;
  78734. /**
  78735. * Instantiates a new FreeCameraInputsManager.
  78736. * @param camera Defines the camera the inputs belong to
  78737. */
  78738. constructor(camera: FreeCamera);
  78739. /**
  78740. * Add keyboard input support to the input manager.
  78741. * @returns the current input manager
  78742. */
  78743. addKeyboard(): FreeCameraInputsManager;
  78744. /**
  78745. * Add mouse input support to the input manager.
  78746. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78747. * @returns the current input manager
  78748. */
  78749. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78750. /**
  78751. * Removes the mouse input support from the manager
  78752. * @returns the current input manager
  78753. */
  78754. removeMouse(): FreeCameraInputsManager;
  78755. /**
  78756. * Add touch input support to the input manager.
  78757. * @returns the current input manager
  78758. */
  78759. addTouch(): FreeCameraInputsManager;
  78760. /**
  78761. * Remove all attached input methods from a camera
  78762. */
  78763. clear(): void;
  78764. }
  78765. }
  78766. declare module BABYLON {
  78767. /**
  78768. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78769. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78770. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78771. */
  78772. export class FreeCamera extends TargetCamera {
  78773. /**
  78774. * Define the collision ellipsoid of the camera.
  78775. * This is helpful to simulate a camera body like the player body around the camera
  78776. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78777. */
  78778. ellipsoid: Vector3;
  78779. /**
  78780. * Define an offset for the position of the ellipsoid around the camera.
  78781. * This can be helpful to determine the center of the body near the gravity center of the body
  78782. * instead of its head.
  78783. */
  78784. ellipsoidOffset: Vector3;
  78785. /**
  78786. * Enable or disable collisions of the camera with the rest of the scene objects.
  78787. */
  78788. checkCollisions: boolean;
  78789. /**
  78790. * Enable or disable gravity on the camera.
  78791. */
  78792. applyGravity: boolean;
  78793. /**
  78794. * Define the input manager associated to the camera.
  78795. */
  78796. inputs: FreeCameraInputsManager;
  78797. /**
  78798. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78799. * Higher values reduce sensitivity.
  78800. */
  78801. /**
  78802. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78803. * Higher values reduce sensitivity.
  78804. */
  78805. angularSensibility: number;
  78806. /**
  78807. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78808. */
  78809. keysUp: number[];
  78810. /**
  78811. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78812. */
  78813. keysDown: number[];
  78814. /**
  78815. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78816. */
  78817. keysLeft: number[];
  78818. /**
  78819. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78820. */
  78821. keysRight: number[];
  78822. /**
  78823. * Event raised when the camera collide with a mesh in the scene.
  78824. */
  78825. onCollide: (collidedMesh: AbstractMesh) => void;
  78826. private _collider;
  78827. private _needMoveForGravity;
  78828. private _oldPosition;
  78829. private _diffPosition;
  78830. private _newPosition;
  78831. /** @hidden */
  78832. _localDirection: Vector3;
  78833. /** @hidden */
  78834. _transformedDirection: Vector3;
  78835. /**
  78836. * Instantiates a Free Camera.
  78837. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78838. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78839. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78840. * @param name Define the name of the camera in the scene
  78841. * @param position Define the start position of the camera in the scene
  78842. * @param scene Define the scene the camera belongs to
  78843. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78844. */
  78845. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78846. /**
  78847. * Attached controls to the current camera.
  78848. * @param element Defines the element the controls should be listened from
  78849. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78850. */
  78851. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78852. /**
  78853. * Detach the current controls from the camera.
  78854. * The camera will stop reacting to inputs.
  78855. * @param element Defines the element to stop listening the inputs from
  78856. */
  78857. detachControl(element: HTMLElement): void;
  78858. private _collisionMask;
  78859. /**
  78860. * Define a collision mask to limit the list of object the camera can collide with
  78861. */
  78862. collisionMask: number;
  78863. /** @hidden */
  78864. _collideWithWorld(displacement: Vector3): void;
  78865. private _onCollisionPositionChange;
  78866. /** @hidden */
  78867. _checkInputs(): void;
  78868. /** @hidden */
  78869. _decideIfNeedsToMove(): boolean;
  78870. /** @hidden */
  78871. _updatePosition(): void;
  78872. /**
  78873. * Destroy the camera and release the current resources hold by it.
  78874. */
  78875. dispose(): void;
  78876. /**
  78877. * Gets the current object class name.
  78878. * @return the class name
  78879. */
  78880. getClassName(): string;
  78881. }
  78882. }
  78883. declare module BABYLON {
  78884. /**
  78885. * Represents a gamepad control stick position
  78886. */
  78887. export class StickValues {
  78888. /**
  78889. * The x component of the control stick
  78890. */
  78891. x: number;
  78892. /**
  78893. * The y component of the control stick
  78894. */
  78895. y: number;
  78896. /**
  78897. * Initializes the gamepad x and y control stick values
  78898. * @param x The x component of the gamepad control stick value
  78899. * @param y The y component of the gamepad control stick value
  78900. */
  78901. constructor(
  78902. /**
  78903. * The x component of the control stick
  78904. */
  78905. x: number,
  78906. /**
  78907. * The y component of the control stick
  78908. */
  78909. y: number);
  78910. }
  78911. /**
  78912. * An interface which manages callbacks for gamepad button changes
  78913. */
  78914. export interface GamepadButtonChanges {
  78915. /**
  78916. * Called when a gamepad has been changed
  78917. */
  78918. changed: boolean;
  78919. /**
  78920. * Called when a gamepad press event has been triggered
  78921. */
  78922. pressChanged: boolean;
  78923. /**
  78924. * Called when a touch event has been triggered
  78925. */
  78926. touchChanged: boolean;
  78927. /**
  78928. * Called when a value has changed
  78929. */
  78930. valueChanged: boolean;
  78931. }
  78932. /**
  78933. * Represents a gamepad
  78934. */
  78935. export class Gamepad {
  78936. /**
  78937. * The id of the gamepad
  78938. */
  78939. id: string;
  78940. /**
  78941. * The index of the gamepad
  78942. */
  78943. index: number;
  78944. /**
  78945. * The browser gamepad
  78946. */
  78947. browserGamepad: any;
  78948. /**
  78949. * Specifies what type of gamepad this represents
  78950. */
  78951. type: number;
  78952. private _leftStick;
  78953. private _rightStick;
  78954. /** @hidden */
  78955. _isConnected: boolean;
  78956. private _leftStickAxisX;
  78957. private _leftStickAxisY;
  78958. private _rightStickAxisX;
  78959. private _rightStickAxisY;
  78960. /**
  78961. * Triggered when the left control stick has been changed
  78962. */
  78963. private _onleftstickchanged;
  78964. /**
  78965. * Triggered when the right control stick has been changed
  78966. */
  78967. private _onrightstickchanged;
  78968. /**
  78969. * Represents a gamepad controller
  78970. */
  78971. static GAMEPAD: number;
  78972. /**
  78973. * Represents a generic controller
  78974. */
  78975. static GENERIC: number;
  78976. /**
  78977. * Represents an XBox controller
  78978. */
  78979. static XBOX: number;
  78980. /**
  78981. * Represents a pose-enabled controller
  78982. */
  78983. static POSE_ENABLED: number;
  78984. /**
  78985. * Represents an Dual Shock controller
  78986. */
  78987. static DUALSHOCK: number;
  78988. /**
  78989. * Specifies whether the left control stick should be Y-inverted
  78990. */
  78991. protected _invertLeftStickY: boolean;
  78992. /**
  78993. * Specifies if the gamepad has been connected
  78994. */
  78995. readonly isConnected: boolean;
  78996. /**
  78997. * Initializes the gamepad
  78998. * @param id The id of the gamepad
  78999. * @param index The index of the gamepad
  79000. * @param browserGamepad The browser gamepad
  79001. * @param leftStickX The x component of the left joystick
  79002. * @param leftStickY The y component of the left joystick
  79003. * @param rightStickX The x component of the right joystick
  79004. * @param rightStickY The y component of the right joystick
  79005. */
  79006. constructor(
  79007. /**
  79008. * The id of the gamepad
  79009. */
  79010. id: string,
  79011. /**
  79012. * The index of the gamepad
  79013. */
  79014. index: number,
  79015. /**
  79016. * The browser gamepad
  79017. */
  79018. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79019. /**
  79020. * Callback triggered when the left joystick has changed
  79021. * @param callback
  79022. */
  79023. onleftstickchanged(callback: (values: StickValues) => void): void;
  79024. /**
  79025. * Callback triggered when the right joystick has changed
  79026. * @param callback
  79027. */
  79028. onrightstickchanged(callback: (values: StickValues) => void): void;
  79029. /**
  79030. * Gets the left joystick
  79031. */
  79032. /**
  79033. * Sets the left joystick values
  79034. */
  79035. leftStick: StickValues;
  79036. /**
  79037. * Gets the right joystick
  79038. */
  79039. /**
  79040. * Sets the right joystick value
  79041. */
  79042. rightStick: StickValues;
  79043. /**
  79044. * Updates the gamepad joystick positions
  79045. */
  79046. update(): void;
  79047. /**
  79048. * Disposes the gamepad
  79049. */
  79050. dispose(): void;
  79051. }
  79052. /**
  79053. * Represents a generic gamepad
  79054. */
  79055. export class GenericPad extends Gamepad {
  79056. private _buttons;
  79057. private _onbuttondown;
  79058. private _onbuttonup;
  79059. /**
  79060. * Observable triggered when a button has been pressed
  79061. */
  79062. onButtonDownObservable: Observable<number>;
  79063. /**
  79064. * Observable triggered when a button has been released
  79065. */
  79066. onButtonUpObservable: Observable<number>;
  79067. /**
  79068. * Callback triggered when a button has been pressed
  79069. * @param callback Called when a button has been pressed
  79070. */
  79071. onbuttondown(callback: (buttonPressed: number) => void): void;
  79072. /**
  79073. * Callback triggered when a button has been released
  79074. * @param callback Called when a button has been released
  79075. */
  79076. onbuttonup(callback: (buttonReleased: number) => void): void;
  79077. /**
  79078. * Initializes the generic gamepad
  79079. * @param id The id of the generic gamepad
  79080. * @param index The index of the generic gamepad
  79081. * @param browserGamepad The browser gamepad
  79082. */
  79083. constructor(id: string, index: number, browserGamepad: any);
  79084. private _setButtonValue;
  79085. /**
  79086. * Updates the generic gamepad
  79087. */
  79088. update(): void;
  79089. /**
  79090. * Disposes the generic gamepad
  79091. */
  79092. dispose(): void;
  79093. }
  79094. }
  79095. declare module BABYLON {
  79096. interface Engine {
  79097. /**
  79098. * Creates a raw texture
  79099. * @param data defines the data to store in the texture
  79100. * @param width defines the width of the texture
  79101. * @param height defines the height of the texture
  79102. * @param format defines the format of the data
  79103. * @param generateMipMaps defines if the engine should generate the mip levels
  79104. * @param invertY defines if data must be stored with Y axis inverted
  79105. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79106. * @param compression defines the compression used (null by default)
  79107. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79108. * @returns the raw texture inside an InternalTexture
  79109. */
  79110. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79111. /**
  79112. * Update a raw texture
  79113. * @param texture defines the texture to update
  79114. * @param data defines the data to store in the texture
  79115. * @param format defines the format of the data
  79116. * @param invertY defines if data must be stored with Y axis inverted
  79117. */
  79118. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79119. /**
  79120. * Update a raw texture
  79121. * @param texture defines the texture to update
  79122. * @param data defines the data to store in the texture
  79123. * @param format defines the format of the data
  79124. * @param invertY defines if data must be stored with Y axis inverted
  79125. * @param compression defines the compression used (null by default)
  79126. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79127. */
  79128. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79129. /**
  79130. * Creates a new raw cube texture
  79131. * @param data defines the array of data to use to create each face
  79132. * @param size defines the size of the textures
  79133. * @param format defines the format of the data
  79134. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79135. * @param generateMipMaps defines if the engine should generate the mip levels
  79136. * @param invertY defines if data must be stored with Y axis inverted
  79137. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79138. * @param compression defines the compression used (null by default)
  79139. * @returns the cube texture as an InternalTexture
  79140. */
  79141. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79142. /**
  79143. * Update a raw cube texture
  79144. * @param texture defines the texture to udpdate
  79145. * @param data defines the data to store
  79146. * @param format defines the data format
  79147. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79148. * @param invertY defines if data must be stored with Y axis inverted
  79149. */
  79150. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79151. /**
  79152. * Update a raw cube texture
  79153. * @param texture defines the texture to udpdate
  79154. * @param data defines the data to store
  79155. * @param format defines the data format
  79156. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79157. * @param invertY defines if data must be stored with Y axis inverted
  79158. * @param compression defines the compression used (null by default)
  79159. */
  79160. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79161. /**
  79162. * Update a raw cube texture
  79163. * @param texture defines the texture to udpdate
  79164. * @param data defines the data to store
  79165. * @param format defines the data format
  79166. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79167. * @param invertY defines if data must be stored with Y axis inverted
  79168. * @param compression defines the compression used (null by default)
  79169. * @param level defines which level of the texture to update
  79170. */
  79171. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79172. /**
  79173. * Creates a new raw cube texture from a specified url
  79174. * @param url defines the url where the data is located
  79175. * @param scene defines the current scene
  79176. * @param size defines the size of the textures
  79177. * @param format defines the format of the data
  79178. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79179. * @param noMipmap defines if the engine should avoid generating the mip levels
  79180. * @param callback defines a callback used to extract texture data from loaded data
  79181. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79182. * @param onLoad defines a callback called when texture is loaded
  79183. * @param onError defines a callback called if there is an error
  79184. * @returns the cube texture as an InternalTexture
  79185. */
  79186. 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;
  79187. /**
  79188. * Creates a new raw cube texture from a specified url
  79189. * @param url defines the url where the data is located
  79190. * @param scene defines the current scene
  79191. * @param size defines the size of the textures
  79192. * @param format defines the format of the data
  79193. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79194. * @param noMipmap defines if the engine should avoid generating the mip levels
  79195. * @param callback defines a callback used to extract texture data from loaded data
  79196. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79197. * @param onLoad defines a callback called when texture is loaded
  79198. * @param onError defines a callback called if there is an error
  79199. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79200. * @param invertY defines if data must be stored with Y axis inverted
  79201. * @returns the cube texture as an InternalTexture
  79202. */
  79203. 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;
  79204. /**
  79205. * Creates a new raw 3D texture
  79206. * @param data defines the data used to create the texture
  79207. * @param width defines the width of the texture
  79208. * @param height defines the height of the texture
  79209. * @param depth defines the depth of the texture
  79210. * @param format defines the format of the texture
  79211. * @param generateMipMaps defines if the engine must generate mip levels
  79212. * @param invertY defines if data must be stored with Y axis inverted
  79213. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79214. * @param compression defines the compressed used (can be null)
  79215. * @param textureType defines the compressed used (can be null)
  79216. * @returns a new raw 3D texture (stored in an InternalTexture)
  79217. */
  79218. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79219. /**
  79220. * Update a raw 3D texture
  79221. * @param texture defines the texture to update
  79222. * @param data defines the data to store
  79223. * @param format defines the data format
  79224. * @param invertY defines if data must be stored with Y axis inverted
  79225. */
  79226. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79227. /**
  79228. * Update a raw 3D texture
  79229. * @param texture defines the texture to update
  79230. * @param data defines the data to store
  79231. * @param format defines the data format
  79232. * @param invertY defines if data must be stored with Y axis inverted
  79233. * @param compression defines the used compression (can be null)
  79234. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79235. */
  79236. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79237. }
  79238. }
  79239. declare module BABYLON {
  79240. /**
  79241. * Raw texture can help creating a texture directly from an array of data.
  79242. * This can be super useful if you either get the data from an uncompressed source or
  79243. * if you wish to create your texture pixel by pixel.
  79244. */
  79245. export class RawTexture extends Texture {
  79246. /**
  79247. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79248. */
  79249. format: number;
  79250. private _engine;
  79251. /**
  79252. * Instantiates a new RawTexture.
  79253. * Raw texture can help creating a texture directly from an array of data.
  79254. * This can be super useful if you either get the data from an uncompressed source or
  79255. * if you wish to create your texture pixel by pixel.
  79256. * @param data define the array of data to use to create the texture
  79257. * @param width define the width of the texture
  79258. * @param height define the height of the texture
  79259. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79260. * @param scene define the scene the texture belongs to
  79261. * @param generateMipMaps define whether mip maps should be generated or not
  79262. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79263. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79264. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79265. */
  79266. constructor(data: ArrayBufferView, width: number, height: number,
  79267. /**
  79268. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79269. */
  79270. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79271. /**
  79272. * Updates the texture underlying data.
  79273. * @param data Define the new data of the texture
  79274. */
  79275. update(data: ArrayBufferView): void;
  79276. /**
  79277. * Creates a luminance texture from some data.
  79278. * @param data Define the texture data
  79279. * @param width Define the width of the texture
  79280. * @param height Define the height of the texture
  79281. * @param scene Define the scene the texture belongs to
  79282. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79283. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79284. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79285. * @returns the luminance texture
  79286. */
  79287. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79288. /**
  79289. * Creates a luminance alpha texture from some data.
  79290. * @param data Define the texture data
  79291. * @param width Define the width of the texture
  79292. * @param height Define the height of the texture
  79293. * @param scene Define the scene the texture belongs to
  79294. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79295. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79296. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79297. * @returns the luminance alpha texture
  79298. */
  79299. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79300. /**
  79301. * Creates an alpha texture from some data.
  79302. * @param data Define the texture data
  79303. * @param width Define the width of the texture
  79304. * @param height Define the height of the texture
  79305. * @param scene Define the scene the texture belongs to
  79306. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79307. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79308. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79309. * @returns the alpha texture
  79310. */
  79311. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79312. /**
  79313. * Creates a RGB texture from some data.
  79314. * @param data Define the texture data
  79315. * @param width Define the width of the texture
  79316. * @param height Define the height of the texture
  79317. * @param scene Define the scene the texture belongs to
  79318. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79319. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79320. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79321. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79322. * @returns the RGB alpha texture
  79323. */
  79324. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79325. /**
  79326. * Creates a RGBA texture from some data.
  79327. * @param data Define the texture data
  79328. * @param width Define the width of the texture
  79329. * @param height Define the height of the texture
  79330. * @param scene Define the scene the texture belongs to
  79331. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79332. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79333. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79334. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79335. * @returns the RGBA texture
  79336. */
  79337. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79338. /**
  79339. * Creates a R texture from some data.
  79340. * @param data Define the texture data
  79341. * @param width Define the width of the texture
  79342. * @param height Define the height of the texture
  79343. * @param scene Define the scene the texture belongs to
  79344. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79345. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79346. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79347. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79348. * @returns the R texture
  79349. */
  79350. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79351. }
  79352. }
  79353. declare module BABYLON {
  79354. /**
  79355. * Interface for the size containing width and height
  79356. */
  79357. export interface ISize {
  79358. /**
  79359. * Width
  79360. */
  79361. width: number;
  79362. /**
  79363. * Heighht
  79364. */
  79365. height: number;
  79366. }
  79367. /**
  79368. * Size containing widht and height
  79369. */
  79370. export class Size implements ISize {
  79371. /**
  79372. * Width
  79373. */
  79374. width: number;
  79375. /**
  79376. * Height
  79377. */
  79378. height: number;
  79379. /**
  79380. * Creates a Size object from the given width and height (floats).
  79381. * @param width width of the new size
  79382. * @param height height of the new size
  79383. */
  79384. constructor(width: number, height: number);
  79385. /**
  79386. * Returns a string with the Size width and height
  79387. * @returns a string with the Size width and height
  79388. */
  79389. toString(): string;
  79390. /**
  79391. * "Size"
  79392. * @returns the string "Size"
  79393. */
  79394. getClassName(): string;
  79395. /**
  79396. * Returns the Size hash code.
  79397. * @returns a hash code for a unique width and height
  79398. */
  79399. getHashCode(): number;
  79400. /**
  79401. * Updates the current size from the given one.
  79402. * @param src the given size
  79403. */
  79404. copyFrom(src: Size): void;
  79405. /**
  79406. * Updates in place the current Size from the given floats.
  79407. * @param width width of the new size
  79408. * @param height height of the new size
  79409. * @returns the updated Size.
  79410. */
  79411. copyFromFloats(width: number, height: number): Size;
  79412. /**
  79413. * Updates in place the current Size from the given floats.
  79414. * @param width width to set
  79415. * @param height height to set
  79416. * @returns the updated Size.
  79417. */
  79418. set(width: number, height: number): Size;
  79419. /**
  79420. * Multiplies the width and height by numbers
  79421. * @param w factor to multiple the width by
  79422. * @param h factor to multiple the height by
  79423. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79424. */
  79425. multiplyByFloats(w: number, h: number): Size;
  79426. /**
  79427. * Clones the size
  79428. * @returns a new Size copied from the given one.
  79429. */
  79430. clone(): Size;
  79431. /**
  79432. * True if the current Size and the given one width and height are strictly equal.
  79433. * @param other the other size to compare against
  79434. * @returns True if the current Size and the given one width and height are strictly equal.
  79435. */
  79436. equals(other: Size): boolean;
  79437. /**
  79438. * The surface of the Size : width * height (float).
  79439. */
  79440. readonly surface: number;
  79441. /**
  79442. * Create a new size of zero
  79443. * @returns a new Size set to (0.0, 0.0)
  79444. */
  79445. static Zero(): Size;
  79446. /**
  79447. * Sums the width and height of two sizes
  79448. * @param otherSize size to add to this size
  79449. * @returns a new Size set as the addition result of the current Size and the given one.
  79450. */
  79451. add(otherSize: Size): Size;
  79452. /**
  79453. * Subtracts the width and height of two
  79454. * @param otherSize size to subtract to this size
  79455. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79456. */
  79457. subtract(otherSize: Size): Size;
  79458. /**
  79459. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79460. * @param start starting size to lerp between
  79461. * @param end end size to lerp between
  79462. * @param amount amount to lerp between the start and end values
  79463. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79464. */
  79465. static Lerp(start: Size, end: Size, amount: number): Size;
  79466. }
  79467. }
  79468. declare module BABYLON {
  79469. /**
  79470. * Defines a runtime animation
  79471. */
  79472. export class RuntimeAnimation {
  79473. private _events;
  79474. /**
  79475. * The current frame of the runtime animation
  79476. */
  79477. private _currentFrame;
  79478. /**
  79479. * The animation used by the runtime animation
  79480. */
  79481. private _animation;
  79482. /**
  79483. * The target of the runtime animation
  79484. */
  79485. private _target;
  79486. /**
  79487. * The initiating animatable
  79488. */
  79489. private _host;
  79490. /**
  79491. * The original value of the runtime animation
  79492. */
  79493. private _originalValue;
  79494. /**
  79495. * The original blend value of the runtime animation
  79496. */
  79497. private _originalBlendValue;
  79498. /**
  79499. * The offsets cache of the runtime animation
  79500. */
  79501. private _offsetsCache;
  79502. /**
  79503. * The high limits cache of the runtime animation
  79504. */
  79505. private _highLimitsCache;
  79506. /**
  79507. * Specifies if the runtime animation has been stopped
  79508. */
  79509. private _stopped;
  79510. /**
  79511. * The blending factor of the runtime animation
  79512. */
  79513. private _blendingFactor;
  79514. /**
  79515. * The BabylonJS scene
  79516. */
  79517. private _scene;
  79518. /**
  79519. * The current value of the runtime animation
  79520. */
  79521. private _currentValue;
  79522. /** @hidden */
  79523. _animationState: _IAnimationState;
  79524. /**
  79525. * The active target of the runtime animation
  79526. */
  79527. private _activeTargets;
  79528. private _currentActiveTarget;
  79529. private _directTarget;
  79530. /**
  79531. * The target path of the runtime animation
  79532. */
  79533. private _targetPath;
  79534. /**
  79535. * The weight of the runtime animation
  79536. */
  79537. private _weight;
  79538. /**
  79539. * The ratio offset of the runtime animation
  79540. */
  79541. private _ratioOffset;
  79542. /**
  79543. * The previous delay of the runtime animation
  79544. */
  79545. private _previousDelay;
  79546. /**
  79547. * The previous ratio of the runtime animation
  79548. */
  79549. private _previousRatio;
  79550. private _enableBlending;
  79551. private _keys;
  79552. private _minFrame;
  79553. private _maxFrame;
  79554. private _minValue;
  79555. private _maxValue;
  79556. private _targetIsArray;
  79557. /**
  79558. * Gets the current frame of the runtime animation
  79559. */
  79560. readonly currentFrame: number;
  79561. /**
  79562. * Gets the weight of the runtime animation
  79563. */
  79564. readonly weight: number;
  79565. /**
  79566. * Gets the current value of the runtime animation
  79567. */
  79568. readonly currentValue: any;
  79569. /**
  79570. * Gets the target path of the runtime animation
  79571. */
  79572. readonly targetPath: string;
  79573. /**
  79574. * Gets the actual target of the runtime animation
  79575. */
  79576. readonly target: any;
  79577. /** @hidden */
  79578. _onLoop: () => void;
  79579. /**
  79580. * Create a new RuntimeAnimation object
  79581. * @param target defines the target of the animation
  79582. * @param animation defines the source animation object
  79583. * @param scene defines the hosting scene
  79584. * @param host defines the initiating Animatable
  79585. */
  79586. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79587. private _preparePath;
  79588. /**
  79589. * Gets the animation from the runtime animation
  79590. */
  79591. readonly animation: Animation;
  79592. /**
  79593. * Resets the runtime animation to the beginning
  79594. * @param restoreOriginal defines whether to restore the target property to the original value
  79595. */
  79596. reset(restoreOriginal?: boolean): void;
  79597. /**
  79598. * Specifies if the runtime animation is stopped
  79599. * @returns Boolean specifying if the runtime animation is stopped
  79600. */
  79601. isStopped(): boolean;
  79602. /**
  79603. * Disposes of the runtime animation
  79604. */
  79605. dispose(): void;
  79606. /**
  79607. * Apply the interpolated value to the target
  79608. * @param currentValue defines the value computed by the animation
  79609. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79610. */
  79611. setValue(currentValue: any, weight: number): void;
  79612. private _getOriginalValues;
  79613. private _setValue;
  79614. /**
  79615. * Gets the loop pmode of the runtime animation
  79616. * @returns Loop Mode
  79617. */
  79618. private _getCorrectLoopMode;
  79619. /**
  79620. * Move the current animation to a given frame
  79621. * @param frame defines the frame to move to
  79622. */
  79623. goToFrame(frame: number): void;
  79624. /**
  79625. * @hidden Internal use only
  79626. */
  79627. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79628. /**
  79629. * Execute the current animation
  79630. * @param delay defines the delay to add to the current frame
  79631. * @param from defines the lower bound of the animation range
  79632. * @param to defines the upper bound of the animation range
  79633. * @param loop defines if the current animation must loop
  79634. * @param speedRatio defines the current speed ratio
  79635. * @param weight defines the weight of the animation (default is -1 so no weight)
  79636. * @param onLoop optional callback called when animation loops
  79637. * @returns a boolean indicating if the animation is running
  79638. */
  79639. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79640. }
  79641. }
  79642. declare module BABYLON {
  79643. /**
  79644. * Class used to store an actual running animation
  79645. */
  79646. export class Animatable {
  79647. /** defines the target object */
  79648. target: any;
  79649. /** defines the starting frame number (default is 0) */
  79650. fromFrame: number;
  79651. /** defines the ending frame number (default is 100) */
  79652. toFrame: number;
  79653. /** defines if the animation must loop (default is false) */
  79654. loopAnimation: boolean;
  79655. /** defines a callback to call when animation ends if it is not looping */
  79656. onAnimationEnd?: (() => void) | null | undefined;
  79657. /** defines a callback to call when animation loops */
  79658. onAnimationLoop?: (() => void) | null | undefined;
  79659. private _localDelayOffset;
  79660. private _pausedDelay;
  79661. private _runtimeAnimations;
  79662. private _paused;
  79663. private _scene;
  79664. private _speedRatio;
  79665. private _weight;
  79666. private _syncRoot;
  79667. /**
  79668. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79669. * This will only apply for non looping animation (default is true)
  79670. */
  79671. disposeOnEnd: boolean;
  79672. /**
  79673. * Gets a boolean indicating if the animation has started
  79674. */
  79675. animationStarted: boolean;
  79676. /**
  79677. * Observer raised when the animation ends
  79678. */
  79679. onAnimationEndObservable: Observable<Animatable>;
  79680. /**
  79681. * Observer raised when the animation loops
  79682. */
  79683. onAnimationLoopObservable: Observable<Animatable>;
  79684. /**
  79685. * Gets the root Animatable used to synchronize and normalize animations
  79686. */
  79687. readonly syncRoot: Nullable<Animatable>;
  79688. /**
  79689. * Gets the current frame of the first RuntimeAnimation
  79690. * Used to synchronize Animatables
  79691. */
  79692. readonly masterFrame: number;
  79693. /**
  79694. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79695. */
  79696. weight: number;
  79697. /**
  79698. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79699. */
  79700. speedRatio: number;
  79701. /**
  79702. * Creates a new Animatable
  79703. * @param scene defines the hosting scene
  79704. * @param target defines the target object
  79705. * @param fromFrame defines the starting frame number (default is 0)
  79706. * @param toFrame defines the ending frame number (default is 100)
  79707. * @param loopAnimation defines if the animation must loop (default is false)
  79708. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79709. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79710. * @param animations defines a group of animation to add to the new Animatable
  79711. * @param onAnimationLoop defines a callback to call when animation loops
  79712. */
  79713. constructor(scene: Scene,
  79714. /** defines the target object */
  79715. target: any,
  79716. /** defines the starting frame number (default is 0) */
  79717. fromFrame?: number,
  79718. /** defines the ending frame number (default is 100) */
  79719. toFrame?: number,
  79720. /** defines if the animation must loop (default is false) */
  79721. loopAnimation?: boolean, speedRatio?: number,
  79722. /** defines a callback to call when animation ends if it is not looping */
  79723. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79724. /** defines a callback to call when animation loops */
  79725. onAnimationLoop?: (() => void) | null | undefined);
  79726. /**
  79727. * Synchronize and normalize current Animatable with a source Animatable
  79728. * This is useful when using animation weights and when animations are not of the same length
  79729. * @param root defines the root Animatable to synchronize with
  79730. * @returns the current Animatable
  79731. */
  79732. syncWith(root: Animatable): Animatable;
  79733. /**
  79734. * Gets the list of runtime animations
  79735. * @returns an array of RuntimeAnimation
  79736. */
  79737. getAnimations(): RuntimeAnimation[];
  79738. /**
  79739. * Adds more animations to the current animatable
  79740. * @param target defines the target of the animations
  79741. * @param animations defines the new animations to add
  79742. */
  79743. appendAnimations(target: any, animations: Animation[]): void;
  79744. /**
  79745. * Gets the source animation for a specific property
  79746. * @param property defines the propertyu to look for
  79747. * @returns null or the source animation for the given property
  79748. */
  79749. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79750. /**
  79751. * Gets the runtime animation for a specific property
  79752. * @param property defines the propertyu to look for
  79753. * @returns null or the runtime animation for the given property
  79754. */
  79755. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79756. /**
  79757. * Resets the animatable to its original state
  79758. */
  79759. reset(): void;
  79760. /**
  79761. * Allows the animatable to blend with current running animations
  79762. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79763. * @param blendingSpeed defines the blending speed to use
  79764. */
  79765. enableBlending(blendingSpeed: number): void;
  79766. /**
  79767. * Disable animation blending
  79768. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79769. */
  79770. disableBlending(): void;
  79771. /**
  79772. * Jump directly to a given frame
  79773. * @param frame defines the frame to jump to
  79774. */
  79775. goToFrame(frame: number): void;
  79776. /**
  79777. * Pause the animation
  79778. */
  79779. pause(): void;
  79780. /**
  79781. * Restart the animation
  79782. */
  79783. restart(): void;
  79784. private _raiseOnAnimationEnd;
  79785. /**
  79786. * Stop and delete the current animation
  79787. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79788. * @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)
  79789. */
  79790. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79791. /**
  79792. * Wait asynchronously for the animation to end
  79793. * @returns a promise which will be fullfilled when the animation ends
  79794. */
  79795. waitAsync(): Promise<Animatable>;
  79796. /** @hidden */
  79797. _animate(delay: number): boolean;
  79798. }
  79799. interface Scene {
  79800. /** @hidden */
  79801. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79802. /** @hidden */
  79803. _processLateAnimationBindingsForMatrices(holder: {
  79804. totalWeight: number;
  79805. animations: RuntimeAnimation[];
  79806. originalValue: Matrix;
  79807. }): any;
  79808. /** @hidden */
  79809. _processLateAnimationBindingsForQuaternions(holder: {
  79810. totalWeight: number;
  79811. animations: RuntimeAnimation[];
  79812. originalValue: Quaternion;
  79813. }, refQuaternion: Quaternion): Quaternion;
  79814. /** @hidden */
  79815. _processLateAnimationBindings(): void;
  79816. /**
  79817. * Will start the animation sequence of a given target
  79818. * @param target defines the target
  79819. * @param from defines from which frame should animation start
  79820. * @param to defines until which frame should animation run.
  79821. * @param weight defines the weight to apply to the animation (1.0 by default)
  79822. * @param loop defines if the animation loops
  79823. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79824. * @param onAnimationEnd defines the function to be executed when the animation ends
  79825. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79826. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79827. * @param onAnimationLoop defines the callback to call when an animation loops
  79828. * @returns the animatable object created for this animation
  79829. */
  79830. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79831. /**
  79832. * Will start the animation sequence of a given target
  79833. * @param target defines the target
  79834. * @param from defines from which frame should animation start
  79835. * @param to defines until which frame should animation run.
  79836. * @param loop defines if the animation loops
  79837. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79838. * @param onAnimationEnd defines the function to be executed when the animation ends
  79839. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79840. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79841. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79842. * @param onAnimationLoop defines the callback to call when an animation loops
  79843. * @returns the animatable object created for this animation
  79844. */
  79845. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79846. /**
  79847. * Will start the animation sequence of a given target and its hierarchy
  79848. * @param target defines the target
  79849. * @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.
  79850. * @param from defines from which frame should animation start
  79851. * @param to defines until which frame should animation run.
  79852. * @param loop defines if the animation loops
  79853. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79854. * @param onAnimationEnd defines the function to be executed when the animation ends
  79855. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79856. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79857. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79858. * @param onAnimationLoop defines the callback to call when an animation loops
  79859. * @returns the list of created animatables
  79860. */
  79861. 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[];
  79862. /**
  79863. * Begin a new animation on a given node
  79864. * @param target defines the target where the animation will take place
  79865. * @param animations defines the list of animations to start
  79866. * @param from defines the initial value
  79867. * @param to defines the final value
  79868. * @param loop defines if you want animation to loop (off by default)
  79869. * @param speedRatio defines the speed ratio to apply to all animations
  79870. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79871. * @param onAnimationLoop defines the callback to call when an animation loops
  79872. * @returns the list of created animatables
  79873. */
  79874. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79875. /**
  79876. * Begin a new animation on a given node and its hierarchy
  79877. * @param target defines the root node where the animation will take place
  79878. * @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.
  79879. * @param animations defines the list of animations to start
  79880. * @param from defines the initial value
  79881. * @param to defines the final value
  79882. * @param loop defines if you want animation to loop (off by default)
  79883. * @param speedRatio defines the speed ratio to apply to all animations
  79884. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79885. * @param onAnimationLoop defines the callback to call when an animation loops
  79886. * @returns the list of animatables created for all nodes
  79887. */
  79888. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79889. /**
  79890. * Gets the animatable associated with a specific target
  79891. * @param target defines the target of the animatable
  79892. * @returns the required animatable if found
  79893. */
  79894. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79895. /**
  79896. * Gets all animatables associated with a given target
  79897. * @param target defines the target to look animatables for
  79898. * @returns an array of Animatables
  79899. */
  79900. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79901. /**
  79902. * Stops and removes all animations that have been applied to the scene
  79903. */
  79904. stopAllAnimations(): void;
  79905. /**
  79906. * Gets the current delta time used by animation engine
  79907. */
  79908. deltaTime: number;
  79909. }
  79910. interface Bone {
  79911. /**
  79912. * Copy an animation range from another bone
  79913. * @param source defines the source bone
  79914. * @param rangeName defines the range name to copy
  79915. * @param frameOffset defines the frame offset
  79916. * @param rescaleAsRequired defines if rescaling must be applied if required
  79917. * @param skelDimensionsRatio defines the scaling ratio
  79918. * @returns true if operation was successful
  79919. */
  79920. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  79921. }
  79922. }
  79923. declare module BABYLON {
  79924. /**
  79925. * Class used to override all child animations of a given target
  79926. */
  79927. export class AnimationPropertiesOverride {
  79928. /**
  79929. * Gets or sets a value indicating if animation blending must be used
  79930. */
  79931. enableBlending: boolean;
  79932. /**
  79933. * Gets or sets the blending speed to use when enableBlending is true
  79934. */
  79935. blendingSpeed: number;
  79936. /**
  79937. * Gets or sets the default loop mode to use
  79938. */
  79939. loopMode: number;
  79940. }
  79941. }
  79942. declare module BABYLON {
  79943. /**
  79944. * Class used to handle skinning animations
  79945. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79946. */
  79947. export class Skeleton implements IAnimatable {
  79948. /** defines the skeleton name */
  79949. name: string;
  79950. /** defines the skeleton Id */
  79951. id: string;
  79952. /**
  79953. * Defines the list of child bones
  79954. */
  79955. bones: Bone[];
  79956. /**
  79957. * Defines an estimate of the dimension of the skeleton at rest
  79958. */
  79959. dimensionsAtRest: Vector3;
  79960. /**
  79961. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  79962. */
  79963. needInitialSkinMatrix: boolean;
  79964. /**
  79965. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  79966. */
  79967. overrideMesh: Nullable<AbstractMesh>;
  79968. /**
  79969. * Gets the list of animations attached to this skeleton
  79970. */
  79971. animations: Array<Animation>;
  79972. private _scene;
  79973. private _isDirty;
  79974. private _transformMatrices;
  79975. private _transformMatrixTexture;
  79976. private _meshesWithPoseMatrix;
  79977. private _animatables;
  79978. private _identity;
  79979. private _synchronizedWithMesh;
  79980. private _ranges;
  79981. private _lastAbsoluteTransformsUpdateId;
  79982. private _canUseTextureForBones;
  79983. private _uniqueId;
  79984. /** @hidden */
  79985. _numBonesWithLinkedTransformNode: number;
  79986. /** @hidden */
  79987. _hasWaitingData: Nullable<boolean>;
  79988. /**
  79989. * Specifies if the skeleton should be serialized
  79990. */
  79991. doNotSerialize: boolean;
  79992. private _useTextureToStoreBoneMatrices;
  79993. /**
  79994. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  79995. * Please note that this option is not available if the hardware does not support it
  79996. */
  79997. useTextureToStoreBoneMatrices: boolean;
  79998. private _animationPropertiesOverride;
  79999. /**
  80000. * Gets or sets the animation properties override
  80001. */
  80002. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80003. /**
  80004. * List of inspectable custom properties (used by the Inspector)
  80005. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80006. */
  80007. inspectableCustomProperties: IInspectable[];
  80008. /**
  80009. * An observable triggered before computing the skeleton's matrices
  80010. */
  80011. onBeforeComputeObservable: Observable<Skeleton>;
  80012. /**
  80013. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80014. */
  80015. readonly isUsingTextureForMatrices: boolean;
  80016. /**
  80017. * Gets the unique ID of this skeleton
  80018. */
  80019. readonly uniqueId: number;
  80020. /**
  80021. * Creates a new skeleton
  80022. * @param name defines the skeleton name
  80023. * @param id defines the skeleton Id
  80024. * @param scene defines the hosting scene
  80025. */
  80026. constructor(
  80027. /** defines the skeleton name */
  80028. name: string,
  80029. /** defines the skeleton Id */
  80030. id: string, scene: Scene);
  80031. /**
  80032. * Gets the current object class name.
  80033. * @return the class name
  80034. */
  80035. getClassName(): string;
  80036. /**
  80037. * Returns an array containing the root bones
  80038. * @returns an array containing the root bones
  80039. */
  80040. getChildren(): Array<Bone>;
  80041. /**
  80042. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80043. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80044. * @returns a Float32Array containing matrices data
  80045. */
  80046. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80047. /**
  80048. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80049. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80050. * @returns a raw texture containing the data
  80051. */
  80052. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80053. /**
  80054. * Gets the current hosting scene
  80055. * @returns a scene object
  80056. */
  80057. getScene(): Scene;
  80058. /**
  80059. * Gets a string representing the current skeleton data
  80060. * @param fullDetails defines a boolean indicating if we want a verbose version
  80061. * @returns a string representing the current skeleton data
  80062. */
  80063. toString(fullDetails?: boolean): string;
  80064. /**
  80065. * Get bone's index searching by name
  80066. * @param name defines bone's name to search for
  80067. * @return the indice of the bone. Returns -1 if not found
  80068. */
  80069. getBoneIndexByName(name: string): number;
  80070. /**
  80071. * Creater a new animation range
  80072. * @param name defines the name of the range
  80073. * @param from defines the start key
  80074. * @param to defines the end key
  80075. */
  80076. createAnimationRange(name: string, from: number, to: number): void;
  80077. /**
  80078. * Delete a specific animation range
  80079. * @param name defines the name of the range
  80080. * @param deleteFrames defines if frames must be removed as well
  80081. */
  80082. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80083. /**
  80084. * Gets a specific animation range
  80085. * @param name defines the name of the range to look for
  80086. * @returns the requested animation range or null if not found
  80087. */
  80088. getAnimationRange(name: string): Nullable<AnimationRange>;
  80089. /**
  80090. * Gets the list of all animation ranges defined on this skeleton
  80091. * @returns an array
  80092. */
  80093. getAnimationRanges(): Nullable<AnimationRange>[];
  80094. /**
  80095. * Copy animation range from a source skeleton.
  80096. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80097. * @param source defines the source skeleton
  80098. * @param name defines the name of the range to copy
  80099. * @param rescaleAsRequired defines if rescaling must be applied if required
  80100. * @returns true if operation was successful
  80101. */
  80102. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80103. /**
  80104. * Forces the skeleton to go to rest pose
  80105. */
  80106. returnToRest(): void;
  80107. private _getHighestAnimationFrame;
  80108. /**
  80109. * Begin a specific animation range
  80110. * @param name defines the name of the range to start
  80111. * @param loop defines if looping must be turned on (false by default)
  80112. * @param speedRatio defines the speed ratio to apply (1 by default)
  80113. * @param onAnimationEnd defines a callback which will be called when animation will end
  80114. * @returns a new animatable
  80115. */
  80116. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80117. /** @hidden */
  80118. _markAsDirty(): void;
  80119. /** @hidden */
  80120. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80121. /** @hidden */
  80122. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80123. private _computeTransformMatrices;
  80124. /**
  80125. * Build all resources required to render a skeleton
  80126. */
  80127. prepare(): void;
  80128. /**
  80129. * Gets the list of animatables currently running for this skeleton
  80130. * @returns an array of animatables
  80131. */
  80132. getAnimatables(): IAnimatable[];
  80133. /**
  80134. * Clone the current skeleton
  80135. * @param name defines the name of the new skeleton
  80136. * @param id defines the id of the new skeleton
  80137. * @returns the new skeleton
  80138. */
  80139. clone(name: string, id: string): Skeleton;
  80140. /**
  80141. * Enable animation blending for this skeleton
  80142. * @param blendingSpeed defines the blending speed to apply
  80143. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80144. */
  80145. enableBlending(blendingSpeed?: number): void;
  80146. /**
  80147. * Releases all resources associated with the current skeleton
  80148. */
  80149. dispose(): void;
  80150. /**
  80151. * Serialize the skeleton in a JSON object
  80152. * @returns a JSON object
  80153. */
  80154. serialize(): any;
  80155. /**
  80156. * Creates a new skeleton from serialized data
  80157. * @param parsedSkeleton defines the serialized data
  80158. * @param scene defines the hosting scene
  80159. * @returns a new skeleton
  80160. */
  80161. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80162. /**
  80163. * Compute all node absolute transforms
  80164. * @param forceUpdate defines if computation must be done even if cache is up to date
  80165. */
  80166. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80167. /**
  80168. * Gets the root pose matrix
  80169. * @returns a matrix
  80170. */
  80171. getPoseMatrix(): Nullable<Matrix>;
  80172. /**
  80173. * Sorts bones per internal index
  80174. */
  80175. sortBones(): void;
  80176. private _sortBones;
  80177. }
  80178. }
  80179. declare module BABYLON {
  80180. /**
  80181. * Class used to store bone information
  80182. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80183. */
  80184. export class Bone extends Node {
  80185. /**
  80186. * defines the bone name
  80187. */
  80188. name: string;
  80189. private static _tmpVecs;
  80190. private static _tmpQuat;
  80191. private static _tmpMats;
  80192. /**
  80193. * Gets the list of child bones
  80194. */
  80195. children: Bone[];
  80196. /** Gets the animations associated with this bone */
  80197. animations: Animation[];
  80198. /**
  80199. * Gets or sets bone length
  80200. */
  80201. length: number;
  80202. /**
  80203. * @hidden Internal only
  80204. * Set this value to map this bone to a different index in the transform matrices
  80205. * Set this value to -1 to exclude the bone from the transform matrices
  80206. */
  80207. _index: Nullable<number>;
  80208. private _skeleton;
  80209. private _localMatrix;
  80210. private _restPose;
  80211. private _baseMatrix;
  80212. private _absoluteTransform;
  80213. private _invertedAbsoluteTransform;
  80214. private _parent;
  80215. private _scalingDeterminant;
  80216. private _worldTransform;
  80217. private _localScaling;
  80218. private _localRotation;
  80219. private _localPosition;
  80220. private _needToDecompose;
  80221. private _needToCompose;
  80222. /** @hidden */
  80223. _linkedTransformNode: Nullable<TransformNode>;
  80224. /** @hidden */
  80225. _waitingTransformNodeId: Nullable<string>;
  80226. /** @hidden */
  80227. /** @hidden */
  80228. _matrix: Matrix;
  80229. /**
  80230. * Create a new bone
  80231. * @param name defines the bone name
  80232. * @param skeleton defines the parent skeleton
  80233. * @param parentBone defines the parent (can be null if the bone is the root)
  80234. * @param localMatrix defines the local matrix
  80235. * @param restPose defines the rest pose matrix
  80236. * @param baseMatrix defines the base matrix
  80237. * @param index defines index of the bone in the hiearchy
  80238. */
  80239. constructor(
  80240. /**
  80241. * defines the bone name
  80242. */
  80243. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80244. /**
  80245. * Gets the current object class name.
  80246. * @return the class name
  80247. */
  80248. getClassName(): string;
  80249. /**
  80250. * Gets the parent skeleton
  80251. * @returns a skeleton
  80252. */
  80253. getSkeleton(): Skeleton;
  80254. /**
  80255. * Gets parent bone
  80256. * @returns a bone or null if the bone is the root of the bone hierarchy
  80257. */
  80258. getParent(): Nullable<Bone>;
  80259. /**
  80260. * Returns an array containing the root bones
  80261. * @returns an array containing the root bones
  80262. */
  80263. getChildren(): Array<Bone>;
  80264. /**
  80265. * Sets the parent bone
  80266. * @param parent defines the parent (can be null if the bone is the root)
  80267. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80268. */
  80269. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80270. /**
  80271. * Gets the local matrix
  80272. * @returns a matrix
  80273. */
  80274. getLocalMatrix(): Matrix;
  80275. /**
  80276. * Gets the base matrix (initial matrix which remains unchanged)
  80277. * @returns a matrix
  80278. */
  80279. getBaseMatrix(): Matrix;
  80280. /**
  80281. * Gets the rest pose matrix
  80282. * @returns a matrix
  80283. */
  80284. getRestPose(): Matrix;
  80285. /**
  80286. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80287. */
  80288. getWorldMatrix(): Matrix;
  80289. /**
  80290. * Sets the local matrix to rest pose matrix
  80291. */
  80292. returnToRest(): void;
  80293. /**
  80294. * Gets the inverse of the absolute transform matrix.
  80295. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80296. * @returns a matrix
  80297. */
  80298. getInvertedAbsoluteTransform(): Matrix;
  80299. /**
  80300. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80301. * @returns a matrix
  80302. */
  80303. getAbsoluteTransform(): Matrix;
  80304. /**
  80305. * Links with the given transform node.
  80306. * The local matrix of this bone is copied from the transform node every frame.
  80307. * @param transformNode defines the transform node to link to
  80308. */
  80309. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80310. /**
  80311. * Gets the node used to drive the bone's transformation
  80312. * @returns a transform node or null
  80313. */
  80314. getTransformNode(): Nullable<TransformNode>;
  80315. /** Gets or sets current position (in local space) */
  80316. position: Vector3;
  80317. /** Gets or sets current rotation (in local space) */
  80318. rotation: Vector3;
  80319. /** Gets or sets current rotation quaternion (in local space) */
  80320. rotationQuaternion: Quaternion;
  80321. /** Gets or sets current scaling (in local space) */
  80322. scaling: Vector3;
  80323. /**
  80324. * Gets the animation properties override
  80325. */
  80326. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80327. private _decompose;
  80328. private _compose;
  80329. /**
  80330. * Update the base and local matrices
  80331. * @param matrix defines the new base or local matrix
  80332. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80333. * @param updateLocalMatrix defines if the local matrix should be updated
  80334. */
  80335. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80336. /** @hidden */
  80337. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80338. /**
  80339. * Flag the bone as dirty (Forcing it to update everything)
  80340. */
  80341. markAsDirty(): void;
  80342. /** @hidden */
  80343. _markAsDirtyAndCompose(): void;
  80344. private _markAsDirtyAndDecompose;
  80345. /**
  80346. * Translate the bone in local or world space
  80347. * @param vec The amount to translate the bone
  80348. * @param space The space that the translation is in
  80349. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80350. */
  80351. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80352. /**
  80353. * Set the postion of the bone in local or world space
  80354. * @param position The position to set the bone
  80355. * @param space The space that the position is in
  80356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80357. */
  80358. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80359. /**
  80360. * Set the absolute position of the bone (world space)
  80361. * @param position The position to set the bone
  80362. * @param mesh The mesh that this bone is attached to
  80363. */
  80364. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80365. /**
  80366. * Scale the bone on the x, y and z axes (in local space)
  80367. * @param x The amount to scale the bone on the x axis
  80368. * @param y The amount to scale the bone on the y axis
  80369. * @param z The amount to scale the bone on the z axis
  80370. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80371. */
  80372. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80373. /**
  80374. * Set the bone scaling in local space
  80375. * @param scale defines the scaling vector
  80376. */
  80377. setScale(scale: Vector3): void;
  80378. /**
  80379. * Gets the current scaling in local space
  80380. * @returns the current scaling vector
  80381. */
  80382. getScale(): Vector3;
  80383. /**
  80384. * Gets the current scaling in local space and stores it in a target vector
  80385. * @param result defines the target vector
  80386. */
  80387. getScaleToRef(result: Vector3): void;
  80388. /**
  80389. * Set the yaw, pitch, and roll of the bone in local or world space
  80390. * @param yaw The rotation of the bone on the y axis
  80391. * @param pitch The rotation of the bone on the x axis
  80392. * @param roll The rotation of the bone on the z axis
  80393. * @param space The space that the axes of rotation are in
  80394. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80395. */
  80396. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80397. /**
  80398. * Add a rotation to the bone on an axis in local or world space
  80399. * @param axis The axis to rotate the bone on
  80400. * @param amount The amount to rotate the bone
  80401. * @param space The space that the axis is in
  80402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80403. */
  80404. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80405. /**
  80406. * Set the rotation of the bone to a particular axis angle in local or world space
  80407. * @param axis The axis to rotate the bone on
  80408. * @param angle The angle that the bone should be rotated to
  80409. * @param space The space that the axis is in
  80410. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80411. */
  80412. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80413. /**
  80414. * Set the euler rotation of the bone in local of world space
  80415. * @param rotation The euler rotation that the bone should be set to
  80416. * @param space The space that the rotation is in
  80417. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80418. */
  80419. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80420. /**
  80421. * Set the quaternion rotation of the bone in local of world space
  80422. * @param quat The quaternion rotation that the bone should be set to
  80423. * @param space The space that the rotation is in
  80424. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80425. */
  80426. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80427. /**
  80428. * Set the rotation matrix of the bone in local of world space
  80429. * @param rotMat The rotation matrix that the bone should be set to
  80430. * @param space The space that the rotation is in
  80431. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80432. */
  80433. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80434. private _rotateWithMatrix;
  80435. private _getNegativeRotationToRef;
  80436. /**
  80437. * Get the position of the bone in local or world space
  80438. * @param space The space that the returned position is in
  80439. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80440. * @returns The position of the bone
  80441. */
  80442. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80443. /**
  80444. * Copy the position of the bone to a vector3 in local or world space
  80445. * @param space The space that the returned position is in
  80446. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80447. * @param result The vector3 to copy the position to
  80448. */
  80449. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80450. /**
  80451. * Get the absolute position of the bone (world space)
  80452. * @param mesh The mesh that this bone is attached to
  80453. * @returns The absolute position of the bone
  80454. */
  80455. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80456. /**
  80457. * Copy the absolute position of the bone (world space) to the result param
  80458. * @param mesh The mesh that this bone is attached to
  80459. * @param result The vector3 to copy the absolute position to
  80460. */
  80461. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80462. /**
  80463. * Compute the absolute transforms of this bone and its children
  80464. */
  80465. computeAbsoluteTransforms(): void;
  80466. /**
  80467. * Get the world direction from an axis that is in the local space of the bone
  80468. * @param localAxis The local direction that is used to compute the world direction
  80469. * @param mesh The mesh that this bone is attached to
  80470. * @returns The world direction
  80471. */
  80472. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80473. /**
  80474. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80475. * @param localAxis The local direction that is used to compute the world direction
  80476. * @param mesh The mesh that this bone is attached to
  80477. * @param result The vector3 that the world direction will be copied to
  80478. */
  80479. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80480. /**
  80481. * Get the euler rotation of the bone in local or world space
  80482. * @param space The space that the rotation should be in
  80483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80484. * @returns The euler rotation
  80485. */
  80486. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80487. /**
  80488. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80489. * @param space The space that the rotation should be in
  80490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80491. * @param result The vector3 that the rotation should be copied to
  80492. */
  80493. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80494. /**
  80495. * Get the quaternion rotation of the bone in either local or world space
  80496. * @param space The space that the rotation should be in
  80497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80498. * @returns The quaternion rotation
  80499. */
  80500. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80501. /**
  80502. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80503. * @param space The space that the rotation should be in
  80504. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80505. * @param result The quaternion that the rotation should be copied to
  80506. */
  80507. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80508. /**
  80509. * Get the rotation matrix of the bone in local or world space
  80510. * @param space The space that the rotation should be in
  80511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80512. * @returns The rotation matrix
  80513. */
  80514. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80515. /**
  80516. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80517. * @param space The space that the rotation should be in
  80518. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80519. * @param result The quaternion that the rotation should be copied to
  80520. */
  80521. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80522. /**
  80523. * Get the world position of a point that is in the local space of the bone
  80524. * @param position The local position
  80525. * @param mesh The mesh that this bone is attached to
  80526. * @returns The world position
  80527. */
  80528. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80529. /**
  80530. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80531. * @param position The local position
  80532. * @param mesh The mesh that this bone is attached to
  80533. * @param result The vector3 that the world position should be copied to
  80534. */
  80535. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80536. /**
  80537. * Get the local position of a point that is in world space
  80538. * @param position The world position
  80539. * @param mesh The mesh that this bone is attached to
  80540. * @returns The local position
  80541. */
  80542. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80543. /**
  80544. * Get the local position of a point that is in world space and copy it to the result param
  80545. * @param position The world position
  80546. * @param mesh The mesh that this bone is attached to
  80547. * @param result The vector3 that the local position should be copied to
  80548. */
  80549. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80550. }
  80551. }
  80552. declare module BABYLON {
  80553. /**
  80554. * 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.
  80555. * @see https://doc.babylonjs.com/how_to/transformnode
  80556. */
  80557. export class TransformNode extends Node {
  80558. /**
  80559. * Object will not rotate to face the camera
  80560. */
  80561. static BILLBOARDMODE_NONE: number;
  80562. /**
  80563. * Object will rotate to face the camera but only on the x axis
  80564. */
  80565. static BILLBOARDMODE_X: number;
  80566. /**
  80567. * Object will rotate to face the camera but only on the y axis
  80568. */
  80569. static BILLBOARDMODE_Y: number;
  80570. /**
  80571. * Object will rotate to face the camera but only on the z axis
  80572. */
  80573. static BILLBOARDMODE_Z: number;
  80574. /**
  80575. * Object will rotate to face the camera
  80576. */
  80577. static BILLBOARDMODE_ALL: number;
  80578. /**
  80579. * Object will rotate to face the camera's position instead of orientation
  80580. */
  80581. static BILLBOARDMODE_USE_POSITION: number;
  80582. private _forward;
  80583. private _forwardInverted;
  80584. private _up;
  80585. private _right;
  80586. private _rightInverted;
  80587. private _position;
  80588. private _rotation;
  80589. private _rotationQuaternion;
  80590. protected _scaling: Vector3;
  80591. protected _isDirty: boolean;
  80592. private _transformToBoneReferal;
  80593. private _isAbsoluteSynced;
  80594. private _billboardMode;
  80595. /**
  80596. * Gets or sets the billboard mode. Default is 0.
  80597. *
  80598. * | Value | Type | Description |
  80599. * | --- | --- | --- |
  80600. * | 0 | BILLBOARDMODE_NONE | |
  80601. * | 1 | BILLBOARDMODE_X | |
  80602. * | 2 | BILLBOARDMODE_Y | |
  80603. * | 4 | BILLBOARDMODE_Z | |
  80604. * | 7 | BILLBOARDMODE_ALL | |
  80605. *
  80606. */
  80607. billboardMode: number;
  80608. private _preserveParentRotationForBillboard;
  80609. /**
  80610. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80611. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80612. */
  80613. preserveParentRotationForBillboard: boolean;
  80614. /**
  80615. * 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
  80616. */
  80617. scalingDeterminant: number;
  80618. private _infiniteDistance;
  80619. /**
  80620. * Gets or sets the distance of the object to max, often used by skybox
  80621. */
  80622. infiniteDistance: boolean;
  80623. /**
  80624. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80625. * By default the system will update normals to compensate
  80626. */
  80627. ignoreNonUniformScaling: boolean;
  80628. /**
  80629. * 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
  80630. */
  80631. reIntegrateRotationIntoRotationQuaternion: boolean;
  80632. /** @hidden */
  80633. _poseMatrix: Nullable<Matrix>;
  80634. /** @hidden */
  80635. _localMatrix: Matrix;
  80636. private _usePivotMatrix;
  80637. private _absolutePosition;
  80638. private _absoluteScaling;
  80639. private _absoluteRotationQuaternion;
  80640. private _pivotMatrix;
  80641. private _pivotMatrixInverse;
  80642. protected _postMultiplyPivotMatrix: boolean;
  80643. protected _isWorldMatrixFrozen: boolean;
  80644. /** @hidden */
  80645. _indexInSceneTransformNodesArray: number;
  80646. /**
  80647. * An event triggered after the world matrix is updated
  80648. */
  80649. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80650. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80651. /**
  80652. * Gets a string identifying the name of the class
  80653. * @returns "TransformNode" string
  80654. */
  80655. getClassName(): string;
  80656. /**
  80657. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80658. */
  80659. position: Vector3;
  80660. /**
  80661. * 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)).
  80662. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80663. */
  80664. rotation: Vector3;
  80665. /**
  80666. * 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)).
  80667. */
  80668. scaling: Vector3;
  80669. /**
  80670. * 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).
  80671. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80672. */
  80673. rotationQuaternion: Nullable<Quaternion>;
  80674. /**
  80675. * The forward direction of that transform in world space.
  80676. */
  80677. readonly forward: Vector3;
  80678. /**
  80679. * The up direction of that transform in world space.
  80680. */
  80681. readonly up: Vector3;
  80682. /**
  80683. * The right direction of that transform in world space.
  80684. */
  80685. readonly right: Vector3;
  80686. /**
  80687. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80688. * @param matrix the matrix to copy the pose from
  80689. * @returns this TransformNode.
  80690. */
  80691. updatePoseMatrix(matrix: Matrix): TransformNode;
  80692. /**
  80693. * Returns the mesh Pose matrix.
  80694. * @returns the pose matrix
  80695. */
  80696. getPoseMatrix(): Matrix;
  80697. /** @hidden */
  80698. _isSynchronized(): boolean;
  80699. /** @hidden */
  80700. _initCache(): void;
  80701. /**
  80702. * Flag the transform node as dirty (Forcing it to update everything)
  80703. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80704. * @returns this transform node
  80705. */
  80706. markAsDirty(property: string): TransformNode;
  80707. /**
  80708. * Returns the current mesh absolute position.
  80709. * Returns a Vector3.
  80710. */
  80711. readonly absolutePosition: Vector3;
  80712. /**
  80713. * Returns the current mesh absolute scaling.
  80714. * Returns a Vector3.
  80715. */
  80716. readonly absoluteScaling: Vector3;
  80717. /**
  80718. * Returns the current mesh absolute rotation.
  80719. * Returns a Quaternion.
  80720. */
  80721. readonly absoluteRotationQuaternion: Quaternion;
  80722. /**
  80723. * Sets a new matrix to apply before all other transformation
  80724. * @param matrix defines the transform matrix
  80725. * @returns the current TransformNode
  80726. */
  80727. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80728. /**
  80729. * Sets a new pivot matrix to the current node
  80730. * @param matrix defines the new pivot matrix to use
  80731. * @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
  80732. * @returns the current TransformNode
  80733. */
  80734. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80735. /**
  80736. * Returns the mesh pivot matrix.
  80737. * Default : Identity.
  80738. * @returns the matrix
  80739. */
  80740. getPivotMatrix(): Matrix;
  80741. /**
  80742. * Instantiate (when possible) or clone that node with its hierarchy
  80743. * @param newParent defines the new parent to use for the instance (or clone)
  80744. * @returns an instance (or a clone) of the current node with its hiearchy
  80745. */
  80746. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80747. /**
  80748. * Prevents the World matrix to be computed any longer
  80749. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80750. * @returns the TransformNode.
  80751. */
  80752. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80753. /**
  80754. * Allows back the World matrix computation.
  80755. * @returns the TransformNode.
  80756. */
  80757. unfreezeWorldMatrix(): this;
  80758. /**
  80759. * True if the World matrix has been frozen.
  80760. */
  80761. readonly isWorldMatrixFrozen: boolean;
  80762. /**
  80763. * Retuns the mesh absolute position in the World.
  80764. * @returns a Vector3.
  80765. */
  80766. getAbsolutePosition(): Vector3;
  80767. /**
  80768. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80769. * @param absolutePosition the absolute position to set
  80770. * @returns the TransformNode.
  80771. */
  80772. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80773. /**
  80774. * Sets the mesh position in its local space.
  80775. * @param vector3 the position to set in localspace
  80776. * @returns the TransformNode.
  80777. */
  80778. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80779. /**
  80780. * Returns the mesh position in the local space from the current World matrix values.
  80781. * @returns a new Vector3.
  80782. */
  80783. getPositionExpressedInLocalSpace(): Vector3;
  80784. /**
  80785. * Translates the mesh along the passed Vector3 in its local space.
  80786. * @param vector3 the distance to translate in localspace
  80787. * @returns the TransformNode.
  80788. */
  80789. locallyTranslate(vector3: Vector3): TransformNode;
  80790. private static _lookAtVectorCache;
  80791. /**
  80792. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80793. * @param targetPoint the position (must be in same space as current mesh) to look at
  80794. * @param yawCor optional yaw (y-axis) correction in radians
  80795. * @param pitchCor optional pitch (x-axis) correction in radians
  80796. * @param rollCor optional roll (z-axis) correction in radians
  80797. * @param space the choosen space of the target
  80798. * @returns the TransformNode.
  80799. */
  80800. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80801. /**
  80802. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80803. * This Vector3 is expressed in the World space.
  80804. * @param localAxis axis to rotate
  80805. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80806. */
  80807. getDirection(localAxis: Vector3): Vector3;
  80808. /**
  80809. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80810. * localAxis is expressed in the mesh local space.
  80811. * result is computed in the Wordl space from the mesh World matrix.
  80812. * @param localAxis axis to rotate
  80813. * @param result the resulting transformnode
  80814. * @returns this TransformNode.
  80815. */
  80816. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80817. /**
  80818. * Sets this transform node rotation to the given local axis.
  80819. * @param localAxis the axis in local space
  80820. * @param yawCor optional yaw (y-axis) correction in radians
  80821. * @param pitchCor optional pitch (x-axis) correction in radians
  80822. * @param rollCor optional roll (z-axis) correction in radians
  80823. * @returns this TransformNode
  80824. */
  80825. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80826. /**
  80827. * Sets a new pivot point to the current node
  80828. * @param point defines the new pivot point to use
  80829. * @param space defines if the point is in world or local space (local by default)
  80830. * @returns the current TransformNode
  80831. */
  80832. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80833. /**
  80834. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80835. * @returns the pivot point
  80836. */
  80837. getPivotPoint(): Vector3;
  80838. /**
  80839. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80840. * @param result the vector3 to store the result
  80841. * @returns this TransformNode.
  80842. */
  80843. getPivotPointToRef(result: Vector3): TransformNode;
  80844. /**
  80845. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80846. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80847. */
  80848. getAbsolutePivotPoint(): Vector3;
  80849. /**
  80850. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80851. * @param result vector3 to store the result
  80852. * @returns this TransformNode.
  80853. */
  80854. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80855. /**
  80856. * Defines the passed node as the parent of the current node.
  80857. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80858. * @see https://doc.babylonjs.com/how_to/parenting
  80859. * @param node the node ot set as the parent
  80860. * @returns this TransformNode.
  80861. */
  80862. setParent(node: Nullable<Node>): TransformNode;
  80863. private _nonUniformScaling;
  80864. /**
  80865. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80866. */
  80867. readonly nonUniformScaling: boolean;
  80868. /** @hidden */
  80869. _updateNonUniformScalingState(value: boolean): boolean;
  80870. /**
  80871. * Attach the current TransformNode to another TransformNode associated with a bone
  80872. * @param bone Bone affecting the TransformNode
  80873. * @param affectedTransformNode TransformNode associated with the bone
  80874. * @returns this object
  80875. */
  80876. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80877. /**
  80878. * Detach the transform node if its associated with a bone
  80879. * @returns this object
  80880. */
  80881. detachFromBone(): TransformNode;
  80882. private static _rotationAxisCache;
  80883. /**
  80884. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80885. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80886. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80887. * The passed axis is also normalized.
  80888. * @param axis the axis to rotate around
  80889. * @param amount the amount to rotate in radians
  80890. * @param space Space to rotate in (Default: local)
  80891. * @returns the TransformNode.
  80892. */
  80893. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80894. /**
  80895. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80896. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80897. * The passed axis is also normalized. .
  80898. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80899. * @param point the point to rotate around
  80900. * @param axis the axis to rotate around
  80901. * @param amount the amount to rotate in radians
  80902. * @returns the TransformNode
  80903. */
  80904. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  80905. /**
  80906. * Translates the mesh along the axis vector for the passed distance in the given space.
  80907. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80908. * @param axis the axis to translate in
  80909. * @param distance the distance to translate
  80910. * @param space Space to rotate in (Default: local)
  80911. * @returns the TransformNode.
  80912. */
  80913. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  80914. /**
  80915. * Adds a rotation step to the mesh current rotation.
  80916. * x, y, z are Euler angles expressed in radians.
  80917. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  80918. * This means this rotation is made in the mesh local space only.
  80919. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  80920. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  80921. * ```javascript
  80922. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  80923. * ```
  80924. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  80925. * 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.
  80926. * @param x Rotation to add
  80927. * @param y Rotation to add
  80928. * @param z Rotation to add
  80929. * @returns the TransformNode.
  80930. */
  80931. addRotation(x: number, y: number, z: number): TransformNode;
  80932. /**
  80933. * @hidden
  80934. */
  80935. protected _getEffectiveParent(): Nullable<Node>;
  80936. /**
  80937. * Computes the world matrix of the node
  80938. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  80939. * @returns the world matrix
  80940. */
  80941. computeWorldMatrix(force?: boolean): Matrix;
  80942. protected _afterComputeWorldMatrix(): void;
  80943. /**
  80944. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  80945. * @param func callback function to add
  80946. *
  80947. * @returns the TransformNode.
  80948. */
  80949. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80950. /**
  80951. * Removes a registered callback function.
  80952. * @param func callback function to remove
  80953. * @returns the TransformNode.
  80954. */
  80955. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  80956. /**
  80957. * Gets the position of the current mesh in camera space
  80958. * @param camera defines the camera to use
  80959. * @returns a position
  80960. */
  80961. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  80962. /**
  80963. * Returns the distance from the mesh to the active camera
  80964. * @param camera defines the camera to use
  80965. * @returns the distance
  80966. */
  80967. getDistanceToCamera(camera?: Nullable<Camera>): number;
  80968. /**
  80969. * Clone the current transform node
  80970. * @param name Name of the new clone
  80971. * @param newParent New parent for the clone
  80972. * @param doNotCloneChildren Do not clone children hierarchy
  80973. * @returns the new transform node
  80974. */
  80975. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  80976. /**
  80977. * Serializes the objects information.
  80978. * @param currentSerializationObject defines the object to serialize in
  80979. * @returns the serialized object
  80980. */
  80981. serialize(currentSerializationObject?: any): any;
  80982. /**
  80983. * Returns a new TransformNode object parsed from the source provided.
  80984. * @param parsedTransformNode is the source.
  80985. * @param scene the scne the object belongs to
  80986. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  80987. * @returns a new TransformNode object parsed from the source provided.
  80988. */
  80989. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  80990. /**
  80991. * Get all child-transformNodes of this node
  80992. * @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
  80993. * @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
  80994. * @returns an array of TransformNode
  80995. */
  80996. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  80997. /**
  80998. * Releases resources associated with this transform node.
  80999. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81000. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81001. */
  81002. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81003. /**
  81004. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81005. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81006. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81007. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81008. * @returns the current mesh
  81009. */
  81010. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81011. private _syncAbsoluteScalingAndRotation;
  81012. }
  81013. }
  81014. declare module BABYLON {
  81015. /**
  81016. * Defines the types of pose enabled controllers that are supported
  81017. */
  81018. export enum PoseEnabledControllerType {
  81019. /**
  81020. * HTC Vive
  81021. */
  81022. VIVE = 0,
  81023. /**
  81024. * Oculus Rift
  81025. */
  81026. OCULUS = 1,
  81027. /**
  81028. * Windows mixed reality
  81029. */
  81030. WINDOWS = 2,
  81031. /**
  81032. * Samsung gear VR
  81033. */
  81034. GEAR_VR = 3,
  81035. /**
  81036. * Google Daydream
  81037. */
  81038. DAYDREAM = 4,
  81039. /**
  81040. * Generic
  81041. */
  81042. GENERIC = 5
  81043. }
  81044. /**
  81045. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81046. */
  81047. export interface MutableGamepadButton {
  81048. /**
  81049. * Value of the button/trigger
  81050. */
  81051. value: number;
  81052. /**
  81053. * If the button/trigger is currently touched
  81054. */
  81055. touched: boolean;
  81056. /**
  81057. * If the button/trigger is currently pressed
  81058. */
  81059. pressed: boolean;
  81060. }
  81061. /**
  81062. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81063. * @hidden
  81064. */
  81065. export interface ExtendedGamepadButton extends GamepadButton {
  81066. /**
  81067. * If the button/trigger is currently pressed
  81068. */
  81069. readonly pressed: boolean;
  81070. /**
  81071. * If the button/trigger is currently touched
  81072. */
  81073. readonly touched: boolean;
  81074. /**
  81075. * Value of the button/trigger
  81076. */
  81077. readonly value: number;
  81078. }
  81079. /** @hidden */
  81080. export interface _GamePadFactory {
  81081. /**
  81082. * Returns wether or not the current gamepad can be created for this type of controller.
  81083. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81084. * @returns true if it can be created, otherwise false
  81085. */
  81086. canCreate(gamepadInfo: any): boolean;
  81087. /**
  81088. * Creates a new instance of the Gamepad.
  81089. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81090. * @returns the new gamepad instance
  81091. */
  81092. create(gamepadInfo: any): Gamepad;
  81093. }
  81094. /**
  81095. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81096. */
  81097. export class PoseEnabledControllerHelper {
  81098. /** @hidden */
  81099. static _ControllerFactories: _GamePadFactory[];
  81100. /** @hidden */
  81101. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81102. /**
  81103. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81104. * @param vrGamepad the gamepad to initialized
  81105. * @returns a vr controller of the type the gamepad identified as
  81106. */
  81107. static InitiateController(vrGamepad: any): Gamepad;
  81108. }
  81109. /**
  81110. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81111. */
  81112. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81113. /**
  81114. * If the controller is used in a webXR session
  81115. */
  81116. isXR: boolean;
  81117. private _deviceRoomPosition;
  81118. private _deviceRoomRotationQuaternion;
  81119. /**
  81120. * The device position in babylon space
  81121. */
  81122. devicePosition: Vector3;
  81123. /**
  81124. * The device rotation in babylon space
  81125. */
  81126. deviceRotationQuaternion: Quaternion;
  81127. /**
  81128. * The scale factor of the device in babylon space
  81129. */
  81130. deviceScaleFactor: number;
  81131. /**
  81132. * (Likely devicePosition should be used instead) The device position in its room space
  81133. */
  81134. position: Vector3;
  81135. /**
  81136. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81137. */
  81138. rotationQuaternion: Quaternion;
  81139. /**
  81140. * The type of controller (Eg. Windows mixed reality)
  81141. */
  81142. controllerType: PoseEnabledControllerType;
  81143. protected _calculatedPosition: Vector3;
  81144. private _calculatedRotation;
  81145. /**
  81146. * The raw pose from the device
  81147. */
  81148. rawPose: DevicePose;
  81149. private _trackPosition;
  81150. private _maxRotationDistFromHeadset;
  81151. private _draggedRoomRotation;
  81152. /**
  81153. * @hidden
  81154. */
  81155. _disableTrackPosition(fixedPosition: Vector3): void;
  81156. /**
  81157. * Internal, the mesh attached to the controller
  81158. * @hidden
  81159. */
  81160. _mesh: Nullable<AbstractMesh>;
  81161. private _poseControlledCamera;
  81162. private _leftHandSystemQuaternion;
  81163. /**
  81164. * Internal, matrix used to convert room space to babylon space
  81165. * @hidden
  81166. */
  81167. _deviceToWorld: Matrix;
  81168. /**
  81169. * Node to be used when casting a ray from the controller
  81170. * @hidden
  81171. */
  81172. _pointingPoseNode: Nullable<TransformNode>;
  81173. /**
  81174. * Name of the child mesh that can be used to cast a ray from the controller
  81175. */
  81176. static readonly POINTING_POSE: string;
  81177. /**
  81178. * Creates a new PoseEnabledController from a gamepad
  81179. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81180. */
  81181. constructor(browserGamepad: any);
  81182. private _workingMatrix;
  81183. /**
  81184. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81185. */
  81186. update(): void;
  81187. /**
  81188. * Updates only the pose device and mesh without doing any button event checking
  81189. */
  81190. protected _updatePoseAndMesh(): void;
  81191. /**
  81192. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81193. * @param poseData raw pose fromthe device
  81194. */
  81195. updateFromDevice(poseData: DevicePose): void;
  81196. /**
  81197. * @hidden
  81198. */
  81199. _meshAttachedObservable: Observable<AbstractMesh>;
  81200. /**
  81201. * Attaches a mesh to the controller
  81202. * @param mesh the mesh to be attached
  81203. */
  81204. attachToMesh(mesh: AbstractMesh): void;
  81205. /**
  81206. * Attaches the controllers mesh to a camera
  81207. * @param camera the camera the mesh should be attached to
  81208. */
  81209. attachToPoseControlledCamera(camera: TargetCamera): void;
  81210. /**
  81211. * Disposes of the controller
  81212. */
  81213. dispose(): void;
  81214. /**
  81215. * The mesh that is attached to the controller
  81216. */
  81217. readonly mesh: Nullable<AbstractMesh>;
  81218. /**
  81219. * Gets the ray of the controller in the direction the controller is pointing
  81220. * @param length the length the resulting ray should be
  81221. * @returns a ray in the direction the controller is pointing
  81222. */
  81223. getForwardRay(length?: number): Ray;
  81224. }
  81225. }
  81226. declare module BABYLON {
  81227. /**
  81228. * Defines the WebVRController object that represents controllers tracked in 3D space
  81229. */
  81230. export abstract class WebVRController extends PoseEnabledController {
  81231. /**
  81232. * Internal, the default controller model for the controller
  81233. */
  81234. protected _defaultModel: Nullable<AbstractMesh>;
  81235. /**
  81236. * Fired when the trigger state has changed
  81237. */
  81238. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81239. /**
  81240. * Fired when the main button state has changed
  81241. */
  81242. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81243. /**
  81244. * Fired when the secondary button state has changed
  81245. */
  81246. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81247. /**
  81248. * Fired when the pad state has changed
  81249. */
  81250. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81251. /**
  81252. * Fired when controllers stick values have changed
  81253. */
  81254. onPadValuesChangedObservable: Observable<StickValues>;
  81255. /**
  81256. * Array of button availible on the controller
  81257. */
  81258. protected _buttons: Array<MutableGamepadButton>;
  81259. private _onButtonStateChange;
  81260. /**
  81261. * Fired when a controller button's state has changed
  81262. * @param callback the callback containing the button that was modified
  81263. */
  81264. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81265. /**
  81266. * X and Y axis corresponding to the controllers joystick
  81267. */
  81268. pad: StickValues;
  81269. /**
  81270. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81271. */
  81272. hand: string;
  81273. /**
  81274. * The default controller model for the controller
  81275. */
  81276. readonly defaultModel: Nullable<AbstractMesh>;
  81277. /**
  81278. * Creates a new WebVRController from a gamepad
  81279. * @param vrGamepad the gamepad that the WebVRController should be created from
  81280. */
  81281. constructor(vrGamepad: any);
  81282. /**
  81283. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81284. */
  81285. update(): void;
  81286. /**
  81287. * Function to be called when a button is modified
  81288. */
  81289. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81290. /**
  81291. * Loads a mesh and attaches it to the controller
  81292. * @param scene the scene the mesh should be added to
  81293. * @param meshLoaded callback for when the mesh has been loaded
  81294. */
  81295. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81296. private _setButtonValue;
  81297. private _changes;
  81298. private _checkChanges;
  81299. /**
  81300. * Disposes of th webVRCOntroller
  81301. */
  81302. dispose(): void;
  81303. }
  81304. }
  81305. declare module BABYLON {
  81306. /**
  81307. * The HemisphericLight simulates the ambient environment light,
  81308. * so the passed direction is the light reflection direction, not the incoming direction.
  81309. */
  81310. export class HemisphericLight extends Light {
  81311. /**
  81312. * The groundColor is the light in the opposite direction to the one specified during creation.
  81313. * 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.
  81314. */
  81315. groundColor: Color3;
  81316. /**
  81317. * The light reflection direction, not the incoming direction.
  81318. */
  81319. direction: Vector3;
  81320. /**
  81321. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81322. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81323. * The HemisphericLight can't cast shadows.
  81324. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81325. * @param name The friendly name of the light
  81326. * @param direction The direction of the light reflection
  81327. * @param scene The scene the light belongs to
  81328. */
  81329. constructor(name: string, direction: Vector3, scene: Scene);
  81330. protected _buildUniformLayout(): void;
  81331. /**
  81332. * Returns the string "HemisphericLight".
  81333. * @return The class name
  81334. */
  81335. getClassName(): string;
  81336. /**
  81337. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81338. * Returns the updated direction.
  81339. * @param target The target the direction should point to
  81340. * @return The computed direction
  81341. */
  81342. setDirectionToTarget(target: Vector3): Vector3;
  81343. /**
  81344. * Returns the shadow generator associated to the light.
  81345. * @returns Always null for hemispheric lights because it does not support shadows.
  81346. */
  81347. getShadowGenerator(): Nullable<IShadowGenerator>;
  81348. /**
  81349. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81350. * @param effect The effect to update
  81351. * @param lightIndex The index of the light in the effect to update
  81352. * @returns The hemispheric light
  81353. */
  81354. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81355. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81356. /**
  81357. * Computes the world matrix of the node
  81358. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81359. * @param useWasUpdatedFlag defines a reserved property
  81360. * @returns the world matrix
  81361. */
  81362. computeWorldMatrix(): Matrix;
  81363. /**
  81364. * Returns the integer 3.
  81365. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81366. */
  81367. getTypeID(): number;
  81368. /**
  81369. * Prepares the list of defines specific to the light type.
  81370. * @param defines the list of defines
  81371. * @param lightIndex defines the index of the light for the effect
  81372. */
  81373. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81374. }
  81375. }
  81376. declare module BABYLON {
  81377. /** @hidden */
  81378. export var vrMultiviewToSingleviewPixelShader: {
  81379. name: string;
  81380. shader: string;
  81381. };
  81382. }
  81383. declare module BABYLON {
  81384. /**
  81385. * Renders to multiple views with a single draw call
  81386. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81387. */
  81388. export class MultiviewRenderTarget extends RenderTargetTexture {
  81389. /**
  81390. * Creates a multiview render target
  81391. * @param scene scene used with the render target
  81392. * @param size the size of the render target (used for each view)
  81393. */
  81394. constructor(scene: Scene, size?: number | {
  81395. width: number;
  81396. height: number;
  81397. } | {
  81398. ratio: number;
  81399. });
  81400. /**
  81401. * @hidden
  81402. * @param faceIndex the face index, if its a cube texture
  81403. */
  81404. _bindFrameBuffer(faceIndex?: number): void;
  81405. /**
  81406. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81407. * @returns the view count
  81408. */
  81409. getViewCount(): number;
  81410. }
  81411. }
  81412. declare module BABYLON {
  81413. /**
  81414. * Represents a camera frustum
  81415. */
  81416. export class Frustum {
  81417. /**
  81418. * Gets the planes representing the frustum
  81419. * @param transform matrix to be applied to the returned planes
  81420. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81421. */
  81422. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81423. /**
  81424. * Gets the near frustum plane transformed by the transform matrix
  81425. * @param transform transformation matrix to be applied to the resulting frustum plane
  81426. * @param frustumPlane the resuling frustum plane
  81427. */
  81428. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81429. /**
  81430. * Gets the far frustum plane transformed by the transform matrix
  81431. * @param transform transformation matrix to be applied to the resulting frustum plane
  81432. * @param frustumPlane the resuling frustum plane
  81433. */
  81434. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81435. /**
  81436. * Gets the left frustum plane transformed by the transform matrix
  81437. * @param transform transformation matrix to be applied to the resulting frustum plane
  81438. * @param frustumPlane the resuling frustum plane
  81439. */
  81440. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81441. /**
  81442. * Gets the right frustum plane transformed by the transform matrix
  81443. * @param transform transformation matrix to be applied to the resulting frustum plane
  81444. * @param frustumPlane the resuling frustum plane
  81445. */
  81446. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81447. /**
  81448. * Gets the top frustum plane transformed by the transform matrix
  81449. * @param transform transformation matrix to be applied to the resulting frustum plane
  81450. * @param frustumPlane the resuling frustum plane
  81451. */
  81452. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81453. /**
  81454. * Gets the bottom frustum plane transformed by the transform matrix
  81455. * @param transform transformation matrix to be applied to the resulting frustum plane
  81456. * @param frustumPlane the resuling frustum plane
  81457. */
  81458. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81459. /**
  81460. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81461. * @param transform transformation matrix to be applied to the resulting frustum planes
  81462. * @param frustumPlanes the resuling frustum planes
  81463. */
  81464. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81465. }
  81466. }
  81467. declare module BABYLON {
  81468. interface Engine {
  81469. /**
  81470. * Creates a new multiview render target
  81471. * @param width defines the width of the texture
  81472. * @param height defines the height of the texture
  81473. * @returns the created multiview texture
  81474. */
  81475. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81476. /**
  81477. * Binds a multiview framebuffer to be drawn to
  81478. * @param multiviewTexture texture to bind
  81479. */
  81480. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81481. }
  81482. interface Camera {
  81483. /**
  81484. * @hidden
  81485. * 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)
  81486. */
  81487. _useMultiviewToSingleView: boolean;
  81488. /**
  81489. * @hidden
  81490. * 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)
  81491. */
  81492. _multiviewTexture: Nullable<RenderTargetTexture>;
  81493. /**
  81494. * @hidden
  81495. * ensures the multiview texture of the camera exists and has the specified width/height
  81496. * @param width height to set on the multiview texture
  81497. * @param height width to set on the multiview texture
  81498. */
  81499. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81500. }
  81501. interface Scene {
  81502. /** @hidden */
  81503. _transformMatrixR: Matrix;
  81504. /** @hidden */
  81505. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81506. /** @hidden */
  81507. _createMultiviewUbo(): void;
  81508. /** @hidden */
  81509. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81510. /** @hidden */
  81511. _renderMultiviewToSingleView(camera: Camera): void;
  81512. }
  81513. }
  81514. declare module BABYLON {
  81515. /**
  81516. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81517. * This will not be used for webXR as it supports displaying texture arrays directly
  81518. */
  81519. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81520. /**
  81521. * Initializes a VRMultiviewToSingleview
  81522. * @param name name of the post process
  81523. * @param camera camera to be applied to
  81524. * @param scaleFactor scaling factor to the size of the output texture
  81525. */
  81526. constructor(name: string, camera: Camera, scaleFactor: number);
  81527. }
  81528. }
  81529. declare module BABYLON {
  81530. interface Engine {
  81531. /** @hidden */
  81532. _vrDisplay: any;
  81533. /** @hidden */
  81534. _vrSupported: boolean;
  81535. /** @hidden */
  81536. _oldSize: Size;
  81537. /** @hidden */
  81538. _oldHardwareScaleFactor: number;
  81539. /** @hidden */
  81540. _vrExclusivePointerMode: boolean;
  81541. /** @hidden */
  81542. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81543. /** @hidden */
  81544. _onVRDisplayPointerRestricted: () => void;
  81545. /** @hidden */
  81546. _onVRDisplayPointerUnrestricted: () => void;
  81547. /** @hidden */
  81548. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81549. /** @hidden */
  81550. _onVrDisplayDisconnect: Nullable<() => void>;
  81551. /** @hidden */
  81552. _onVrDisplayPresentChange: Nullable<() => void>;
  81553. /**
  81554. * Observable signaled when VR display mode changes
  81555. */
  81556. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81557. /**
  81558. * Observable signaled when VR request present is complete
  81559. */
  81560. onVRRequestPresentComplete: Observable<boolean>;
  81561. /**
  81562. * Observable signaled when VR request present starts
  81563. */
  81564. onVRRequestPresentStart: Observable<Engine>;
  81565. /**
  81566. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81567. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81568. */
  81569. isInVRExclusivePointerMode: boolean;
  81570. /**
  81571. * Gets a boolean indicating if a webVR device was detected
  81572. * @returns true if a webVR device was detected
  81573. */
  81574. isVRDevicePresent(): boolean;
  81575. /**
  81576. * Gets the current webVR device
  81577. * @returns the current webVR device (or null)
  81578. */
  81579. getVRDevice(): any;
  81580. /**
  81581. * Initializes a webVR display and starts listening to display change events
  81582. * The onVRDisplayChangedObservable will be notified upon these changes
  81583. * @returns A promise containing a VRDisplay and if vr is supported
  81584. */
  81585. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81586. /** @hidden */
  81587. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81588. /**
  81589. * Call this function to switch to webVR mode
  81590. * Will do nothing if webVR is not supported or if there is no webVR device
  81591. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81592. */
  81593. enableVR(): void;
  81594. /** @hidden */
  81595. _onVRFullScreenTriggered(): void;
  81596. }
  81597. }
  81598. declare module BABYLON {
  81599. /**
  81600. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81601. * IMPORTANT!! The data is right-hand data.
  81602. * @export
  81603. * @interface DevicePose
  81604. */
  81605. export interface DevicePose {
  81606. /**
  81607. * The position of the device, values in array are [x,y,z].
  81608. */
  81609. readonly position: Nullable<Float32Array>;
  81610. /**
  81611. * The linearVelocity of the device, values in array are [x,y,z].
  81612. */
  81613. readonly linearVelocity: Nullable<Float32Array>;
  81614. /**
  81615. * The linearAcceleration of the device, values in array are [x,y,z].
  81616. */
  81617. readonly linearAcceleration: Nullable<Float32Array>;
  81618. /**
  81619. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81620. */
  81621. readonly orientation: Nullable<Float32Array>;
  81622. /**
  81623. * The angularVelocity of the device, values in array are [x,y,z].
  81624. */
  81625. readonly angularVelocity: Nullable<Float32Array>;
  81626. /**
  81627. * The angularAcceleration of the device, values in array are [x,y,z].
  81628. */
  81629. readonly angularAcceleration: Nullable<Float32Array>;
  81630. }
  81631. /**
  81632. * Interface representing a pose controlled object in Babylon.
  81633. * A pose controlled object has both regular pose values as well as pose values
  81634. * from an external device such as a VR head mounted display
  81635. */
  81636. export interface PoseControlled {
  81637. /**
  81638. * The position of the object in babylon space.
  81639. */
  81640. position: Vector3;
  81641. /**
  81642. * The rotation quaternion of the object in babylon space.
  81643. */
  81644. rotationQuaternion: Quaternion;
  81645. /**
  81646. * The position of the device in babylon space.
  81647. */
  81648. devicePosition?: Vector3;
  81649. /**
  81650. * The rotation quaternion of the device in babylon space.
  81651. */
  81652. deviceRotationQuaternion: Quaternion;
  81653. /**
  81654. * The raw pose coming from the device.
  81655. */
  81656. rawPose: Nullable<DevicePose>;
  81657. /**
  81658. * The scale of the device to be used when translating from device space to babylon space.
  81659. */
  81660. deviceScaleFactor: number;
  81661. /**
  81662. * Updates the poseControlled values based on the input device pose.
  81663. * @param poseData the pose data to update the object with
  81664. */
  81665. updateFromDevice(poseData: DevicePose): void;
  81666. }
  81667. /**
  81668. * Set of options to customize the webVRCamera
  81669. */
  81670. export interface WebVROptions {
  81671. /**
  81672. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81673. */
  81674. trackPosition?: boolean;
  81675. /**
  81676. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81677. */
  81678. positionScale?: number;
  81679. /**
  81680. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81681. */
  81682. displayName?: string;
  81683. /**
  81684. * Should the native controller meshes be initialized. (default: true)
  81685. */
  81686. controllerMeshes?: boolean;
  81687. /**
  81688. * Creating a default HemiLight only on controllers. (default: true)
  81689. */
  81690. defaultLightingOnControllers?: boolean;
  81691. /**
  81692. * If you don't want to use the default VR button of the helper. (default: false)
  81693. */
  81694. useCustomVRButton?: boolean;
  81695. /**
  81696. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81697. */
  81698. customVRButton?: HTMLButtonElement;
  81699. /**
  81700. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81701. */
  81702. rayLength?: number;
  81703. /**
  81704. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81705. */
  81706. defaultHeight?: number;
  81707. /**
  81708. * If multiview should be used if availible (default: false)
  81709. */
  81710. useMultiview?: boolean;
  81711. }
  81712. /**
  81713. * This represents a WebVR camera.
  81714. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81715. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81716. */
  81717. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81718. private webVROptions;
  81719. /**
  81720. * @hidden
  81721. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81722. */
  81723. _vrDevice: any;
  81724. /**
  81725. * The rawPose of the vrDevice.
  81726. */
  81727. rawPose: Nullable<DevicePose>;
  81728. private _onVREnabled;
  81729. private _specsVersion;
  81730. private _attached;
  81731. private _frameData;
  81732. protected _descendants: Array<Node>;
  81733. private _deviceRoomPosition;
  81734. /** @hidden */
  81735. _deviceRoomRotationQuaternion: Quaternion;
  81736. private _standingMatrix;
  81737. /**
  81738. * Represents device position in babylon space.
  81739. */
  81740. devicePosition: Vector3;
  81741. /**
  81742. * Represents device rotation in babylon space.
  81743. */
  81744. deviceRotationQuaternion: Quaternion;
  81745. /**
  81746. * The scale of the device to be used when translating from device space to babylon space.
  81747. */
  81748. deviceScaleFactor: number;
  81749. private _deviceToWorld;
  81750. private _worldToDevice;
  81751. /**
  81752. * References to the webVR controllers for the vrDevice.
  81753. */
  81754. controllers: Array<WebVRController>;
  81755. /**
  81756. * Emits an event when a controller is attached.
  81757. */
  81758. onControllersAttachedObservable: Observable<WebVRController[]>;
  81759. /**
  81760. * Emits an event when a controller's mesh has been loaded;
  81761. */
  81762. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81763. /**
  81764. * Emits an event when the HMD's pose has been updated.
  81765. */
  81766. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81767. private _poseSet;
  81768. /**
  81769. * If the rig cameras be used as parent instead of this camera.
  81770. */
  81771. rigParenting: boolean;
  81772. private _lightOnControllers;
  81773. private _defaultHeight?;
  81774. /**
  81775. * Instantiates a WebVRFreeCamera.
  81776. * @param name The name of the WebVRFreeCamera
  81777. * @param position The starting anchor position for the camera
  81778. * @param scene The scene the camera belongs to
  81779. * @param webVROptions a set of customizable options for the webVRCamera
  81780. */
  81781. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81782. /**
  81783. * Gets the device distance from the ground in meters.
  81784. * @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.
  81785. */
  81786. deviceDistanceToRoomGround(): number;
  81787. /**
  81788. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81789. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81790. */
  81791. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81792. /**
  81793. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81794. * @returns A promise with a boolean set to if the standing matrix is supported.
  81795. */
  81796. useStandingMatrixAsync(): Promise<boolean>;
  81797. /**
  81798. * Disposes the camera
  81799. */
  81800. dispose(): void;
  81801. /**
  81802. * Gets a vrController by name.
  81803. * @param name The name of the controller to retreive
  81804. * @returns the controller matching the name specified or null if not found
  81805. */
  81806. getControllerByName(name: string): Nullable<WebVRController>;
  81807. private _leftController;
  81808. /**
  81809. * The controller corresponding to the users left hand.
  81810. */
  81811. readonly leftController: Nullable<WebVRController>;
  81812. private _rightController;
  81813. /**
  81814. * The controller corresponding to the users right hand.
  81815. */
  81816. readonly rightController: Nullable<WebVRController>;
  81817. /**
  81818. * Casts a ray forward from the vrCamera's gaze.
  81819. * @param length Length of the ray (default: 100)
  81820. * @returns the ray corresponding to the gaze
  81821. */
  81822. getForwardRay(length?: number): Ray;
  81823. /**
  81824. * @hidden
  81825. * Updates the camera based on device's frame data
  81826. */
  81827. _checkInputs(): void;
  81828. /**
  81829. * Updates the poseControlled values based on the input device pose.
  81830. * @param poseData Pose coming from the device
  81831. */
  81832. updateFromDevice(poseData: DevicePose): void;
  81833. private _htmlElementAttached;
  81834. private _detachIfAttached;
  81835. /**
  81836. * WebVR's attach control will start broadcasting frames to the device.
  81837. * Note that in certain browsers (chrome for example) this function must be called
  81838. * within a user-interaction callback. Example:
  81839. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81840. *
  81841. * @param element html element to attach the vrDevice to
  81842. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81843. */
  81844. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81845. /**
  81846. * Detaches the camera from the html element and disables VR
  81847. *
  81848. * @param element html element to detach from
  81849. */
  81850. detachControl(element: HTMLElement): void;
  81851. /**
  81852. * @returns the name of this class
  81853. */
  81854. getClassName(): string;
  81855. /**
  81856. * Calls resetPose on the vrDisplay
  81857. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81858. */
  81859. resetToCurrentRotation(): void;
  81860. /**
  81861. * @hidden
  81862. * Updates the rig cameras (left and right eye)
  81863. */
  81864. _updateRigCameras(): void;
  81865. private _workingVector;
  81866. private _oneVector;
  81867. private _workingMatrix;
  81868. private updateCacheCalled;
  81869. private _correctPositionIfNotTrackPosition;
  81870. /**
  81871. * @hidden
  81872. * Updates the cached values of the camera
  81873. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81874. */
  81875. _updateCache(ignoreParentClass?: boolean): void;
  81876. /**
  81877. * @hidden
  81878. * Get current device position in babylon world
  81879. */
  81880. _computeDevicePosition(): void;
  81881. /**
  81882. * Updates the current device position and rotation in the babylon world
  81883. */
  81884. update(): void;
  81885. /**
  81886. * @hidden
  81887. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81888. * @returns an identity matrix
  81889. */
  81890. _getViewMatrix(): Matrix;
  81891. private _tmpMatrix;
  81892. /**
  81893. * This function is called by the two RIG cameras.
  81894. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81895. * @hidden
  81896. */
  81897. _getWebVRViewMatrix(): Matrix;
  81898. /** @hidden */
  81899. _getWebVRProjectionMatrix(): Matrix;
  81900. private _onGamepadConnectedObserver;
  81901. private _onGamepadDisconnectedObserver;
  81902. private _updateCacheWhenTrackingDisabledObserver;
  81903. /**
  81904. * Initializes the controllers and their meshes
  81905. */
  81906. initControllers(): void;
  81907. }
  81908. }
  81909. declare module BABYLON {
  81910. /**
  81911. * Size options for a post process
  81912. */
  81913. export type PostProcessOptions = {
  81914. width: number;
  81915. height: number;
  81916. };
  81917. /**
  81918. * PostProcess can be used to apply a shader to a texture after it has been rendered
  81919. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  81920. */
  81921. export class PostProcess {
  81922. /** Name of the PostProcess. */
  81923. name: string;
  81924. /**
  81925. * Gets or sets the unique id of the post process
  81926. */
  81927. uniqueId: number;
  81928. /**
  81929. * Width of the texture to apply the post process on
  81930. */
  81931. width: number;
  81932. /**
  81933. * Height of the texture to apply the post process on
  81934. */
  81935. height: number;
  81936. /**
  81937. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  81938. * @hidden
  81939. */
  81940. _outputTexture: Nullable<InternalTexture>;
  81941. /**
  81942. * Sampling mode used by the shader
  81943. * See https://doc.babylonjs.com/classes/3.1/texture
  81944. */
  81945. renderTargetSamplingMode: number;
  81946. /**
  81947. * Clear color to use when screen clearing
  81948. */
  81949. clearColor: Color4;
  81950. /**
  81951. * If the buffer needs to be cleared before applying the post process. (default: true)
  81952. * Should be set to false if shader will overwrite all previous pixels.
  81953. */
  81954. autoClear: boolean;
  81955. /**
  81956. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  81957. */
  81958. alphaMode: number;
  81959. /**
  81960. * Sets the setAlphaBlendConstants of the babylon engine
  81961. */
  81962. alphaConstants: Color4;
  81963. /**
  81964. * Animations to be used for the post processing
  81965. */
  81966. animations: Animation[];
  81967. /**
  81968. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  81969. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  81970. */
  81971. enablePixelPerfectMode: boolean;
  81972. /**
  81973. * Force the postprocess to be applied without taking in account viewport
  81974. */
  81975. forceFullscreenViewport: boolean;
  81976. /**
  81977. * List of inspectable custom properties (used by the Inspector)
  81978. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81979. */
  81980. inspectableCustomProperties: IInspectable[];
  81981. /**
  81982. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  81983. *
  81984. * | Value | Type | Description |
  81985. * | ----- | ----------------------------------- | ----------- |
  81986. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  81987. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  81988. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  81989. *
  81990. */
  81991. scaleMode: number;
  81992. /**
  81993. * Force textures to be a power of two (default: false)
  81994. */
  81995. alwaysForcePOT: boolean;
  81996. private _samples;
  81997. /**
  81998. * Number of sample textures (default: 1)
  81999. */
  82000. samples: number;
  82001. /**
  82002. * Modify the scale of the post process to be the same as the viewport (default: false)
  82003. */
  82004. adaptScaleToCurrentViewport: boolean;
  82005. private _camera;
  82006. private _scene;
  82007. private _engine;
  82008. private _options;
  82009. private _reusable;
  82010. private _textureType;
  82011. /**
  82012. * Smart array of input and output textures for the post process.
  82013. * @hidden
  82014. */
  82015. _textures: SmartArray<InternalTexture>;
  82016. /**
  82017. * The index in _textures that corresponds to the output texture.
  82018. * @hidden
  82019. */
  82020. _currentRenderTextureInd: number;
  82021. private _effect;
  82022. private _samplers;
  82023. private _fragmentUrl;
  82024. private _vertexUrl;
  82025. private _parameters;
  82026. private _scaleRatio;
  82027. protected _indexParameters: any;
  82028. private _shareOutputWithPostProcess;
  82029. private _texelSize;
  82030. private _forcedOutputTexture;
  82031. /**
  82032. * Returns the fragment url or shader name used in the post process.
  82033. * @returns the fragment url or name in the shader store.
  82034. */
  82035. getEffectName(): string;
  82036. /**
  82037. * An event triggered when the postprocess is activated.
  82038. */
  82039. onActivateObservable: Observable<Camera>;
  82040. private _onActivateObserver;
  82041. /**
  82042. * A function that is added to the onActivateObservable
  82043. */
  82044. onActivate: Nullable<(camera: Camera) => void>;
  82045. /**
  82046. * An event triggered when the postprocess changes its size.
  82047. */
  82048. onSizeChangedObservable: Observable<PostProcess>;
  82049. private _onSizeChangedObserver;
  82050. /**
  82051. * A function that is added to the onSizeChangedObservable
  82052. */
  82053. onSizeChanged: (postProcess: PostProcess) => void;
  82054. /**
  82055. * An event triggered when the postprocess applies its effect.
  82056. */
  82057. onApplyObservable: Observable<Effect>;
  82058. private _onApplyObserver;
  82059. /**
  82060. * A function that is added to the onApplyObservable
  82061. */
  82062. onApply: (effect: Effect) => void;
  82063. /**
  82064. * An event triggered before rendering the postprocess
  82065. */
  82066. onBeforeRenderObservable: Observable<Effect>;
  82067. private _onBeforeRenderObserver;
  82068. /**
  82069. * A function that is added to the onBeforeRenderObservable
  82070. */
  82071. onBeforeRender: (effect: Effect) => void;
  82072. /**
  82073. * An event triggered after rendering the postprocess
  82074. */
  82075. onAfterRenderObservable: Observable<Effect>;
  82076. private _onAfterRenderObserver;
  82077. /**
  82078. * A function that is added to the onAfterRenderObservable
  82079. */
  82080. onAfterRender: (efect: Effect) => void;
  82081. /**
  82082. * 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
  82083. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82084. */
  82085. inputTexture: InternalTexture;
  82086. /**
  82087. * Gets the camera which post process is applied to.
  82088. * @returns The camera the post process is applied to.
  82089. */
  82090. getCamera(): Camera;
  82091. /**
  82092. * Gets the texel size of the postprocess.
  82093. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82094. */
  82095. readonly texelSize: Vector2;
  82096. /**
  82097. * Creates a new instance PostProcess
  82098. * @param name The name of the PostProcess.
  82099. * @param fragmentUrl The url of the fragment shader to be used.
  82100. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82101. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82102. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82103. * @param camera The camera to apply the render pass to.
  82104. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82105. * @param engine The engine which the post process will be applied. (default: current engine)
  82106. * @param reusable If the post process can be reused on the same frame. (default: false)
  82107. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82108. * @param textureType Type of textures used when performing the post process. (default: 0)
  82109. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82110. * @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
  82111. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82112. */
  82113. constructor(
  82114. /** Name of the PostProcess. */
  82115. 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);
  82116. /**
  82117. * Gets a string idenfifying the name of the class
  82118. * @returns "PostProcess" string
  82119. */
  82120. getClassName(): string;
  82121. /**
  82122. * Gets the engine which this post process belongs to.
  82123. * @returns The engine the post process was enabled with.
  82124. */
  82125. getEngine(): Engine;
  82126. /**
  82127. * The effect that is created when initializing the post process.
  82128. * @returns The created effect corresponding the the postprocess.
  82129. */
  82130. getEffect(): Effect;
  82131. /**
  82132. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82133. * @param postProcess The post process to share the output with.
  82134. * @returns This post process.
  82135. */
  82136. shareOutputWith(postProcess: PostProcess): PostProcess;
  82137. /**
  82138. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82139. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82140. */
  82141. useOwnOutput(): void;
  82142. /**
  82143. * Updates the effect with the current post process compile time values and recompiles the shader.
  82144. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82145. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82146. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82147. * @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
  82148. * @param onCompiled Called when the shader has been compiled.
  82149. * @param onError Called if there is an error when compiling a shader.
  82150. */
  82151. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82152. /**
  82153. * The post process is reusable if it can be used multiple times within one frame.
  82154. * @returns If the post process is reusable
  82155. */
  82156. isReusable(): boolean;
  82157. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82158. markTextureDirty(): void;
  82159. /**
  82160. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82161. * 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.
  82162. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82163. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82164. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82165. * @returns The target texture that was bound to be written to.
  82166. */
  82167. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82168. /**
  82169. * If the post process is supported.
  82170. */
  82171. readonly isSupported: boolean;
  82172. /**
  82173. * The aspect ratio of the output texture.
  82174. */
  82175. readonly aspectRatio: number;
  82176. /**
  82177. * Get a value indicating if the post-process is ready to be used
  82178. * @returns true if the post-process is ready (shader is compiled)
  82179. */
  82180. isReady(): boolean;
  82181. /**
  82182. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82183. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82184. */
  82185. apply(): Nullable<Effect>;
  82186. private _disposeTextures;
  82187. /**
  82188. * Disposes the post process.
  82189. * @param camera The camera to dispose the post process on.
  82190. */
  82191. dispose(camera?: Camera): void;
  82192. }
  82193. }
  82194. declare module BABYLON {
  82195. /** @hidden */
  82196. export var kernelBlurVaryingDeclaration: {
  82197. name: string;
  82198. shader: string;
  82199. };
  82200. }
  82201. declare module BABYLON {
  82202. /** @hidden */
  82203. export var kernelBlurFragment: {
  82204. name: string;
  82205. shader: string;
  82206. };
  82207. }
  82208. declare module BABYLON {
  82209. /** @hidden */
  82210. export var kernelBlurFragment2: {
  82211. name: string;
  82212. shader: string;
  82213. };
  82214. }
  82215. declare module BABYLON {
  82216. /** @hidden */
  82217. export var kernelBlurPixelShader: {
  82218. name: string;
  82219. shader: string;
  82220. };
  82221. }
  82222. declare module BABYLON {
  82223. /** @hidden */
  82224. export var kernelBlurVertex: {
  82225. name: string;
  82226. shader: string;
  82227. };
  82228. }
  82229. declare module BABYLON {
  82230. /** @hidden */
  82231. export var kernelBlurVertexShader: {
  82232. name: string;
  82233. shader: string;
  82234. };
  82235. }
  82236. declare module BABYLON {
  82237. /**
  82238. * The Blur Post Process which blurs an image based on a kernel and direction.
  82239. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82240. */
  82241. export class BlurPostProcess extends PostProcess {
  82242. /** The direction in which to blur the image. */
  82243. direction: Vector2;
  82244. private blockCompilation;
  82245. protected _kernel: number;
  82246. protected _idealKernel: number;
  82247. protected _packedFloat: boolean;
  82248. private _staticDefines;
  82249. /**
  82250. * Sets the length in pixels of the blur sample region
  82251. */
  82252. /**
  82253. * Gets the length in pixels of the blur sample region
  82254. */
  82255. kernel: number;
  82256. /**
  82257. * Sets wether or not the blur needs to unpack/repack floats
  82258. */
  82259. /**
  82260. * Gets wether or not the blur is unpacking/repacking floats
  82261. */
  82262. packedFloat: boolean;
  82263. /**
  82264. * Creates a new instance BlurPostProcess
  82265. * @param name The name of the effect.
  82266. * @param direction The direction in which to blur the image.
  82267. * @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.
  82268. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82269. * @param camera The camera to apply the render pass to.
  82270. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82271. * @param engine The engine which the post process will be applied. (default: current engine)
  82272. * @param reusable If the post process can be reused on the same frame. (default: false)
  82273. * @param textureType Type of textures used when performing the post process. (default: 0)
  82274. * @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)
  82275. */
  82276. constructor(name: string,
  82277. /** The direction in which to blur the image. */
  82278. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82279. /**
  82280. * Updates the effect with the current post process compile time values and recompiles the shader.
  82281. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82282. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82283. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82284. * @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
  82285. * @param onCompiled Called when the shader has been compiled.
  82286. * @param onError Called if there is an error when compiling a shader.
  82287. */
  82288. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82289. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82290. /**
  82291. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82292. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82293. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82294. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82295. * The gaps between physical kernels are compensated for in the weighting of the samples
  82296. * @param idealKernel Ideal blur kernel.
  82297. * @return Nearest best kernel.
  82298. */
  82299. protected _nearestBestKernel(idealKernel: number): number;
  82300. /**
  82301. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82302. * @param x The point on the Gaussian distribution to sample.
  82303. * @return the value of the Gaussian function at x.
  82304. */
  82305. protected _gaussianWeight(x: number): number;
  82306. /**
  82307. * Generates a string that can be used as a floating point number in GLSL.
  82308. * @param x Value to print.
  82309. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82310. * @return GLSL float string.
  82311. */
  82312. protected _glslFloat(x: number, decimalFigures?: number): string;
  82313. }
  82314. }
  82315. declare module BABYLON {
  82316. /**
  82317. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82318. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82319. * You can then easily use it as a reflectionTexture on a flat surface.
  82320. * In case the surface is not a plane, please consider relying on reflection probes.
  82321. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82322. */
  82323. export class MirrorTexture extends RenderTargetTexture {
  82324. private scene;
  82325. /**
  82326. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82327. * 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.
  82328. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82329. */
  82330. mirrorPlane: Plane;
  82331. /**
  82332. * Define the blur ratio used to blur the reflection if needed.
  82333. */
  82334. blurRatio: number;
  82335. /**
  82336. * Define the adaptive blur kernel used to blur the reflection if needed.
  82337. * This will autocompute the closest best match for the `blurKernel`
  82338. */
  82339. adaptiveBlurKernel: number;
  82340. /**
  82341. * Define the blur kernel used to blur the reflection if needed.
  82342. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82343. */
  82344. blurKernel: number;
  82345. /**
  82346. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82347. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82348. */
  82349. blurKernelX: number;
  82350. /**
  82351. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82352. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82353. */
  82354. blurKernelY: number;
  82355. private _autoComputeBlurKernel;
  82356. protected _onRatioRescale(): void;
  82357. private _updateGammaSpace;
  82358. private _imageProcessingConfigChangeObserver;
  82359. private _transformMatrix;
  82360. private _mirrorMatrix;
  82361. private _savedViewMatrix;
  82362. private _blurX;
  82363. private _blurY;
  82364. private _adaptiveBlurKernel;
  82365. private _blurKernelX;
  82366. private _blurKernelY;
  82367. private _blurRatio;
  82368. /**
  82369. * Instantiates a Mirror Texture.
  82370. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82371. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82372. * You can then easily use it as a reflectionTexture on a flat surface.
  82373. * In case the surface is not a plane, please consider relying on reflection probes.
  82374. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82375. * @param name
  82376. * @param size
  82377. * @param scene
  82378. * @param generateMipMaps
  82379. * @param type
  82380. * @param samplingMode
  82381. * @param generateDepthBuffer
  82382. */
  82383. constructor(name: string, size: number | {
  82384. width: number;
  82385. height: number;
  82386. } | {
  82387. ratio: number;
  82388. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82389. private _preparePostProcesses;
  82390. /**
  82391. * Clone the mirror texture.
  82392. * @returns the cloned texture
  82393. */
  82394. clone(): MirrorTexture;
  82395. /**
  82396. * Serialize the texture to a JSON representation you could use in Parse later on
  82397. * @returns the serialized JSON representation
  82398. */
  82399. serialize(): any;
  82400. /**
  82401. * Dispose the texture and release its associated resources.
  82402. */
  82403. dispose(): void;
  82404. }
  82405. }
  82406. declare module BABYLON {
  82407. /**
  82408. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82409. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82410. */
  82411. export class Texture extends BaseTexture {
  82412. /**
  82413. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82414. */
  82415. static SerializeBuffers: boolean;
  82416. /** @hidden */
  82417. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82418. /** @hidden */
  82419. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82420. /** @hidden */
  82421. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82422. /** nearest is mag = nearest and min = nearest and mip = linear */
  82423. static readonly NEAREST_SAMPLINGMODE: number;
  82424. /** nearest is mag = nearest and min = nearest and mip = linear */
  82425. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82426. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82427. static readonly BILINEAR_SAMPLINGMODE: number;
  82428. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82429. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82430. /** Trilinear is mag = linear and min = linear and mip = linear */
  82431. static readonly TRILINEAR_SAMPLINGMODE: number;
  82432. /** Trilinear is mag = linear and min = linear and mip = linear */
  82433. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82434. /** mag = nearest and min = nearest and mip = nearest */
  82435. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82436. /** mag = nearest and min = linear and mip = nearest */
  82437. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82438. /** mag = nearest and min = linear and mip = linear */
  82439. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82440. /** mag = nearest and min = linear and mip = none */
  82441. static readonly NEAREST_LINEAR: number;
  82442. /** mag = nearest and min = nearest and mip = none */
  82443. static readonly NEAREST_NEAREST: number;
  82444. /** mag = linear and min = nearest and mip = nearest */
  82445. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82446. /** mag = linear and min = nearest and mip = linear */
  82447. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82448. /** mag = linear and min = linear and mip = none */
  82449. static readonly LINEAR_LINEAR: number;
  82450. /** mag = linear and min = nearest and mip = none */
  82451. static readonly LINEAR_NEAREST: number;
  82452. /** Explicit coordinates mode */
  82453. static readonly EXPLICIT_MODE: number;
  82454. /** Spherical coordinates mode */
  82455. static readonly SPHERICAL_MODE: number;
  82456. /** Planar coordinates mode */
  82457. static readonly PLANAR_MODE: number;
  82458. /** Cubic coordinates mode */
  82459. static readonly CUBIC_MODE: number;
  82460. /** Projection coordinates mode */
  82461. static readonly PROJECTION_MODE: number;
  82462. /** Inverse Cubic coordinates mode */
  82463. static readonly SKYBOX_MODE: number;
  82464. /** Inverse Cubic coordinates mode */
  82465. static readonly INVCUBIC_MODE: number;
  82466. /** Equirectangular coordinates mode */
  82467. static readonly EQUIRECTANGULAR_MODE: number;
  82468. /** Equirectangular Fixed coordinates mode */
  82469. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82470. /** Equirectangular Fixed Mirrored coordinates mode */
  82471. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82472. /** Texture is not repeating outside of 0..1 UVs */
  82473. static readonly CLAMP_ADDRESSMODE: number;
  82474. /** Texture is repeating outside of 0..1 UVs */
  82475. static readonly WRAP_ADDRESSMODE: number;
  82476. /** Texture is repeating and mirrored */
  82477. static readonly MIRROR_ADDRESSMODE: number;
  82478. /**
  82479. * 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
  82480. */
  82481. static UseSerializedUrlIfAny: boolean;
  82482. /**
  82483. * Define the url of the texture.
  82484. */
  82485. url: Nullable<string>;
  82486. /**
  82487. * Define an offset on the texture to offset the u coordinates of the UVs
  82488. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82489. */
  82490. uOffset: number;
  82491. /**
  82492. * Define an offset on the texture to offset the v coordinates of the UVs
  82493. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82494. */
  82495. vOffset: number;
  82496. /**
  82497. * Define an offset on the texture to scale the u coordinates of the UVs
  82498. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82499. */
  82500. uScale: number;
  82501. /**
  82502. * Define an offset on the texture to scale the v coordinates of the UVs
  82503. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82504. */
  82505. vScale: number;
  82506. /**
  82507. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82508. * @see http://doc.babylonjs.com/how_to/more_materials
  82509. */
  82510. uAng: number;
  82511. /**
  82512. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82513. * @see http://doc.babylonjs.com/how_to/more_materials
  82514. */
  82515. vAng: number;
  82516. /**
  82517. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82518. * @see http://doc.babylonjs.com/how_to/more_materials
  82519. */
  82520. wAng: number;
  82521. /**
  82522. * Defines the center of rotation (U)
  82523. */
  82524. uRotationCenter: number;
  82525. /**
  82526. * Defines the center of rotation (V)
  82527. */
  82528. vRotationCenter: number;
  82529. /**
  82530. * Defines the center of rotation (W)
  82531. */
  82532. wRotationCenter: number;
  82533. /**
  82534. * Are mip maps generated for this texture or not.
  82535. */
  82536. readonly noMipmap: boolean;
  82537. /**
  82538. * List of inspectable custom properties (used by the Inspector)
  82539. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82540. */
  82541. inspectableCustomProperties: Nullable<IInspectable[]>;
  82542. private _noMipmap;
  82543. /** @hidden */
  82544. _invertY: boolean;
  82545. private _rowGenerationMatrix;
  82546. private _cachedTextureMatrix;
  82547. private _projectionModeMatrix;
  82548. private _t0;
  82549. private _t1;
  82550. private _t2;
  82551. private _cachedUOffset;
  82552. private _cachedVOffset;
  82553. private _cachedUScale;
  82554. private _cachedVScale;
  82555. private _cachedUAng;
  82556. private _cachedVAng;
  82557. private _cachedWAng;
  82558. private _cachedProjectionMatrixId;
  82559. private _cachedCoordinatesMode;
  82560. /** @hidden */
  82561. protected _initialSamplingMode: number;
  82562. /** @hidden */
  82563. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82564. private _deleteBuffer;
  82565. protected _format: Nullable<number>;
  82566. private _delayedOnLoad;
  82567. private _delayedOnError;
  82568. private _mimeType?;
  82569. /**
  82570. * Observable triggered once the texture has been loaded.
  82571. */
  82572. onLoadObservable: Observable<Texture>;
  82573. protected _isBlocking: boolean;
  82574. /**
  82575. * Is the texture preventing material to render while loading.
  82576. * If false, a default texture will be used instead of the loading one during the preparation step.
  82577. */
  82578. isBlocking: boolean;
  82579. /**
  82580. * Get the current sampling mode associated with the texture.
  82581. */
  82582. readonly samplingMode: number;
  82583. /**
  82584. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82585. */
  82586. readonly invertY: boolean;
  82587. /**
  82588. * Instantiates a new texture.
  82589. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82590. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82591. * @param url defines the url of the picture to load as a texture
  82592. * @param scene defines the scene or engine the texture will belong to
  82593. * @param noMipmap defines if the texture will require mip maps or not
  82594. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  82595. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82596. * @param onLoad defines a callback triggered when the texture has been loaded
  82597. * @param onError defines a callback triggered when an error occurred during the loading session
  82598. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  82599. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  82600. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82601. * @param mimeType defines an optional mime type information
  82602. */
  82603. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  82604. /**
  82605. * Update the url (and optional buffer) of this texture if url was null during construction.
  82606. * @param url the url of the texture
  82607. * @param buffer the buffer of the texture (defaults to null)
  82608. * @param onLoad callback called when the texture is loaded (defaults to null)
  82609. */
  82610. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82611. /**
  82612. * Finish the loading sequence of a texture flagged as delayed load.
  82613. * @hidden
  82614. */
  82615. delayLoad(): void;
  82616. private _prepareRowForTextureGeneration;
  82617. /**
  82618. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82619. * @returns the transform matrix of the texture.
  82620. */
  82621. getTextureMatrix(): Matrix;
  82622. /**
  82623. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82624. * @returns The reflection texture transform
  82625. */
  82626. getReflectionTextureMatrix(): Matrix;
  82627. /**
  82628. * Clones the texture.
  82629. * @returns the cloned texture
  82630. */
  82631. clone(): Texture;
  82632. /**
  82633. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82634. * @returns The JSON representation of the texture
  82635. */
  82636. serialize(): any;
  82637. /**
  82638. * Get the current class name of the texture useful for serialization or dynamic coding.
  82639. * @returns "Texture"
  82640. */
  82641. getClassName(): string;
  82642. /**
  82643. * Dispose the texture and release its associated resources.
  82644. */
  82645. dispose(): void;
  82646. /**
  82647. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82648. * @param parsedTexture Define the JSON representation of the texture
  82649. * @param scene Define the scene the parsed texture should be instantiated in
  82650. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82651. * @returns The parsed texture if successful
  82652. */
  82653. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82654. /**
  82655. * Creates a texture from its base 64 representation.
  82656. * @param data Define the base64 payload without the data: prefix
  82657. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82658. * @param scene Define the scene the texture should belong to
  82659. * @param noMipmap Forces the texture to not create mip map information if true
  82660. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82661. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82662. * @param onLoad define a callback triggered when the texture has been loaded
  82663. * @param onError define a callback triggered when an error occurred during the loading session
  82664. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82665. * @returns the created texture
  82666. */
  82667. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82668. /**
  82669. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82670. * @param data Define the base64 payload without the data: prefix
  82671. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82672. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82673. * @param scene Define the scene the texture should belong to
  82674. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82675. * @param noMipmap Forces the texture to not create mip map information if true
  82676. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82677. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82678. * @param onLoad define a callback triggered when the texture has been loaded
  82679. * @param onError define a callback triggered when an error occurred during the loading session
  82680. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82681. * @returns the created texture
  82682. */
  82683. 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;
  82684. }
  82685. }
  82686. declare module BABYLON {
  82687. /**
  82688. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82689. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82690. */
  82691. export class PostProcessManager {
  82692. private _scene;
  82693. private _indexBuffer;
  82694. private _vertexBuffers;
  82695. /**
  82696. * Creates a new instance PostProcess
  82697. * @param scene The scene that the post process is associated with.
  82698. */
  82699. constructor(scene: Scene);
  82700. private _prepareBuffers;
  82701. private _buildIndexBuffer;
  82702. /**
  82703. * Rebuilds the vertex buffers of the manager.
  82704. * @hidden
  82705. */
  82706. _rebuild(): void;
  82707. /**
  82708. * Prepares a frame to be run through a post process.
  82709. * @param sourceTexture The input texture to the post procesess. (default: null)
  82710. * @param postProcesses An array of post processes to be run. (default: null)
  82711. * @returns True if the post processes were able to be run.
  82712. * @hidden
  82713. */
  82714. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82715. /**
  82716. * Manually render a set of post processes to a texture.
  82717. * @param postProcesses An array of post processes to be run.
  82718. * @param targetTexture The target texture to render to.
  82719. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82720. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82721. * @param lodLevel defines which lod of the texture to render to
  82722. */
  82723. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82724. /**
  82725. * Finalize the result of the output of the postprocesses.
  82726. * @param doNotPresent If true the result will not be displayed to the screen.
  82727. * @param targetTexture The target texture to render to.
  82728. * @param faceIndex The index of the face to bind the target texture to.
  82729. * @param postProcesses The array of post processes to render.
  82730. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82731. * @hidden
  82732. */
  82733. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82734. /**
  82735. * Disposes of the post process manager.
  82736. */
  82737. dispose(): void;
  82738. }
  82739. }
  82740. declare module BABYLON {
  82741. /** Interface used by value gradients (color, factor, ...) */
  82742. export interface IValueGradient {
  82743. /**
  82744. * Gets or sets the gradient value (between 0 and 1)
  82745. */
  82746. gradient: number;
  82747. }
  82748. /** Class used to store color4 gradient */
  82749. export class ColorGradient implements IValueGradient {
  82750. /**
  82751. * Gets or sets the gradient value (between 0 and 1)
  82752. */
  82753. gradient: number;
  82754. /**
  82755. * Gets or sets first associated color
  82756. */
  82757. color1: Color4;
  82758. /**
  82759. * Gets or sets second associated color
  82760. */
  82761. color2?: Color4;
  82762. /**
  82763. * Will get a color picked randomly between color1 and color2.
  82764. * If color2 is undefined then color1 will be used
  82765. * @param result defines the target Color4 to store the result in
  82766. */
  82767. getColorToRef(result: Color4): void;
  82768. }
  82769. /** Class used to store color 3 gradient */
  82770. export class Color3Gradient implements IValueGradient {
  82771. /**
  82772. * Gets or sets the gradient value (between 0 and 1)
  82773. */
  82774. gradient: number;
  82775. /**
  82776. * Gets or sets the associated color
  82777. */
  82778. color: Color3;
  82779. }
  82780. /** Class used to store factor gradient */
  82781. export class FactorGradient implements IValueGradient {
  82782. /**
  82783. * Gets or sets the gradient value (between 0 and 1)
  82784. */
  82785. gradient: number;
  82786. /**
  82787. * Gets or sets first associated factor
  82788. */
  82789. factor1: number;
  82790. /**
  82791. * Gets or sets second associated factor
  82792. */
  82793. factor2?: number;
  82794. /**
  82795. * Will get a number picked randomly between factor1 and factor2.
  82796. * If factor2 is undefined then factor1 will be used
  82797. * @returns the picked number
  82798. */
  82799. getFactor(): number;
  82800. }
  82801. /**
  82802. * Helper used to simplify some generic gradient tasks
  82803. */
  82804. export class GradientHelper {
  82805. /**
  82806. * Gets the current gradient from an array of IValueGradient
  82807. * @param ratio defines the current ratio to get
  82808. * @param gradients defines the array of IValueGradient
  82809. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82810. */
  82811. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82812. }
  82813. }
  82814. declare module BABYLON {
  82815. interface ThinEngine {
  82816. /**
  82817. * Creates a dynamic texture
  82818. * @param width defines the width of the texture
  82819. * @param height defines the height of the texture
  82820. * @param generateMipMaps defines if the engine should generate the mip levels
  82821. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82822. * @returns the dynamic texture inside an InternalTexture
  82823. */
  82824. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82825. /**
  82826. * Update the content of a dynamic texture
  82827. * @param texture defines the texture to update
  82828. * @param canvas defines the canvas containing the source
  82829. * @param invertY defines if data must be stored with Y axis inverted
  82830. * @param premulAlpha defines if alpha is stored as premultiplied
  82831. * @param format defines the format of the data
  82832. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82833. */
  82834. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82835. }
  82836. }
  82837. declare module BABYLON {
  82838. /**
  82839. * A class extending Texture allowing drawing on a texture
  82840. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82841. */
  82842. export class DynamicTexture extends Texture {
  82843. private _generateMipMaps;
  82844. private _canvas;
  82845. private _context;
  82846. private _engine;
  82847. /**
  82848. * Creates a DynamicTexture
  82849. * @param name defines the name of the texture
  82850. * @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
  82851. * @param scene defines the scene where you want the texture
  82852. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82853. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82854. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82855. */
  82856. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82857. /**
  82858. * Get the current class name of the texture useful for serialization or dynamic coding.
  82859. * @returns "DynamicTexture"
  82860. */
  82861. getClassName(): string;
  82862. /**
  82863. * Gets the current state of canRescale
  82864. */
  82865. readonly canRescale: boolean;
  82866. private _recreate;
  82867. /**
  82868. * Scales the texture
  82869. * @param ratio the scale factor to apply to both width and height
  82870. */
  82871. scale(ratio: number): void;
  82872. /**
  82873. * Resizes the texture
  82874. * @param width the new width
  82875. * @param height the new height
  82876. */
  82877. scaleTo(width: number, height: number): void;
  82878. /**
  82879. * Gets the context of the canvas used by the texture
  82880. * @returns the canvas context of the dynamic texture
  82881. */
  82882. getContext(): CanvasRenderingContext2D;
  82883. /**
  82884. * Clears the texture
  82885. */
  82886. clear(): void;
  82887. /**
  82888. * Updates the texture
  82889. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82890. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82891. */
  82892. update(invertY?: boolean, premulAlpha?: boolean): void;
  82893. /**
  82894. * Draws text onto the texture
  82895. * @param text defines the text to be drawn
  82896. * @param x defines the placement of the text from the left
  82897. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82898. * @param font defines the font to be used with font-style, font-size, font-name
  82899. * @param color defines the color used for the text
  82900. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82901. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82902. * @param update defines whether texture is immediately update (default is true)
  82903. */
  82904. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82905. /**
  82906. * Clones the texture
  82907. * @returns the clone of the texture.
  82908. */
  82909. clone(): DynamicTexture;
  82910. /**
  82911. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  82912. * @returns a serialized dynamic texture object
  82913. */
  82914. serialize(): any;
  82915. /** @hidden */
  82916. _rebuild(): void;
  82917. }
  82918. }
  82919. declare module BABYLON {
  82920. interface AbstractScene {
  82921. /**
  82922. * The list of procedural textures added to the scene
  82923. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82924. */
  82925. proceduralTextures: Array<ProceduralTexture>;
  82926. }
  82927. /**
  82928. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  82929. * in a given scene.
  82930. */
  82931. export class ProceduralTextureSceneComponent implements ISceneComponent {
  82932. /**
  82933. * The component name helpfull to identify the component in the list of scene components.
  82934. */
  82935. readonly name: string;
  82936. /**
  82937. * The scene the component belongs to.
  82938. */
  82939. scene: Scene;
  82940. /**
  82941. * Creates a new instance of the component for the given scene
  82942. * @param scene Defines the scene to register the component in
  82943. */
  82944. constructor(scene: Scene);
  82945. /**
  82946. * Registers the component in a given scene
  82947. */
  82948. register(): void;
  82949. /**
  82950. * Rebuilds the elements related to this component in case of
  82951. * context lost for instance.
  82952. */
  82953. rebuild(): void;
  82954. /**
  82955. * Disposes the component and the associated ressources.
  82956. */
  82957. dispose(): void;
  82958. private _beforeClear;
  82959. }
  82960. }
  82961. declare module BABYLON {
  82962. interface ThinEngine {
  82963. /**
  82964. * Creates a new render target cube texture
  82965. * @param size defines the size of the texture
  82966. * @param options defines the options used to create the texture
  82967. * @returns a new render target cube texture stored in an InternalTexture
  82968. */
  82969. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  82970. }
  82971. }
  82972. declare module BABYLON {
  82973. /** @hidden */
  82974. export var proceduralVertexShader: {
  82975. name: string;
  82976. shader: string;
  82977. };
  82978. }
  82979. declare module BABYLON {
  82980. /**
  82981. * 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.
  82982. * This is the base class of any Procedural texture and contains most of the shareable code.
  82983. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  82984. */
  82985. export class ProceduralTexture extends Texture {
  82986. isCube: boolean;
  82987. /**
  82988. * Define if the texture is enabled or not (disabled texture will not render)
  82989. */
  82990. isEnabled: boolean;
  82991. /**
  82992. * Define if the texture must be cleared before rendering (default is true)
  82993. */
  82994. autoClear: boolean;
  82995. /**
  82996. * Callback called when the texture is generated
  82997. */
  82998. onGenerated: () => void;
  82999. /**
  83000. * Event raised when the texture is generated
  83001. */
  83002. onGeneratedObservable: Observable<ProceduralTexture>;
  83003. /** @hidden */
  83004. _generateMipMaps: boolean;
  83005. /** @hidden **/
  83006. _effect: Effect;
  83007. /** @hidden */
  83008. _textures: {
  83009. [key: string]: Texture;
  83010. };
  83011. private _size;
  83012. private _currentRefreshId;
  83013. private _refreshRate;
  83014. private _vertexBuffers;
  83015. private _indexBuffer;
  83016. private _uniforms;
  83017. private _samplers;
  83018. private _fragment;
  83019. private _floats;
  83020. private _ints;
  83021. private _floatsArrays;
  83022. private _colors3;
  83023. private _colors4;
  83024. private _vectors2;
  83025. private _vectors3;
  83026. private _matrices;
  83027. private _fallbackTexture;
  83028. private _fallbackTextureUsed;
  83029. private _engine;
  83030. private _cachedDefines;
  83031. private _contentUpdateId;
  83032. private _contentData;
  83033. /**
  83034. * Instantiates a new procedural texture.
  83035. * 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.
  83036. * This is the base class of any Procedural texture and contains most of the shareable code.
  83037. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83038. * @param name Define the name of the texture
  83039. * @param size Define the size of the texture to create
  83040. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83041. * @param scene Define the scene the texture belongs to
  83042. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83043. * @param generateMipMaps Define if the texture should creates mip maps or not
  83044. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83045. */
  83046. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83047. /**
  83048. * The effect that is created when initializing the post process.
  83049. * @returns The created effect corresponding the the postprocess.
  83050. */
  83051. getEffect(): Effect;
  83052. /**
  83053. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83054. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83055. */
  83056. getContent(): Nullable<ArrayBufferView>;
  83057. private _createIndexBuffer;
  83058. /** @hidden */
  83059. _rebuild(): void;
  83060. /**
  83061. * Resets the texture in order to recreate its associated resources.
  83062. * This can be called in case of context loss
  83063. */
  83064. reset(): void;
  83065. protected _getDefines(): string;
  83066. /**
  83067. * Is the texture ready to be used ? (rendered at least once)
  83068. * @returns true if ready, otherwise, false.
  83069. */
  83070. isReady(): boolean;
  83071. /**
  83072. * Resets the refresh counter of the texture and start bak from scratch.
  83073. * Could be useful to regenerate the texture if it is setup to render only once.
  83074. */
  83075. resetRefreshCounter(): void;
  83076. /**
  83077. * Set the fragment shader to use in order to render the texture.
  83078. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83079. */
  83080. setFragment(fragment: any): void;
  83081. /**
  83082. * Define the refresh rate of the texture or the rendering frequency.
  83083. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83084. */
  83085. refreshRate: number;
  83086. /** @hidden */
  83087. _shouldRender(): boolean;
  83088. /**
  83089. * Get the size the texture is rendering at.
  83090. * @returns the size (texture is always squared)
  83091. */
  83092. getRenderSize(): number;
  83093. /**
  83094. * Resize the texture to new value.
  83095. * @param size Define the new size the texture should have
  83096. * @param generateMipMaps Define whether the new texture should create mip maps
  83097. */
  83098. resize(size: number, generateMipMaps: boolean): void;
  83099. private _checkUniform;
  83100. /**
  83101. * Set a texture in the shader program used to render.
  83102. * @param name Define the name of the uniform samplers as defined in the shader
  83103. * @param texture Define the texture to bind to this sampler
  83104. * @return the texture itself allowing "fluent" like uniform updates
  83105. */
  83106. setTexture(name: string, texture: Texture): ProceduralTexture;
  83107. /**
  83108. * Set a float in the shader.
  83109. * @param name Define the name of the uniform as defined in the shader
  83110. * @param value Define the value to give to the uniform
  83111. * @return the texture itself allowing "fluent" like uniform updates
  83112. */
  83113. setFloat(name: string, value: number): ProceduralTexture;
  83114. /**
  83115. * Set a int in the shader.
  83116. * @param name Define the name of the uniform as defined in the shader
  83117. * @param value Define the value to give to the uniform
  83118. * @return the texture itself allowing "fluent" like uniform updates
  83119. */
  83120. setInt(name: string, value: number): ProceduralTexture;
  83121. /**
  83122. * Set an array of floats in the shader.
  83123. * @param name Define the name of the uniform as defined in the shader
  83124. * @param value Define the value to give to the uniform
  83125. * @return the texture itself allowing "fluent" like uniform updates
  83126. */
  83127. setFloats(name: string, value: number[]): ProceduralTexture;
  83128. /**
  83129. * Set a vec3 in the shader from a Color3.
  83130. * @param name Define the name of the uniform as defined in the shader
  83131. * @param value Define the value to give to the uniform
  83132. * @return the texture itself allowing "fluent" like uniform updates
  83133. */
  83134. setColor3(name: string, value: Color3): ProceduralTexture;
  83135. /**
  83136. * Set a vec4 in the shader from a Color4.
  83137. * @param name Define the name of the uniform as defined in the shader
  83138. * @param value Define the value to give to the uniform
  83139. * @return the texture itself allowing "fluent" like uniform updates
  83140. */
  83141. setColor4(name: string, value: Color4): ProceduralTexture;
  83142. /**
  83143. * Set a vec2 in the shader from a Vector2.
  83144. * @param name Define the name of the uniform as defined in the shader
  83145. * @param value Define the value to give to the uniform
  83146. * @return the texture itself allowing "fluent" like uniform updates
  83147. */
  83148. setVector2(name: string, value: Vector2): ProceduralTexture;
  83149. /**
  83150. * Set a vec3 in the shader from a Vector3.
  83151. * @param name Define the name of the uniform as defined in the shader
  83152. * @param value Define the value to give to the uniform
  83153. * @return the texture itself allowing "fluent" like uniform updates
  83154. */
  83155. setVector3(name: string, value: Vector3): ProceduralTexture;
  83156. /**
  83157. * Set a mat4 in the shader from a MAtrix.
  83158. * @param name Define the name of the uniform as defined in the shader
  83159. * @param value Define the value to give to the uniform
  83160. * @return the texture itself allowing "fluent" like uniform updates
  83161. */
  83162. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83163. /**
  83164. * Render the texture to its associated render target.
  83165. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83166. */
  83167. render(useCameraPostProcess?: boolean): void;
  83168. /**
  83169. * Clone the texture.
  83170. * @returns the cloned texture
  83171. */
  83172. clone(): ProceduralTexture;
  83173. /**
  83174. * Dispose the texture and release its asoociated resources.
  83175. */
  83176. dispose(): void;
  83177. }
  83178. }
  83179. declare module BABYLON {
  83180. /**
  83181. * This represents the base class for particle system in Babylon.
  83182. * 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.
  83183. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83184. * @example https://doc.babylonjs.com/babylon101/particles
  83185. */
  83186. export class BaseParticleSystem {
  83187. /**
  83188. * Source color is added to the destination color without alpha affecting the result
  83189. */
  83190. static BLENDMODE_ONEONE: number;
  83191. /**
  83192. * Blend current color and particle color using particle’s alpha
  83193. */
  83194. static BLENDMODE_STANDARD: number;
  83195. /**
  83196. * Add current color and particle color multiplied by particle’s alpha
  83197. */
  83198. static BLENDMODE_ADD: number;
  83199. /**
  83200. * Multiply current color with particle color
  83201. */
  83202. static BLENDMODE_MULTIPLY: number;
  83203. /**
  83204. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83205. */
  83206. static BLENDMODE_MULTIPLYADD: number;
  83207. /**
  83208. * List of animations used by the particle system.
  83209. */
  83210. animations: Animation[];
  83211. /**
  83212. * The id of the Particle system.
  83213. */
  83214. id: string;
  83215. /**
  83216. * The friendly name of the Particle system.
  83217. */
  83218. name: string;
  83219. /**
  83220. * The rendering group used by the Particle system to chose when to render.
  83221. */
  83222. renderingGroupId: number;
  83223. /**
  83224. * The emitter represents the Mesh or position we are attaching the particle system to.
  83225. */
  83226. emitter: Nullable<AbstractMesh | Vector3>;
  83227. /**
  83228. * The maximum number of particles to emit per frame
  83229. */
  83230. emitRate: number;
  83231. /**
  83232. * If you want to launch only a few particles at once, that can be done, as well.
  83233. */
  83234. manualEmitCount: number;
  83235. /**
  83236. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83237. */
  83238. updateSpeed: number;
  83239. /**
  83240. * The amount of time the particle system is running (depends of the overall update speed).
  83241. */
  83242. targetStopDuration: number;
  83243. /**
  83244. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83245. */
  83246. disposeOnStop: boolean;
  83247. /**
  83248. * Minimum power of emitting particles.
  83249. */
  83250. minEmitPower: number;
  83251. /**
  83252. * Maximum power of emitting particles.
  83253. */
  83254. maxEmitPower: number;
  83255. /**
  83256. * Minimum life time of emitting particles.
  83257. */
  83258. minLifeTime: number;
  83259. /**
  83260. * Maximum life time of emitting particles.
  83261. */
  83262. maxLifeTime: number;
  83263. /**
  83264. * Minimum Size of emitting particles.
  83265. */
  83266. minSize: number;
  83267. /**
  83268. * Maximum Size of emitting particles.
  83269. */
  83270. maxSize: number;
  83271. /**
  83272. * Minimum scale of emitting particles on X axis.
  83273. */
  83274. minScaleX: number;
  83275. /**
  83276. * Maximum scale of emitting particles on X axis.
  83277. */
  83278. maxScaleX: number;
  83279. /**
  83280. * Minimum scale of emitting particles on Y axis.
  83281. */
  83282. minScaleY: number;
  83283. /**
  83284. * Maximum scale of emitting particles on Y axis.
  83285. */
  83286. maxScaleY: number;
  83287. /**
  83288. * Gets or sets the minimal initial rotation in radians.
  83289. */
  83290. minInitialRotation: number;
  83291. /**
  83292. * Gets or sets the maximal initial rotation in radians.
  83293. */
  83294. maxInitialRotation: number;
  83295. /**
  83296. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83297. */
  83298. minAngularSpeed: number;
  83299. /**
  83300. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83301. */
  83302. maxAngularSpeed: number;
  83303. /**
  83304. * The texture used to render each particle. (this can be a spritesheet)
  83305. */
  83306. particleTexture: Nullable<Texture>;
  83307. /**
  83308. * The layer mask we are rendering the particles through.
  83309. */
  83310. layerMask: number;
  83311. /**
  83312. * This can help using your own shader to render the particle system.
  83313. * The according effect will be created
  83314. */
  83315. customShader: any;
  83316. /**
  83317. * By default particle system starts as soon as they are created. This prevents the
  83318. * automatic start to happen and let you decide when to start emitting particles.
  83319. */
  83320. preventAutoStart: boolean;
  83321. private _noiseTexture;
  83322. /**
  83323. * Gets or sets a texture used to add random noise to particle positions
  83324. */
  83325. noiseTexture: Nullable<ProceduralTexture>;
  83326. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83327. noiseStrength: Vector3;
  83328. /**
  83329. * Callback triggered when the particle animation is ending.
  83330. */
  83331. onAnimationEnd: Nullable<() => void>;
  83332. /**
  83333. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83334. */
  83335. blendMode: number;
  83336. /**
  83337. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83338. * to override the particles.
  83339. */
  83340. forceDepthWrite: boolean;
  83341. /** 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 */
  83342. preWarmCycles: number;
  83343. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83344. preWarmStepOffset: number;
  83345. /**
  83346. * 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)
  83347. */
  83348. spriteCellChangeSpeed: number;
  83349. /**
  83350. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83351. */
  83352. startSpriteCellID: number;
  83353. /**
  83354. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83355. */
  83356. endSpriteCellID: number;
  83357. /**
  83358. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83359. */
  83360. spriteCellWidth: number;
  83361. /**
  83362. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83363. */
  83364. spriteCellHeight: number;
  83365. /**
  83366. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83367. */
  83368. spriteRandomStartCell: boolean;
  83369. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83370. translationPivot: Vector2;
  83371. /** @hidden */
  83372. protected _isAnimationSheetEnabled: boolean;
  83373. /**
  83374. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83375. */
  83376. beginAnimationOnStart: boolean;
  83377. /**
  83378. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83379. */
  83380. beginAnimationFrom: number;
  83381. /**
  83382. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83383. */
  83384. beginAnimationTo: number;
  83385. /**
  83386. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83387. */
  83388. beginAnimationLoop: boolean;
  83389. /**
  83390. * Gets or sets a world offset applied to all particles
  83391. */
  83392. worldOffset: Vector3;
  83393. /**
  83394. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83395. */
  83396. isAnimationSheetEnabled: boolean;
  83397. /**
  83398. * Get hosting scene
  83399. * @returns the scene
  83400. */
  83401. getScene(): Scene;
  83402. /**
  83403. * You can use gravity if you want to give an orientation to your particles.
  83404. */
  83405. gravity: Vector3;
  83406. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83407. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83408. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83409. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83410. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83411. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83412. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83413. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83414. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83415. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83416. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83417. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83418. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83419. /**
  83420. * Defines the delay in milliseconds before starting the system (0 by default)
  83421. */
  83422. startDelay: number;
  83423. /**
  83424. * Gets the current list of drag gradients.
  83425. * You must use addDragGradient and removeDragGradient to udpate this list
  83426. * @returns the list of drag gradients
  83427. */
  83428. getDragGradients(): Nullable<Array<FactorGradient>>;
  83429. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83430. limitVelocityDamping: number;
  83431. /**
  83432. * Gets the current list of limit velocity gradients.
  83433. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83434. * @returns the list of limit velocity gradients
  83435. */
  83436. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83437. /**
  83438. * Gets the current list of color gradients.
  83439. * You must use addColorGradient and removeColorGradient to udpate this list
  83440. * @returns the list of color gradients
  83441. */
  83442. getColorGradients(): Nullable<Array<ColorGradient>>;
  83443. /**
  83444. * Gets the current list of size gradients.
  83445. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83446. * @returns the list of size gradients
  83447. */
  83448. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83449. /**
  83450. * Gets the current list of color remap gradients.
  83451. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83452. * @returns the list of color remap gradients
  83453. */
  83454. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83455. /**
  83456. * Gets the current list of alpha remap gradients.
  83457. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83458. * @returns the list of alpha remap gradients
  83459. */
  83460. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83461. /**
  83462. * Gets the current list of life time gradients.
  83463. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83464. * @returns the list of life time gradients
  83465. */
  83466. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83467. /**
  83468. * Gets the current list of angular speed gradients.
  83469. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83470. * @returns the list of angular speed gradients
  83471. */
  83472. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83473. /**
  83474. * Gets the current list of velocity gradients.
  83475. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83476. * @returns the list of velocity gradients
  83477. */
  83478. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83479. /**
  83480. * Gets the current list of start size gradients.
  83481. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83482. * @returns the list of start size gradients
  83483. */
  83484. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83485. /**
  83486. * Gets the current list of emit rate gradients.
  83487. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83488. * @returns the list of emit rate gradients
  83489. */
  83490. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83491. /**
  83492. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83493. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83494. */
  83495. direction1: Vector3;
  83496. /**
  83497. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83498. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83499. */
  83500. direction2: Vector3;
  83501. /**
  83502. * 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.
  83503. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83504. */
  83505. minEmitBox: Vector3;
  83506. /**
  83507. * 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.
  83508. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83509. */
  83510. maxEmitBox: Vector3;
  83511. /**
  83512. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83513. */
  83514. color1: Color4;
  83515. /**
  83516. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83517. */
  83518. color2: Color4;
  83519. /**
  83520. * Color the particle will have at the end of its lifetime
  83521. */
  83522. colorDead: Color4;
  83523. /**
  83524. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83525. */
  83526. textureMask: Color4;
  83527. /**
  83528. * The particle emitter type defines the emitter used by the particle system.
  83529. * It can be for example box, sphere, or cone...
  83530. */
  83531. particleEmitterType: IParticleEmitterType;
  83532. /** @hidden */
  83533. _isSubEmitter: boolean;
  83534. /**
  83535. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83536. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83537. */
  83538. billboardMode: number;
  83539. protected _isBillboardBased: boolean;
  83540. /**
  83541. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83542. */
  83543. isBillboardBased: boolean;
  83544. /**
  83545. * The scene the particle system belongs to.
  83546. */
  83547. protected _scene: Scene;
  83548. /**
  83549. * Local cache of defines for image processing.
  83550. */
  83551. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83552. /**
  83553. * Default configuration related to image processing available in the standard Material.
  83554. */
  83555. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83556. /**
  83557. * Gets the image processing configuration used either in this material.
  83558. */
  83559. /**
  83560. * Sets the Default image processing configuration used either in the this material.
  83561. *
  83562. * If sets to null, the scene one is in use.
  83563. */
  83564. imageProcessingConfiguration: ImageProcessingConfiguration;
  83565. /**
  83566. * Attaches a new image processing configuration to the Standard Material.
  83567. * @param configuration
  83568. */
  83569. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83570. /** @hidden */
  83571. protected _reset(): void;
  83572. /** @hidden */
  83573. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83574. /**
  83575. * Instantiates a particle system.
  83576. * 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.
  83577. * @param name The name of the particle system
  83578. */
  83579. constructor(name: string);
  83580. /**
  83581. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83582. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83583. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83584. * @returns the emitter
  83585. */
  83586. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83587. /**
  83588. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83589. * @param radius The radius of the hemisphere to emit from
  83590. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83591. * @returns the emitter
  83592. */
  83593. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83594. /**
  83595. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83596. * @param radius The radius of the sphere to emit from
  83597. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83598. * @returns the emitter
  83599. */
  83600. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83601. /**
  83602. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83603. * @param radius The radius of the sphere to emit from
  83604. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83605. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83606. * @returns the emitter
  83607. */
  83608. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83609. /**
  83610. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83611. * @param radius The radius of the emission cylinder
  83612. * @param height The height of the emission cylinder
  83613. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83614. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83615. * @returns the emitter
  83616. */
  83617. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83618. /**
  83619. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83620. * @param radius The radius of the cylinder to emit from
  83621. * @param height The height of the emission cylinder
  83622. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83623. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83624. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83625. * @returns the emitter
  83626. */
  83627. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83628. /**
  83629. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83630. * @param radius The radius of the cone to emit from
  83631. * @param angle The base angle of the cone
  83632. * @returns the emitter
  83633. */
  83634. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83635. /**
  83636. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83637. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83638. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83639. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83640. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83641. * @returns the emitter
  83642. */
  83643. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83644. }
  83645. }
  83646. declare module BABYLON {
  83647. /**
  83648. * Type of sub emitter
  83649. */
  83650. export enum SubEmitterType {
  83651. /**
  83652. * Attached to the particle over it's lifetime
  83653. */
  83654. ATTACHED = 0,
  83655. /**
  83656. * Created when the particle dies
  83657. */
  83658. END = 1
  83659. }
  83660. /**
  83661. * Sub emitter class used to emit particles from an existing particle
  83662. */
  83663. export class SubEmitter {
  83664. /**
  83665. * the particle system to be used by the sub emitter
  83666. */
  83667. particleSystem: ParticleSystem;
  83668. /**
  83669. * Type of the submitter (Default: END)
  83670. */
  83671. type: SubEmitterType;
  83672. /**
  83673. * 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)
  83674. * Note: This only is supported when using an emitter of type Mesh
  83675. */
  83676. inheritDirection: boolean;
  83677. /**
  83678. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83679. */
  83680. inheritedVelocityAmount: number;
  83681. /**
  83682. * Creates a sub emitter
  83683. * @param particleSystem the particle system to be used by the sub emitter
  83684. */
  83685. constructor(
  83686. /**
  83687. * the particle system to be used by the sub emitter
  83688. */
  83689. particleSystem: ParticleSystem);
  83690. /**
  83691. * Clones the sub emitter
  83692. * @returns the cloned sub emitter
  83693. */
  83694. clone(): SubEmitter;
  83695. /**
  83696. * Serialize current object to a JSON object
  83697. * @returns the serialized object
  83698. */
  83699. serialize(): any;
  83700. /** @hidden */
  83701. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83702. /**
  83703. * Creates a new SubEmitter from a serialized JSON version
  83704. * @param serializationObject defines the JSON object to read from
  83705. * @param scene defines the hosting scene
  83706. * @param rootUrl defines the rootUrl for data loading
  83707. * @returns a new SubEmitter
  83708. */
  83709. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83710. /** Release associated resources */
  83711. dispose(): void;
  83712. }
  83713. }
  83714. declare module BABYLON {
  83715. /** @hidden */
  83716. export var clipPlaneFragmentDeclaration: {
  83717. name: string;
  83718. shader: string;
  83719. };
  83720. }
  83721. declare module BABYLON {
  83722. /** @hidden */
  83723. export var imageProcessingDeclaration: {
  83724. name: string;
  83725. shader: string;
  83726. };
  83727. }
  83728. declare module BABYLON {
  83729. /** @hidden */
  83730. export var imageProcessingFunctions: {
  83731. name: string;
  83732. shader: string;
  83733. };
  83734. }
  83735. declare module BABYLON {
  83736. /** @hidden */
  83737. export var clipPlaneFragment: {
  83738. name: string;
  83739. shader: string;
  83740. };
  83741. }
  83742. declare module BABYLON {
  83743. /** @hidden */
  83744. export var particlesPixelShader: {
  83745. name: string;
  83746. shader: string;
  83747. };
  83748. }
  83749. declare module BABYLON {
  83750. /** @hidden */
  83751. export var clipPlaneVertexDeclaration: {
  83752. name: string;
  83753. shader: string;
  83754. };
  83755. }
  83756. declare module BABYLON {
  83757. /** @hidden */
  83758. export var clipPlaneVertex: {
  83759. name: string;
  83760. shader: string;
  83761. };
  83762. }
  83763. declare module BABYLON {
  83764. /** @hidden */
  83765. export var particlesVertexShader: {
  83766. name: string;
  83767. shader: string;
  83768. };
  83769. }
  83770. declare module BABYLON {
  83771. /**
  83772. * This represents a particle system in Babylon.
  83773. * 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.
  83774. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83775. * @example https://doc.babylonjs.com/babylon101/particles
  83776. */
  83777. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83778. /**
  83779. * Billboard mode will only apply to Y axis
  83780. */
  83781. static readonly BILLBOARDMODE_Y: number;
  83782. /**
  83783. * Billboard mode will apply to all axes
  83784. */
  83785. static readonly BILLBOARDMODE_ALL: number;
  83786. /**
  83787. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83788. */
  83789. static readonly BILLBOARDMODE_STRETCHED: number;
  83790. /**
  83791. * This function can be defined to provide custom update for active particles.
  83792. * This function will be called instead of regular update (age, position, color, etc.).
  83793. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83794. */
  83795. updateFunction: (particles: Particle[]) => void;
  83796. private _emitterWorldMatrix;
  83797. /**
  83798. * This function can be defined to specify initial direction for every new particle.
  83799. * It by default use the emitterType defined function
  83800. */
  83801. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83802. /**
  83803. * This function can be defined to specify initial position for every new particle.
  83804. * It by default use the emitterType defined function
  83805. */
  83806. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83807. /**
  83808. * @hidden
  83809. */
  83810. _inheritedVelocityOffset: Vector3;
  83811. /**
  83812. * An event triggered when the system is disposed
  83813. */
  83814. onDisposeObservable: Observable<ParticleSystem>;
  83815. private _onDisposeObserver;
  83816. /**
  83817. * Sets a callback that will be triggered when the system is disposed
  83818. */
  83819. onDispose: () => void;
  83820. private _particles;
  83821. private _epsilon;
  83822. private _capacity;
  83823. private _stockParticles;
  83824. private _newPartsExcess;
  83825. private _vertexData;
  83826. private _vertexBuffer;
  83827. private _vertexBuffers;
  83828. private _spriteBuffer;
  83829. private _indexBuffer;
  83830. private _effect;
  83831. private _customEffect;
  83832. private _cachedDefines;
  83833. private _scaledColorStep;
  83834. private _colorDiff;
  83835. private _scaledDirection;
  83836. private _scaledGravity;
  83837. private _currentRenderId;
  83838. private _alive;
  83839. private _useInstancing;
  83840. private _started;
  83841. private _stopped;
  83842. private _actualFrame;
  83843. private _scaledUpdateSpeed;
  83844. private _vertexBufferSize;
  83845. /** @hidden */
  83846. _currentEmitRateGradient: Nullable<FactorGradient>;
  83847. /** @hidden */
  83848. _currentEmitRate1: number;
  83849. /** @hidden */
  83850. _currentEmitRate2: number;
  83851. /** @hidden */
  83852. _currentStartSizeGradient: Nullable<FactorGradient>;
  83853. /** @hidden */
  83854. _currentStartSize1: number;
  83855. /** @hidden */
  83856. _currentStartSize2: number;
  83857. private readonly _rawTextureWidth;
  83858. private _rampGradientsTexture;
  83859. private _useRampGradients;
  83860. /** Gets or sets a boolean indicating that ramp gradients must be used
  83861. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83862. */
  83863. useRampGradients: boolean;
  83864. /**
  83865. * 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.
  83866. * 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: [])
  83867. */
  83868. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83869. private _subEmitters;
  83870. /**
  83871. * @hidden
  83872. * If the particle systems emitter should be disposed when the particle system is disposed
  83873. */
  83874. _disposeEmitterOnDispose: boolean;
  83875. /**
  83876. * The current active Sub-systems, this property is used by the root particle system only.
  83877. */
  83878. activeSubSystems: Array<ParticleSystem>;
  83879. private _rootParticleSystem;
  83880. /**
  83881. * Gets the current list of active particles
  83882. */
  83883. readonly particles: Particle[];
  83884. /**
  83885. * Returns the string "ParticleSystem"
  83886. * @returns a string containing the class name
  83887. */
  83888. getClassName(): string;
  83889. /**
  83890. * Instantiates a particle system.
  83891. * 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.
  83892. * @param name The name of the particle system
  83893. * @param capacity The max number of particles alive at the same time
  83894. * @param scene The scene the particle system belongs to
  83895. * @param customEffect a custom effect used to change the way particles are rendered by default
  83896. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83897. * @param epsilon Offset used to render the particles
  83898. */
  83899. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83900. private _addFactorGradient;
  83901. private _removeFactorGradient;
  83902. /**
  83903. * Adds a new life time gradient
  83904. * @param gradient defines the gradient to use (between 0 and 1)
  83905. * @param factor defines the life time factor to affect to the specified gradient
  83906. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83907. * @returns the current particle system
  83908. */
  83909. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83910. /**
  83911. * Remove a specific life time gradient
  83912. * @param gradient defines the gradient to remove
  83913. * @returns the current particle system
  83914. */
  83915. removeLifeTimeGradient(gradient: number): IParticleSystem;
  83916. /**
  83917. * Adds a new size gradient
  83918. * @param gradient defines the gradient to use (between 0 and 1)
  83919. * @param factor defines the size factor to affect to the specified gradient
  83920. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83921. * @returns the current particle system
  83922. */
  83923. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83924. /**
  83925. * Remove a specific size gradient
  83926. * @param gradient defines the gradient to remove
  83927. * @returns the current particle system
  83928. */
  83929. removeSizeGradient(gradient: number): IParticleSystem;
  83930. /**
  83931. * Adds a new color remap gradient
  83932. * @param gradient defines the gradient to use (between 0 and 1)
  83933. * @param min defines the color remap minimal range
  83934. * @param max defines the color remap maximal range
  83935. * @returns the current particle system
  83936. */
  83937. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83938. /**
  83939. * Remove a specific color remap gradient
  83940. * @param gradient defines the gradient to remove
  83941. * @returns the current particle system
  83942. */
  83943. removeColorRemapGradient(gradient: number): IParticleSystem;
  83944. /**
  83945. * Adds a new alpha remap gradient
  83946. * @param gradient defines the gradient to use (between 0 and 1)
  83947. * @param min defines the alpha remap minimal range
  83948. * @param max defines the alpha remap maximal range
  83949. * @returns the current particle system
  83950. */
  83951. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  83952. /**
  83953. * Remove a specific alpha remap gradient
  83954. * @param gradient defines the gradient to remove
  83955. * @returns the current particle system
  83956. */
  83957. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  83958. /**
  83959. * Adds a new angular speed gradient
  83960. * @param gradient defines the gradient to use (between 0 and 1)
  83961. * @param factor defines the angular speed to affect to the specified gradient
  83962. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83963. * @returns the current particle system
  83964. */
  83965. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83966. /**
  83967. * Remove a specific angular speed gradient
  83968. * @param gradient defines the gradient to remove
  83969. * @returns the current particle system
  83970. */
  83971. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  83972. /**
  83973. * Adds a new velocity gradient
  83974. * @param gradient defines the gradient to use (between 0 and 1)
  83975. * @param factor defines the velocity to affect to the specified gradient
  83976. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83977. * @returns the current particle system
  83978. */
  83979. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83980. /**
  83981. * Remove a specific velocity gradient
  83982. * @param gradient defines the gradient to remove
  83983. * @returns the current particle system
  83984. */
  83985. removeVelocityGradient(gradient: number): IParticleSystem;
  83986. /**
  83987. * Adds a new limit velocity gradient
  83988. * @param gradient defines the gradient to use (between 0 and 1)
  83989. * @param factor defines the limit velocity value to affect to the specified gradient
  83990. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  83991. * @returns the current particle system
  83992. */
  83993. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  83994. /**
  83995. * Remove a specific limit velocity gradient
  83996. * @param gradient defines the gradient to remove
  83997. * @returns the current particle system
  83998. */
  83999. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84000. /**
  84001. * Adds a new drag gradient
  84002. * @param gradient defines the gradient to use (between 0 and 1)
  84003. * @param factor defines the drag value to affect to the specified gradient
  84004. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84005. * @returns the current particle system
  84006. */
  84007. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84008. /**
  84009. * Remove a specific drag gradient
  84010. * @param gradient defines the gradient to remove
  84011. * @returns the current particle system
  84012. */
  84013. removeDragGradient(gradient: number): IParticleSystem;
  84014. /**
  84015. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84016. * @param gradient defines the gradient to use (between 0 and 1)
  84017. * @param factor defines the emit rate value to affect to the specified gradient
  84018. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84019. * @returns the current particle system
  84020. */
  84021. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84022. /**
  84023. * Remove a specific emit rate gradient
  84024. * @param gradient defines the gradient to remove
  84025. * @returns the current particle system
  84026. */
  84027. removeEmitRateGradient(gradient: number): IParticleSystem;
  84028. /**
  84029. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84030. * @param gradient defines the gradient to use (between 0 and 1)
  84031. * @param factor defines the start size value to affect to the specified gradient
  84032. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84033. * @returns the current particle system
  84034. */
  84035. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84036. /**
  84037. * Remove a specific start size gradient
  84038. * @param gradient defines the gradient to remove
  84039. * @returns the current particle system
  84040. */
  84041. removeStartSizeGradient(gradient: number): IParticleSystem;
  84042. private _createRampGradientTexture;
  84043. /**
  84044. * Gets the current list of ramp gradients.
  84045. * You must use addRampGradient and removeRampGradient to udpate this list
  84046. * @returns the list of ramp gradients
  84047. */
  84048. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84049. /**
  84050. * Adds a new ramp gradient used to remap particle colors
  84051. * @param gradient defines the gradient to use (between 0 and 1)
  84052. * @param color defines the color to affect to the specified gradient
  84053. * @returns the current particle system
  84054. */
  84055. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84056. /**
  84057. * Remove a specific ramp gradient
  84058. * @param gradient defines the gradient to remove
  84059. * @returns the current particle system
  84060. */
  84061. removeRampGradient(gradient: number): ParticleSystem;
  84062. /**
  84063. * Adds a new color gradient
  84064. * @param gradient defines the gradient to use (between 0 and 1)
  84065. * @param color1 defines the color to affect to the specified gradient
  84066. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84067. * @returns this particle system
  84068. */
  84069. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84070. /**
  84071. * Remove a specific color gradient
  84072. * @param gradient defines the gradient to remove
  84073. * @returns this particle system
  84074. */
  84075. removeColorGradient(gradient: number): IParticleSystem;
  84076. private _fetchR;
  84077. protected _reset(): void;
  84078. private _resetEffect;
  84079. private _createVertexBuffers;
  84080. private _createIndexBuffer;
  84081. /**
  84082. * Gets the maximum number of particles active at the same time.
  84083. * @returns The max number of active particles.
  84084. */
  84085. getCapacity(): number;
  84086. /**
  84087. * Gets whether there are still active particles in the system.
  84088. * @returns True if it is alive, otherwise false.
  84089. */
  84090. isAlive(): boolean;
  84091. /**
  84092. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84093. * @returns True if it has been started, otherwise false.
  84094. */
  84095. isStarted(): boolean;
  84096. private _prepareSubEmitterInternalArray;
  84097. /**
  84098. * Starts the particle system and begins to emit
  84099. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84100. */
  84101. start(delay?: number): void;
  84102. /**
  84103. * Stops the particle system.
  84104. * @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.
  84105. */
  84106. stop(stopSubEmitters?: boolean): void;
  84107. /**
  84108. * Remove all active particles
  84109. */
  84110. reset(): void;
  84111. /**
  84112. * @hidden (for internal use only)
  84113. */
  84114. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84115. /**
  84116. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84117. * Its lifetime will start back at 0.
  84118. */
  84119. recycleParticle: (particle: Particle) => void;
  84120. private _stopSubEmitters;
  84121. private _createParticle;
  84122. private _removeFromRoot;
  84123. private _emitFromParticle;
  84124. private _update;
  84125. /** @hidden */
  84126. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84127. /** @hidden */
  84128. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84129. /** @hidden */
  84130. private _getEffect;
  84131. /**
  84132. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84133. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84134. */
  84135. animate(preWarmOnly?: boolean): void;
  84136. private _appendParticleVertices;
  84137. /**
  84138. * Rebuilds the particle system.
  84139. */
  84140. rebuild(): void;
  84141. /**
  84142. * Is this system ready to be used/rendered
  84143. * @return true if the system is ready
  84144. */
  84145. isReady(): boolean;
  84146. private _render;
  84147. /**
  84148. * Renders the particle system in its current state.
  84149. * @returns the current number of particles
  84150. */
  84151. render(): number;
  84152. /**
  84153. * Disposes the particle system and free the associated resources
  84154. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84155. */
  84156. dispose(disposeTexture?: boolean): void;
  84157. /**
  84158. * Clones the particle system.
  84159. * @param name The name of the cloned object
  84160. * @param newEmitter The new emitter to use
  84161. * @returns the cloned particle system
  84162. */
  84163. clone(name: string, newEmitter: any): ParticleSystem;
  84164. /**
  84165. * Serializes the particle system to a JSON object.
  84166. * @returns the JSON object
  84167. */
  84168. serialize(): any;
  84169. /** @hidden */
  84170. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84171. /** @hidden */
  84172. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84173. /**
  84174. * Parses a JSON object to create a particle system.
  84175. * @param parsedParticleSystem The JSON object to parse
  84176. * @param scene The scene to create the particle system in
  84177. * @param rootUrl The root url to use to load external dependencies like texture
  84178. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84179. * @returns the Parsed particle system
  84180. */
  84181. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84182. }
  84183. }
  84184. declare module BABYLON {
  84185. /**
  84186. * A particle represents one of the element emitted by a particle system.
  84187. * This is mainly define by its coordinates, direction, velocity and age.
  84188. */
  84189. export class Particle {
  84190. /**
  84191. * The particle system the particle belongs to.
  84192. */
  84193. particleSystem: ParticleSystem;
  84194. private static _Count;
  84195. /**
  84196. * Unique ID of the particle
  84197. */
  84198. id: number;
  84199. /**
  84200. * The world position of the particle in the scene.
  84201. */
  84202. position: Vector3;
  84203. /**
  84204. * The world direction of the particle in the scene.
  84205. */
  84206. direction: Vector3;
  84207. /**
  84208. * The color of the particle.
  84209. */
  84210. color: Color4;
  84211. /**
  84212. * The color change of the particle per step.
  84213. */
  84214. colorStep: Color4;
  84215. /**
  84216. * Defines how long will the life of the particle be.
  84217. */
  84218. lifeTime: number;
  84219. /**
  84220. * The current age of the particle.
  84221. */
  84222. age: number;
  84223. /**
  84224. * The current size of the particle.
  84225. */
  84226. size: number;
  84227. /**
  84228. * The current scale of the particle.
  84229. */
  84230. scale: Vector2;
  84231. /**
  84232. * The current angle of the particle.
  84233. */
  84234. angle: number;
  84235. /**
  84236. * Defines how fast is the angle changing.
  84237. */
  84238. angularSpeed: number;
  84239. /**
  84240. * Defines the cell index used by the particle to be rendered from a sprite.
  84241. */
  84242. cellIndex: number;
  84243. /**
  84244. * The information required to support color remapping
  84245. */
  84246. remapData: Vector4;
  84247. /** @hidden */
  84248. _randomCellOffset?: number;
  84249. /** @hidden */
  84250. _initialDirection: Nullable<Vector3>;
  84251. /** @hidden */
  84252. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84253. /** @hidden */
  84254. _initialStartSpriteCellID: number;
  84255. /** @hidden */
  84256. _initialEndSpriteCellID: number;
  84257. /** @hidden */
  84258. _currentColorGradient: Nullable<ColorGradient>;
  84259. /** @hidden */
  84260. _currentColor1: Color4;
  84261. /** @hidden */
  84262. _currentColor2: Color4;
  84263. /** @hidden */
  84264. _currentSizeGradient: Nullable<FactorGradient>;
  84265. /** @hidden */
  84266. _currentSize1: number;
  84267. /** @hidden */
  84268. _currentSize2: number;
  84269. /** @hidden */
  84270. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84271. /** @hidden */
  84272. _currentAngularSpeed1: number;
  84273. /** @hidden */
  84274. _currentAngularSpeed2: number;
  84275. /** @hidden */
  84276. _currentVelocityGradient: Nullable<FactorGradient>;
  84277. /** @hidden */
  84278. _currentVelocity1: number;
  84279. /** @hidden */
  84280. _currentVelocity2: number;
  84281. /** @hidden */
  84282. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84283. /** @hidden */
  84284. _currentLimitVelocity1: number;
  84285. /** @hidden */
  84286. _currentLimitVelocity2: number;
  84287. /** @hidden */
  84288. _currentDragGradient: Nullable<FactorGradient>;
  84289. /** @hidden */
  84290. _currentDrag1: number;
  84291. /** @hidden */
  84292. _currentDrag2: number;
  84293. /** @hidden */
  84294. _randomNoiseCoordinates1: Vector3;
  84295. /** @hidden */
  84296. _randomNoiseCoordinates2: Vector3;
  84297. /**
  84298. * Creates a new instance Particle
  84299. * @param particleSystem the particle system the particle belongs to
  84300. */
  84301. constructor(
  84302. /**
  84303. * The particle system the particle belongs to.
  84304. */
  84305. particleSystem: ParticleSystem);
  84306. private updateCellInfoFromSystem;
  84307. /**
  84308. * Defines how the sprite cell index is updated for the particle
  84309. */
  84310. updateCellIndex(): void;
  84311. /** @hidden */
  84312. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84313. /** @hidden */
  84314. _inheritParticleInfoToSubEmitters(): void;
  84315. /** @hidden */
  84316. _reset(): void;
  84317. /**
  84318. * Copy the properties of particle to another one.
  84319. * @param other the particle to copy the information to.
  84320. */
  84321. copyTo(other: Particle): void;
  84322. }
  84323. }
  84324. declare module BABYLON {
  84325. /**
  84326. * Particle emitter represents a volume emitting particles.
  84327. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84328. */
  84329. export interface IParticleEmitterType {
  84330. /**
  84331. * Called by the particle System when the direction is computed for the created particle.
  84332. * @param worldMatrix is the world matrix of the particle system
  84333. * @param directionToUpdate is the direction vector to update with the result
  84334. * @param particle is the particle we are computed the direction for
  84335. */
  84336. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84337. /**
  84338. * Called by the particle System when the position is computed for the created particle.
  84339. * @param worldMatrix is the world matrix of the particle system
  84340. * @param positionToUpdate is the position vector to update with the result
  84341. * @param particle is the particle we are computed the position for
  84342. */
  84343. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84344. /**
  84345. * Clones the current emitter and returns a copy of it
  84346. * @returns the new emitter
  84347. */
  84348. clone(): IParticleEmitterType;
  84349. /**
  84350. * Called by the GPUParticleSystem to setup the update shader
  84351. * @param effect defines the update shader
  84352. */
  84353. applyToShader(effect: Effect): void;
  84354. /**
  84355. * Returns a string to use to update the GPU particles update shader
  84356. * @returns the effect defines string
  84357. */
  84358. getEffectDefines(): string;
  84359. /**
  84360. * Returns a string representing the class name
  84361. * @returns a string containing the class name
  84362. */
  84363. getClassName(): string;
  84364. /**
  84365. * Serializes the particle system to a JSON object.
  84366. * @returns the JSON object
  84367. */
  84368. serialize(): any;
  84369. /**
  84370. * Parse properties from a JSON object
  84371. * @param serializationObject defines the JSON object
  84372. */
  84373. parse(serializationObject: any): void;
  84374. }
  84375. }
  84376. declare module BABYLON {
  84377. /**
  84378. * Particle emitter emitting particles from the inside of a box.
  84379. * It emits the particles randomly between 2 given directions.
  84380. */
  84381. export class BoxParticleEmitter implements IParticleEmitterType {
  84382. /**
  84383. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84384. */
  84385. direction1: Vector3;
  84386. /**
  84387. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84388. */
  84389. direction2: Vector3;
  84390. /**
  84391. * 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.
  84392. */
  84393. minEmitBox: Vector3;
  84394. /**
  84395. * 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.
  84396. */
  84397. maxEmitBox: Vector3;
  84398. /**
  84399. * Creates a new instance BoxParticleEmitter
  84400. */
  84401. constructor();
  84402. /**
  84403. * Called by the particle System when the direction is computed for the created particle.
  84404. * @param worldMatrix is the world matrix of the particle system
  84405. * @param directionToUpdate is the direction vector to update with the result
  84406. * @param particle is the particle we are computed the direction for
  84407. */
  84408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84409. /**
  84410. * Called by the particle System when the position is computed for the created particle.
  84411. * @param worldMatrix is the world matrix of the particle system
  84412. * @param positionToUpdate is the position vector to update with the result
  84413. * @param particle is the particle we are computed the position for
  84414. */
  84415. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84416. /**
  84417. * Clones the current emitter and returns a copy of it
  84418. * @returns the new emitter
  84419. */
  84420. clone(): BoxParticleEmitter;
  84421. /**
  84422. * Called by the GPUParticleSystem to setup the update shader
  84423. * @param effect defines the update shader
  84424. */
  84425. applyToShader(effect: Effect): void;
  84426. /**
  84427. * Returns a string to use to update the GPU particles update shader
  84428. * @returns a string containng the defines string
  84429. */
  84430. getEffectDefines(): string;
  84431. /**
  84432. * Returns the string "BoxParticleEmitter"
  84433. * @returns a string containing the class name
  84434. */
  84435. getClassName(): string;
  84436. /**
  84437. * Serializes the particle system to a JSON object.
  84438. * @returns the JSON object
  84439. */
  84440. serialize(): any;
  84441. /**
  84442. * Parse properties from a JSON object
  84443. * @param serializationObject defines the JSON object
  84444. */
  84445. parse(serializationObject: any): void;
  84446. }
  84447. }
  84448. declare module BABYLON {
  84449. /**
  84450. * Particle emitter emitting particles from the inside of a cone.
  84451. * It emits the particles alongside the cone volume from the base to the particle.
  84452. * The emission direction might be randomized.
  84453. */
  84454. export class ConeParticleEmitter implements IParticleEmitterType {
  84455. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84456. directionRandomizer: number;
  84457. private _radius;
  84458. private _angle;
  84459. private _height;
  84460. /**
  84461. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84462. */
  84463. radiusRange: number;
  84464. /**
  84465. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84466. */
  84467. heightRange: number;
  84468. /**
  84469. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84470. */
  84471. emitFromSpawnPointOnly: boolean;
  84472. /**
  84473. * Gets or sets the radius of the emission cone
  84474. */
  84475. radius: number;
  84476. /**
  84477. * Gets or sets the angle of the emission cone
  84478. */
  84479. angle: number;
  84480. private _buildHeight;
  84481. /**
  84482. * Creates a new instance ConeParticleEmitter
  84483. * @param radius the radius of the emission cone (1 by default)
  84484. * @param angle the cone base angle (PI by default)
  84485. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84486. */
  84487. constructor(radius?: number, angle?: number,
  84488. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84489. directionRandomizer?: number);
  84490. /**
  84491. * Called by the particle System when the direction is computed for the created particle.
  84492. * @param worldMatrix is the world matrix of the particle system
  84493. * @param directionToUpdate is the direction vector to update with the result
  84494. * @param particle is the particle we are computed the direction for
  84495. */
  84496. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84497. /**
  84498. * Called by the particle System when the position is computed for the created particle.
  84499. * @param worldMatrix is the world matrix of the particle system
  84500. * @param positionToUpdate is the position vector to update with the result
  84501. * @param particle is the particle we are computed the position for
  84502. */
  84503. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84504. /**
  84505. * Clones the current emitter and returns a copy of it
  84506. * @returns the new emitter
  84507. */
  84508. clone(): ConeParticleEmitter;
  84509. /**
  84510. * Called by the GPUParticleSystem to setup the update shader
  84511. * @param effect defines the update shader
  84512. */
  84513. applyToShader(effect: Effect): void;
  84514. /**
  84515. * Returns a string to use to update the GPU particles update shader
  84516. * @returns a string containng the defines string
  84517. */
  84518. getEffectDefines(): string;
  84519. /**
  84520. * Returns the string "ConeParticleEmitter"
  84521. * @returns a string containing the class name
  84522. */
  84523. getClassName(): string;
  84524. /**
  84525. * Serializes the particle system to a JSON object.
  84526. * @returns the JSON object
  84527. */
  84528. serialize(): any;
  84529. /**
  84530. * Parse properties from a JSON object
  84531. * @param serializationObject defines the JSON object
  84532. */
  84533. parse(serializationObject: any): void;
  84534. }
  84535. }
  84536. declare module BABYLON {
  84537. /**
  84538. * Particle emitter emitting particles from the inside of a cylinder.
  84539. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84540. */
  84541. export class CylinderParticleEmitter implements IParticleEmitterType {
  84542. /**
  84543. * The radius of the emission cylinder.
  84544. */
  84545. radius: number;
  84546. /**
  84547. * The height of the emission cylinder.
  84548. */
  84549. height: number;
  84550. /**
  84551. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84552. */
  84553. radiusRange: number;
  84554. /**
  84555. * How much to randomize the particle direction [0-1].
  84556. */
  84557. directionRandomizer: number;
  84558. /**
  84559. * Creates a new instance CylinderParticleEmitter
  84560. * @param radius the radius of the emission cylinder (1 by default)
  84561. * @param height the height of the emission cylinder (1 by default)
  84562. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84563. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84564. */
  84565. constructor(
  84566. /**
  84567. * The radius of the emission cylinder.
  84568. */
  84569. radius?: number,
  84570. /**
  84571. * The height of the emission cylinder.
  84572. */
  84573. height?: number,
  84574. /**
  84575. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84576. */
  84577. radiusRange?: number,
  84578. /**
  84579. * How much to randomize the particle direction [0-1].
  84580. */
  84581. directionRandomizer?: number);
  84582. /**
  84583. * Called by the particle System when the direction is computed for the created particle.
  84584. * @param worldMatrix is the world matrix of the particle system
  84585. * @param directionToUpdate is the direction vector to update with the result
  84586. * @param particle is the particle we are computed the direction for
  84587. */
  84588. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84589. /**
  84590. * Called by the particle System when the position is computed for the created particle.
  84591. * @param worldMatrix is the world matrix of the particle system
  84592. * @param positionToUpdate is the position vector to update with the result
  84593. * @param particle is the particle we are computed the position for
  84594. */
  84595. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84596. /**
  84597. * Clones the current emitter and returns a copy of it
  84598. * @returns the new emitter
  84599. */
  84600. clone(): CylinderParticleEmitter;
  84601. /**
  84602. * Called by the GPUParticleSystem to setup the update shader
  84603. * @param effect defines the update shader
  84604. */
  84605. applyToShader(effect: Effect): void;
  84606. /**
  84607. * Returns a string to use to update the GPU particles update shader
  84608. * @returns a string containng the defines string
  84609. */
  84610. getEffectDefines(): string;
  84611. /**
  84612. * Returns the string "CylinderParticleEmitter"
  84613. * @returns a string containing the class name
  84614. */
  84615. getClassName(): string;
  84616. /**
  84617. * Serializes the particle system to a JSON object.
  84618. * @returns the JSON object
  84619. */
  84620. serialize(): any;
  84621. /**
  84622. * Parse properties from a JSON object
  84623. * @param serializationObject defines the JSON object
  84624. */
  84625. parse(serializationObject: any): void;
  84626. }
  84627. /**
  84628. * Particle emitter emitting particles from the inside of a cylinder.
  84629. * It emits the particles randomly between two vectors.
  84630. */
  84631. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84632. /**
  84633. * The min limit of the emission direction.
  84634. */
  84635. direction1: Vector3;
  84636. /**
  84637. * The max limit of the emission direction.
  84638. */
  84639. direction2: Vector3;
  84640. /**
  84641. * Creates a new instance CylinderDirectedParticleEmitter
  84642. * @param radius the radius of the emission cylinder (1 by default)
  84643. * @param height the height of the emission cylinder (1 by default)
  84644. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84645. * @param direction1 the min limit of the emission direction (up vector by default)
  84646. * @param direction2 the max limit of the emission direction (up vector by default)
  84647. */
  84648. constructor(radius?: number, height?: number, radiusRange?: number,
  84649. /**
  84650. * The min limit of the emission direction.
  84651. */
  84652. direction1?: Vector3,
  84653. /**
  84654. * The max limit of the emission direction.
  84655. */
  84656. direction2?: Vector3);
  84657. /**
  84658. * Called by the particle System when the direction is computed for the created particle.
  84659. * @param worldMatrix is the world matrix of the particle system
  84660. * @param directionToUpdate is the direction vector to update with the result
  84661. * @param particle is the particle we are computed the direction for
  84662. */
  84663. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84664. /**
  84665. * Clones the current emitter and returns a copy of it
  84666. * @returns the new emitter
  84667. */
  84668. clone(): CylinderDirectedParticleEmitter;
  84669. /**
  84670. * Called by the GPUParticleSystem to setup the update shader
  84671. * @param effect defines the update shader
  84672. */
  84673. applyToShader(effect: Effect): void;
  84674. /**
  84675. * Returns a string to use to update the GPU particles update shader
  84676. * @returns a string containng the defines string
  84677. */
  84678. getEffectDefines(): string;
  84679. /**
  84680. * Returns the string "CylinderDirectedParticleEmitter"
  84681. * @returns a string containing the class name
  84682. */
  84683. getClassName(): string;
  84684. /**
  84685. * Serializes the particle system to a JSON object.
  84686. * @returns the JSON object
  84687. */
  84688. serialize(): any;
  84689. /**
  84690. * Parse properties from a JSON object
  84691. * @param serializationObject defines the JSON object
  84692. */
  84693. parse(serializationObject: any): void;
  84694. }
  84695. }
  84696. declare module BABYLON {
  84697. /**
  84698. * Particle emitter emitting particles from the inside of a hemisphere.
  84699. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84700. */
  84701. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84702. /**
  84703. * The radius of the emission hemisphere.
  84704. */
  84705. radius: number;
  84706. /**
  84707. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84708. */
  84709. radiusRange: number;
  84710. /**
  84711. * How much to randomize the particle direction [0-1].
  84712. */
  84713. directionRandomizer: number;
  84714. /**
  84715. * Creates a new instance HemisphericParticleEmitter
  84716. * @param radius the radius of the emission hemisphere (1 by default)
  84717. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84718. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84719. */
  84720. constructor(
  84721. /**
  84722. * The radius of the emission hemisphere.
  84723. */
  84724. radius?: number,
  84725. /**
  84726. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84727. */
  84728. radiusRange?: number,
  84729. /**
  84730. * How much to randomize the particle direction [0-1].
  84731. */
  84732. directionRandomizer?: number);
  84733. /**
  84734. * Called by the particle System when the direction is computed for the created particle.
  84735. * @param worldMatrix is the world matrix of the particle system
  84736. * @param directionToUpdate is the direction vector to update with the result
  84737. * @param particle is the particle we are computed the direction for
  84738. */
  84739. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84740. /**
  84741. * Called by the particle System when the position is computed for the created particle.
  84742. * @param worldMatrix is the world matrix of the particle system
  84743. * @param positionToUpdate is the position vector to update with the result
  84744. * @param particle is the particle we are computed the position for
  84745. */
  84746. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84747. /**
  84748. * Clones the current emitter and returns a copy of it
  84749. * @returns the new emitter
  84750. */
  84751. clone(): HemisphericParticleEmitter;
  84752. /**
  84753. * Called by the GPUParticleSystem to setup the update shader
  84754. * @param effect defines the update shader
  84755. */
  84756. applyToShader(effect: Effect): void;
  84757. /**
  84758. * Returns a string to use to update the GPU particles update shader
  84759. * @returns a string containng the defines string
  84760. */
  84761. getEffectDefines(): string;
  84762. /**
  84763. * Returns the string "HemisphericParticleEmitter"
  84764. * @returns a string containing the class name
  84765. */
  84766. getClassName(): string;
  84767. /**
  84768. * Serializes the particle system to a JSON object.
  84769. * @returns the JSON object
  84770. */
  84771. serialize(): any;
  84772. /**
  84773. * Parse properties from a JSON object
  84774. * @param serializationObject defines the JSON object
  84775. */
  84776. parse(serializationObject: any): void;
  84777. }
  84778. }
  84779. declare module BABYLON {
  84780. /**
  84781. * Particle emitter emitting particles from a point.
  84782. * It emits the particles randomly between 2 given directions.
  84783. */
  84784. export class PointParticleEmitter implements IParticleEmitterType {
  84785. /**
  84786. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84787. */
  84788. direction1: Vector3;
  84789. /**
  84790. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84791. */
  84792. direction2: Vector3;
  84793. /**
  84794. * Creates a new instance PointParticleEmitter
  84795. */
  84796. constructor();
  84797. /**
  84798. * Called by the particle System when the direction is computed for the created particle.
  84799. * @param worldMatrix is the world matrix of the particle system
  84800. * @param directionToUpdate is the direction vector to update with the result
  84801. * @param particle is the particle we are computed the direction for
  84802. */
  84803. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84804. /**
  84805. * Called by the particle System when the position is computed for the created particle.
  84806. * @param worldMatrix is the world matrix of the particle system
  84807. * @param positionToUpdate is the position vector to update with the result
  84808. * @param particle is the particle we are computed the position for
  84809. */
  84810. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84811. /**
  84812. * Clones the current emitter and returns a copy of it
  84813. * @returns the new emitter
  84814. */
  84815. clone(): PointParticleEmitter;
  84816. /**
  84817. * Called by the GPUParticleSystem to setup the update shader
  84818. * @param effect defines the update shader
  84819. */
  84820. applyToShader(effect: Effect): void;
  84821. /**
  84822. * Returns a string to use to update the GPU particles update shader
  84823. * @returns a string containng the defines string
  84824. */
  84825. getEffectDefines(): string;
  84826. /**
  84827. * Returns the string "PointParticleEmitter"
  84828. * @returns a string containing the class name
  84829. */
  84830. getClassName(): string;
  84831. /**
  84832. * Serializes the particle system to a JSON object.
  84833. * @returns the JSON object
  84834. */
  84835. serialize(): any;
  84836. /**
  84837. * Parse properties from a JSON object
  84838. * @param serializationObject defines the JSON object
  84839. */
  84840. parse(serializationObject: any): void;
  84841. }
  84842. }
  84843. declare module BABYLON {
  84844. /**
  84845. * Particle emitter emitting particles from the inside of a sphere.
  84846. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84847. */
  84848. export class SphereParticleEmitter implements IParticleEmitterType {
  84849. /**
  84850. * The radius of the emission sphere.
  84851. */
  84852. radius: number;
  84853. /**
  84854. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84855. */
  84856. radiusRange: number;
  84857. /**
  84858. * How much to randomize the particle direction [0-1].
  84859. */
  84860. directionRandomizer: number;
  84861. /**
  84862. * Creates a new instance SphereParticleEmitter
  84863. * @param radius the radius of the emission sphere (1 by default)
  84864. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84865. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84866. */
  84867. constructor(
  84868. /**
  84869. * The radius of the emission sphere.
  84870. */
  84871. radius?: number,
  84872. /**
  84873. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84874. */
  84875. radiusRange?: number,
  84876. /**
  84877. * How much to randomize the particle direction [0-1].
  84878. */
  84879. directionRandomizer?: number);
  84880. /**
  84881. * Called by the particle System when the direction is computed for the created particle.
  84882. * @param worldMatrix is the world matrix of the particle system
  84883. * @param directionToUpdate is the direction vector to update with the result
  84884. * @param particle is the particle we are computed the direction for
  84885. */
  84886. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84887. /**
  84888. * Called by the particle System when the position is computed for the created particle.
  84889. * @param worldMatrix is the world matrix of the particle system
  84890. * @param positionToUpdate is the position vector to update with the result
  84891. * @param particle is the particle we are computed the position for
  84892. */
  84893. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84894. /**
  84895. * Clones the current emitter and returns a copy of it
  84896. * @returns the new emitter
  84897. */
  84898. clone(): SphereParticleEmitter;
  84899. /**
  84900. * Called by the GPUParticleSystem to setup the update shader
  84901. * @param effect defines the update shader
  84902. */
  84903. applyToShader(effect: Effect): void;
  84904. /**
  84905. * Returns a string to use to update the GPU particles update shader
  84906. * @returns a string containng the defines string
  84907. */
  84908. getEffectDefines(): string;
  84909. /**
  84910. * Returns the string "SphereParticleEmitter"
  84911. * @returns a string containing the class name
  84912. */
  84913. getClassName(): string;
  84914. /**
  84915. * Serializes the particle system to a JSON object.
  84916. * @returns the JSON object
  84917. */
  84918. serialize(): any;
  84919. /**
  84920. * Parse properties from a JSON object
  84921. * @param serializationObject defines the JSON object
  84922. */
  84923. parse(serializationObject: any): void;
  84924. }
  84925. /**
  84926. * Particle emitter emitting particles from the inside of a sphere.
  84927. * It emits the particles randomly between two vectors.
  84928. */
  84929. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  84930. /**
  84931. * The min limit of the emission direction.
  84932. */
  84933. direction1: Vector3;
  84934. /**
  84935. * The max limit of the emission direction.
  84936. */
  84937. direction2: Vector3;
  84938. /**
  84939. * Creates a new instance SphereDirectedParticleEmitter
  84940. * @param radius the radius of the emission sphere (1 by default)
  84941. * @param direction1 the min limit of the emission direction (up vector by default)
  84942. * @param direction2 the max limit of the emission direction (up vector by default)
  84943. */
  84944. constructor(radius?: number,
  84945. /**
  84946. * The min limit of the emission direction.
  84947. */
  84948. direction1?: Vector3,
  84949. /**
  84950. * The max limit of the emission direction.
  84951. */
  84952. direction2?: Vector3);
  84953. /**
  84954. * Called by the particle System when the direction is computed for the created particle.
  84955. * @param worldMatrix is the world matrix of the particle system
  84956. * @param directionToUpdate is the direction vector to update with the result
  84957. * @param particle is the particle we are computed the direction for
  84958. */
  84959. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84960. /**
  84961. * Clones the current emitter and returns a copy of it
  84962. * @returns the new emitter
  84963. */
  84964. clone(): SphereDirectedParticleEmitter;
  84965. /**
  84966. * Called by the GPUParticleSystem to setup the update shader
  84967. * @param effect defines the update shader
  84968. */
  84969. applyToShader(effect: Effect): void;
  84970. /**
  84971. * Returns a string to use to update the GPU particles update shader
  84972. * @returns a string containng the defines string
  84973. */
  84974. getEffectDefines(): string;
  84975. /**
  84976. * Returns the string "SphereDirectedParticleEmitter"
  84977. * @returns a string containing the class name
  84978. */
  84979. getClassName(): string;
  84980. /**
  84981. * Serializes the particle system to a JSON object.
  84982. * @returns the JSON object
  84983. */
  84984. serialize(): any;
  84985. /**
  84986. * Parse properties from a JSON object
  84987. * @param serializationObject defines the JSON object
  84988. */
  84989. parse(serializationObject: any): void;
  84990. }
  84991. }
  84992. declare module BABYLON {
  84993. /**
  84994. * Interface representing a particle system in Babylon.js.
  84995. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  84996. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  84997. */
  84998. export interface IParticleSystem {
  84999. /**
  85000. * List of animations used by the particle system.
  85001. */
  85002. animations: Animation[];
  85003. /**
  85004. * The id of the Particle system.
  85005. */
  85006. id: string;
  85007. /**
  85008. * The name of the Particle system.
  85009. */
  85010. name: string;
  85011. /**
  85012. * The emitter represents the Mesh or position we are attaching the particle system to.
  85013. */
  85014. emitter: Nullable<AbstractMesh | Vector3>;
  85015. /**
  85016. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85017. */
  85018. isBillboardBased: boolean;
  85019. /**
  85020. * The rendering group used by the Particle system to chose when to render.
  85021. */
  85022. renderingGroupId: number;
  85023. /**
  85024. * The layer mask we are rendering the particles through.
  85025. */
  85026. layerMask: number;
  85027. /**
  85028. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85029. */
  85030. updateSpeed: number;
  85031. /**
  85032. * The amount of time the particle system is running (depends of the overall update speed).
  85033. */
  85034. targetStopDuration: number;
  85035. /**
  85036. * The texture used to render each particle. (this can be a spritesheet)
  85037. */
  85038. particleTexture: Nullable<Texture>;
  85039. /**
  85040. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85041. */
  85042. blendMode: number;
  85043. /**
  85044. * Minimum life time of emitting particles.
  85045. */
  85046. minLifeTime: number;
  85047. /**
  85048. * Maximum life time of emitting particles.
  85049. */
  85050. maxLifeTime: number;
  85051. /**
  85052. * Minimum Size of emitting particles.
  85053. */
  85054. minSize: number;
  85055. /**
  85056. * Maximum Size of emitting particles.
  85057. */
  85058. maxSize: number;
  85059. /**
  85060. * Minimum scale of emitting particles on X axis.
  85061. */
  85062. minScaleX: number;
  85063. /**
  85064. * Maximum scale of emitting particles on X axis.
  85065. */
  85066. maxScaleX: number;
  85067. /**
  85068. * Minimum scale of emitting particles on Y axis.
  85069. */
  85070. minScaleY: number;
  85071. /**
  85072. * Maximum scale of emitting particles on Y axis.
  85073. */
  85074. maxScaleY: number;
  85075. /**
  85076. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85077. */
  85078. color1: Color4;
  85079. /**
  85080. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85081. */
  85082. color2: Color4;
  85083. /**
  85084. * Color the particle will have at the end of its lifetime.
  85085. */
  85086. colorDead: Color4;
  85087. /**
  85088. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85089. */
  85090. emitRate: number;
  85091. /**
  85092. * You can use gravity if you want to give an orientation to your particles.
  85093. */
  85094. gravity: Vector3;
  85095. /**
  85096. * Minimum power of emitting particles.
  85097. */
  85098. minEmitPower: number;
  85099. /**
  85100. * Maximum power of emitting particles.
  85101. */
  85102. maxEmitPower: number;
  85103. /**
  85104. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85105. */
  85106. minAngularSpeed: number;
  85107. /**
  85108. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85109. */
  85110. maxAngularSpeed: number;
  85111. /**
  85112. * Gets or sets the minimal initial rotation in radians.
  85113. */
  85114. minInitialRotation: number;
  85115. /**
  85116. * Gets or sets the maximal initial rotation in radians.
  85117. */
  85118. maxInitialRotation: number;
  85119. /**
  85120. * The particle emitter type defines the emitter used by the particle system.
  85121. * It can be for example box, sphere, or cone...
  85122. */
  85123. particleEmitterType: Nullable<IParticleEmitterType>;
  85124. /**
  85125. * Defines the delay in milliseconds before starting the system (0 by default)
  85126. */
  85127. startDelay: number;
  85128. /**
  85129. * 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
  85130. */
  85131. preWarmCycles: number;
  85132. /**
  85133. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85134. */
  85135. preWarmStepOffset: number;
  85136. /**
  85137. * 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)
  85138. */
  85139. spriteCellChangeSpeed: number;
  85140. /**
  85141. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85142. */
  85143. startSpriteCellID: number;
  85144. /**
  85145. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85146. */
  85147. endSpriteCellID: number;
  85148. /**
  85149. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85150. */
  85151. spriteCellWidth: number;
  85152. /**
  85153. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85154. */
  85155. spriteCellHeight: number;
  85156. /**
  85157. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85158. */
  85159. spriteRandomStartCell: boolean;
  85160. /**
  85161. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85162. */
  85163. isAnimationSheetEnabled: boolean;
  85164. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85165. translationPivot: Vector2;
  85166. /**
  85167. * Gets or sets a texture used to add random noise to particle positions
  85168. */
  85169. noiseTexture: Nullable<BaseTexture>;
  85170. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85171. noiseStrength: Vector3;
  85172. /**
  85173. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85174. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85175. */
  85176. billboardMode: number;
  85177. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85178. limitVelocityDamping: number;
  85179. /**
  85180. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85181. */
  85182. beginAnimationOnStart: boolean;
  85183. /**
  85184. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85185. */
  85186. beginAnimationFrom: number;
  85187. /**
  85188. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85189. */
  85190. beginAnimationTo: number;
  85191. /**
  85192. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85193. */
  85194. beginAnimationLoop: boolean;
  85195. /**
  85196. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85197. */
  85198. disposeOnStop: boolean;
  85199. /**
  85200. * Gets the maximum number of particles active at the same time.
  85201. * @returns The max number of active particles.
  85202. */
  85203. getCapacity(): number;
  85204. /**
  85205. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85206. * @returns True if it has been started, otherwise false.
  85207. */
  85208. isStarted(): boolean;
  85209. /**
  85210. * Animates the particle system for this frame.
  85211. */
  85212. animate(): void;
  85213. /**
  85214. * Renders the particle system in its current state.
  85215. * @returns the current number of particles
  85216. */
  85217. render(): number;
  85218. /**
  85219. * Dispose the particle system and frees its associated resources.
  85220. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85221. */
  85222. dispose(disposeTexture?: boolean): void;
  85223. /**
  85224. * Clones the particle system.
  85225. * @param name The name of the cloned object
  85226. * @param newEmitter The new emitter to use
  85227. * @returns the cloned particle system
  85228. */
  85229. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85230. /**
  85231. * Serializes the particle system to a JSON object.
  85232. * @returns the JSON object
  85233. */
  85234. serialize(): any;
  85235. /**
  85236. * Rebuild the particle system
  85237. */
  85238. rebuild(): void;
  85239. /**
  85240. * Starts the particle system and begins to emit
  85241. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85242. */
  85243. start(delay?: number): void;
  85244. /**
  85245. * Stops the particle system.
  85246. */
  85247. stop(): void;
  85248. /**
  85249. * Remove all active particles
  85250. */
  85251. reset(): void;
  85252. /**
  85253. * Is this system ready to be used/rendered
  85254. * @return true if the system is ready
  85255. */
  85256. isReady(): boolean;
  85257. /**
  85258. * Adds a new color gradient
  85259. * @param gradient defines the gradient to use (between 0 and 1)
  85260. * @param color1 defines the color to affect to the specified gradient
  85261. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85262. * @returns the current particle system
  85263. */
  85264. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85265. /**
  85266. * Remove a specific color gradient
  85267. * @param gradient defines the gradient to remove
  85268. * @returns the current particle system
  85269. */
  85270. removeColorGradient(gradient: number): IParticleSystem;
  85271. /**
  85272. * Adds a new size gradient
  85273. * @param gradient defines the gradient to use (between 0 and 1)
  85274. * @param factor defines the size factor to affect to the specified gradient
  85275. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85276. * @returns the current particle system
  85277. */
  85278. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85279. /**
  85280. * Remove a specific size gradient
  85281. * @param gradient defines the gradient to remove
  85282. * @returns the current particle system
  85283. */
  85284. removeSizeGradient(gradient: number): IParticleSystem;
  85285. /**
  85286. * Gets the current list of color gradients.
  85287. * You must use addColorGradient and removeColorGradient to udpate this list
  85288. * @returns the list of color gradients
  85289. */
  85290. getColorGradients(): Nullable<Array<ColorGradient>>;
  85291. /**
  85292. * Gets the current list of size gradients.
  85293. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85294. * @returns the list of size gradients
  85295. */
  85296. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85297. /**
  85298. * Gets the current list of angular speed gradients.
  85299. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85300. * @returns the list of angular speed gradients
  85301. */
  85302. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85303. /**
  85304. * Adds a new angular speed gradient
  85305. * @param gradient defines the gradient to use (between 0 and 1)
  85306. * @param factor defines the angular speed to affect to the specified gradient
  85307. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85308. * @returns the current particle system
  85309. */
  85310. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85311. /**
  85312. * Remove a specific angular speed gradient
  85313. * @param gradient defines the gradient to remove
  85314. * @returns the current particle system
  85315. */
  85316. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85317. /**
  85318. * Gets the current list of velocity gradients.
  85319. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85320. * @returns the list of velocity gradients
  85321. */
  85322. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85323. /**
  85324. * Adds a new velocity gradient
  85325. * @param gradient defines the gradient to use (between 0 and 1)
  85326. * @param factor defines the velocity to affect to the specified gradient
  85327. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85328. * @returns the current particle system
  85329. */
  85330. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85331. /**
  85332. * Remove a specific velocity gradient
  85333. * @param gradient defines the gradient to remove
  85334. * @returns the current particle system
  85335. */
  85336. removeVelocityGradient(gradient: number): IParticleSystem;
  85337. /**
  85338. * Gets the current list of limit velocity gradients.
  85339. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85340. * @returns the list of limit velocity gradients
  85341. */
  85342. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85343. /**
  85344. * Adds a new limit velocity gradient
  85345. * @param gradient defines the gradient to use (between 0 and 1)
  85346. * @param factor defines the limit velocity to affect to the specified gradient
  85347. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85348. * @returns the current particle system
  85349. */
  85350. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85351. /**
  85352. * Remove a specific limit velocity gradient
  85353. * @param gradient defines the gradient to remove
  85354. * @returns the current particle system
  85355. */
  85356. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85357. /**
  85358. * Adds a new drag gradient
  85359. * @param gradient defines the gradient to use (between 0 and 1)
  85360. * @param factor defines the drag to affect to the specified gradient
  85361. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85362. * @returns the current particle system
  85363. */
  85364. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85365. /**
  85366. * Remove a specific drag gradient
  85367. * @param gradient defines the gradient to remove
  85368. * @returns the current particle system
  85369. */
  85370. removeDragGradient(gradient: number): IParticleSystem;
  85371. /**
  85372. * Gets the current list of drag gradients.
  85373. * You must use addDragGradient and removeDragGradient to udpate this list
  85374. * @returns the list of drag gradients
  85375. */
  85376. getDragGradients(): Nullable<Array<FactorGradient>>;
  85377. /**
  85378. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85379. * @param gradient defines the gradient to use (between 0 and 1)
  85380. * @param factor defines the emit rate to affect to the specified gradient
  85381. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85382. * @returns the current particle system
  85383. */
  85384. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85385. /**
  85386. * Remove a specific emit rate gradient
  85387. * @param gradient defines the gradient to remove
  85388. * @returns the current particle system
  85389. */
  85390. removeEmitRateGradient(gradient: number): IParticleSystem;
  85391. /**
  85392. * Gets the current list of emit rate gradients.
  85393. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85394. * @returns the list of emit rate gradients
  85395. */
  85396. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85397. /**
  85398. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85399. * @param gradient defines the gradient to use (between 0 and 1)
  85400. * @param factor defines the start size to affect to the specified gradient
  85401. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85402. * @returns the current particle system
  85403. */
  85404. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85405. /**
  85406. * Remove a specific start size gradient
  85407. * @param gradient defines the gradient to remove
  85408. * @returns the current particle system
  85409. */
  85410. removeStartSizeGradient(gradient: number): IParticleSystem;
  85411. /**
  85412. * Gets the current list of start size gradients.
  85413. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85414. * @returns the list of start size gradients
  85415. */
  85416. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85417. /**
  85418. * Adds a new life time gradient
  85419. * @param gradient defines the gradient to use (between 0 and 1)
  85420. * @param factor defines the life time factor to affect to the specified gradient
  85421. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85422. * @returns the current particle system
  85423. */
  85424. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85425. /**
  85426. * Remove a specific life time gradient
  85427. * @param gradient defines the gradient to remove
  85428. * @returns the current particle system
  85429. */
  85430. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85431. /**
  85432. * Gets the current list of life time gradients.
  85433. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85434. * @returns the list of life time gradients
  85435. */
  85436. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85437. /**
  85438. * Gets the current list of color gradients.
  85439. * You must use addColorGradient and removeColorGradient to udpate this list
  85440. * @returns the list of color gradients
  85441. */
  85442. getColorGradients(): Nullable<Array<ColorGradient>>;
  85443. /**
  85444. * Adds a new ramp gradient used to remap particle colors
  85445. * @param gradient defines the gradient to use (between 0 and 1)
  85446. * @param color defines the color to affect to the specified gradient
  85447. * @returns the current particle system
  85448. */
  85449. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85450. /**
  85451. * Gets the current list of ramp gradients.
  85452. * You must use addRampGradient and removeRampGradient to udpate this list
  85453. * @returns the list of ramp gradients
  85454. */
  85455. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85456. /** Gets or sets a boolean indicating that ramp gradients must be used
  85457. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85458. */
  85459. useRampGradients: boolean;
  85460. /**
  85461. * Adds a new color remap gradient
  85462. * @param gradient defines the gradient to use (between 0 and 1)
  85463. * @param min defines the color remap minimal range
  85464. * @param max defines the color remap maximal range
  85465. * @returns the current particle system
  85466. */
  85467. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85468. /**
  85469. * Gets the current list of color remap gradients.
  85470. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85471. * @returns the list of color remap gradients
  85472. */
  85473. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85474. /**
  85475. * Adds a new alpha remap gradient
  85476. * @param gradient defines the gradient to use (between 0 and 1)
  85477. * @param min defines the alpha remap minimal range
  85478. * @param max defines the alpha remap maximal range
  85479. * @returns the current particle system
  85480. */
  85481. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85482. /**
  85483. * Gets the current list of alpha remap gradients.
  85484. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85485. * @returns the list of alpha remap gradients
  85486. */
  85487. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85488. /**
  85489. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85490. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85491. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85492. * @returns the emitter
  85493. */
  85494. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85495. /**
  85496. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85497. * @param radius The radius of the hemisphere to emit from
  85498. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85499. * @returns the emitter
  85500. */
  85501. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85502. /**
  85503. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85504. * @param radius The radius of the sphere to emit from
  85505. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85506. * @returns the emitter
  85507. */
  85508. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85509. /**
  85510. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85511. * @param radius The radius of the sphere to emit from
  85512. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85513. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85514. * @returns the emitter
  85515. */
  85516. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85517. /**
  85518. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85519. * @param radius The radius of the emission cylinder
  85520. * @param height The height of the emission cylinder
  85521. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85522. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85523. * @returns the emitter
  85524. */
  85525. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85526. /**
  85527. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85528. * @param radius The radius of the cylinder to emit from
  85529. * @param height The height of the emission cylinder
  85530. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85531. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85532. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85533. * @returns the emitter
  85534. */
  85535. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85536. /**
  85537. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85538. * @param radius The radius of the cone to emit from
  85539. * @param angle The base angle of the cone
  85540. * @returns the emitter
  85541. */
  85542. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85543. /**
  85544. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85545. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85546. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85547. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85548. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85549. * @returns the emitter
  85550. */
  85551. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85552. /**
  85553. * Get hosting scene
  85554. * @returns the scene
  85555. */
  85556. getScene(): Scene;
  85557. }
  85558. }
  85559. declare module BABYLON {
  85560. /**
  85561. * Creates an instance based on a source mesh.
  85562. */
  85563. export class InstancedMesh extends AbstractMesh {
  85564. private _sourceMesh;
  85565. private _currentLOD;
  85566. /** @hidden */
  85567. _indexInSourceMeshInstanceArray: number;
  85568. constructor(name: string, source: Mesh);
  85569. /**
  85570. * Returns the string "InstancedMesh".
  85571. */
  85572. getClassName(): string;
  85573. /** Gets the list of lights affecting that mesh */
  85574. readonly lightSources: Light[];
  85575. _resyncLightSources(): void;
  85576. _resyncLighSource(light: Light): void;
  85577. _removeLightSource(light: Light, dispose: boolean): void;
  85578. /**
  85579. * If the source mesh receives shadows
  85580. */
  85581. readonly receiveShadows: boolean;
  85582. /**
  85583. * The material of the source mesh
  85584. */
  85585. readonly material: Nullable<Material>;
  85586. /**
  85587. * Visibility of the source mesh
  85588. */
  85589. readonly visibility: number;
  85590. /**
  85591. * Skeleton of the source mesh
  85592. */
  85593. readonly skeleton: Nullable<Skeleton>;
  85594. /**
  85595. * Rendering ground id of the source mesh
  85596. */
  85597. renderingGroupId: number;
  85598. /**
  85599. * Returns the total number of vertices (integer).
  85600. */
  85601. getTotalVertices(): number;
  85602. /**
  85603. * Returns a positive integer : the total number of indices in this mesh geometry.
  85604. * @returns the numner of indices or zero if the mesh has no geometry.
  85605. */
  85606. getTotalIndices(): number;
  85607. /**
  85608. * The source mesh of the instance
  85609. */
  85610. readonly sourceMesh: Mesh;
  85611. /**
  85612. * Is this node ready to be used/rendered
  85613. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85614. * @return {boolean} is it ready
  85615. */
  85616. isReady(completeCheck?: boolean): boolean;
  85617. /**
  85618. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85619. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85620. * @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.
  85621. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85622. */
  85623. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85624. /**
  85625. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85626. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85627. * The `data` are either a numeric array either a Float32Array.
  85628. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85629. * 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).
  85630. * Note that a new underlying VertexBuffer object is created each call.
  85631. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85632. *
  85633. * Possible `kind` values :
  85634. * - VertexBuffer.PositionKind
  85635. * - VertexBuffer.UVKind
  85636. * - VertexBuffer.UV2Kind
  85637. * - VertexBuffer.UV3Kind
  85638. * - VertexBuffer.UV4Kind
  85639. * - VertexBuffer.UV5Kind
  85640. * - VertexBuffer.UV6Kind
  85641. * - VertexBuffer.ColorKind
  85642. * - VertexBuffer.MatricesIndicesKind
  85643. * - VertexBuffer.MatricesIndicesExtraKind
  85644. * - VertexBuffer.MatricesWeightsKind
  85645. * - VertexBuffer.MatricesWeightsExtraKind
  85646. *
  85647. * Returns the Mesh.
  85648. */
  85649. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85650. /**
  85651. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85652. * If the mesh has no geometry, it is simply returned as it is.
  85653. * The `data` are either a numeric array either a Float32Array.
  85654. * No new underlying VertexBuffer object is created.
  85655. * 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.
  85656. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85657. *
  85658. * Possible `kind` values :
  85659. * - VertexBuffer.PositionKind
  85660. * - VertexBuffer.UVKind
  85661. * - VertexBuffer.UV2Kind
  85662. * - VertexBuffer.UV3Kind
  85663. * - VertexBuffer.UV4Kind
  85664. * - VertexBuffer.UV5Kind
  85665. * - VertexBuffer.UV6Kind
  85666. * - VertexBuffer.ColorKind
  85667. * - VertexBuffer.MatricesIndicesKind
  85668. * - VertexBuffer.MatricesIndicesExtraKind
  85669. * - VertexBuffer.MatricesWeightsKind
  85670. * - VertexBuffer.MatricesWeightsExtraKind
  85671. *
  85672. * Returns the Mesh.
  85673. */
  85674. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85675. /**
  85676. * Sets the mesh indices.
  85677. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85678. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85679. * This method creates a new index buffer each call.
  85680. * Returns the Mesh.
  85681. */
  85682. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85683. /**
  85684. * Boolean : True if the mesh owns the requested kind of data.
  85685. */
  85686. isVerticesDataPresent(kind: string): boolean;
  85687. /**
  85688. * Returns an array of indices (IndicesArray).
  85689. */
  85690. getIndices(): Nullable<IndicesArray>;
  85691. readonly _positions: Nullable<Vector3[]>;
  85692. /**
  85693. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85694. * This means the mesh underlying bounding box and sphere are recomputed.
  85695. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85696. * @returns the current mesh
  85697. */
  85698. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85699. /** @hidden */
  85700. _preActivate(): InstancedMesh;
  85701. /** @hidden */
  85702. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85703. /** @hidden */
  85704. _postActivate(): void;
  85705. getWorldMatrix(): Matrix;
  85706. readonly isAnInstance: boolean;
  85707. /**
  85708. * Returns the current associated LOD AbstractMesh.
  85709. */
  85710. getLOD(camera: Camera): AbstractMesh;
  85711. /** @hidden */
  85712. _syncSubMeshes(): InstancedMesh;
  85713. /** @hidden */
  85714. _generatePointsArray(): boolean;
  85715. /**
  85716. * Creates a new InstancedMesh from the current mesh.
  85717. * - name (string) : the cloned mesh name
  85718. * - newParent (optional Node) : the optional Node to parent the clone to.
  85719. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85720. *
  85721. * Returns the clone.
  85722. */
  85723. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85724. /**
  85725. * Disposes the InstancedMesh.
  85726. * Returns nothing.
  85727. */
  85728. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85729. }
  85730. }
  85731. declare module BABYLON {
  85732. /**
  85733. * Defines the options associated with the creation of a shader material.
  85734. */
  85735. export interface IShaderMaterialOptions {
  85736. /**
  85737. * Does the material work in alpha blend mode
  85738. */
  85739. needAlphaBlending: boolean;
  85740. /**
  85741. * Does the material work in alpha test mode
  85742. */
  85743. needAlphaTesting: boolean;
  85744. /**
  85745. * The list of attribute names used in the shader
  85746. */
  85747. attributes: string[];
  85748. /**
  85749. * The list of unifrom names used in the shader
  85750. */
  85751. uniforms: string[];
  85752. /**
  85753. * The list of UBO names used in the shader
  85754. */
  85755. uniformBuffers: string[];
  85756. /**
  85757. * The list of sampler names used in the shader
  85758. */
  85759. samplers: string[];
  85760. /**
  85761. * The list of defines used in the shader
  85762. */
  85763. defines: string[];
  85764. }
  85765. /**
  85766. * 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.
  85767. *
  85768. * This returned material effects how the mesh will look based on the code in the shaders.
  85769. *
  85770. * @see http://doc.babylonjs.com/how_to/shader_material
  85771. */
  85772. export class ShaderMaterial extends Material {
  85773. private _shaderPath;
  85774. private _options;
  85775. private _textures;
  85776. private _textureArrays;
  85777. private _floats;
  85778. private _ints;
  85779. private _floatsArrays;
  85780. private _colors3;
  85781. private _colors3Arrays;
  85782. private _colors4;
  85783. private _colors4Arrays;
  85784. private _vectors2;
  85785. private _vectors3;
  85786. private _vectors4;
  85787. private _matrices;
  85788. private _matrices3x3;
  85789. private _matrices2x2;
  85790. private _vectors2Arrays;
  85791. private _vectors3Arrays;
  85792. private _vectors4Arrays;
  85793. private _cachedWorldViewMatrix;
  85794. private _cachedWorldViewProjectionMatrix;
  85795. private _renderId;
  85796. /**
  85797. * Instantiate a new shader material.
  85798. * 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.
  85799. * This returned material effects how the mesh will look based on the code in the shaders.
  85800. * @see http://doc.babylonjs.com/how_to/shader_material
  85801. * @param name Define the name of the material in the scene
  85802. * @param scene Define the scene the material belongs to
  85803. * @param shaderPath Defines the route to the shader code in one of three ways:
  85804. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85805. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85806. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85807. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85808. * @param options Define the options used to create the shader
  85809. */
  85810. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85811. /**
  85812. * Gets the options used to compile the shader.
  85813. * They can be modified to trigger a new compilation
  85814. */
  85815. readonly options: IShaderMaterialOptions;
  85816. /**
  85817. * Gets the current class name of the material e.g. "ShaderMaterial"
  85818. * Mainly use in serialization.
  85819. * @returns the class name
  85820. */
  85821. getClassName(): string;
  85822. /**
  85823. * Specifies if the material will require alpha blending
  85824. * @returns a boolean specifying if alpha blending is needed
  85825. */
  85826. needAlphaBlending(): boolean;
  85827. /**
  85828. * Specifies if this material should be rendered in alpha test mode
  85829. * @returns a boolean specifying if an alpha test is needed.
  85830. */
  85831. needAlphaTesting(): boolean;
  85832. private _checkUniform;
  85833. /**
  85834. * Set a texture in the shader.
  85835. * @param name Define the name of the uniform samplers as defined in the shader
  85836. * @param texture Define the texture to bind to this sampler
  85837. * @return the material itself allowing "fluent" like uniform updates
  85838. */
  85839. setTexture(name: string, texture: Texture): ShaderMaterial;
  85840. /**
  85841. * Set a texture array in the shader.
  85842. * @param name Define the name of the uniform sampler array as defined in the shader
  85843. * @param textures Define the list of textures to bind to this sampler
  85844. * @return the material itself allowing "fluent" like uniform updates
  85845. */
  85846. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85847. /**
  85848. * Set a float in the shader.
  85849. * @param name Define the name of the uniform as defined in the shader
  85850. * @param value Define the value to give to the uniform
  85851. * @return the material itself allowing "fluent" like uniform updates
  85852. */
  85853. setFloat(name: string, value: number): ShaderMaterial;
  85854. /**
  85855. * Set a int in the shader.
  85856. * @param name Define the name of the uniform as defined in the shader
  85857. * @param value Define the value to give to the uniform
  85858. * @return the material itself allowing "fluent" like uniform updates
  85859. */
  85860. setInt(name: string, value: number): ShaderMaterial;
  85861. /**
  85862. * Set an array of floats in the shader.
  85863. * @param name Define the name of the uniform as defined in the shader
  85864. * @param value Define the value to give to the uniform
  85865. * @return the material itself allowing "fluent" like uniform updates
  85866. */
  85867. setFloats(name: string, value: number[]): ShaderMaterial;
  85868. /**
  85869. * Set a vec3 in the shader from a Color3.
  85870. * @param name Define the name of the uniform as defined in the shader
  85871. * @param value Define the value to give to the uniform
  85872. * @return the material itself allowing "fluent" like uniform updates
  85873. */
  85874. setColor3(name: string, value: Color3): ShaderMaterial;
  85875. /**
  85876. * Set a vec3 array in the shader from a Color3 array.
  85877. * @param name Define the name of the uniform as defined in the shader
  85878. * @param value Define the value to give to the uniform
  85879. * @return the material itself allowing "fluent" like uniform updates
  85880. */
  85881. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85882. /**
  85883. * Set a vec4 in the shader from a Color4.
  85884. * @param name Define the name of the uniform as defined in the shader
  85885. * @param value Define the value to give to the uniform
  85886. * @return the material itself allowing "fluent" like uniform updates
  85887. */
  85888. setColor4(name: string, value: Color4): ShaderMaterial;
  85889. /**
  85890. * Set a vec4 array in the shader from a Color4 array.
  85891. * @param name Define the name of the uniform as defined in the shader
  85892. * @param value Define the value to give to the uniform
  85893. * @return the material itself allowing "fluent" like uniform updates
  85894. */
  85895. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85896. /**
  85897. * Set a vec2 in the shader from a Vector2.
  85898. * @param name Define the name of the uniform as defined in the shader
  85899. * @param value Define the value to give to the uniform
  85900. * @return the material itself allowing "fluent" like uniform updates
  85901. */
  85902. setVector2(name: string, value: Vector2): ShaderMaterial;
  85903. /**
  85904. * Set a vec3 in the shader from a Vector3.
  85905. * @param name Define the name of the uniform as defined in the shader
  85906. * @param value Define the value to give to the uniform
  85907. * @return the material itself allowing "fluent" like uniform updates
  85908. */
  85909. setVector3(name: string, value: Vector3): ShaderMaterial;
  85910. /**
  85911. * Set a vec4 in the shader from a Vector4.
  85912. * @param name Define the name of the uniform as defined in the shader
  85913. * @param value Define the value to give to the uniform
  85914. * @return the material itself allowing "fluent" like uniform updates
  85915. */
  85916. setVector4(name: string, value: Vector4): ShaderMaterial;
  85917. /**
  85918. * Set a mat4 in the shader from a Matrix.
  85919. * @param name Define the name of the uniform as defined in the shader
  85920. * @param value Define the value to give to the uniform
  85921. * @return the material itself allowing "fluent" like uniform updates
  85922. */
  85923. setMatrix(name: string, value: Matrix): ShaderMaterial;
  85924. /**
  85925. * Set a mat3 in the shader from a Float32Array.
  85926. * @param name Define the name of the uniform as defined in the shader
  85927. * @param value Define the value to give to the uniform
  85928. * @return the material itself allowing "fluent" like uniform updates
  85929. */
  85930. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  85931. /**
  85932. * Set a mat2 in the shader from a Float32Array.
  85933. * @param name Define the name of the uniform as defined in the shader
  85934. * @param value Define the value to give to the uniform
  85935. * @return the material itself allowing "fluent" like uniform updates
  85936. */
  85937. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  85938. /**
  85939. * Set a vec2 array in the shader from a number array.
  85940. * @param name Define the name of the uniform as defined in the shader
  85941. * @param value Define the value to give to the uniform
  85942. * @return the material itself allowing "fluent" like uniform updates
  85943. */
  85944. setArray2(name: string, value: number[]): ShaderMaterial;
  85945. /**
  85946. * Set a vec3 array in the shader from a number array.
  85947. * @param name Define the name of the uniform as defined in the shader
  85948. * @param value Define the value to give to the uniform
  85949. * @return the material itself allowing "fluent" like uniform updates
  85950. */
  85951. setArray3(name: string, value: number[]): ShaderMaterial;
  85952. /**
  85953. * Set a vec4 array in the shader from a number array.
  85954. * @param name Define the name of the uniform as defined in the shader
  85955. * @param value Define the value to give to the uniform
  85956. * @return the material itself allowing "fluent" like uniform updates
  85957. */
  85958. setArray4(name: string, value: number[]): ShaderMaterial;
  85959. private _checkCache;
  85960. /**
  85961. * Specifies that the submesh is ready to be used
  85962. * @param mesh defines the mesh to check
  85963. * @param subMesh defines which submesh to check
  85964. * @param useInstances specifies that instances should be used
  85965. * @returns a boolean indicating that the submesh is ready or not
  85966. */
  85967. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  85968. /**
  85969. * Checks if the material is ready to render the requested mesh
  85970. * @param mesh Define the mesh to render
  85971. * @param useInstances Define whether or not the material is used with instances
  85972. * @returns true if ready, otherwise false
  85973. */
  85974. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  85975. /**
  85976. * Binds the world matrix to the material
  85977. * @param world defines the world transformation matrix
  85978. */
  85979. bindOnlyWorldMatrix(world: Matrix): void;
  85980. /**
  85981. * Binds the material to the mesh
  85982. * @param world defines the world transformation matrix
  85983. * @param mesh defines the mesh to bind the material to
  85984. */
  85985. bind(world: Matrix, mesh?: Mesh): void;
  85986. /**
  85987. * Gets the active textures from the material
  85988. * @returns an array of textures
  85989. */
  85990. getActiveTextures(): BaseTexture[];
  85991. /**
  85992. * Specifies if the material uses a texture
  85993. * @param texture defines the texture to check against the material
  85994. * @returns a boolean specifying if the material uses the texture
  85995. */
  85996. hasTexture(texture: BaseTexture): boolean;
  85997. /**
  85998. * Makes a duplicate of the material, and gives it a new name
  85999. * @param name defines the new name for the duplicated material
  86000. * @returns the cloned material
  86001. */
  86002. clone(name: string): ShaderMaterial;
  86003. /**
  86004. * Disposes the material
  86005. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86006. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86007. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86008. */
  86009. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86010. /**
  86011. * Serializes this material in a JSON representation
  86012. * @returns the serialized material object
  86013. */
  86014. serialize(): any;
  86015. /**
  86016. * Creates a shader material from parsed shader material data
  86017. * @param source defines the JSON represnetation of the material
  86018. * @param scene defines the hosting scene
  86019. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86020. * @returns a new material
  86021. */
  86022. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86023. }
  86024. }
  86025. declare module BABYLON {
  86026. /** @hidden */
  86027. export var colorPixelShader: {
  86028. name: string;
  86029. shader: string;
  86030. };
  86031. }
  86032. declare module BABYLON {
  86033. /** @hidden */
  86034. export var colorVertexShader: {
  86035. name: string;
  86036. shader: string;
  86037. };
  86038. }
  86039. declare module BABYLON {
  86040. /**
  86041. * Line mesh
  86042. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86043. */
  86044. export class LinesMesh extends Mesh {
  86045. /**
  86046. * If vertex color should be applied to the mesh
  86047. */
  86048. readonly useVertexColor?: boolean | undefined;
  86049. /**
  86050. * If vertex alpha should be applied to the mesh
  86051. */
  86052. readonly useVertexAlpha?: boolean | undefined;
  86053. /**
  86054. * Color of the line (Default: White)
  86055. */
  86056. color: Color3;
  86057. /**
  86058. * Alpha of the line (Default: 1)
  86059. */
  86060. alpha: number;
  86061. /**
  86062. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86063. * This margin is expressed in world space coordinates, so its value may vary.
  86064. * Default value is 0.1
  86065. */
  86066. intersectionThreshold: number;
  86067. private _colorShader;
  86068. private color4;
  86069. /**
  86070. * Creates a new LinesMesh
  86071. * @param name defines the name
  86072. * @param scene defines the hosting scene
  86073. * @param parent defines the parent mesh if any
  86074. * @param source defines the optional source LinesMesh used to clone data from
  86075. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86076. * When false, achieved by calling a clone(), also passing False.
  86077. * This will make creation of children, recursive.
  86078. * @param useVertexColor defines if this LinesMesh supports vertex color
  86079. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86080. */
  86081. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86082. /**
  86083. * If vertex color should be applied to the mesh
  86084. */
  86085. useVertexColor?: boolean | undefined,
  86086. /**
  86087. * If vertex alpha should be applied to the mesh
  86088. */
  86089. useVertexAlpha?: boolean | undefined);
  86090. private _addClipPlaneDefine;
  86091. private _removeClipPlaneDefine;
  86092. isReady(): boolean;
  86093. /**
  86094. * Returns the string "LineMesh"
  86095. */
  86096. getClassName(): string;
  86097. /**
  86098. * @hidden
  86099. */
  86100. /**
  86101. * @hidden
  86102. */
  86103. material: Material;
  86104. /**
  86105. * @hidden
  86106. */
  86107. readonly checkCollisions: boolean;
  86108. /** @hidden */
  86109. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86110. /** @hidden */
  86111. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86112. /**
  86113. * Disposes of the line mesh
  86114. * @param doNotRecurse If children should be disposed
  86115. */
  86116. dispose(doNotRecurse?: boolean): void;
  86117. /**
  86118. * Returns a new LineMesh object cloned from the current one.
  86119. */
  86120. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86121. /**
  86122. * Creates a new InstancedLinesMesh object from the mesh model.
  86123. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86124. * @param name defines the name of the new instance
  86125. * @returns a new InstancedLinesMesh
  86126. */
  86127. createInstance(name: string): InstancedLinesMesh;
  86128. }
  86129. /**
  86130. * Creates an instance based on a source LinesMesh
  86131. */
  86132. export class InstancedLinesMesh extends InstancedMesh {
  86133. /**
  86134. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86135. * This margin is expressed in world space coordinates, so its value may vary.
  86136. * Initilized with the intersectionThreshold value of the source LinesMesh
  86137. */
  86138. intersectionThreshold: number;
  86139. constructor(name: string, source: LinesMesh);
  86140. /**
  86141. * Returns the string "InstancedLinesMesh".
  86142. */
  86143. getClassName(): string;
  86144. }
  86145. }
  86146. declare module BABYLON {
  86147. /** @hidden */
  86148. export var linePixelShader: {
  86149. name: string;
  86150. shader: string;
  86151. };
  86152. }
  86153. declare module BABYLON {
  86154. /** @hidden */
  86155. export var lineVertexShader: {
  86156. name: string;
  86157. shader: string;
  86158. };
  86159. }
  86160. declare module BABYLON {
  86161. interface AbstractMesh {
  86162. /**
  86163. * Gets the edgesRenderer associated with the mesh
  86164. */
  86165. edgesRenderer: Nullable<EdgesRenderer>;
  86166. }
  86167. interface LinesMesh {
  86168. /**
  86169. * Enables the edge rendering mode on the mesh.
  86170. * This mode makes the mesh edges visible
  86171. * @param epsilon defines the maximal distance between two angles to detect a face
  86172. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86173. * @returns the currentAbstractMesh
  86174. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86175. */
  86176. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86177. }
  86178. interface InstancedLinesMesh {
  86179. /**
  86180. * Enables the edge rendering mode on the mesh.
  86181. * This mode makes the mesh edges visible
  86182. * @param epsilon defines the maximal distance between two angles to detect a face
  86183. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86184. * @returns the current InstancedLinesMesh
  86185. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86186. */
  86187. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86188. }
  86189. /**
  86190. * Defines the minimum contract an Edges renderer should follow.
  86191. */
  86192. export interface IEdgesRenderer extends IDisposable {
  86193. /**
  86194. * Gets or sets a boolean indicating if the edgesRenderer is active
  86195. */
  86196. isEnabled: boolean;
  86197. /**
  86198. * Renders the edges of the attached mesh,
  86199. */
  86200. render(): void;
  86201. /**
  86202. * Checks wether or not the edges renderer is ready to render.
  86203. * @return true if ready, otherwise false.
  86204. */
  86205. isReady(): boolean;
  86206. }
  86207. /**
  86208. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86209. */
  86210. export class EdgesRenderer implements IEdgesRenderer {
  86211. /**
  86212. * Define the size of the edges with an orthographic camera
  86213. */
  86214. edgesWidthScalerForOrthographic: number;
  86215. /**
  86216. * Define the size of the edges with a perspective camera
  86217. */
  86218. edgesWidthScalerForPerspective: number;
  86219. protected _source: AbstractMesh;
  86220. protected _linesPositions: number[];
  86221. protected _linesNormals: number[];
  86222. protected _linesIndices: number[];
  86223. protected _epsilon: number;
  86224. protected _indicesCount: number;
  86225. protected _lineShader: ShaderMaterial;
  86226. protected _ib: DataBuffer;
  86227. protected _buffers: {
  86228. [key: string]: Nullable<VertexBuffer>;
  86229. };
  86230. protected _checkVerticesInsteadOfIndices: boolean;
  86231. private _meshRebuildObserver;
  86232. private _meshDisposeObserver;
  86233. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86234. isEnabled: boolean;
  86235. /**
  86236. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86237. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86238. * @param source Mesh used to create edges
  86239. * @param epsilon sum of angles in adjacency to check for edge
  86240. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86241. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86242. */
  86243. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86244. protected _prepareRessources(): void;
  86245. /** @hidden */
  86246. _rebuild(): void;
  86247. /**
  86248. * Releases the required resources for the edges renderer
  86249. */
  86250. dispose(): void;
  86251. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86252. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86253. /**
  86254. * Checks if the pair of p0 and p1 is en edge
  86255. * @param faceIndex
  86256. * @param edge
  86257. * @param faceNormals
  86258. * @param p0
  86259. * @param p1
  86260. * @private
  86261. */
  86262. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86263. /**
  86264. * push line into the position, normal and index buffer
  86265. * @protected
  86266. */
  86267. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86268. /**
  86269. * Generates lines edges from adjacencjes
  86270. * @private
  86271. */
  86272. _generateEdgesLines(): void;
  86273. /**
  86274. * Checks wether or not the edges renderer is ready to render.
  86275. * @return true if ready, otherwise false.
  86276. */
  86277. isReady(): boolean;
  86278. /**
  86279. * Renders the edges of the attached mesh,
  86280. */
  86281. render(): void;
  86282. }
  86283. /**
  86284. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86285. */
  86286. export class LineEdgesRenderer extends EdgesRenderer {
  86287. /**
  86288. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86289. * @param source LineMesh used to generate edges
  86290. * @param epsilon not important (specified angle for edge detection)
  86291. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86292. */
  86293. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86294. /**
  86295. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86296. */
  86297. _generateEdgesLines(): void;
  86298. }
  86299. }
  86300. declare module BABYLON {
  86301. /**
  86302. * This represents the object necessary to create a rendering group.
  86303. * This is exclusively used and created by the rendering manager.
  86304. * To modify the behavior, you use the available helpers in your scene or meshes.
  86305. * @hidden
  86306. */
  86307. export class RenderingGroup {
  86308. index: number;
  86309. private static _zeroVector;
  86310. private _scene;
  86311. private _opaqueSubMeshes;
  86312. private _transparentSubMeshes;
  86313. private _alphaTestSubMeshes;
  86314. private _depthOnlySubMeshes;
  86315. private _particleSystems;
  86316. private _spriteManagers;
  86317. private _opaqueSortCompareFn;
  86318. private _alphaTestSortCompareFn;
  86319. private _transparentSortCompareFn;
  86320. private _renderOpaque;
  86321. private _renderAlphaTest;
  86322. private _renderTransparent;
  86323. /** @hidden */
  86324. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86325. onBeforeTransparentRendering: () => void;
  86326. /**
  86327. * Set the opaque sort comparison function.
  86328. * If null the sub meshes will be render in the order they were created
  86329. */
  86330. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86331. /**
  86332. * Set the alpha test sort comparison function.
  86333. * If null the sub meshes will be render in the order they were created
  86334. */
  86335. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86336. /**
  86337. * Set the transparent sort comparison function.
  86338. * If null the sub meshes will be render in the order they were created
  86339. */
  86340. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86341. /**
  86342. * Creates a new rendering group.
  86343. * @param index The rendering group index
  86344. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86345. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86346. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86347. */
  86348. 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>);
  86349. /**
  86350. * Render all the sub meshes contained in the group.
  86351. * @param customRenderFunction Used to override the default render behaviour of the group.
  86352. * @returns true if rendered some submeshes.
  86353. */
  86354. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86355. /**
  86356. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86357. * @param subMeshes The submeshes to render
  86358. */
  86359. private renderOpaqueSorted;
  86360. /**
  86361. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86362. * @param subMeshes The submeshes to render
  86363. */
  86364. private renderAlphaTestSorted;
  86365. /**
  86366. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86367. * @param subMeshes The submeshes to render
  86368. */
  86369. private renderTransparentSorted;
  86370. /**
  86371. * Renders the submeshes in a specified order.
  86372. * @param subMeshes The submeshes to sort before render
  86373. * @param sortCompareFn The comparison function use to sort
  86374. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86375. * @param transparent Specifies to activate blending if true
  86376. */
  86377. private static renderSorted;
  86378. /**
  86379. * Renders the submeshes in the order they were dispatched (no sort applied).
  86380. * @param subMeshes The submeshes to render
  86381. */
  86382. private static renderUnsorted;
  86383. /**
  86384. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86385. * are rendered back to front if in the same alpha index.
  86386. *
  86387. * @param a The first submesh
  86388. * @param b The second submesh
  86389. * @returns The result of the comparison
  86390. */
  86391. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86392. /**
  86393. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86394. * are rendered back to front.
  86395. *
  86396. * @param a The first submesh
  86397. * @param b The second submesh
  86398. * @returns The result of the comparison
  86399. */
  86400. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86401. /**
  86402. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86403. * are rendered front to back (prevent overdraw).
  86404. *
  86405. * @param a The first submesh
  86406. * @param b The second submesh
  86407. * @returns The result of the comparison
  86408. */
  86409. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86410. /**
  86411. * Resets the different lists of submeshes to prepare a new frame.
  86412. */
  86413. prepare(): void;
  86414. dispose(): void;
  86415. /**
  86416. * Inserts the submesh in its correct queue depending on its material.
  86417. * @param subMesh The submesh to dispatch
  86418. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86419. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86420. */
  86421. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86422. dispatchSprites(spriteManager: ISpriteManager): void;
  86423. dispatchParticles(particleSystem: IParticleSystem): void;
  86424. private _renderParticles;
  86425. private _renderSprites;
  86426. }
  86427. }
  86428. declare module BABYLON {
  86429. /**
  86430. * Interface describing the different options available in the rendering manager
  86431. * regarding Auto Clear between groups.
  86432. */
  86433. export interface IRenderingManagerAutoClearSetup {
  86434. /**
  86435. * Defines whether or not autoclear is enable.
  86436. */
  86437. autoClear: boolean;
  86438. /**
  86439. * Defines whether or not to autoclear the depth buffer.
  86440. */
  86441. depth: boolean;
  86442. /**
  86443. * Defines whether or not to autoclear the stencil buffer.
  86444. */
  86445. stencil: boolean;
  86446. }
  86447. /**
  86448. * This class is used by the onRenderingGroupObservable
  86449. */
  86450. export class RenderingGroupInfo {
  86451. /**
  86452. * The Scene that being rendered
  86453. */
  86454. scene: Scene;
  86455. /**
  86456. * The camera currently used for the rendering pass
  86457. */
  86458. camera: Nullable<Camera>;
  86459. /**
  86460. * The ID of the renderingGroup being processed
  86461. */
  86462. renderingGroupId: number;
  86463. }
  86464. /**
  86465. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86466. * It is enable to manage the different groups as well as the different necessary sort functions.
  86467. * This should not be used directly aside of the few static configurations
  86468. */
  86469. export class RenderingManager {
  86470. /**
  86471. * The max id used for rendering groups (not included)
  86472. */
  86473. static MAX_RENDERINGGROUPS: number;
  86474. /**
  86475. * The min id used for rendering groups (included)
  86476. */
  86477. static MIN_RENDERINGGROUPS: number;
  86478. /**
  86479. * Used to globally prevent autoclearing scenes.
  86480. */
  86481. static AUTOCLEAR: boolean;
  86482. /**
  86483. * @hidden
  86484. */
  86485. _useSceneAutoClearSetup: boolean;
  86486. private _scene;
  86487. private _renderingGroups;
  86488. private _depthStencilBufferAlreadyCleaned;
  86489. private _autoClearDepthStencil;
  86490. private _customOpaqueSortCompareFn;
  86491. private _customAlphaTestSortCompareFn;
  86492. private _customTransparentSortCompareFn;
  86493. private _renderingGroupInfo;
  86494. /**
  86495. * Instantiates a new rendering group for a particular scene
  86496. * @param scene Defines the scene the groups belongs to
  86497. */
  86498. constructor(scene: Scene);
  86499. private _clearDepthStencilBuffer;
  86500. /**
  86501. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86502. * @hidden
  86503. */
  86504. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86505. /**
  86506. * Resets the different information of the group to prepare a new frame
  86507. * @hidden
  86508. */
  86509. reset(): void;
  86510. /**
  86511. * Dispose and release the group and its associated resources.
  86512. * @hidden
  86513. */
  86514. dispose(): void;
  86515. /**
  86516. * Clear the info related to rendering groups preventing retention points during dispose.
  86517. */
  86518. freeRenderingGroups(): void;
  86519. private _prepareRenderingGroup;
  86520. /**
  86521. * Add a sprite manager to the rendering manager in order to render it this frame.
  86522. * @param spriteManager Define the sprite manager to render
  86523. */
  86524. dispatchSprites(spriteManager: ISpriteManager): void;
  86525. /**
  86526. * Add a particle system to the rendering manager in order to render it this frame.
  86527. * @param particleSystem Define the particle system to render
  86528. */
  86529. dispatchParticles(particleSystem: IParticleSystem): void;
  86530. /**
  86531. * Add a submesh to the manager in order to render it this frame
  86532. * @param subMesh The submesh to dispatch
  86533. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86534. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86535. */
  86536. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86537. /**
  86538. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86539. * This allowed control for front to back rendering or reversly depending of the special needs.
  86540. *
  86541. * @param renderingGroupId The rendering group id corresponding to its index
  86542. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86543. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86544. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86545. */
  86546. 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;
  86547. /**
  86548. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86549. *
  86550. * @param renderingGroupId The rendering group id corresponding to its index
  86551. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86552. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86553. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86554. */
  86555. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86556. /**
  86557. * Gets the current auto clear configuration for one rendering group of the rendering
  86558. * manager.
  86559. * @param index the rendering group index to get the information for
  86560. * @returns The auto clear setup for the requested rendering group
  86561. */
  86562. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86563. }
  86564. }
  86565. declare module BABYLON {
  86566. /**
  86567. * This Helps creating a texture that will be created from a camera in your scene.
  86568. * It is basically a dynamic texture that could be used to create special effects for instance.
  86569. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86570. */
  86571. export class RenderTargetTexture extends Texture {
  86572. isCube: boolean;
  86573. /**
  86574. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86575. */
  86576. static readonly REFRESHRATE_RENDER_ONCE: number;
  86577. /**
  86578. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86579. */
  86580. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86581. /**
  86582. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86583. * the central point of your effect and can save a lot of performances.
  86584. */
  86585. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86586. /**
  86587. * Use this predicate to dynamically define the list of mesh you want to render.
  86588. * If set, the renderList property will be overwritten.
  86589. */
  86590. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86591. private _renderList;
  86592. /**
  86593. * Use this list to define the list of mesh you want to render.
  86594. */
  86595. renderList: Nullable<Array<AbstractMesh>>;
  86596. private _hookArray;
  86597. /**
  86598. * Define if particles should be rendered in your texture.
  86599. */
  86600. renderParticles: boolean;
  86601. /**
  86602. * Define if sprites should be rendered in your texture.
  86603. */
  86604. renderSprites: boolean;
  86605. /**
  86606. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86607. */
  86608. coordinatesMode: number;
  86609. /**
  86610. * Define the camera used to render the texture.
  86611. */
  86612. activeCamera: Nullable<Camera>;
  86613. /**
  86614. * Override the render function of the texture with your own one.
  86615. */
  86616. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86617. /**
  86618. * Define if camera post processes should be use while rendering the texture.
  86619. */
  86620. useCameraPostProcesses: boolean;
  86621. /**
  86622. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86623. */
  86624. ignoreCameraViewport: boolean;
  86625. private _postProcessManager;
  86626. private _postProcesses;
  86627. private _resizeObserver;
  86628. /**
  86629. * An event triggered when the texture is unbind.
  86630. */
  86631. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86632. /**
  86633. * An event triggered when the texture is unbind.
  86634. */
  86635. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86636. private _onAfterUnbindObserver;
  86637. /**
  86638. * Set a after unbind callback in the texture.
  86639. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86640. */
  86641. onAfterUnbind: () => void;
  86642. /**
  86643. * An event triggered before rendering the texture
  86644. */
  86645. onBeforeRenderObservable: Observable<number>;
  86646. private _onBeforeRenderObserver;
  86647. /**
  86648. * Set a before render callback in the texture.
  86649. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86650. */
  86651. onBeforeRender: (faceIndex: number) => void;
  86652. /**
  86653. * An event triggered after rendering the texture
  86654. */
  86655. onAfterRenderObservable: Observable<number>;
  86656. private _onAfterRenderObserver;
  86657. /**
  86658. * Set a after render callback in the texture.
  86659. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86660. */
  86661. onAfterRender: (faceIndex: number) => void;
  86662. /**
  86663. * An event triggered after the texture clear
  86664. */
  86665. onClearObservable: Observable<Engine>;
  86666. private _onClearObserver;
  86667. /**
  86668. * Set a clear callback in the texture.
  86669. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86670. */
  86671. onClear: (Engine: Engine) => void;
  86672. /**
  86673. * An event triggered when the texture is resized.
  86674. */
  86675. onResizeObservable: Observable<RenderTargetTexture>;
  86676. /**
  86677. * Define the clear color of the Render Target if it should be different from the scene.
  86678. */
  86679. clearColor: Color4;
  86680. protected _size: number | {
  86681. width: number;
  86682. height: number;
  86683. };
  86684. protected _initialSizeParameter: number | {
  86685. width: number;
  86686. height: number;
  86687. } | {
  86688. ratio: number;
  86689. };
  86690. protected _sizeRatio: Nullable<number>;
  86691. /** @hidden */
  86692. _generateMipMaps: boolean;
  86693. protected _renderingManager: RenderingManager;
  86694. /** @hidden */
  86695. _waitingRenderList: string[];
  86696. protected _doNotChangeAspectRatio: boolean;
  86697. protected _currentRefreshId: number;
  86698. protected _refreshRate: number;
  86699. protected _textureMatrix: Matrix;
  86700. protected _samples: number;
  86701. protected _renderTargetOptions: RenderTargetCreationOptions;
  86702. /**
  86703. * Gets render target creation options that were used.
  86704. */
  86705. readonly renderTargetOptions: RenderTargetCreationOptions;
  86706. protected _engine: Engine;
  86707. protected _onRatioRescale(): void;
  86708. /**
  86709. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86710. * It must define where the camera used to render the texture is set
  86711. */
  86712. boundingBoxPosition: Vector3;
  86713. private _boundingBoxSize;
  86714. /**
  86715. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86716. * When defined, the cubemap will switch to local mode
  86717. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86718. * @example https://www.babylonjs-playground.com/#RNASML
  86719. */
  86720. boundingBoxSize: Vector3;
  86721. /**
  86722. * In case the RTT has been created with a depth texture, get the associated
  86723. * depth texture.
  86724. * Otherwise, return null.
  86725. */
  86726. depthStencilTexture: Nullable<InternalTexture>;
  86727. /**
  86728. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86729. * or used a shadow, depth texture...
  86730. * @param name The friendly name of the texture
  86731. * @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)
  86732. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86733. * @param generateMipMaps True if mip maps need to be generated after render.
  86734. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86735. * @param type The type of the buffer in the RTT (int, half float, float...)
  86736. * @param isCube True if a cube texture needs to be created
  86737. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86738. * @param generateDepthBuffer True to generate a depth buffer
  86739. * @param generateStencilBuffer True to generate a stencil buffer
  86740. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86741. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86742. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86743. */
  86744. constructor(name: string, size: number | {
  86745. width: number;
  86746. height: number;
  86747. } | {
  86748. ratio: number;
  86749. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86750. /**
  86751. * Creates a depth stencil texture.
  86752. * This is only available in WebGL 2 or with the depth texture extension available.
  86753. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86754. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86755. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86756. */
  86757. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86758. private _processSizeParameter;
  86759. /**
  86760. * Define the number of samples to use in case of MSAA.
  86761. * It defaults to one meaning no MSAA has been enabled.
  86762. */
  86763. samples: number;
  86764. /**
  86765. * Resets the refresh counter of the texture and start bak from scratch.
  86766. * Could be useful to regenerate the texture if it is setup to render only once.
  86767. */
  86768. resetRefreshCounter(): void;
  86769. /**
  86770. * Define the refresh rate of the texture or the rendering frequency.
  86771. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86772. */
  86773. refreshRate: number;
  86774. /**
  86775. * Adds a post process to the render target rendering passes.
  86776. * @param postProcess define the post process to add
  86777. */
  86778. addPostProcess(postProcess: PostProcess): void;
  86779. /**
  86780. * Clear all the post processes attached to the render target
  86781. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86782. */
  86783. clearPostProcesses(dispose?: boolean): void;
  86784. /**
  86785. * Remove one of the post process from the list of attached post processes to the texture
  86786. * @param postProcess define the post process to remove from the list
  86787. */
  86788. removePostProcess(postProcess: PostProcess): void;
  86789. /** @hidden */
  86790. _shouldRender(): boolean;
  86791. /**
  86792. * Gets the actual render size of the texture.
  86793. * @returns the width of the render size
  86794. */
  86795. getRenderSize(): number;
  86796. /**
  86797. * Gets the actual render width of the texture.
  86798. * @returns the width of the render size
  86799. */
  86800. getRenderWidth(): number;
  86801. /**
  86802. * Gets the actual render height of the texture.
  86803. * @returns the height of the render size
  86804. */
  86805. getRenderHeight(): number;
  86806. /**
  86807. * Get if the texture can be rescaled or not.
  86808. */
  86809. readonly canRescale: boolean;
  86810. /**
  86811. * Resize the texture using a ratio.
  86812. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86813. */
  86814. scale(ratio: number): void;
  86815. /**
  86816. * Get the texture reflection matrix used to rotate/transform the reflection.
  86817. * @returns the reflection matrix
  86818. */
  86819. getReflectionTextureMatrix(): Matrix;
  86820. /**
  86821. * Resize the texture to a new desired size.
  86822. * Be carrefull as it will recreate all the data in the new texture.
  86823. * @param size Define the new size. It can be:
  86824. * - a number for squared texture,
  86825. * - an object containing { width: number, height: number }
  86826. * - or an object containing a ratio { ratio: number }
  86827. */
  86828. resize(size: number | {
  86829. width: number;
  86830. height: number;
  86831. } | {
  86832. ratio: number;
  86833. }): void;
  86834. /**
  86835. * Renders all the objects from the render list into the texture.
  86836. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86837. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86838. */
  86839. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86840. private _bestReflectionRenderTargetDimension;
  86841. /**
  86842. * @hidden
  86843. * @param faceIndex face index to bind to if this is a cubetexture
  86844. */
  86845. _bindFrameBuffer(faceIndex?: number): void;
  86846. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86847. private renderToTarget;
  86848. /**
  86849. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86850. * This allowed control for front to back rendering or reversly depending of the special needs.
  86851. *
  86852. * @param renderingGroupId The rendering group id corresponding to its index
  86853. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86854. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86855. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86856. */
  86857. 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;
  86858. /**
  86859. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86860. *
  86861. * @param renderingGroupId The rendering group id corresponding to its index
  86862. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86863. */
  86864. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86865. /**
  86866. * Clones the texture.
  86867. * @returns the cloned texture
  86868. */
  86869. clone(): RenderTargetTexture;
  86870. /**
  86871. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86872. * @returns The JSON representation of the texture
  86873. */
  86874. serialize(): any;
  86875. /**
  86876. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86877. */
  86878. disposeFramebufferObjects(): void;
  86879. /**
  86880. * Dispose the texture and release its associated resources.
  86881. */
  86882. dispose(): void;
  86883. /** @hidden */
  86884. _rebuild(): void;
  86885. /**
  86886. * Clear the info related to rendering groups preventing retention point in material dispose.
  86887. */
  86888. freeRenderingGroups(): void;
  86889. /**
  86890. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86891. * @returns the view count
  86892. */
  86893. getViewCount(): number;
  86894. }
  86895. }
  86896. declare module BABYLON {
  86897. /**
  86898. * Base class for the main features of a material in Babylon.js
  86899. */
  86900. export class Material implements IAnimatable {
  86901. /**
  86902. * Returns the triangle fill mode
  86903. */
  86904. static readonly TriangleFillMode: number;
  86905. /**
  86906. * Returns the wireframe mode
  86907. */
  86908. static readonly WireFrameFillMode: number;
  86909. /**
  86910. * Returns the point fill mode
  86911. */
  86912. static readonly PointFillMode: number;
  86913. /**
  86914. * Returns the point list draw mode
  86915. */
  86916. static readonly PointListDrawMode: number;
  86917. /**
  86918. * Returns the line list draw mode
  86919. */
  86920. static readonly LineListDrawMode: number;
  86921. /**
  86922. * Returns the line loop draw mode
  86923. */
  86924. static readonly LineLoopDrawMode: number;
  86925. /**
  86926. * Returns the line strip draw mode
  86927. */
  86928. static readonly LineStripDrawMode: number;
  86929. /**
  86930. * Returns the triangle strip draw mode
  86931. */
  86932. static readonly TriangleStripDrawMode: number;
  86933. /**
  86934. * Returns the triangle fan draw mode
  86935. */
  86936. static readonly TriangleFanDrawMode: number;
  86937. /**
  86938. * Stores the clock-wise side orientation
  86939. */
  86940. static readonly ClockWiseSideOrientation: number;
  86941. /**
  86942. * Stores the counter clock-wise side orientation
  86943. */
  86944. static readonly CounterClockWiseSideOrientation: number;
  86945. /**
  86946. * The dirty texture flag value
  86947. */
  86948. static readonly TextureDirtyFlag: number;
  86949. /**
  86950. * The dirty light flag value
  86951. */
  86952. static readonly LightDirtyFlag: number;
  86953. /**
  86954. * The dirty fresnel flag value
  86955. */
  86956. static readonly FresnelDirtyFlag: number;
  86957. /**
  86958. * The dirty attribute flag value
  86959. */
  86960. static readonly AttributesDirtyFlag: number;
  86961. /**
  86962. * The dirty misc flag value
  86963. */
  86964. static readonly MiscDirtyFlag: number;
  86965. /**
  86966. * The all dirty flag value
  86967. */
  86968. static readonly AllDirtyFlag: number;
  86969. /**
  86970. * The ID of the material
  86971. */
  86972. id: string;
  86973. /**
  86974. * Gets or sets the unique id of the material
  86975. */
  86976. uniqueId: number;
  86977. /**
  86978. * The name of the material
  86979. */
  86980. name: string;
  86981. /**
  86982. * Gets or sets user defined metadata
  86983. */
  86984. metadata: any;
  86985. /**
  86986. * For internal use only. Please do not use.
  86987. */
  86988. reservedDataStore: any;
  86989. /**
  86990. * Specifies if the ready state should be checked on each call
  86991. */
  86992. checkReadyOnEveryCall: boolean;
  86993. /**
  86994. * Specifies if the ready state should be checked once
  86995. */
  86996. checkReadyOnlyOnce: boolean;
  86997. /**
  86998. * The state of the material
  86999. */
  87000. state: string;
  87001. /**
  87002. * The alpha value of the material
  87003. */
  87004. protected _alpha: number;
  87005. /**
  87006. * List of inspectable custom properties (used by the Inspector)
  87007. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87008. */
  87009. inspectableCustomProperties: IInspectable[];
  87010. /**
  87011. * Sets the alpha value of the material
  87012. */
  87013. /**
  87014. * Gets the alpha value of the material
  87015. */
  87016. alpha: number;
  87017. /**
  87018. * Specifies if back face culling is enabled
  87019. */
  87020. protected _backFaceCulling: boolean;
  87021. /**
  87022. * Sets the back-face culling state
  87023. */
  87024. /**
  87025. * Gets the back-face culling state
  87026. */
  87027. backFaceCulling: boolean;
  87028. /**
  87029. * Stores the value for side orientation
  87030. */
  87031. sideOrientation: number;
  87032. /**
  87033. * Callback triggered when the material is compiled
  87034. */
  87035. onCompiled: Nullable<(effect: Effect) => void>;
  87036. /**
  87037. * Callback triggered when an error occurs
  87038. */
  87039. onError: Nullable<(effect: Effect, errors: string) => void>;
  87040. /**
  87041. * Callback triggered to get the render target textures
  87042. */
  87043. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87044. /**
  87045. * Gets a boolean indicating that current material needs to register RTT
  87046. */
  87047. readonly hasRenderTargetTextures: boolean;
  87048. /**
  87049. * Specifies if the material should be serialized
  87050. */
  87051. doNotSerialize: boolean;
  87052. /**
  87053. * @hidden
  87054. */
  87055. _storeEffectOnSubMeshes: boolean;
  87056. /**
  87057. * Stores the animations for the material
  87058. */
  87059. animations: Nullable<Array<Animation>>;
  87060. /**
  87061. * An event triggered when the material is disposed
  87062. */
  87063. onDisposeObservable: Observable<Material>;
  87064. /**
  87065. * An observer which watches for dispose events
  87066. */
  87067. private _onDisposeObserver;
  87068. private _onUnBindObservable;
  87069. /**
  87070. * Called during a dispose event
  87071. */
  87072. onDispose: () => void;
  87073. private _onBindObservable;
  87074. /**
  87075. * An event triggered when the material is bound
  87076. */
  87077. readonly onBindObservable: Observable<AbstractMesh>;
  87078. /**
  87079. * An observer which watches for bind events
  87080. */
  87081. private _onBindObserver;
  87082. /**
  87083. * Called during a bind event
  87084. */
  87085. onBind: (Mesh: AbstractMesh) => void;
  87086. /**
  87087. * An event triggered when the material is unbound
  87088. */
  87089. readonly onUnBindObservable: Observable<Material>;
  87090. /**
  87091. * Stores the value of the alpha mode
  87092. */
  87093. private _alphaMode;
  87094. /**
  87095. * Sets the value of the alpha mode.
  87096. *
  87097. * | Value | Type | Description |
  87098. * | --- | --- | --- |
  87099. * | 0 | ALPHA_DISABLE | |
  87100. * | 1 | ALPHA_ADD | |
  87101. * | 2 | ALPHA_COMBINE | |
  87102. * | 3 | ALPHA_SUBTRACT | |
  87103. * | 4 | ALPHA_MULTIPLY | |
  87104. * | 5 | ALPHA_MAXIMIZED | |
  87105. * | 6 | ALPHA_ONEONE | |
  87106. * | 7 | ALPHA_PREMULTIPLIED | |
  87107. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87108. * | 9 | ALPHA_INTERPOLATE | |
  87109. * | 10 | ALPHA_SCREENMODE | |
  87110. *
  87111. */
  87112. /**
  87113. * Gets the value of the alpha mode
  87114. */
  87115. alphaMode: number;
  87116. /**
  87117. * Stores the state of the need depth pre-pass value
  87118. */
  87119. private _needDepthPrePass;
  87120. /**
  87121. * Sets the need depth pre-pass value
  87122. */
  87123. /**
  87124. * Gets the depth pre-pass value
  87125. */
  87126. needDepthPrePass: boolean;
  87127. /**
  87128. * Specifies if depth writing should be disabled
  87129. */
  87130. disableDepthWrite: boolean;
  87131. /**
  87132. * Specifies if depth writing should be forced
  87133. */
  87134. forceDepthWrite: boolean;
  87135. /**
  87136. * Specifies if there should be a separate pass for culling
  87137. */
  87138. separateCullingPass: boolean;
  87139. /**
  87140. * Stores the state specifing if fog should be enabled
  87141. */
  87142. private _fogEnabled;
  87143. /**
  87144. * Sets the state for enabling fog
  87145. */
  87146. /**
  87147. * Gets the value of the fog enabled state
  87148. */
  87149. fogEnabled: boolean;
  87150. /**
  87151. * Stores the size of points
  87152. */
  87153. pointSize: number;
  87154. /**
  87155. * Stores the z offset value
  87156. */
  87157. zOffset: number;
  87158. /**
  87159. * Gets a value specifying if wireframe mode is enabled
  87160. */
  87161. /**
  87162. * Sets the state of wireframe mode
  87163. */
  87164. wireframe: boolean;
  87165. /**
  87166. * Gets the value specifying if point clouds are enabled
  87167. */
  87168. /**
  87169. * Sets the state of point cloud mode
  87170. */
  87171. pointsCloud: boolean;
  87172. /**
  87173. * Gets the material fill mode
  87174. */
  87175. /**
  87176. * Sets the material fill mode
  87177. */
  87178. fillMode: number;
  87179. /**
  87180. * @hidden
  87181. * Stores the effects for the material
  87182. */
  87183. _effect: Nullable<Effect>;
  87184. /**
  87185. * @hidden
  87186. * Specifies if the material was previously ready
  87187. */
  87188. _wasPreviouslyReady: boolean;
  87189. /**
  87190. * Specifies if uniform buffers should be used
  87191. */
  87192. private _useUBO;
  87193. /**
  87194. * Stores a reference to the scene
  87195. */
  87196. private _scene;
  87197. /**
  87198. * Stores the fill mode state
  87199. */
  87200. private _fillMode;
  87201. /**
  87202. * Specifies if the depth write state should be cached
  87203. */
  87204. private _cachedDepthWriteState;
  87205. /**
  87206. * Stores the uniform buffer
  87207. */
  87208. protected _uniformBuffer: UniformBuffer;
  87209. /** @hidden */
  87210. _indexInSceneMaterialArray: number;
  87211. /** @hidden */
  87212. meshMap: Nullable<{
  87213. [id: string]: AbstractMesh | undefined;
  87214. }>;
  87215. /**
  87216. * Creates a material instance
  87217. * @param name defines the name of the material
  87218. * @param scene defines the scene to reference
  87219. * @param doNotAdd specifies if the material should be added to the scene
  87220. */
  87221. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87222. /**
  87223. * Returns a string representation of the current material
  87224. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87225. * @returns a string with material information
  87226. */
  87227. toString(fullDetails?: boolean): string;
  87228. /**
  87229. * Gets the class name of the material
  87230. * @returns a string with the class name of the material
  87231. */
  87232. getClassName(): string;
  87233. /**
  87234. * Specifies if updates for the material been locked
  87235. */
  87236. readonly isFrozen: boolean;
  87237. /**
  87238. * Locks updates for the material
  87239. */
  87240. freeze(): void;
  87241. /**
  87242. * Unlocks updates for the material
  87243. */
  87244. unfreeze(): void;
  87245. /**
  87246. * Specifies if the material is ready to be used
  87247. * @param mesh defines the mesh to check
  87248. * @param useInstances specifies if instances should be used
  87249. * @returns a boolean indicating if the material is ready to be used
  87250. */
  87251. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87252. /**
  87253. * Specifies that the submesh is ready to be used
  87254. * @param mesh defines the mesh to check
  87255. * @param subMesh defines which submesh to check
  87256. * @param useInstances specifies that instances should be used
  87257. * @returns a boolean indicating that the submesh is ready or not
  87258. */
  87259. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87260. /**
  87261. * Returns the material effect
  87262. * @returns the effect associated with the material
  87263. */
  87264. getEffect(): Nullable<Effect>;
  87265. /**
  87266. * Returns the current scene
  87267. * @returns a Scene
  87268. */
  87269. getScene(): Scene;
  87270. /**
  87271. * Specifies if the material will require alpha blending
  87272. * @returns a boolean specifying if alpha blending is needed
  87273. */
  87274. needAlphaBlending(): boolean;
  87275. /**
  87276. * Specifies if the mesh will require alpha blending
  87277. * @param mesh defines the mesh to check
  87278. * @returns a boolean specifying if alpha blending is needed for the mesh
  87279. */
  87280. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87281. /**
  87282. * Specifies if this material should be rendered in alpha test mode
  87283. * @returns a boolean specifying if an alpha test is needed.
  87284. */
  87285. needAlphaTesting(): boolean;
  87286. /**
  87287. * Gets the texture used for the alpha test
  87288. * @returns the texture to use for alpha testing
  87289. */
  87290. getAlphaTestTexture(): Nullable<BaseTexture>;
  87291. /**
  87292. * Marks the material to indicate that it needs to be re-calculated
  87293. */
  87294. markDirty(): void;
  87295. /** @hidden */
  87296. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87297. /**
  87298. * Binds the material to the mesh
  87299. * @param world defines the world transformation matrix
  87300. * @param mesh defines the mesh to bind the material to
  87301. */
  87302. bind(world: Matrix, mesh?: Mesh): void;
  87303. /**
  87304. * Binds the submesh to the material
  87305. * @param world defines the world transformation matrix
  87306. * @param mesh defines the mesh containing the submesh
  87307. * @param subMesh defines the submesh to bind the material to
  87308. */
  87309. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87310. /**
  87311. * Binds the world matrix to the material
  87312. * @param world defines the world transformation matrix
  87313. */
  87314. bindOnlyWorldMatrix(world: Matrix): void;
  87315. /**
  87316. * Binds the scene's uniform buffer to the effect.
  87317. * @param effect defines the effect to bind to the scene uniform buffer
  87318. * @param sceneUbo defines the uniform buffer storing scene data
  87319. */
  87320. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87321. /**
  87322. * Binds the view matrix to the effect
  87323. * @param effect defines the effect to bind the view matrix to
  87324. */
  87325. bindView(effect: Effect): void;
  87326. /**
  87327. * Binds the view projection matrix to the effect
  87328. * @param effect defines the effect to bind the view projection matrix to
  87329. */
  87330. bindViewProjection(effect: Effect): void;
  87331. /**
  87332. * Specifies if material alpha testing should be turned on for the mesh
  87333. * @param mesh defines the mesh to check
  87334. */
  87335. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87336. /**
  87337. * Processes to execute after binding the material to a mesh
  87338. * @param mesh defines the rendered mesh
  87339. */
  87340. protected _afterBind(mesh?: Mesh): void;
  87341. /**
  87342. * Unbinds the material from the mesh
  87343. */
  87344. unbind(): void;
  87345. /**
  87346. * Gets the active textures from the material
  87347. * @returns an array of textures
  87348. */
  87349. getActiveTextures(): BaseTexture[];
  87350. /**
  87351. * Specifies if the material uses a texture
  87352. * @param texture defines the texture to check against the material
  87353. * @returns a boolean specifying if the material uses the texture
  87354. */
  87355. hasTexture(texture: BaseTexture): boolean;
  87356. /**
  87357. * Makes a duplicate of the material, and gives it a new name
  87358. * @param name defines the new name for the duplicated material
  87359. * @returns the cloned material
  87360. */
  87361. clone(name: string): Nullable<Material>;
  87362. /**
  87363. * Gets the meshes bound to the material
  87364. * @returns an array of meshes bound to the material
  87365. */
  87366. getBindedMeshes(): AbstractMesh[];
  87367. /**
  87368. * Force shader compilation
  87369. * @param mesh defines the mesh associated with this material
  87370. * @param onCompiled defines a function to execute once the material is compiled
  87371. * @param options defines the options to configure the compilation
  87372. * @param onError defines a function to execute if the material fails compiling
  87373. */
  87374. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87375. clipPlane: boolean;
  87376. }>, onError?: (reason: string) => void): void;
  87377. /**
  87378. * Force shader compilation
  87379. * @param mesh defines the mesh that will use this material
  87380. * @param options defines additional options for compiling the shaders
  87381. * @returns a promise that resolves when the compilation completes
  87382. */
  87383. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87384. clipPlane: boolean;
  87385. }>): Promise<void>;
  87386. private static readonly _AllDirtyCallBack;
  87387. private static readonly _ImageProcessingDirtyCallBack;
  87388. private static readonly _TextureDirtyCallBack;
  87389. private static readonly _FresnelDirtyCallBack;
  87390. private static readonly _MiscDirtyCallBack;
  87391. private static readonly _LightsDirtyCallBack;
  87392. private static readonly _AttributeDirtyCallBack;
  87393. private static _FresnelAndMiscDirtyCallBack;
  87394. private static _TextureAndMiscDirtyCallBack;
  87395. private static readonly _DirtyCallbackArray;
  87396. private static readonly _RunDirtyCallBacks;
  87397. /**
  87398. * Marks a define in the material to indicate that it needs to be re-computed
  87399. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87400. */
  87401. markAsDirty(flag: number): void;
  87402. /**
  87403. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87404. * @param func defines a function which checks material defines against the submeshes
  87405. */
  87406. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87407. /**
  87408. * Indicates that we need to re-calculated for all submeshes
  87409. */
  87410. protected _markAllSubMeshesAsAllDirty(): void;
  87411. /**
  87412. * Indicates that image processing needs to be re-calculated for all submeshes
  87413. */
  87414. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87415. /**
  87416. * Indicates that textures need to be re-calculated for all submeshes
  87417. */
  87418. protected _markAllSubMeshesAsTexturesDirty(): void;
  87419. /**
  87420. * Indicates that fresnel needs to be re-calculated for all submeshes
  87421. */
  87422. protected _markAllSubMeshesAsFresnelDirty(): void;
  87423. /**
  87424. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87425. */
  87426. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87427. /**
  87428. * Indicates that lights need to be re-calculated for all submeshes
  87429. */
  87430. protected _markAllSubMeshesAsLightsDirty(): void;
  87431. /**
  87432. * Indicates that attributes need to be re-calculated for all submeshes
  87433. */
  87434. protected _markAllSubMeshesAsAttributesDirty(): void;
  87435. /**
  87436. * Indicates that misc needs to be re-calculated for all submeshes
  87437. */
  87438. protected _markAllSubMeshesAsMiscDirty(): void;
  87439. /**
  87440. * Indicates that textures and misc need to be re-calculated for all submeshes
  87441. */
  87442. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87443. /**
  87444. * Disposes the material
  87445. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87446. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87447. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87448. */
  87449. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87450. /** @hidden */
  87451. private releaseVertexArrayObject;
  87452. /**
  87453. * Serializes this material
  87454. * @returns the serialized material object
  87455. */
  87456. serialize(): any;
  87457. /**
  87458. * Creates a material from parsed material data
  87459. * @param parsedMaterial defines parsed material data
  87460. * @param scene defines the hosting scene
  87461. * @param rootUrl defines the root URL to use to load textures
  87462. * @returns a new material
  87463. */
  87464. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87465. }
  87466. }
  87467. declare module BABYLON {
  87468. /**
  87469. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87470. * separate meshes. This can be use to improve performances.
  87471. * @see http://doc.babylonjs.com/how_to/multi_materials
  87472. */
  87473. export class MultiMaterial extends Material {
  87474. private _subMaterials;
  87475. /**
  87476. * Gets or Sets the list of Materials used within the multi material.
  87477. * They need to be ordered according to the submeshes order in the associated mesh
  87478. */
  87479. subMaterials: Nullable<Material>[];
  87480. /**
  87481. * Function used to align with Node.getChildren()
  87482. * @returns the list of Materials used within the multi material
  87483. */
  87484. getChildren(): Nullable<Material>[];
  87485. /**
  87486. * Instantiates a new Multi Material
  87487. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87488. * separate meshes. This can be use to improve performances.
  87489. * @see http://doc.babylonjs.com/how_to/multi_materials
  87490. * @param name Define the name in the scene
  87491. * @param scene Define the scene the material belongs to
  87492. */
  87493. constructor(name: string, scene: Scene);
  87494. private _hookArray;
  87495. /**
  87496. * Get one of the submaterial by its index in the submaterials array
  87497. * @param index The index to look the sub material at
  87498. * @returns The Material if the index has been defined
  87499. */
  87500. getSubMaterial(index: number): Nullable<Material>;
  87501. /**
  87502. * Get the list of active textures for the whole sub materials list.
  87503. * @returns All the textures that will be used during the rendering
  87504. */
  87505. getActiveTextures(): BaseTexture[];
  87506. /**
  87507. * Gets the current class name of the material e.g. "MultiMaterial"
  87508. * Mainly use in serialization.
  87509. * @returns the class name
  87510. */
  87511. getClassName(): string;
  87512. /**
  87513. * Checks if the material is ready to render the requested sub mesh
  87514. * @param mesh Define the mesh the submesh belongs to
  87515. * @param subMesh Define the sub mesh to look readyness for
  87516. * @param useInstances Define whether or not the material is used with instances
  87517. * @returns true if ready, otherwise false
  87518. */
  87519. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87520. /**
  87521. * Clones the current material and its related sub materials
  87522. * @param name Define the name of the newly cloned material
  87523. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87524. * @returns the cloned material
  87525. */
  87526. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87527. /**
  87528. * Serializes the materials into a JSON representation.
  87529. * @returns the JSON representation
  87530. */
  87531. serialize(): any;
  87532. /**
  87533. * Dispose the material and release its associated resources
  87534. * @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)
  87535. * @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)
  87536. * @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)
  87537. */
  87538. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87539. /**
  87540. * Creates a MultiMaterial from parsed MultiMaterial data.
  87541. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87542. * @param scene defines the hosting scene
  87543. * @returns a new MultiMaterial
  87544. */
  87545. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87546. }
  87547. }
  87548. declare module BABYLON {
  87549. /**
  87550. * Base class for submeshes
  87551. */
  87552. export class BaseSubMesh {
  87553. /** @hidden */
  87554. _materialDefines: Nullable<MaterialDefines>;
  87555. /** @hidden */
  87556. _materialEffect: Nullable<Effect>;
  87557. /**
  87558. * Gets associated effect
  87559. */
  87560. readonly effect: Nullable<Effect>;
  87561. /**
  87562. * Sets associated effect (effect used to render this submesh)
  87563. * @param effect defines the effect to associate with
  87564. * @param defines defines the set of defines used to compile this effect
  87565. */
  87566. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87567. }
  87568. /**
  87569. * Defines a subdivision inside a mesh
  87570. */
  87571. export class SubMesh extends BaseSubMesh implements ICullable {
  87572. /** the material index to use */
  87573. materialIndex: number;
  87574. /** vertex index start */
  87575. verticesStart: number;
  87576. /** vertices count */
  87577. verticesCount: number;
  87578. /** index start */
  87579. indexStart: number;
  87580. /** indices count */
  87581. indexCount: number;
  87582. /** @hidden */
  87583. _linesIndexCount: number;
  87584. private _mesh;
  87585. private _renderingMesh;
  87586. private _boundingInfo;
  87587. private _linesIndexBuffer;
  87588. /** @hidden */
  87589. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87590. /** @hidden */
  87591. _trianglePlanes: Plane[];
  87592. /** @hidden */
  87593. _lastColliderTransformMatrix: Nullable<Matrix>;
  87594. /** @hidden */
  87595. _renderId: number;
  87596. /** @hidden */
  87597. _alphaIndex: number;
  87598. /** @hidden */
  87599. _distanceToCamera: number;
  87600. /** @hidden */
  87601. _id: number;
  87602. private _currentMaterial;
  87603. /**
  87604. * Add a new submesh to a mesh
  87605. * @param materialIndex defines the material index to use
  87606. * @param verticesStart defines vertex index start
  87607. * @param verticesCount defines vertices count
  87608. * @param indexStart defines index start
  87609. * @param indexCount defines indices count
  87610. * @param mesh defines the parent mesh
  87611. * @param renderingMesh defines an optional rendering mesh
  87612. * @param createBoundingBox defines if bounding box should be created for this submesh
  87613. * @returns the new submesh
  87614. */
  87615. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87616. /**
  87617. * Creates a new submesh
  87618. * @param materialIndex defines the material index to use
  87619. * @param verticesStart defines vertex index start
  87620. * @param verticesCount defines vertices count
  87621. * @param indexStart defines index start
  87622. * @param indexCount defines indices count
  87623. * @param mesh defines the parent mesh
  87624. * @param renderingMesh defines an optional rendering mesh
  87625. * @param createBoundingBox defines if bounding box should be created for this submesh
  87626. */
  87627. constructor(
  87628. /** the material index to use */
  87629. materialIndex: number,
  87630. /** vertex index start */
  87631. verticesStart: number,
  87632. /** vertices count */
  87633. verticesCount: number,
  87634. /** index start */
  87635. indexStart: number,
  87636. /** indices count */
  87637. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87638. /**
  87639. * Returns true if this submesh covers the entire parent mesh
  87640. * @ignorenaming
  87641. */
  87642. readonly IsGlobal: boolean;
  87643. /**
  87644. * Returns the submesh BoudingInfo object
  87645. * @returns current bounding info (or mesh's one if the submesh is global)
  87646. */
  87647. getBoundingInfo(): BoundingInfo;
  87648. /**
  87649. * Sets the submesh BoundingInfo
  87650. * @param boundingInfo defines the new bounding info to use
  87651. * @returns the SubMesh
  87652. */
  87653. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87654. /**
  87655. * Returns the mesh of the current submesh
  87656. * @return the parent mesh
  87657. */
  87658. getMesh(): AbstractMesh;
  87659. /**
  87660. * Returns the rendering mesh of the submesh
  87661. * @returns the rendering mesh (could be different from parent mesh)
  87662. */
  87663. getRenderingMesh(): Mesh;
  87664. /**
  87665. * Returns the submesh material
  87666. * @returns null or the current material
  87667. */
  87668. getMaterial(): Nullable<Material>;
  87669. /**
  87670. * Sets a new updated BoundingInfo object to the submesh
  87671. * @param data defines an optional position array to use to determine the bounding info
  87672. * @returns the SubMesh
  87673. */
  87674. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87675. /** @hidden */
  87676. _checkCollision(collider: Collider): boolean;
  87677. /**
  87678. * Updates the submesh BoundingInfo
  87679. * @param world defines the world matrix to use to update the bounding info
  87680. * @returns the submesh
  87681. */
  87682. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87683. /**
  87684. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87685. * @param frustumPlanes defines the frustum planes
  87686. * @returns true if the submesh is intersecting with the frustum
  87687. */
  87688. isInFrustum(frustumPlanes: Plane[]): boolean;
  87689. /**
  87690. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87691. * @param frustumPlanes defines the frustum planes
  87692. * @returns true if the submesh is inside the frustum
  87693. */
  87694. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87695. /**
  87696. * Renders the submesh
  87697. * @param enableAlphaMode defines if alpha needs to be used
  87698. * @returns the submesh
  87699. */
  87700. render(enableAlphaMode: boolean): SubMesh;
  87701. /**
  87702. * @hidden
  87703. */
  87704. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87705. /**
  87706. * Checks if the submesh intersects with a ray
  87707. * @param ray defines the ray to test
  87708. * @returns true is the passed ray intersects the submesh bounding box
  87709. */
  87710. canIntersects(ray: Ray): boolean;
  87711. /**
  87712. * Intersects current submesh with a ray
  87713. * @param ray defines the ray to test
  87714. * @param positions defines mesh's positions array
  87715. * @param indices defines mesh's indices array
  87716. * @param fastCheck defines if only bounding info should be used
  87717. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87718. * @returns intersection info or null if no intersection
  87719. */
  87720. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87721. /** @hidden */
  87722. private _intersectLines;
  87723. /** @hidden */
  87724. private _intersectUnIndexedLines;
  87725. /** @hidden */
  87726. private _intersectTriangles;
  87727. /** @hidden */
  87728. private _intersectUnIndexedTriangles;
  87729. /** @hidden */
  87730. _rebuild(): void;
  87731. /**
  87732. * Creates a new submesh from the passed mesh
  87733. * @param newMesh defines the new hosting mesh
  87734. * @param newRenderingMesh defines an optional rendering mesh
  87735. * @returns the new submesh
  87736. */
  87737. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87738. /**
  87739. * Release associated resources
  87740. */
  87741. dispose(): void;
  87742. /**
  87743. * Gets the class name
  87744. * @returns the string "SubMesh".
  87745. */
  87746. getClassName(): string;
  87747. /**
  87748. * Creates a new submesh from indices data
  87749. * @param materialIndex the index of the main mesh material
  87750. * @param startIndex the index where to start the copy in the mesh indices array
  87751. * @param indexCount the number of indices to copy then from the startIndex
  87752. * @param mesh the main mesh to create the submesh from
  87753. * @param renderingMesh the optional rendering mesh
  87754. * @returns a new submesh
  87755. */
  87756. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87757. }
  87758. }
  87759. declare module BABYLON {
  87760. /**
  87761. * Class used to represent data loading progression
  87762. */
  87763. export class SceneLoaderFlags {
  87764. private static _ForceFullSceneLoadingForIncremental;
  87765. private static _ShowLoadingScreen;
  87766. private static _CleanBoneMatrixWeights;
  87767. private static _loggingLevel;
  87768. /**
  87769. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87770. */
  87771. static ForceFullSceneLoadingForIncremental: boolean;
  87772. /**
  87773. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87774. */
  87775. static ShowLoadingScreen: boolean;
  87776. /**
  87777. * Defines the current logging level (while loading the scene)
  87778. * @ignorenaming
  87779. */
  87780. static loggingLevel: number;
  87781. /**
  87782. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87783. */
  87784. static CleanBoneMatrixWeights: boolean;
  87785. }
  87786. }
  87787. declare module BABYLON {
  87788. /**
  87789. * Class used to store geometry data (vertex buffers + index buffer)
  87790. */
  87791. export class Geometry implements IGetSetVerticesData {
  87792. /**
  87793. * Gets or sets the ID of the geometry
  87794. */
  87795. id: string;
  87796. /**
  87797. * Gets or sets the unique ID of the geometry
  87798. */
  87799. uniqueId: number;
  87800. /**
  87801. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87802. */
  87803. delayLoadState: number;
  87804. /**
  87805. * Gets the file containing the data to load when running in delay load state
  87806. */
  87807. delayLoadingFile: Nullable<string>;
  87808. /**
  87809. * Callback called when the geometry is updated
  87810. */
  87811. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87812. private _scene;
  87813. private _engine;
  87814. private _meshes;
  87815. private _totalVertices;
  87816. /** @hidden */
  87817. _indices: IndicesArray;
  87818. /** @hidden */
  87819. _vertexBuffers: {
  87820. [key: string]: VertexBuffer;
  87821. };
  87822. private _isDisposed;
  87823. private _extend;
  87824. private _boundingBias;
  87825. /** @hidden */
  87826. _delayInfo: Array<string>;
  87827. private _indexBuffer;
  87828. private _indexBufferIsUpdatable;
  87829. /** @hidden */
  87830. _boundingInfo: Nullable<BoundingInfo>;
  87831. /** @hidden */
  87832. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87833. /** @hidden */
  87834. _softwareSkinningFrameId: number;
  87835. private _vertexArrayObjects;
  87836. private _updatable;
  87837. /** @hidden */
  87838. _positions: Nullable<Vector3[]>;
  87839. /**
  87840. * 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
  87841. */
  87842. /**
  87843. * 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
  87844. */
  87845. boundingBias: Vector2;
  87846. /**
  87847. * Static function used to attach a new empty geometry to a mesh
  87848. * @param mesh defines the mesh to attach the geometry to
  87849. * @returns the new Geometry
  87850. */
  87851. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87852. /**
  87853. * Creates a new geometry
  87854. * @param id defines the unique ID
  87855. * @param scene defines the hosting scene
  87856. * @param vertexData defines the VertexData used to get geometry data
  87857. * @param updatable defines if geometry must be updatable (false by default)
  87858. * @param mesh defines the mesh that will be associated with the geometry
  87859. */
  87860. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87861. /**
  87862. * Gets the current extend of the geometry
  87863. */
  87864. readonly extend: {
  87865. minimum: Vector3;
  87866. maximum: Vector3;
  87867. };
  87868. /**
  87869. * Gets the hosting scene
  87870. * @returns the hosting Scene
  87871. */
  87872. getScene(): Scene;
  87873. /**
  87874. * Gets the hosting engine
  87875. * @returns the hosting Engine
  87876. */
  87877. getEngine(): Engine;
  87878. /**
  87879. * Defines if the geometry is ready to use
  87880. * @returns true if the geometry is ready to be used
  87881. */
  87882. isReady(): boolean;
  87883. /**
  87884. * Gets a value indicating that the geometry should not be serialized
  87885. */
  87886. readonly doNotSerialize: boolean;
  87887. /** @hidden */
  87888. _rebuild(): void;
  87889. /**
  87890. * Affects all geometry data in one call
  87891. * @param vertexData defines the geometry data
  87892. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87893. */
  87894. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87895. /**
  87896. * Set specific vertex data
  87897. * @param kind defines the data kind (Position, normal, etc...)
  87898. * @param data defines the vertex data to use
  87899. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87900. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87901. */
  87902. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87903. /**
  87904. * Removes a specific vertex data
  87905. * @param kind defines the data kind (Position, normal, etc...)
  87906. */
  87907. removeVerticesData(kind: string): void;
  87908. /**
  87909. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  87910. * @param buffer defines the vertex buffer to use
  87911. * @param totalVertices defines the total number of vertices for position kind (could be null)
  87912. */
  87913. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  87914. /**
  87915. * Update a specific vertex buffer
  87916. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  87917. * It will do nothing if the buffer is not updatable
  87918. * @param kind defines the data kind (Position, normal, etc...)
  87919. * @param data defines the data to use
  87920. * @param offset defines the offset in the target buffer where to store the data
  87921. * @param useBytes set to true if the offset is in bytes
  87922. */
  87923. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  87924. /**
  87925. * Update a specific vertex buffer
  87926. * This function will create a new buffer if the current one is not updatable
  87927. * @param kind defines the data kind (Position, normal, etc...)
  87928. * @param data defines the data to use
  87929. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  87930. */
  87931. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  87932. private _updateBoundingInfo;
  87933. /** @hidden */
  87934. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  87935. /**
  87936. * Gets total number of vertices
  87937. * @returns the total number of vertices
  87938. */
  87939. getTotalVertices(): number;
  87940. /**
  87941. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  87942. * @param kind defines the data kind (Position, normal, etc...)
  87943. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  87944. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  87945. * @returns a float array containing vertex data
  87946. */
  87947. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  87948. /**
  87949. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  87950. * @param kind defines the data kind (Position, normal, etc...)
  87951. * @returns true if the vertex buffer with the specified kind is updatable
  87952. */
  87953. isVertexBufferUpdatable(kind: string): boolean;
  87954. /**
  87955. * Gets a specific vertex buffer
  87956. * @param kind defines the data kind (Position, normal, etc...)
  87957. * @returns a VertexBuffer
  87958. */
  87959. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  87960. /**
  87961. * Returns all vertex buffers
  87962. * @return an object holding all vertex buffers indexed by kind
  87963. */
  87964. getVertexBuffers(): Nullable<{
  87965. [key: string]: VertexBuffer;
  87966. }>;
  87967. /**
  87968. * Gets a boolean indicating if specific vertex buffer is present
  87969. * @param kind defines the data kind (Position, normal, etc...)
  87970. * @returns true if data is present
  87971. */
  87972. isVerticesDataPresent(kind: string): boolean;
  87973. /**
  87974. * Gets a list of all attached data kinds (Position, normal, etc...)
  87975. * @returns a list of string containing all kinds
  87976. */
  87977. getVerticesDataKinds(): string[];
  87978. /**
  87979. * Update index buffer
  87980. * @param indices defines the indices to store in the index buffer
  87981. * @param offset defines the offset in the target buffer where to store the data
  87982. * @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)
  87983. */
  87984. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  87985. /**
  87986. * Creates a new index buffer
  87987. * @param indices defines the indices to store in the index buffer
  87988. * @param totalVertices defines the total number of vertices (could be null)
  87989. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  87990. */
  87991. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  87992. /**
  87993. * Return the total number of indices
  87994. * @returns the total number of indices
  87995. */
  87996. getTotalIndices(): number;
  87997. /**
  87998. * Gets the index buffer array
  87999. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88000. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88001. * @returns the index buffer array
  88002. */
  88003. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88004. /**
  88005. * Gets the index buffer
  88006. * @return the index buffer
  88007. */
  88008. getIndexBuffer(): Nullable<DataBuffer>;
  88009. /** @hidden */
  88010. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88011. /**
  88012. * Release the associated resources for a specific mesh
  88013. * @param mesh defines the source mesh
  88014. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88015. */
  88016. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88017. /**
  88018. * Apply current geometry to a given mesh
  88019. * @param mesh defines the mesh to apply geometry to
  88020. */
  88021. applyToMesh(mesh: Mesh): void;
  88022. private _updateExtend;
  88023. private _applyToMesh;
  88024. private notifyUpdate;
  88025. /**
  88026. * Load the geometry if it was flagged as delay loaded
  88027. * @param scene defines the hosting scene
  88028. * @param onLoaded defines a callback called when the geometry is loaded
  88029. */
  88030. load(scene: Scene, onLoaded?: () => void): void;
  88031. private _queueLoad;
  88032. /**
  88033. * Invert the geometry to move from a right handed system to a left handed one.
  88034. */
  88035. toLeftHanded(): void;
  88036. /** @hidden */
  88037. _resetPointsArrayCache(): void;
  88038. /** @hidden */
  88039. _generatePointsArray(): boolean;
  88040. /**
  88041. * Gets a value indicating if the geometry is disposed
  88042. * @returns true if the geometry was disposed
  88043. */
  88044. isDisposed(): boolean;
  88045. private _disposeVertexArrayObjects;
  88046. /**
  88047. * Free all associated resources
  88048. */
  88049. dispose(): void;
  88050. /**
  88051. * Clone the current geometry into a new geometry
  88052. * @param id defines the unique ID of the new geometry
  88053. * @returns a new geometry object
  88054. */
  88055. copy(id: string): Geometry;
  88056. /**
  88057. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88058. * @return a JSON representation of the current geometry data (without the vertices data)
  88059. */
  88060. serialize(): any;
  88061. private toNumberArray;
  88062. /**
  88063. * Serialize all vertices data into a JSON oject
  88064. * @returns a JSON representation of the current geometry data
  88065. */
  88066. serializeVerticeData(): any;
  88067. /**
  88068. * Extracts a clone of a mesh geometry
  88069. * @param mesh defines the source mesh
  88070. * @param id defines the unique ID of the new geometry object
  88071. * @returns the new geometry object
  88072. */
  88073. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88074. /**
  88075. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88076. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88077. * Be aware Math.random() could cause collisions, but:
  88078. * "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"
  88079. * @returns a string containing a new GUID
  88080. */
  88081. static RandomId(): string;
  88082. /** @hidden */
  88083. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88084. private static _CleanMatricesWeights;
  88085. /**
  88086. * Create a new geometry from persisted data (Using .babylon file format)
  88087. * @param parsedVertexData defines the persisted data
  88088. * @param scene defines the hosting scene
  88089. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88090. * @returns the new geometry object
  88091. */
  88092. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88093. }
  88094. }
  88095. declare module BABYLON {
  88096. /**
  88097. * Define an interface for all classes that will get and set the data on vertices
  88098. */
  88099. export interface IGetSetVerticesData {
  88100. /**
  88101. * Gets a boolean indicating if specific vertex data is present
  88102. * @param kind defines the vertex data kind to use
  88103. * @returns true is data kind is present
  88104. */
  88105. isVerticesDataPresent(kind: string): boolean;
  88106. /**
  88107. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88108. * @param kind defines the data kind (Position, normal, etc...)
  88109. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88110. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88111. * @returns a float array containing vertex data
  88112. */
  88113. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88114. /**
  88115. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88116. * @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.
  88117. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88118. * @returns the indices array or an empty array if the mesh has no geometry
  88119. */
  88120. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88121. /**
  88122. * Set specific vertex data
  88123. * @param kind defines the data kind (Position, normal, etc...)
  88124. * @param data defines the vertex data to use
  88125. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88126. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88127. */
  88128. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88129. /**
  88130. * Update a specific associated vertex buffer
  88131. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88132. * - VertexBuffer.PositionKind
  88133. * - VertexBuffer.UVKind
  88134. * - VertexBuffer.UV2Kind
  88135. * - VertexBuffer.UV3Kind
  88136. * - VertexBuffer.UV4Kind
  88137. * - VertexBuffer.UV5Kind
  88138. * - VertexBuffer.UV6Kind
  88139. * - VertexBuffer.ColorKind
  88140. * - VertexBuffer.MatricesIndicesKind
  88141. * - VertexBuffer.MatricesIndicesExtraKind
  88142. * - VertexBuffer.MatricesWeightsKind
  88143. * - VertexBuffer.MatricesWeightsExtraKind
  88144. * @param data defines the data source
  88145. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88146. * @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)
  88147. */
  88148. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88149. /**
  88150. * Creates a new index buffer
  88151. * @param indices defines the indices to store in the index buffer
  88152. * @param totalVertices defines the total number of vertices (could be null)
  88153. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88154. */
  88155. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88156. }
  88157. /**
  88158. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88159. */
  88160. export class VertexData {
  88161. /**
  88162. * Mesh side orientation : usually the external or front surface
  88163. */
  88164. static readonly FRONTSIDE: number;
  88165. /**
  88166. * Mesh side orientation : usually the internal or back surface
  88167. */
  88168. static readonly BACKSIDE: number;
  88169. /**
  88170. * Mesh side orientation : both internal and external or front and back surfaces
  88171. */
  88172. static readonly DOUBLESIDE: number;
  88173. /**
  88174. * Mesh side orientation : by default, `FRONTSIDE`
  88175. */
  88176. static readonly DEFAULTSIDE: number;
  88177. /**
  88178. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88179. */
  88180. positions: Nullable<FloatArray>;
  88181. /**
  88182. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88183. */
  88184. normals: Nullable<FloatArray>;
  88185. /**
  88186. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88187. */
  88188. tangents: Nullable<FloatArray>;
  88189. /**
  88190. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88191. */
  88192. uvs: Nullable<FloatArray>;
  88193. /**
  88194. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88195. */
  88196. uvs2: Nullable<FloatArray>;
  88197. /**
  88198. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88199. */
  88200. uvs3: Nullable<FloatArray>;
  88201. /**
  88202. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88203. */
  88204. uvs4: Nullable<FloatArray>;
  88205. /**
  88206. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88207. */
  88208. uvs5: Nullable<FloatArray>;
  88209. /**
  88210. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88211. */
  88212. uvs6: Nullable<FloatArray>;
  88213. /**
  88214. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88215. */
  88216. colors: Nullable<FloatArray>;
  88217. /**
  88218. * 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).
  88219. */
  88220. matricesIndices: Nullable<FloatArray>;
  88221. /**
  88222. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88223. */
  88224. matricesWeights: Nullable<FloatArray>;
  88225. /**
  88226. * An array extending the number of possible indices
  88227. */
  88228. matricesIndicesExtra: Nullable<FloatArray>;
  88229. /**
  88230. * An array extending the number of possible weights when the number of indices is extended
  88231. */
  88232. matricesWeightsExtra: Nullable<FloatArray>;
  88233. /**
  88234. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88235. */
  88236. indices: Nullable<IndicesArray>;
  88237. /**
  88238. * Uses the passed data array to set the set the values for the specified kind of data
  88239. * @param data a linear array of floating numbers
  88240. * @param kind the type of data that is being set, eg positions, colors etc
  88241. */
  88242. set(data: FloatArray, kind: string): void;
  88243. /**
  88244. * Associates the vertexData to the passed Mesh.
  88245. * Sets it as updatable or not (default `false`)
  88246. * @param mesh the mesh the vertexData is applied to
  88247. * @param updatable when used and having the value true allows new data to update the vertexData
  88248. * @returns the VertexData
  88249. */
  88250. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88251. /**
  88252. * Associates the vertexData to the passed Geometry.
  88253. * Sets it as updatable or not (default `false`)
  88254. * @param geometry the geometry the vertexData is applied to
  88255. * @param updatable when used and having the value true allows new data to update the vertexData
  88256. * @returns VertexData
  88257. */
  88258. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88259. /**
  88260. * Updates the associated mesh
  88261. * @param mesh the mesh to be updated
  88262. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88263. * @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
  88264. * @returns VertexData
  88265. */
  88266. updateMesh(mesh: Mesh): VertexData;
  88267. /**
  88268. * Updates the associated geometry
  88269. * @param geometry the geometry to be updated
  88270. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88271. * @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
  88272. * @returns VertexData.
  88273. */
  88274. updateGeometry(geometry: Geometry): VertexData;
  88275. private _applyTo;
  88276. private _update;
  88277. /**
  88278. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88279. * @param matrix the transforming matrix
  88280. * @returns the VertexData
  88281. */
  88282. transform(matrix: Matrix): VertexData;
  88283. /**
  88284. * Merges the passed VertexData into the current one
  88285. * @param other the VertexData to be merged into the current one
  88286. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88287. * @returns the modified VertexData
  88288. */
  88289. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88290. private _mergeElement;
  88291. private _validate;
  88292. /**
  88293. * Serializes the VertexData
  88294. * @returns a serialized object
  88295. */
  88296. serialize(): any;
  88297. /**
  88298. * Extracts the vertexData from a mesh
  88299. * @param mesh the mesh from which to extract the VertexData
  88300. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88301. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88302. * @returns the object VertexData associated to the passed mesh
  88303. */
  88304. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88305. /**
  88306. * Extracts the vertexData from the geometry
  88307. * @param geometry the geometry from which to extract the VertexData
  88308. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88309. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88310. * @returns the object VertexData associated to the passed mesh
  88311. */
  88312. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88313. private static _ExtractFrom;
  88314. /**
  88315. * Creates the VertexData for a Ribbon
  88316. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88317. * * pathArray array of paths, each of which an array of successive Vector3
  88318. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88319. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88320. * * 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
  88321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88322. * * 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)
  88323. * * 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)
  88324. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88325. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88326. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88327. * @returns the VertexData of the ribbon
  88328. */
  88329. static CreateRibbon(options: {
  88330. pathArray: Vector3[][];
  88331. closeArray?: boolean;
  88332. closePath?: boolean;
  88333. offset?: number;
  88334. sideOrientation?: number;
  88335. frontUVs?: Vector4;
  88336. backUVs?: Vector4;
  88337. invertUV?: boolean;
  88338. uvs?: Vector2[];
  88339. colors?: Color4[];
  88340. }): VertexData;
  88341. /**
  88342. * Creates the VertexData for a box
  88343. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88344. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88345. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88346. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88347. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88348. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88349. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88350. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88351. * * 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)
  88352. * * 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)
  88353. * @returns the VertexData of the box
  88354. */
  88355. static CreateBox(options: {
  88356. size?: number;
  88357. width?: number;
  88358. height?: number;
  88359. depth?: number;
  88360. faceUV?: Vector4[];
  88361. faceColors?: Color4[];
  88362. sideOrientation?: number;
  88363. frontUVs?: Vector4;
  88364. backUVs?: Vector4;
  88365. }): VertexData;
  88366. /**
  88367. * Creates the VertexData for a tiled box
  88368. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88369. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88370. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88371. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88372. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88373. * @returns the VertexData of the box
  88374. */
  88375. static CreateTiledBox(options: {
  88376. pattern?: number;
  88377. width?: number;
  88378. height?: number;
  88379. depth?: number;
  88380. tileSize?: number;
  88381. tileWidth?: number;
  88382. tileHeight?: number;
  88383. alignHorizontal?: number;
  88384. alignVertical?: number;
  88385. faceUV?: Vector4[];
  88386. faceColors?: Color4[];
  88387. sideOrientation?: number;
  88388. }): VertexData;
  88389. /**
  88390. * Creates the VertexData for a tiled plane
  88391. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88392. * * pattern a limited pattern arrangement depending on the number
  88393. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88394. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88395. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88397. * * 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)
  88398. * * 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)
  88399. * @returns the VertexData of the tiled plane
  88400. */
  88401. static CreateTiledPlane(options: {
  88402. pattern?: number;
  88403. tileSize?: number;
  88404. tileWidth?: number;
  88405. tileHeight?: number;
  88406. size?: number;
  88407. width?: number;
  88408. height?: number;
  88409. alignHorizontal?: number;
  88410. alignVertical?: number;
  88411. sideOrientation?: number;
  88412. frontUVs?: Vector4;
  88413. backUVs?: Vector4;
  88414. }): VertexData;
  88415. /**
  88416. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88417. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88418. * * segments sets the number of horizontal strips optional, default 32
  88419. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88420. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88421. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88422. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88423. * * 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
  88424. * * 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
  88425. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88426. * * 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)
  88427. * * 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)
  88428. * @returns the VertexData of the ellipsoid
  88429. */
  88430. static CreateSphere(options: {
  88431. segments?: number;
  88432. diameter?: number;
  88433. diameterX?: number;
  88434. diameterY?: number;
  88435. diameterZ?: number;
  88436. arc?: number;
  88437. slice?: number;
  88438. sideOrientation?: number;
  88439. frontUVs?: Vector4;
  88440. backUVs?: Vector4;
  88441. }): VertexData;
  88442. /**
  88443. * Creates the VertexData for a cylinder, cone or prism
  88444. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88445. * * height sets the height (y direction) of the cylinder, optional, default 2
  88446. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88447. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88448. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88449. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88450. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88451. * * 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
  88452. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88453. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88454. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88455. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88456. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88457. * * 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)
  88458. * * 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)
  88459. * @returns the VertexData of the cylinder, cone or prism
  88460. */
  88461. static CreateCylinder(options: {
  88462. height?: number;
  88463. diameterTop?: number;
  88464. diameterBottom?: number;
  88465. diameter?: number;
  88466. tessellation?: number;
  88467. subdivisions?: number;
  88468. arc?: number;
  88469. faceColors?: Color4[];
  88470. faceUV?: Vector4[];
  88471. hasRings?: boolean;
  88472. enclose?: boolean;
  88473. sideOrientation?: number;
  88474. frontUVs?: Vector4;
  88475. backUVs?: Vector4;
  88476. }): VertexData;
  88477. /**
  88478. * Creates the VertexData for a torus
  88479. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88480. * * diameter the diameter of the torus, optional default 1
  88481. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88482. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88483. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88484. * * 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)
  88485. * * 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)
  88486. * @returns the VertexData of the torus
  88487. */
  88488. static CreateTorus(options: {
  88489. diameter?: number;
  88490. thickness?: number;
  88491. tessellation?: number;
  88492. sideOrientation?: number;
  88493. frontUVs?: Vector4;
  88494. backUVs?: Vector4;
  88495. }): VertexData;
  88496. /**
  88497. * Creates the VertexData of the LineSystem
  88498. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88499. * - lines an array of lines, each line being an array of successive Vector3
  88500. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88501. * @returns the VertexData of the LineSystem
  88502. */
  88503. static CreateLineSystem(options: {
  88504. lines: Vector3[][];
  88505. colors?: Nullable<Color4[][]>;
  88506. }): VertexData;
  88507. /**
  88508. * Create the VertexData for a DashedLines
  88509. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88510. * - points an array successive Vector3
  88511. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88512. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88513. * - dashNb the intended total number of dashes, optional, default 200
  88514. * @returns the VertexData for the DashedLines
  88515. */
  88516. static CreateDashedLines(options: {
  88517. points: Vector3[];
  88518. dashSize?: number;
  88519. gapSize?: number;
  88520. dashNb?: number;
  88521. }): VertexData;
  88522. /**
  88523. * Creates the VertexData for a Ground
  88524. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88525. * - width the width (x direction) of the ground, optional, default 1
  88526. * - height the height (z direction) of the ground, optional, default 1
  88527. * - subdivisions the number of subdivisions per side, optional, default 1
  88528. * @returns the VertexData of the Ground
  88529. */
  88530. static CreateGround(options: {
  88531. width?: number;
  88532. height?: number;
  88533. subdivisions?: number;
  88534. subdivisionsX?: number;
  88535. subdivisionsY?: number;
  88536. }): VertexData;
  88537. /**
  88538. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88539. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88540. * * xmin the ground minimum X coordinate, optional, default -1
  88541. * * zmin the ground minimum Z coordinate, optional, default -1
  88542. * * xmax the ground maximum X coordinate, optional, default 1
  88543. * * zmax the ground maximum Z coordinate, optional, default 1
  88544. * * 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}
  88545. * * 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}
  88546. * @returns the VertexData of the TiledGround
  88547. */
  88548. static CreateTiledGround(options: {
  88549. xmin: number;
  88550. zmin: number;
  88551. xmax: number;
  88552. zmax: number;
  88553. subdivisions?: {
  88554. w: number;
  88555. h: number;
  88556. };
  88557. precision?: {
  88558. w: number;
  88559. h: number;
  88560. };
  88561. }): VertexData;
  88562. /**
  88563. * Creates the VertexData of the Ground designed from a heightmap
  88564. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88565. * * width the width (x direction) of the ground
  88566. * * height the height (z direction) of the ground
  88567. * * subdivisions the number of subdivisions per side
  88568. * * minHeight the minimum altitude on the ground, optional, default 0
  88569. * * maxHeight the maximum altitude on the ground, optional default 1
  88570. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88571. * * buffer the array holding the image color data
  88572. * * bufferWidth the width of image
  88573. * * bufferHeight the height of image
  88574. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88575. * @returns the VertexData of the Ground designed from a heightmap
  88576. */
  88577. static CreateGroundFromHeightMap(options: {
  88578. width: number;
  88579. height: number;
  88580. subdivisions: number;
  88581. minHeight: number;
  88582. maxHeight: number;
  88583. colorFilter: Color3;
  88584. buffer: Uint8Array;
  88585. bufferWidth: number;
  88586. bufferHeight: number;
  88587. alphaFilter: number;
  88588. }): VertexData;
  88589. /**
  88590. * Creates the VertexData for a Plane
  88591. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88592. * * size sets the width and height of the plane to the value of size, optional default 1
  88593. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88594. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88595. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88596. * * 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)
  88597. * * 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)
  88598. * @returns the VertexData of the box
  88599. */
  88600. static CreatePlane(options: {
  88601. size?: number;
  88602. width?: number;
  88603. height?: number;
  88604. sideOrientation?: number;
  88605. frontUVs?: Vector4;
  88606. backUVs?: Vector4;
  88607. }): VertexData;
  88608. /**
  88609. * Creates the VertexData of the Disc or regular Polygon
  88610. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88611. * * radius the radius of the disc, optional default 0.5
  88612. * * tessellation the number of polygon sides, optional, default 64
  88613. * * 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
  88614. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88615. * * 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)
  88616. * * 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)
  88617. * @returns the VertexData of the box
  88618. */
  88619. static CreateDisc(options: {
  88620. radius?: number;
  88621. tessellation?: number;
  88622. arc?: number;
  88623. sideOrientation?: number;
  88624. frontUVs?: Vector4;
  88625. backUVs?: Vector4;
  88626. }): VertexData;
  88627. /**
  88628. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88629. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88630. * @param polygon a mesh built from polygonTriangulation.build()
  88631. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88632. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88633. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88634. * @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)
  88635. * @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)
  88636. * @returns the VertexData of the Polygon
  88637. */
  88638. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88639. /**
  88640. * Creates the VertexData of the IcoSphere
  88641. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88642. * * radius the radius of the IcoSphere, optional default 1
  88643. * * radiusX allows stretching in the x direction, optional, default radius
  88644. * * radiusY allows stretching in the y direction, optional, default radius
  88645. * * radiusZ allows stretching in the z direction, optional, default radius
  88646. * * flat when true creates a flat shaded mesh, optional, default true
  88647. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88648. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88649. * * 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)
  88650. * * 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)
  88651. * @returns the VertexData of the IcoSphere
  88652. */
  88653. static CreateIcoSphere(options: {
  88654. radius?: number;
  88655. radiusX?: number;
  88656. radiusY?: number;
  88657. radiusZ?: number;
  88658. flat?: boolean;
  88659. subdivisions?: number;
  88660. sideOrientation?: number;
  88661. frontUVs?: Vector4;
  88662. backUVs?: Vector4;
  88663. }): VertexData;
  88664. /**
  88665. * Creates the VertexData for a Polyhedron
  88666. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88667. * * type provided types are:
  88668. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88669. * * 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)
  88670. * * size the size of the IcoSphere, optional default 1
  88671. * * sizeX allows stretching in the x direction, optional, default size
  88672. * * sizeY allows stretching in the y direction, optional, default size
  88673. * * sizeZ allows stretching in the z direction, optional, default size
  88674. * * 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
  88675. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88676. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88677. * * flat when true creates a flat shaded mesh, optional, default true
  88678. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88680. * * 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)
  88681. * * 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)
  88682. * @returns the VertexData of the Polyhedron
  88683. */
  88684. static CreatePolyhedron(options: {
  88685. type?: number;
  88686. size?: number;
  88687. sizeX?: number;
  88688. sizeY?: number;
  88689. sizeZ?: number;
  88690. custom?: any;
  88691. faceUV?: Vector4[];
  88692. faceColors?: Color4[];
  88693. flat?: boolean;
  88694. sideOrientation?: number;
  88695. frontUVs?: Vector4;
  88696. backUVs?: Vector4;
  88697. }): VertexData;
  88698. /**
  88699. * Creates the VertexData for a TorusKnot
  88700. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88701. * * radius the radius of the torus knot, optional, default 2
  88702. * * tube the thickness of the tube, optional, default 0.5
  88703. * * radialSegments the number of sides on each tube segments, optional, default 32
  88704. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88705. * * p the number of windings around the z axis, optional, default 2
  88706. * * q the number of windings around the x axis, optional, default 3
  88707. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88708. * * 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)
  88709. * * 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)
  88710. * @returns the VertexData of the Torus Knot
  88711. */
  88712. static CreateTorusKnot(options: {
  88713. radius?: number;
  88714. tube?: number;
  88715. radialSegments?: number;
  88716. tubularSegments?: number;
  88717. p?: number;
  88718. q?: number;
  88719. sideOrientation?: number;
  88720. frontUVs?: Vector4;
  88721. backUVs?: Vector4;
  88722. }): VertexData;
  88723. /**
  88724. * Compute normals for given positions and indices
  88725. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88726. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88727. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88728. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88729. * * facetNormals : optional array of facet normals (vector3)
  88730. * * facetPositions : optional array of facet positions (vector3)
  88731. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88732. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88733. * * bInfo : optional bounding info, required for facetPartitioning computation
  88734. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88735. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88736. * * useRightHandedSystem: optional boolean to for right handed system computation
  88737. * * depthSort : optional boolean to enable the facet depth sort computation
  88738. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88739. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88740. */
  88741. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88742. facetNormals?: any;
  88743. facetPositions?: any;
  88744. facetPartitioning?: any;
  88745. ratio?: number;
  88746. bInfo?: any;
  88747. bbSize?: Vector3;
  88748. subDiv?: any;
  88749. useRightHandedSystem?: boolean;
  88750. depthSort?: boolean;
  88751. distanceTo?: Vector3;
  88752. depthSortedFacets?: any;
  88753. }): void;
  88754. /** @hidden */
  88755. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88756. /**
  88757. * Applies VertexData created from the imported parameters to the geometry
  88758. * @param parsedVertexData the parsed data from an imported file
  88759. * @param geometry the geometry to apply the VertexData to
  88760. */
  88761. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88762. }
  88763. }
  88764. declare module BABYLON {
  88765. /**
  88766. * Defines a target to use with MorphTargetManager
  88767. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88768. */
  88769. export class MorphTarget implements IAnimatable {
  88770. /** defines the name of the target */
  88771. name: string;
  88772. /**
  88773. * Gets or sets the list of animations
  88774. */
  88775. animations: Animation[];
  88776. private _scene;
  88777. private _positions;
  88778. private _normals;
  88779. private _tangents;
  88780. private _uvs;
  88781. private _influence;
  88782. /**
  88783. * Observable raised when the influence changes
  88784. */
  88785. onInfluenceChanged: Observable<boolean>;
  88786. /** @hidden */
  88787. _onDataLayoutChanged: Observable<void>;
  88788. /**
  88789. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88790. */
  88791. influence: number;
  88792. /**
  88793. * Gets or sets the id of the morph Target
  88794. */
  88795. id: string;
  88796. private _animationPropertiesOverride;
  88797. /**
  88798. * Gets or sets the animation properties override
  88799. */
  88800. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88801. /**
  88802. * Creates a new MorphTarget
  88803. * @param name defines the name of the target
  88804. * @param influence defines the influence to use
  88805. * @param scene defines the scene the morphtarget belongs to
  88806. */
  88807. constructor(
  88808. /** defines the name of the target */
  88809. name: string, influence?: number, scene?: Nullable<Scene>);
  88810. /**
  88811. * Gets a boolean defining if the target contains position data
  88812. */
  88813. readonly hasPositions: boolean;
  88814. /**
  88815. * Gets a boolean defining if the target contains normal data
  88816. */
  88817. readonly hasNormals: boolean;
  88818. /**
  88819. * Gets a boolean defining if the target contains tangent data
  88820. */
  88821. readonly hasTangents: boolean;
  88822. /**
  88823. * Gets a boolean defining if the target contains texture coordinates data
  88824. */
  88825. readonly hasUVs: boolean;
  88826. /**
  88827. * Affects position data to this target
  88828. * @param data defines the position data to use
  88829. */
  88830. setPositions(data: Nullable<FloatArray>): void;
  88831. /**
  88832. * Gets the position data stored in this target
  88833. * @returns a FloatArray containing the position data (or null if not present)
  88834. */
  88835. getPositions(): Nullable<FloatArray>;
  88836. /**
  88837. * Affects normal data to this target
  88838. * @param data defines the normal data to use
  88839. */
  88840. setNormals(data: Nullable<FloatArray>): void;
  88841. /**
  88842. * Gets the normal data stored in this target
  88843. * @returns a FloatArray containing the normal data (or null if not present)
  88844. */
  88845. getNormals(): Nullable<FloatArray>;
  88846. /**
  88847. * Affects tangent data to this target
  88848. * @param data defines the tangent data to use
  88849. */
  88850. setTangents(data: Nullable<FloatArray>): void;
  88851. /**
  88852. * Gets the tangent data stored in this target
  88853. * @returns a FloatArray containing the tangent data (or null if not present)
  88854. */
  88855. getTangents(): Nullable<FloatArray>;
  88856. /**
  88857. * Affects texture coordinates data to this target
  88858. * @param data defines the texture coordinates data to use
  88859. */
  88860. setUVs(data: Nullable<FloatArray>): void;
  88861. /**
  88862. * Gets the texture coordinates data stored in this target
  88863. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88864. */
  88865. getUVs(): Nullable<FloatArray>;
  88866. /**
  88867. * Serializes the current target into a Serialization object
  88868. * @returns the serialized object
  88869. */
  88870. serialize(): any;
  88871. /**
  88872. * Returns the string "MorphTarget"
  88873. * @returns "MorphTarget"
  88874. */
  88875. getClassName(): string;
  88876. /**
  88877. * Creates a new target from serialized data
  88878. * @param serializationObject defines the serialized data to use
  88879. * @returns a new MorphTarget
  88880. */
  88881. static Parse(serializationObject: any): MorphTarget;
  88882. /**
  88883. * Creates a MorphTarget from mesh data
  88884. * @param mesh defines the source mesh
  88885. * @param name defines the name to use for the new target
  88886. * @param influence defines the influence to attach to the target
  88887. * @returns a new MorphTarget
  88888. */
  88889. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88890. }
  88891. }
  88892. declare module BABYLON {
  88893. /**
  88894. * This class is used to deform meshes using morphing between different targets
  88895. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88896. */
  88897. export class MorphTargetManager {
  88898. private _targets;
  88899. private _targetInfluenceChangedObservers;
  88900. private _targetDataLayoutChangedObservers;
  88901. private _activeTargets;
  88902. private _scene;
  88903. private _influences;
  88904. private _supportsNormals;
  88905. private _supportsTangents;
  88906. private _supportsUVs;
  88907. private _vertexCount;
  88908. private _uniqueId;
  88909. private _tempInfluences;
  88910. /**
  88911. * Gets or sets a boolean indicating if normals must be morphed
  88912. */
  88913. enableNormalMorphing: boolean;
  88914. /**
  88915. * Gets or sets a boolean indicating if tangents must be morphed
  88916. */
  88917. enableTangentMorphing: boolean;
  88918. /**
  88919. * Gets or sets a boolean indicating if UV must be morphed
  88920. */
  88921. enableUVMorphing: boolean;
  88922. /**
  88923. * Creates a new MorphTargetManager
  88924. * @param scene defines the current scene
  88925. */
  88926. constructor(scene?: Nullable<Scene>);
  88927. /**
  88928. * Gets the unique ID of this manager
  88929. */
  88930. readonly uniqueId: number;
  88931. /**
  88932. * Gets the number of vertices handled by this manager
  88933. */
  88934. readonly vertexCount: number;
  88935. /**
  88936. * Gets a boolean indicating if this manager supports morphing of normals
  88937. */
  88938. readonly supportsNormals: boolean;
  88939. /**
  88940. * Gets a boolean indicating if this manager supports morphing of tangents
  88941. */
  88942. readonly supportsTangents: boolean;
  88943. /**
  88944. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  88945. */
  88946. readonly supportsUVs: boolean;
  88947. /**
  88948. * Gets the number of targets stored in this manager
  88949. */
  88950. readonly numTargets: number;
  88951. /**
  88952. * Gets the number of influencers (ie. the number of targets with influences > 0)
  88953. */
  88954. readonly numInfluencers: number;
  88955. /**
  88956. * Gets the list of influences (one per target)
  88957. */
  88958. readonly influences: Float32Array;
  88959. /**
  88960. * Gets the active target at specified index. An active target is a target with an influence > 0
  88961. * @param index defines the index to check
  88962. * @returns the requested target
  88963. */
  88964. getActiveTarget(index: number): MorphTarget;
  88965. /**
  88966. * Gets the target at specified index
  88967. * @param index defines the index to check
  88968. * @returns the requested target
  88969. */
  88970. getTarget(index: number): MorphTarget;
  88971. /**
  88972. * Add a new target to this manager
  88973. * @param target defines the target to add
  88974. */
  88975. addTarget(target: MorphTarget): void;
  88976. /**
  88977. * Removes a target from the manager
  88978. * @param target defines the target to remove
  88979. */
  88980. removeTarget(target: MorphTarget): void;
  88981. /**
  88982. * Serializes the current manager into a Serialization object
  88983. * @returns the serialized object
  88984. */
  88985. serialize(): any;
  88986. private _syncActiveTargets;
  88987. /**
  88988. * Syncrhonize the targets with all the meshes using this morph target manager
  88989. */
  88990. synchronize(): void;
  88991. /**
  88992. * Creates a new MorphTargetManager from serialized data
  88993. * @param serializationObject defines the serialized data
  88994. * @param scene defines the hosting scene
  88995. * @returns the new MorphTargetManager
  88996. */
  88997. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  88998. }
  88999. }
  89000. declare module BABYLON {
  89001. /**
  89002. * Class used to represent a specific level of detail of a mesh
  89003. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89004. */
  89005. export class MeshLODLevel {
  89006. /** Defines the distance where this level should start being displayed */
  89007. distance: number;
  89008. /** Defines the mesh to use to render this level */
  89009. mesh: Nullable<Mesh>;
  89010. /**
  89011. * Creates a new LOD level
  89012. * @param distance defines the distance where this level should star being displayed
  89013. * @param mesh defines the mesh to use to render this level
  89014. */
  89015. constructor(
  89016. /** Defines the distance where this level should start being displayed */
  89017. distance: number,
  89018. /** Defines the mesh to use to render this level */
  89019. mesh: Nullable<Mesh>);
  89020. }
  89021. }
  89022. declare module BABYLON {
  89023. /**
  89024. * Mesh representing the gorund
  89025. */
  89026. export class GroundMesh extends Mesh {
  89027. /** If octree should be generated */
  89028. generateOctree: boolean;
  89029. private _heightQuads;
  89030. /** @hidden */
  89031. _subdivisionsX: number;
  89032. /** @hidden */
  89033. _subdivisionsY: number;
  89034. /** @hidden */
  89035. _width: number;
  89036. /** @hidden */
  89037. _height: number;
  89038. /** @hidden */
  89039. _minX: number;
  89040. /** @hidden */
  89041. _maxX: number;
  89042. /** @hidden */
  89043. _minZ: number;
  89044. /** @hidden */
  89045. _maxZ: number;
  89046. constructor(name: string, scene: Scene);
  89047. /**
  89048. * "GroundMesh"
  89049. * @returns "GroundMesh"
  89050. */
  89051. getClassName(): string;
  89052. /**
  89053. * The minimum of x and y subdivisions
  89054. */
  89055. readonly subdivisions: number;
  89056. /**
  89057. * X subdivisions
  89058. */
  89059. readonly subdivisionsX: number;
  89060. /**
  89061. * Y subdivisions
  89062. */
  89063. readonly subdivisionsY: number;
  89064. /**
  89065. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89066. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89067. * @param chunksCount the number of subdivisions for x and y
  89068. * @param octreeBlocksSize (Default: 32)
  89069. */
  89070. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89071. /**
  89072. * Returns a height (y) value in the Worl system :
  89073. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89074. * @param x x coordinate
  89075. * @param z z coordinate
  89076. * @returns the ground y position if (x, z) are outside the ground surface.
  89077. */
  89078. getHeightAtCoordinates(x: number, z: number): number;
  89079. /**
  89080. * Returns a normalized vector (Vector3) orthogonal to the ground
  89081. * at the ground coordinates (x, z) expressed in the World system.
  89082. * @param x x coordinate
  89083. * @param z z coordinate
  89084. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89085. */
  89086. getNormalAtCoordinates(x: number, z: number): Vector3;
  89087. /**
  89088. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89089. * at the ground coordinates (x, z) expressed in the World system.
  89090. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89091. * @param x x coordinate
  89092. * @param z z coordinate
  89093. * @param ref vector to store the result
  89094. * @returns the GroundMesh.
  89095. */
  89096. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89097. /**
  89098. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89099. * if the ground has been updated.
  89100. * This can be used in the render loop.
  89101. * @returns the GroundMesh.
  89102. */
  89103. updateCoordinateHeights(): GroundMesh;
  89104. private _getFacetAt;
  89105. private _initHeightQuads;
  89106. private _computeHeightQuads;
  89107. /**
  89108. * Serializes this ground mesh
  89109. * @param serializationObject object to write serialization to
  89110. */
  89111. serialize(serializationObject: any): void;
  89112. /**
  89113. * Parses a serialized ground mesh
  89114. * @param parsedMesh the serialized mesh
  89115. * @param scene the scene to create the ground mesh in
  89116. * @returns the created ground mesh
  89117. */
  89118. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89119. }
  89120. }
  89121. declare module BABYLON {
  89122. /**
  89123. * Interface for Physics-Joint data
  89124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89125. */
  89126. export interface PhysicsJointData {
  89127. /**
  89128. * The main pivot of the joint
  89129. */
  89130. mainPivot?: Vector3;
  89131. /**
  89132. * The connected pivot of the joint
  89133. */
  89134. connectedPivot?: Vector3;
  89135. /**
  89136. * The main axis of the joint
  89137. */
  89138. mainAxis?: Vector3;
  89139. /**
  89140. * The connected axis of the joint
  89141. */
  89142. connectedAxis?: Vector3;
  89143. /**
  89144. * The collision of the joint
  89145. */
  89146. collision?: boolean;
  89147. /**
  89148. * Native Oimo/Cannon/Energy data
  89149. */
  89150. nativeParams?: any;
  89151. }
  89152. /**
  89153. * This is a holder class for the physics joint created by the physics plugin
  89154. * It holds a set of functions to control the underlying joint
  89155. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89156. */
  89157. export class PhysicsJoint {
  89158. /**
  89159. * The type of the physics joint
  89160. */
  89161. type: number;
  89162. /**
  89163. * The data for the physics joint
  89164. */
  89165. jointData: PhysicsJointData;
  89166. private _physicsJoint;
  89167. protected _physicsPlugin: IPhysicsEnginePlugin;
  89168. /**
  89169. * Initializes the physics joint
  89170. * @param type The type of the physics joint
  89171. * @param jointData The data for the physics joint
  89172. */
  89173. constructor(
  89174. /**
  89175. * The type of the physics joint
  89176. */
  89177. type: number,
  89178. /**
  89179. * The data for the physics joint
  89180. */
  89181. jointData: PhysicsJointData);
  89182. /**
  89183. * Gets the physics joint
  89184. */
  89185. /**
  89186. * Sets the physics joint
  89187. */
  89188. physicsJoint: any;
  89189. /**
  89190. * Sets the physics plugin
  89191. */
  89192. physicsPlugin: IPhysicsEnginePlugin;
  89193. /**
  89194. * Execute a function that is physics-plugin specific.
  89195. * @param {Function} func the function that will be executed.
  89196. * It accepts two parameters: the physics world and the physics joint
  89197. */
  89198. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89199. /**
  89200. * Distance-Joint type
  89201. */
  89202. static DistanceJoint: number;
  89203. /**
  89204. * Hinge-Joint type
  89205. */
  89206. static HingeJoint: number;
  89207. /**
  89208. * Ball-and-Socket joint type
  89209. */
  89210. static BallAndSocketJoint: number;
  89211. /**
  89212. * Wheel-Joint type
  89213. */
  89214. static WheelJoint: number;
  89215. /**
  89216. * Slider-Joint type
  89217. */
  89218. static SliderJoint: number;
  89219. /**
  89220. * Prismatic-Joint type
  89221. */
  89222. static PrismaticJoint: number;
  89223. /**
  89224. * Universal-Joint type
  89225. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89226. */
  89227. static UniversalJoint: number;
  89228. /**
  89229. * Hinge-Joint 2 type
  89230. */
  89231. static Hinge2Joint: number;
  89232. /**
  89233. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89234. */
  89235. static PointToPointJoint: number;
  89236. /**
  89237. * Spring-Joint type
  89238. */
  89239. static SpringJoint: number;
  89240. /**
  89241. * Lock-Joint type
  89242. */
  89243. static LockJoint: number;
  89244. }
  89245. /**
  89246. * A class representing a physics distance joint
  89247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89248. */
  89249. export class DistanceJoint extends PhysicsJoint {
  89250. /**
  89251. *
  89252. * @param jointData The data for the Distance-Joint
  89253. */
  89254. constructor(jointData: DistanceJointData);
  89255. /**
  89256. * Update the predefined distance.
  89257. * @param maxDistance The maximum preferred distance
  89258. * @param minDistance The minimum preferred distance
  89259. */
  89260. updateDistance(maxDistance: number, minDistance?: number): void;
  89261. }
  89262. /**
  89263. * Represents a Motor-Enabled Joint
  89264. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89265. */
  89266. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89267. /**
  89268. * Initializes the Motor-Enabled Joint
  89269. * @param type The type of the joint
  89270. * @param jointData The physica joint data for the joint
  89271. */
  89272. constructor(type: number, jointData: PhysicsJointData);
  89273. /**
  89274. * Set the motor values.
  89275. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89276. * @param force the force to apply
  89277. * @param maxForce max force for this motor.
  89278. */
  89279. setMotor(force?: number, maxForce?: number): void;
  89280. /**
  89281. * Set the motor's limits.
  89282. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89283. * @param upperLimit The upper limit of the motor
  89284. * @param lowerLimit The lower limit of the motor
  89285. */
  89286. setLimit(upperLimit: number, lowerLimit?: number): void;
  89287. }
  89288. /**
  89289. * This class represents a single physics Hinge-Joint
  89290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89291. */
  89292. export class HingeJoint extends MotorEnabledJoint {
  89293. /**
  89294. * Initializes the Hinge-Joint
  89295. * @param jointData The joint data for the Hinge-Joint
  89296. */
  89297. constructor(jointData: PhysicsJointData);
  89298. /**
  89299. * Set the motor values.
  89300. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89301. * @param {number} force the force to apply
  89302. * @param {number} maxForce max force for this motor.
  89303. */
  89304. setMotor(force?: number, maxForce?: number): void;
  89305. /**
  89306. * Set the motor's limits.
  89307. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89308. * @param upperLimit The upper limit of the motor
  89309. * @param lowerLimit The lower limit of the motor
  89310. */
  89311. setLimit(upperLimit: number, lowerLimit?: number): void;
  89312. }
  89313. /**
  89314. * This class represents a dual hinge physics joint (same as wheel joint)
  89315. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89316. */
  89317. export class Hinge2Joint extends MotorEnabledJoint {
  89318. /**
  89319. * Initializes the Hinge2-Joint
  89320. * @param jointData The joint data for the Hinge2-Joint
  89321. */
  89322. constructor(jointData: PhysicsJointData);
  89323. /**
  89324. * Set the motor values.
  89325. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89326. * @param {number} targetSpeed the speed the motor is to reach
  89327. * @param {number} maxForce max force for this motor.
  89328. * @param {motorIndex} the motor's index, 0 or 1.
  89329. */
  89330. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89331. /**
  89332. * Set the motor limits.
  89333. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89334. * @param {number} upperLimit the upper limit
  89335. * @param {number} lowerLimit lower limit
  89336. * @param {motorIndex} the motor's index, 0 or 1.
  89337. */
  89338. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89339. }
  89340. /**
  89341. * Interface for a motor enabled joint
  89342. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89343. */
  89344. export interface IMotorEnabledJoint {
  89345. /**
  89346. * Physics joint
  89347. */
  89348. physicsJoint: any;
  89349. /**
  89350. * Sets the motor of the motor-enabled joint
  89351. * @param force The force of the motor
  89352. * @param maxForce The maximum force of the motor
  89353. * @param motorIndex The index of the motor
  89354. */
  89355. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89356. /**
  89357. * Sets the limit of the motor
  89358. * @param upperLimit The upper limit of the motor
  89359. * @param lowerLimit The lower limit of the motor
  89360. * @param motorIndex The index of the motor
  89361. */
  89362. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89363. }
  89364. /**
  89365. * Joint data for a Distance-Joint
  89366. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89367. */
  89368. export interface DistanceJointData extends PhysicsJointData {
  89369. /**
  89370. * Max distance the 2 joint objects can be apart
  89371. */
  89372. maxDistance: number;
  89373. }
  89374. /**
  89375. * Joint data from a spring joint
  89376. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89377. */
  89378. export interface SpringJointData extends PhysicsJointData {
  89379. /**
  89380. * Length of the spring
  89381. */
  89382. length: number;
  89383. /**
  89384. * Stiffness of the spring
  89385. */
  89386. stiffness: number;
  89387. /**
  89388. * Damping of the spring
  89389. */
  89390. damping: number;
  89391. /** this callback will be called when applying the force to the impostors. */
  89392. forceApplicationCallback: () => void;
  89393. }
  89394. }
  89395. declare module BABYLON {
  89396. /**
  89397. * Holds the data for the raycast result
  89398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89399. */
  89400. export class PhysicsRaycastResult {
  89401. private _hasHit;
  89402. private _hitDistance;
  89403. private _hitNormalWorld;
  89404. private _hitPointWorld;
  89405. private _rayFromWorld;
  89406. private _rayToWorld;
  89407. /**
  89408. * Gets if there was a hit
  89409. */
  89410. readonly hasHit: boolean;
  89411. /**
  89412. * Gets the distance from the hit
  89413. */
  89414. readonly hitDistance: number;
  89415. /**
  89416. * Gets the hit normal/direction in the world
  89417. */
  89418. readonly hitNormalWorld: Vector3;
  89419. /**
  89420. * Gets the hit point in the world
  89421. */
  89422. readonly hitPointWorld: Vector3;
  89423. /**
  89424. * Gets the ray "start point" of the ray in the world
  89425. */
  89426. readonly rayFromWorld: Vector3;
  89427. /**
  89428. * Gets the ray "end point" of the ray in the world
  89429. */
  89430. readonly rayToWorld: Vector3;
  89431. /**
  89432. * Sets the hit data (normal & point in world space)
  89433. * @param hitNormalWorld defines the normal in world space
  89434. * @param hitPointWorld defines the point in world space
  89435. */
  89436. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89437. /**
  89438. * Sets the distance from the start point to the hit point
  89439. * @param distance
  89440. */
  89441. setHitDistance(distance: number): void;
  89442. /**
  89443. * Calculates the distance manually
  89444. */
  89445. calculateHitDistance(): void;
  89446. /**
  89447. * Resets all the values to default
  89448. * @param from The from point on world space
  89449. * @param to The to point on world space
  89450. */
  89451. reset(from?: Vector3, to?: Vector3): void;
  89452. }
  89453. /**
  89454. * Interface for the size containing width and height
  89455. */
  89456. interface IXYZ {
  89457. /**
  89458. * X
  89459. */
  89460. x: number;
  89461. /**
  89462. * Y
  89463. */
  89464. y: number;
  89465. /**
  89466. * Z
  89467. */
  89468. z: number;
  89469. }
  89470. }
  89471. declare module BABYLON {
  89472. /**
  89473. * Interface used to describe a physics joint
  89474. */
  89475. export interface PhysicsImpostorJoint {
  89476. /** Defines the main impostor to which the joint is linked */
  89477. mainImpostor: PhysicsImpostor;
  89478. /** Defines the impostor that is connected to the main impostor using this joint */
  89479. connectedImpostor: PhysicsImpostor;
  89480. /** Defines the joint itself */
  89481. joint: PhysicsJoint;
  89482. }
  89483. /** @hidden */
  89484. export interface IPhysicsEnginePlugin {
  89485. world: any;
  89486. name: string;
  89487. setGravity(gravity: Vector3): void;
  89488. setTimeStep(timeStep: number): void;
  89489. getTimeStep(): number;
  89490. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89491. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89492. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89493. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89494. removePhysicsBody(impostor: PhysicsImpostor): void;
  89495. generateJoint(joint: PhysicsImpostorJoint): void;
  89496. removeJoint(joint: PhysicsImpostorJoint): void;
  89497. isSupported(): boolean;
  89498. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89499. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89500. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89501. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89502. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89503. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89504. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89505. getBodyMass(impostor: PhysicsImpostor): number;
  89506. getBodyFriction(impostor: PhysicsImpostor): number;
  89507. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89508. getBodyRestitution(impostor: PhysicsImpostor): number;
  89509. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89510. getBodyPressure?(impostor: PhysicsImpostor): number;
  89511. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89512. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89513. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89514. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89515. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89516. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89517. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89518. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89519. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89520. sleepBody(impostor: PhysicsImpostor): void;
  89521. wakeUpBody(impostor: PhysicsImpostor): void;
  89522. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89523. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89524. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89525. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89526. getRadius(impostor: PhysicsImpostor): number;
  89527. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89528. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89529. dispose(): void;
  89530. }
  89531. /**
  89532. * Interface used to define a physics engine
  89533. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89534. */
  89535. export interface IPhysicsEngine {
  89536. /**
  89537. * Gets the gravity vector used by the simulation
  89538. */
  89539. gravity: Vector3;
  89540. /**
  89541. * Sets the gravity vector used by the simulation
  89542. * @param gravity defines the gravity vector to use
  89543. */
  89544. setGravity(gravity: Vector3): void;
  89545. /**
  89546. * Set the time step of the physics engine.
  89547. * Default is 1/60.
  89548. * To slow it down, enter 1/600 for example.
  89549. * To speed it up, 1/30
  89550. * @param newTimeStep the new timestep to apply to this world.
  89551. */
  89552. setTimeStep(newTimeStep: number): void;
  89553. /**
  89554. * Get the time step of the physics engine.
  89555. * @returns the current time step
  89556. */
  89557. getTimeStep(): number;
  89558. /**
  89559. * Release all resources
  89560. */
  89561. dispose(): void;
  89562. /**
  89563. * Gets the name of the current physics plugin
  89564. * @returns the name of the plugin
  89565. */
  89566. getPhysicsPluginName(): string;
  89567. /**
  89568. * Adding a new impostor for the impostor tracking.
  89569. * This will be done by the impostor itself.
  89570. * @param impostor the impostor to add
  89571. */
  89572. addImpostor(impostor: PhysicsImpostor): void;
  89573. /**
  89574. * Remove an impostor from the engine.
  89575. * This impostor and its mesh will not longer be updated by the physics engine.
  89576. * @param impostor the impostor to remove
  89577. */
  89578. removeImpostor(impostor: PhysicsImpostor): void;
  89579. /**
  89580. * Add a joint to the physics engine
  89581. * @param mainImpostor defines the main impostor to which the joint is added.
  89582. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89583. * @param joint defines the joint that will connect both impostors.
  89584. */
  89585. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89586. /**
  89587. * Removes a joint from the simulation
  89588. * @param mainImpostor defines the impostor used with the joint
  89589. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89590. * @param joint defines the joint to remove
  89591. */
  89592. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89593. /**
  89594. * Gets the current plugin used to run the simulation
  89595. * @returns current plugin
  89596. */
  89597. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89598. /**
  89599. * Gets the list of physic impostors
  89600. * @returns an array of PhysicsImpostor
  89601. */
  89602. getImpostors(): Array<PhysicsImpostor>;
  89603. /**
  89604. * Gets the impostor for a physics enabled object
  89605. * @param object defines the object impersonated by the impostor
  89606. * @returns the PhysicsImpostor or null if not found
  89607. */
  89608. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89609. /**
  89610. * Gets the impostor for a physics body object
  89611. * @param body defines physics body used by the impostor
  89612. * @returns the PhysicsImpostor or null if not found
  89613. */
  89614. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89615. /**
  89616. * Does a raycast in the physics world
  89617. * @param from when should the ray start?
  89618. * @param to when should the ray end?
  89619. * @returns PhysicsRaycastResult
  89620. */
  89621. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89622. /**
  89623. * Called by the scene. No need to call it.
  89624. * @param delta defines the timespam between frames
  89625. */
  89626. _step(delta: number): void;
  89627. }
  89628. }
  89629. declare module BABYLON {
  89630. /**
  89631. * The interface for the physics imposter parameters
  89632. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89633. */
  89634. export interface PhysicsImpostorParameters {
  89635. /**
  89636. * The mass of the physics imposter
  89637. */
  89638. mass: number;
  89639. /**
  89640. * The friction of the physics imposter
  89641. */
  89642. friction?: number;
  89643. /**
  89644. * The coefficient of restitution of the physics imposter
  89645. */
  89646. restitution?: number;
  89647. /**
  89648. * The native options of the physics imposter
  89649. */
  89650. nativeOptions?: any;
  89651. /**
  89652. * Specifies if the parent should be ignored
  89653. */
  89654. ignoreParent?: boolean;
  89655. /**
  89656. * Specifies if bi-directional transformations should be disabled
  89657. */
  89658. disableBidirectionalTransformation?: boolean;
  89659. /**
  89660. * The pressure inside the physics imposter, soft object only
  89661. */
  89662. pressure?: number;
  89663. /**
  89664. * The stiffness the physics imposter, soft object only
  89665. */
  89666. stiffness?: number;
  89667. /**
  89668. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89669. */
  89670. velocityIterations?: number;
  89671. /**
  89672. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89673. */
  89674. positionIterations?: number;
  89675. /**
  89676. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89677. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89678. * Add to fix multiple points
  89679. */
  89680. fixedPoints?: number;
  89681. /**
  89682. * The collision margin around a soft object
  89683. */
  89684. margin?: number;
  89685. /**
  89686. * The collision margin around a soft object
  89687. */
  89688. damping?: number;
  89689. /**
  89690. * The path for a rope based on an extrusion
  89691. */
  89692. path?: any;
  89693. /**
  89694. * The shape of an extrusion used for a rope based on an extrusion
  89695. */
  89696. shape?: any;
  89697. }
  89698. /**
  89699. * Interface for a physics-enabled object
  89700. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89701. */
  89702. export interface IPhysicsEnabledObject {
  89703. /**
  89704. * The position of the physics-enabled object
  89705. */
  89706. position: Vector3;
  89707. /**
  89708. * The rotation of the physics-enabled object
  89709. */
  89710. rotationQuaternion: Nullable<Quaternion>;
  89711. /**
  89712. * The scale of the physics-enabled object
  89713. */
  89714. scaling: Vector3;
  89715. /**
  89716. * The rotation of the physics-enabled object
  89717. */
  89718. rotation?: Vector3;
  89719. /**
  89720. * The parent of the physics-enabled object
  89721. */
  89722. parent?: any;
  89723. /**
  89724. * The bounding info of the physics-enabled object
  89725. * @returns The bounding info of the physics-enabled object
  89726. */
  89727. getBoundingInfo(): BoundingInfo;
  89728. /**
  89729. * Computes the world matrix
  89730. * @param force Specifies if the world matrix should be computed by force
  89731. * @returns A world matrix
  89732. */
  89733. computeWorldMatrix(force: boolean): Matrix;
  89734. /**
  89735. * Gets the world matrix
  89736. * @returns A world matrix
  89737. */
  89738. getWorldMatrix?(): Matrix;
  89739. /**
  89740. * Gets the child meshes
  89741. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89742. * @returns An array of abstract meshes
  89743. */
  89744. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89745. /**
  89746. * Gets the vertex data
  89747. * @param kind The type of vertex data
  89748. * @returns A nullable array of numbers, or a float32 array
  89749. */
  89750. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89751. /**
  89752. * Gets the indices from the mesh
  89753. * @returns A nullable array of index arrays
  89754. */
  89755. getIndices?(): Nullable<IndicesArray>;
  89756. /**
  89757. * Gets the scene from the mesh
  89758. * @returns the indices array or null
  89759. */
  89760. getScene?(): Scene;
  89761. /**
  89762. * Gets the absolute position from the mesh
  89763. * @returns the absolute position
  89764. */
  89765. getAbsolutePosition(): Vector3;
  89766. /**
  89767. * Gets the absolute pivot point from the mesh
  89768. * @returns the absolute pivot point
  89769. */
  89770. getAbsolutePivotPoint(): Vector3;
  89771. /**
  89772. * Rotates the mesh
  89773. * @param axis The axis of rotation
  89774. * @param amount The amount of rotation
  89775. * @param space The space of the rotation
  89776. * @returns The rotation transform node
  89777. */
  89778. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89779. /**
  89780. * Translates the mesh
  89781. * @param axis The axis of translation
  89782. * @param distance The distance of translation
  89783. * @param space The space of the translation
  89784. * @returns The transform node
  89785. */
  89786. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89787. /**
  89788. * Sets the absolute position of the mesh
  89789. * @param absolutePosition The absolute position of the mesh
  89790. * @returns The transform node
  89791. */
  89792. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89793. /**
  89794. * Gets the class name of the mesh
  89795. * @returns The class name
  89796. */
  89797. getClassName(): string;
  89798. }
  89799. /**
  89800. * Represents a physics imposter
  89801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89802. */
  89803. export class PhysicsImpostor {
  89804. /**
  89805. * The physics-enabled object used as the physics imposter
  89806. */
  89807. object: IPhysicsEnabledObject;
  89808. /**
  89809. * The type of the physics imposter
  89810. */
  89811. type: number;
  89812. private _options;
  89813. private _scene?;
  89814. /**
  89815. * The default object size of the imposter
  89816. */
  89817. static DEFAULT_OBJECT_SIZE: Vector3;
  89818. /**
  89819. * The identity quaternion of the imposter
  89820. */
  89821. static IDENTITY_QUATERNION: Quaternion;
  89822. /** @hidden */
  89823. _pluginData: any;
  89824. private _physicsEngine;
  89825. private _physicsBody;
  89826. private _bodyUpdateRequired;
  89827. private _onBeforePhysicsStepCallbacks;
  89828. private _onAfterPhysicsStepCallbacks;
  89829. /** @hidden */
  89830. _onPhysicsCollideCallbacks: Array<{
  89831. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89832. otherImpostors: Array<PhysicsImpostor>;
  89833. }>;
  89834. private _deltaPosition;
  89835. private _deltaRotation;
  89836. private _deltaRotationConjugated;
  89837. /** @hidden */
  89838. _isFromLine: boolean;
  89839. private _parent;
  89840. private _isDisposed;
  89841. private static _tmpVecs;
  89842. private static _tmpQuat;
  89843. /**
  89844. * Specifies if the physics imposter is disposed
  89845. */
  89846. readonly isDisposed: boolean;
  89847. /**
  89848. * Gets the mass of the physics imposter
  89849. */
  89850. mass: number;
  89851. /**
  89852. * Gets the coefficient of friction
  89853. */
  89854. /**
  89855. * Sets the coefficient of friction
  89856. */
  89857. friction: number;
  89858. /**
  89859. * Gets the coefficient of restitution
  89860. */
  89861. /**
  89862. * Sets the coefficient of restitution
  89863. */
  89864. restitution: number;
  89865. /**
  89866. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89867. */
  89868. /**
  89869. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89870. */
  89871. pressure: number;
  89872. /**
  89873. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89874. */
  89875. /**
  89876. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89877. */
  89878. stiffness: number;
  89879. /**
  89880. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89881. */
  89882. /**
  89883. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89884. */
  89885. velocityIterations: number;
  89886. /**
  89887. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89888. */
  89889. /**
  89890. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89891. */
  89892. positionIterations: number;
  89893. /**
  89894. * The unique id of the physics imposter
  89895. * set by the physics engine when adding this impostor to the array
  89896. */
  89897. uniqueId: number;
  89898. /**
  89899. * @hidden
  89900. */
  89901. soft: boolean;
  89902. /**
  89903. * @hidden
  89904. */
  89905. segments: number;
  89906. private _joints;
  89907. /**
  89908. * Initializes the physics imposter
  89909. * @param object The physics-enabled object used as the physics imposter
  89910. * @param type The type of the physics imposter
  89911. * @param _options The options for the physics imposter
  89912. * @param _scene The Babylon scene
  89913. */
  89914. constructor(
  89915. /**
  89916. * The physics-enabled object used as the physics imposter
  89917. */
  89918. object: IPhysicsEnabledObject,
  89919. /**
  89920. * The type of the physics imposter
  89921. */
  89922. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  89923. /**
  89924. * This function will completly initialize this impostor.
  89925. * It will create a new body - but only if this mesh has no parent.
  89926. * If it has, this impostor will not be used other than to define the impostor
  89927. * of the child mesh.
  89928. * @hidden
  89929. */
  89930. _init(): void;
  89931. private _getPhysicsParent;
  89932. /**
  89933. * Should a new body be generated.
  89934. * @returns boolean specifying if body initialization is required
  89935. */
  89936. isBodyInitRequired(): boolean;
  89937. /**
  89938. * Sets the updated scaling
  89939. * @param updated Specifies if the scaling is updated
  89940. */
  89941. setScalingUpdated(): void;
  89942. /**
  89943. * Force a regeneration of this or the parent's impostor's body.
  89944. * Use under cautious - This will remove all joints already implemented.
  89945. */
  89946. forceUpdate(): void;
  89947. /**
  89948. * Gets the body that holds this impostor. Either its own, or its parent.
  89949. */
  89950. /**
  89951. * Set the physics body. Used mainly by the physics engine/plugin
  89952. */
  89953. physicsBody: any;
  89954. /**
  89955. * Get the parent of the physics imposter
  89956. * @returns Physics imposter or null
  89957. */
  89958. /**
  89959. * Sets the parent of the physics imposter
  89960. */
  89961. parent: Nullable<PhysicsImpostor>;
  89962. /**
  89963. * Resets the update flags
  89964. */
  89965. resetUpdateFlags(): void;
  89966. /**
  89967. * Gets the object extend size
  89968. * @returns the object extend size
  89969. */
  89970. getObjectExtendSize(): Vector3;
  89971. /**
  89972. * Gets the object center
  89973. * @returns The object center
  89974. */
  89975. getObjectCenter(): Vector3;
  89976. /**
  89977. * Get a specific parametes from the options parameter
  89978. * @param paramName The object parameter name
  89979. * @returns The object parameter
  89980. */
  89981. getParam(paramName: string): any;
  89982. /**
  89983. * Sets a specific parameter in the options given to the physics plugin
  89984. * @param paramName The parameter name
  89985. * @param value The value of the parameter
  89986. */
  89987. setParam(paramName: string, value: number): void;
  89988. /**
  89989. * Specifically change the body's mass option. Won't recreate the physics body object
  89990. * @param mass The mass of the physics imposter
  89991. */
  89992. setMass(mass: number): void;
  89993. /**
  89994. * Gets the linear velocity
  89995. * @returns linear velocity or null
  89996. */
  89997. getLinearVelocity(): Nullable<Vector3>;
  89998. /**
  89999. * Sets the linear velocity
  90000. * @param velocity linear velocity or null
  90001. */
  90002. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90003. /**
  90004. * Gets the angular velocity
  90005. * @returns angular velocity or null
  90006. */
  90007. getAngularVelocity(): Nullable<Vector3>;
  90008. /**
  90009. * Sets the angular velocity
  90010. * @param velocity The velocity or null
  90011. */
  90012. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90013. /**
  90014. * Execute a function with the physics plugin native code
  90015. * Provide a function the will have two variables - the world object and the physics body object
  90016. * @param func The function to execute with the physics plugin native code
  90017. */
  90018. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90019. /**
  90020. * Register a function that will be executed before the physics world is stepping forward
  90021. * @param func The function to execute before the physics world is stepped forward
  90022. */
  90023. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90024. /**
  90025. * Unregister a function that will be executed before the physics world is stepping forward
  90026. * @param func The function to execute before the physics world is stepped forward
  90027. */
  90028. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90029. /**
  90030. * Register a function that will be executed after the physics step
  90031. * @param func The function to execute after physics step
  90032. */
  90033. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90034. /**
  90035. * Unregisters a function that will be executed after the physics step
  90036. * @param func The function to execute after physics step
  90037. */
  90038. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90039. /**
  90040. * register a function that will be executed when this impostor collides against a different body
  90041. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90042. * @param func Callback that is executed on collision
  90043. */
  90044. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90045. /**
  90046. * Unregisters the physics imposter on contact
  90047. * @param collideAgainst The physics object to collide against
  90048. * @param func Callback to execute on collision
  90049. */
  90050. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90051. private _tmpQuat;
  90052. private _tmpQuat2;
  90053. /**
  90054. * Get the parent rotation
  90055. * @returns The parent rotation
  90056. */
  90057. getParentsRotation(): Quaternion;
  90058. /**
  90059. * this function is executed by the physics engine.
  90060. */
  90061. beforeStep: () => void;
  90062. /**
  90063. * this function is executed by the physics engine
  90064. */
  90065. afterStep: () => void;
  90066. /**
  90067. * Legacy collision detection event support
  90068. */
  90069. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90070. /**
  90071. * event and body object due to cannon's event-based architecture.
  90072. */
  90073. onCollide: (e: {
  90074. body: any;
  90075. }) => void;
  90076. /**
  90077. * Apply a force
  90078. * @param force The force to apply
  90079. * @param contactPoint The contact point for the force
  90080. * @returns The physics imposter
  90081. */
  90082. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90083. /**
  90084. * Apply an impulse
  90085. * @param force The impulse force
  90086. * @param contactPoint The contact point for the impulse force
  90087. * @returns The physics imposter
  90088. */
  90089. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90090. /**
  90091. * A help function to create a joint
  90092. * @param otherImpostor A physics imposter used to create a joint
  90093. * @param jointType The type of joint
  90094. * @param jointData The data for the joint
  90095. * @returns The physics imposter
  90096. */
  90097. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90098. /**
  90099. * Add a joint to this impostor with a different impostor
  90100. * @param otherImpostor A physics imposter used to add a joint
  90101. * @param joint The joint to add
  90102. * @returns The physics imposter
  90103. */
  90104. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90105. /**
  90106. * Add an anchor to a cloth impostor
  90107. * @param otherImpostor rigid impostor to anchor to
  90108. * @param width ratio across width from 0 to 1
  90109. * @param height ratio up height from 0 to 1
  90110. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90111. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90112. * @returns impostor the soft imposter
  90113. */
  90114. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90115. /**
  90116. * Add a hook to a rope impostor
  90117. * @param otherImpostor rigid impostor to anchor to
  90118. * @param length ratio across rope from 0 to 1
  90119. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90120. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90121. * @returns impostor the rope imposter
  90122. */
  90123. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90124. /**
  90125. * Will keep this body still, in a sleep mode.
  90126. * @returns the physics imposter
  90127. */
  90128. sleep(): PhysicsImpostor;
  90129. /**
  90130. * Wake the body up.
  90131. * @returns The physics imposter
  90132. */
  90133. wakeUp(): PhysicsImpostor;
  90134. /**
  90135. * Clones the physics imposter
  90136. * @param newObject The physics imposter clones to this physics-enabled object
  90137. * @returns A nullable physics imposter
  90138. */
  90139. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90140. /**
  90141. * Disposes the physics imposter
  90142. */
  90143. dispose(): void;
  90144. /**
  90145. * Sets the delta position
  90146. * @param position The delta position amount
  90147. */
  90148. setDeltaPosition(position: Vector3): void;
  90149. /**
  90150. * Sets the delta rotation
  90151. * @param rotation The delta rotation amount
  90152. */
  90153. setDeltaRotation(rotation: Quaternion): void;
  90154. /**
  90155. * Gets the box size of the physics imposter and stores the result in the input parameter
  90156. * @param result Stores the box size
  90157. * @returns The physics imposter
  90158. */
  90159. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90160. /**
  90161. * Gets the radius of the physics imposter
  90162. * @returns Radius of the physics imposter
  90163. */
  90164. getRadius(): number;
  90165. /**
  90166. * Sync a bone with this impostor
  90167. * @param bone The bone to sync to the impostor.
  90168. * @param boneMesh The mesh that the bone is influencing.
  90169. * @param jointPivot The pivot of the joint / bone in local space.
  90170. * @param distToJoint Optional distance from the impostor to the joint.
  90171. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90172. */
  90173. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90174. /**
  90175. * Sync impostor to a bone
  90176. * @param bone The bone that the impostor will be synced to.
  90177. * @param boneMesh The mesh that the bone is influencing.
  90178. * @param jointPivot The pivot of the joint / bone in local space.
  90179. * @param distToJoint Optional distance from the impostor to the joint.
  90180. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90181. * @param boneAxis Optional vector3 axis the bone is aligned with
  90182. */
  90183. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90184. /**
  90185. * No-Imposter type
  90186. */
  90187. static NoImpostor: number;
  90188. /**
  90189. * Sphere-Imposter type
  90190. */
  90191. static SphereImpostor: number;
  90192. /**
  90193. * Box-Imposter type
  90194. */
  90195. static BoxImpostor: number;
  90196. /**
  90197. * Plane-Imposter type
  90198. */
  90199. static PlaneImpostor: number;
  90200. /**
  90201. * Mesh-imposter type
  90202. */
  90203. static MeshImpostor: number;
  90204. /**
  90205. * Capsule-Impostor type (Ammo.js plugin only)
  90206. */
  90207. static CapsuleImpostor: number;
  90208. /**
  90209. * Cylinder-Imposter type
  90210. */
  90211. static CylinderImpostor: number;
  90212. /**
  90213. * Particle-Imposter type
  90214. */
  90215. static ParticleImpostor: number;
  90216. /**
  90217. * Heightmap-Imposter type
  90218. */
  90219. static HeightmapImpostor: number;
  90220. /**
  90221. * ConvexHull-Impostor type (Ammo.js plugin only)
  90222. */
  90223. static ConvexHullImpostor: number;
  90224. /**
  90225. * Rope-Imposter type
  90226. */
  90227. static RopeImpostor: number;
  90228. /**
  90229. * Cloth-Imposter type
  90230. */
  90231. static ClothImpostor: number;
  90232. /**
  90233. * Softbody-Imposter type
  90234. */
  90235. static SoftbodyImpostor: number;
  90236. }
  90237. }
  90238. declare module BABYLON {
  90239. /**
  90240. * @hidden
  90241. **/
  90242. export class _CreationDataStorage {
  90243. closePath?: boolean;
  90244. closeArray?: boolean;
  90245. idx: number[];
  90246. dashSize: number;
  90247. gapSize: number;
  90248. path3D: Path3D;
  90249. pathArray: Vector3[][];
  90250. arc: number;
  90251. radius: number;
  90252. cap: number;
  90253. tessellation: number;
  90254. }
  90255. /**
  90256. * @hidden
  90257. **/
  90258. class _InstanceDataStorage {
  90259. visibleInstances: any;
  90260. batchCache: _InstancesBatch;
  90261. instancesBufferSize: number;
  90262. instancesBuffer: Nullable<Buffer>;
  90263. instancesData: Float32Array;
  90264. overridenInstanceCount: number;
  90265. isFrozen: boolean;
  90266. previousBatch: Nullable<_InstancesBatch>;
  90267. hardwareInstancedRendering: boolean;
  90268. sideOrientation: number;
  90269. }
  90270. /**
  90271. * @hidden
  90272. **/
  90273. export class _InstancesBatch {
  90274. mustReturn: boolean;
  90275. visibleInstances: Nullable<InstancedMesh[]>[];
  90276. renderSelf: boolean[];
  90277. hardwareInstancedRendering: boolean[];
  90278. }
  90279. /**
  90280. * Class used to represent renderable models
  90281. */
  90282. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90283. /**
  90284. * Mesh side orientation : usually the external or front surface
  90285. */
  90286. static readonly FRONTSIDE: number;
  90287. /**
  90288. * Mesh side orientation : usually the internal or back surface
  90289. */
  90290. static readonly BACKSIDE: number;
  90291. /**
  90292. * Mesh side orientation : both internal and external or front and back surfaces
  90293. */
  90294. static readonly DOUBLESIDE: number;
  90295. /**
  90296. * Mesh side orientation : by default, `FRONTSIDE`
  90297. */
  90298. static readonly DEFAULTSIDE: number;
  90299. /**
  90300. * Mesh cap setting : no cap
  90301. */
  90302. static readonly NO_CAP: number;
  90303. /**
  90304. * Mesh cap setting : one cap at the beginning of the mesh
  90305. */
  90306. static readonly CAP_START: number;
  90307. /**
  90308. * Mesh cap setting : one cap at the end of the mesh
  90309. */
  90310. static readonly CAP_END: number;
  90311. /**
  90312. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90313. */
  90314. static readonly CAP_ALL: number;
  90315. /**
  90316. * Mesh pattern setting : no flip or rotate
  90317. */
  90318. static readonly NO_FLIP: number;
  90319. /**
  90320. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90321. */
  90322. static readonly FLIP_TILE: number;
  90323. /**
  90324. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90325. */
  90326. static readonly ROTATE_TILE: number;
  90327. /**
  90328. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90329. */
  90330. static readonly FLIP_ROW: number;
  90331. /**
  90332. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90333. */
  90334. static readonly ROTATE_ROW: number;
  90335. /**
  90336. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90337. */
  90338. static readonly FLIP_N_ROTATE_TILE: number;
  90339. /**
  90340. * Mesh pattern setting : rotate pattern and rotate
  90341. */
  90342. static readonly FLIP_N_ROTATE_ROW: number;
  90343. /**
  90344. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90345. */
  90346. static readonly CENTER: number;
  90347. /**
  90348. * Mesh tile positioning : part tiles on left
  90349. */
  90350. static readonly LEFT: number;
  90351. /**
  90352. * Mesh tile positioning : part tiles on right
  90353. */
  90354. static readonly RIGHT: number;
  90355. /**
  90356. * Mesh tile positioning : part tiles on top
  90357. */
  90358. static readonly TOP: number;
  90359. /**
  90360. * Mesh tile positioning : part tiles on bottom
  90361. */
  90362. static readonly BOTTOM: number;
  90363. /**
  90364. * Gets the default side orientation.
  90365. * @param orientation the orientation to value to attempt to get
  90366. * @returns the default orientation
  90367. * @hidden
  90368. */
  90369. static _GetDefaultSideOrientation(orientation?: number): number;
  90370. private _internalMeshDataInfo;
  90371. /**
  90372. * An event triggered before rendering the mesh
  90373. */
  90374. readonly onBeforeRenderObservable: Observable<Mesh>;
  90375. /**
  90376. * An event triggered before binding the mesh
  90377. */
  90378. readonly onBeforeBindObservable: Observable<Mesh>;
  90379. /**
  90380. * An event triggered after rendering the mesh
  90381. */
  90382. readonly onAfterRenderObservable: Observable<Mesh>;
  90383. /**
  90384. * An event triggered before drawing the mesh
  90385. */
  90386. readonly onBeforeDrawObservable: Observable<Mesh>;
  90387. private _onBeforeDrawObserver;
  90388. /**
  90389. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90390. */
  90391. onBeforeDraw: () => void;
  90392. readonly hasInstances: boolean;
  90393. /**
  90394. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90395. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90396. */
  90397. delayLoadState: number;
  90398. /**
  90399. * Gets the list of instances created from this mesh
  90400. * it is not supposed to be modified manually.
  90401. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90402. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90403. */
  90404. instances: InstancedMesh[];
  90405. /**
  90406. * Gets the file containing delay loading data for this mesh
  90407. */
  90408. delayLoadingFile: string;
  90409. /** @hidden */
  90410. _binaryInfo: any;
  90411. /**
  90412. * User defined function used to change how LOD level selection is done
  90413. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90414. */
  90415. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90416. /**
  90417. * Gets or sets the morph target manager
  90418. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90419. */
  90420. morphTargetManager: Nullable<MorphTargetManager>;
  90421. /** @hidden */
  90422. _creationDataStorage: Nullable<_CreationDataStorage>;
  90423. /** @hidden */
  90424. _geometry: Nullable<Geometry>;
  90425. /** @hidden */
  90426. _delayInfo: Array<string>;
  90427. /** @hidden */
  90428. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90429. /** @hidden */
  90430. _instanceDataStorage: _InstanceDataStorage;
  90431. private _effectiveMaterial;
  90432. /** @hidden */
  90433. _shouldGenerateFlatShading: boolean;
  90434. /** @hidden */
  90435. _originalBuilderSideOrientation: number;
  90436. /**
  90437. * Use this property to change the original side orientation defined at construction time
  90438. */
  90439. overrideMaterialSideOrientation: Nullable<number>;
  90440. /**
  90441. * Gets the source mesh (the one used to clone this one from)
  90442. */
  90443. readonly source: Nullable<Mesh>;
  90444. /**
  90445. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90446. */
  90447. isUnIndexed: boolean;
  90448. /**
  90449. * @constructor
  90450. * @param name The value used by scene.getMeshByName() to do a lookup.
  90451. * @param scene The scene to add this mesh to.
  90452. * @param parent The parent of this mesh, if it has one
  90453. * @param source An optional Mesh from which geometry is shared, cloned.
  90454. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90455. * When false, achieved by calling a clone(), also passing False.
  90456. * This will make creation of children, recursive.
  90457. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90458. */
  90459. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90460. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90461. /**
  90462. * Gets the class name
  90463. * @returns the string "Mesh".
  90464. */
  90465. getClassName(): string;
  90466. /** @hidden */
  90467. readonly _isMesh: boolean;
  90468. /**
  90469. * Returns a description of this mesh
  90470. * @param fullDetails define if full details about this mesh must be used
  90471. * @returns a descriptive string representing this mesh
  90472. */
  90473. toString(fullDetails?: boolean): string;
  90474. /** @hidden */
  90475. _unBindEffect(): void;
  90476. /**
  90477. * Gets a boolean indicating if this mesh has LOD
  90478. */
  90479. readonly hasLODLevels: boolean;
  90480. /**
  90481. * Gets the list of MeshLODLevel associated with the current mesh
  90482. * @returns an array of MeshLODLevel
  90483. */
  90484. getLODLevels(): MeshLODLevel[];
  90485. private _sortLODLevels;
  90486. /**
  90487. * Add a mesh as LOD level triggered at the given distance.
  90488. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90489. * @param distance The distance from the center of the object to show this level
  90490. * @param mesh The mesh to be added as LOD level (can be null)
  90491. * @return This mesh (for chaining)
  90492. */
  90493. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90494. /**
  90495. * Returns the LOD level mesh at the passed distance or null if not found.
  90496. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90497. * @param distance The distance from the center of the object to show this level
  90498. * @returns a Mesh or `null`
  90499. */
  90500. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90501. /**
  90502. * Remove a mesh from the LOD array
  90503. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90504. * @param mesh defines the mesh to be removed
  90505. * @return This mesh (for chaining)
  90506. */
  90507. removeLODLevel(mesh: Mesh): Mesh;
  90508. /**
  90509. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90510. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90511. * @param camera defines the camera to use to compute distance
  90512. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90513. * @return This mesh (for chaining)
  90514. */
  90515. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90516. /**
  90517. * Gets the mesh internal Geometry object
  90518. */
  90519. readonly geometry: Nullable<Geometry>;
  90520. /**
  90521. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90522. * @returns the total number of vertices
  90523. */
  90524. getTotalVertices(): number;
  90525. /**
  90526. * Returns the content of an associated vertex buffer
  90527. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90528. * - VertexBuffer.PositionKind
  90529. * - VertexBuffer.UVKind
  90530. * - VertexBuffer.UV2Kind
  90531. * - VertexBuffer.UV3Kind
  90532. * - VertexBuffer.UV4Kind
  90533. * - VertexBuffer.UV5Kind
  90534. * - VertexBuffer.UV6Kind
  90535. * - VertexBuffer.ColorKind
  90536. * - VertexBuffer.MatricesIndicesKind
  90537. * - VertexBuffer.MatricesIndicesExtraKind
  90538. * - VertexBuffer.MatricesWeightsKind
  90539. * - VertexBuffer.MatricesWeightsExtraKind
  90540. * @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
  90541. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90542. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90543. */
  90544. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90545. /**
  90546. * Returns the mesh VertexBuffer object from the requested `kind`
  90547. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90548. * - VertexBuffer.PositionKind
  90549. * - VertexBuffer.NormalKind
  90550. * - VertexBuffer.UVKind
  90551. * - VertexBuffer.UV2Kind
  90552. * - VertexBuffer.UV3Kind
  90553. * - VertexBuffer.UV4Kind
  90554. * - VertexBuffer.UV5Kind
  90555. * - VertexBuffer.UV6Kind
  90556. * - VertexBuffer.ColorKind
  90557. * - VertexBuffer.MatricesIndicesKind
  90558. * - VertexBuffer.MatricesIndicesExtraKind
  90559. * - VertexBuffer.MatricesWeightsKind
  90560. * - VertexBuffer.MatricesWeightsExtraKind
  90561. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90562. */
  90563. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90564. /**
  90565. * Tests if a specific vertex buffer is associated with this mesh
  90566. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90567. * - VertexBuffer.PositionKind
  90568. * - VertexBuffer.NormalKind
  90569. * - VertexBuffer.UVKind
  90570. * - VertexBuffer.UV2Kind
  90571. * - VertexBuffer.UV3Kind
  90572. * - VertexBuffer.UV4Kind
  90573. * - VertexBuffer.UV5Kind
  90574. * - VertexBuffer.UV6Kind
  90575. * - VertexBuffer.ColorKind
  90576. * - VertexBuffer.MatricesIndicesKind
  90577. * - VertexBuffer.MatricesIndicesExtraKind
  90578. * - VertexBuffer.MatricesWeightsKind
  90579. * - VertexBuffer.MatricesWeightsExtraKind
  90580. * @returns a boolean
  90581. */
  90582. isVerticesDataPresent(kind: string): boolean;
  90583. /**
  90584. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90585. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90586. * - VertexBuffer.PositionKind
  90587. * - VertexBuffer.UVKind
  90588. * - VertexBuffer.UV2Kind
  90589. * - VertexBuffer.UV3Kind
  90590. * - VertexBuffer.UV4Kind
  90591. * - VertexBuffer.UV5Kind
  90592. * - VertexBuffer.UV6Kind
  90593. * - VertexBuffer.ColorKind
  90594. * - VertexBuffer.MatricesIndicesKind
  90595. * - VertexBuffer.MatricesIndicesExtraKind
  90596. * - VertexBuffer.MatricesWeightsKind
  90597. * - VertexBuffer.MatricesWeightsExtraKind
  90598. * @returns a boolean
  90599. */
  90600. isVertexBufferUpdatable(kind: string): boolean;
  90601. /**
  90602. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90603. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90604. * - VertexBuffer.PositionKind
  90605. * - VertexBuffer.NormalKind
  90606. * - VertexBuffer.UVKind
  90607. * - VertexBuffer.UV2Kind
  90608. * - VertexBuffer.UV3Kind
  90609. * - VertexBuffer.UV4Kind
  90610. * - VertexBuffer.UV5Kind
  90611. * - VertexBuffer.UV6Kind
  90612. * - VertexBuffer.ColorKind
  90613. * - VertexBuffer.MatricesIndicesKind
  90614. * - VertexBuffer.MatricesIndicesExtraKind
  90615. * - VertexBuffer.MatricesWeightsKind
  90616. * - VertexBuffer.MatricesWeightsExtraKind
  90617. * @returns an array of strings
  90618. */
  90619. getVerticesDataKinds(): string[];
  90620. /**
  90621. * Returns a positive integer : the total number of indices in this mesh geometry.
  90622. * @returns the numner of indices or zero if the mesh has no geometry.
  90623. */
  90624. getTotalIndices(): number;
  90625. /**
  90626. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90627. * @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.
  90628. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90629. * @returns the indices array or an empty array if the mesh has no geometry
  90630. */
  90631. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90632. readonly isBlocked: boolean;
  90633. /**
  90634. * Determine if the current mesh is ready to be rendered
  90635. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90636. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90637. * @returns true if all associated assets are ready (material, textures, shaders)
  90638. */
  90639. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90640. /**
  90641. * 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.
  90642. */
  90643. readonly areNormalsFrozen: boolean;
  90644. /**
  90645. * 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.
  90646. * @returns the current mesh
  90647. */
  90648. freezeNormals(): Mesh;
  90649. /**
  90650. * 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
  90651. * @returns the current mesh
  90652. */
  90653. unfreezeNormals(): Mesh;
  90654. /**
  90655. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90656. */
  90657. overridenInstanceCount: number;
  90658. /** @hidden */
  90659. _preActivate(): Mesh;
  90660. /** @hidden */
  90661. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90662. /** @hidden */
  90663. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90664. /**
  90665. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90666. * This means the mesh underlying bounding box and sphere are recomputed.
  90667. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90668. * @returns the current mesh
  90669. */
  90670. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90671. /** @hidden */
  90672. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90673. /**
  90674. * This function will subdivide the mesh into multiple submeshes
  90675. * @param count defines the expected number of submeshes
  90676. */
  90677. subdivide(count: number): void;
  90678. /**
  90679. * Copy a FloatArray into a specific associated vertex buffer
  90680. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90681. * - VertexBuffer.PositionKind
  90682. * - VertexBuffer.UVKind
  90683. * - VertexBuffer.UV2Kind
  90684. * - VertexBuffer.UV3Kind
  90685. * - VertexBuffer.UV4Kind
  90686. * - VertexBuffer.UV5Kind
  90687. * - VertexBuffer.UV6Kind
  90688. * - VertexBuffer.ColorKind
  90689. * - VertexBuffer.MatricesIndicesKind
  90690. * - VertexBuffer.MatricesIndicesExtraKind
  90691. * - VertexBuffer.MatricesWeightsKind
  90692. * - VertexBuffer.MatricesWeightsExtraKind
  90693. * @param data defines the data source
  90694. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90695. * @param stride defines the data stride size (can be null)
  90696. * @returns the current mesh
  90697. */
  90698. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90699. /**
  90700. * Flags an associated vertex buffer as updatable
  90701. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90702. * - VertexBuffer.PositionKind
  90703. * - VertexBuffer.UVKind
  90704. * - VertexBuffer.UV2Kind
  90705. * - VertexBuffer.UV3Kind
  90706. * - VertexBuffer.UV4Kind
  90707. * - VertexBuffer.UV5Kind
  90708. * - VertexBuffer.UV6Kind
  90709. * - VertexBuffer.ColorKind
  90710. * - VertexBuffer.MatricesIndicesKind
  90711. * - VertexBuffer.MatricesIndicesExtraKind
  90712. * - VertexBuffer.MatricesWeightsKind
  90713. * - VertexBuffer.MatricesWeightsExtraKind
  90714. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90715. */
  90716. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90717. /**
  90718. * Sets the mesh global Vertex Buffer
  90719. * @param buffer defines the buffer to use
  90720. * @returns the current mesh
  90721. */
  90722. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90723. /**
  90724. * Update a specific associated vertex buffer
  90725. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90726. * - VertexBuffer.PositionKind
  90727. * - VertexBuffer.UVKind
  90728. * - VertexBuffer.UV2Kind
  90729. * - VertexBuffer.UV3Kind
  90730. * - VertexBuffer.UV4Kind
  90731. * - VertexBuffer.UV5Kind
  90732. * - VertexBuffer.UV6Kind
  90733. * - VertexBuffer.ColorKind
  90734. * - VertexBuffer.MatricesIndicesKind
  90735. * - VertexBuffer.MatricesIndicesExtraKind
  90736. * - VertexBuffer.MatricesWeightsKind
  90737. * - VertexBuffer.MatricesWeightsExtraKind
  90738. * @param data defines the data source
  90739. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90740. * @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)
  90741. * @returns the current mesh
  90742. */
  90743. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90744. /**
  90745. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90746. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90747. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90748. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90749. * @returns the current mesh
  90750. */
  90751. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90752. /**
  90753. * Creates a un-shared specific occurence of the geometry for the mesh.
  90754. * @returns the current mesh
  90755. */
  90756. makeGeometryUnique(): Mesh;
  90757. /**
  90758. * Set the index buffer of this mesh
  90759. * @param indices defines the source data
  90760. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90761. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90762. * @returns the current mesh
  90763. */
  90764. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90765. /**
  90766. * Update the current index buffer
  90767. * @param indices defines the source data
  90768. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90769. * @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)
  90770. * @returns the current mesh
  90771. */
  90772. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90773. /**
  90774. * Invert the geometry to move from a right handed system to a left handed one.
  90775. * @returns the current mesh
  90776. */
  90777. toLeftHanded(): Mesh;
  90778. /** @hidden */
  90779. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90780. /** @hidden */
  90781. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90782. /**
  90783. * Registers for this mesh a javascript function called just before the rendering process
  90784. * @param func defines the function to call before rendering this mesh
  90785. * @returns the current mesh
  90786. */
  90787. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90788. /**
  90789. * Disposes a previously registered javascript function called before the rendering
  90790. * @param func defines the function to remove
  90791. * @returns the current mesh
  90792. */
  90793. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90794. /**
  90795. * Registers for this mesh a javascript function called just after the rendering is complete
  90796. * @param func defines the function to call after rendering this mesh
  90797. * @returns the current mesh
  90798. */
  90799. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90800. /**
  90801. * Disposes a previously registered javascript function called after the rendering.
  90802. * @param func defines the function to remove
  90803. * @returns the current mesh
  90804. */
  90805. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90806. /** @hidden */
  90807. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90808. /** @hidden */
  90809. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90810. /** @hidden */
  90811. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90812. /** @hidden */
  90813. _rebuild(): void;
  90814. /** @hidden */
  90815. _freeze(): void;
  90816. /** @hidden */
  90817. _unFreeze(): void;
  90818. /**
  90819. * 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
  90820. * @param subMesh defines the subMesh to render
  90821. * @param enableAlphaMode defines if alpha mode can be changed
  90822. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  90823. * @returns the current mesh
  90824. */
  90825. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  90826. private _onBeforeDraw;
  90827. /**
  90828. * Renormalize the mesh and patch it up if there are no weights
  90829. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90830. * However in the case of zero weights then we set just a single influence to 1.
  90831. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90832. */
  90833. cleanMatrixWeights(): void;
  90834. private normalizeSkinFourWeights;
  90835. private normalizeSkinWeightsAndExtra;
  90836. /**
  90837. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90838. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90839. * the user know there was an issue with importing the mesh
  90840. * @returns a validation object with skinned, valid and report string
  90841. */
  90842. validateSkinning(): {
  90843. skinned: boolean;
  90844. valid: boolean;
  90845. report: string;
  90846. };
  90847. /** @hidden */
  90848. _checkDelayState(): Mesh;
  90849. private _queueLoad;
  90850. /**
  90851. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90852. * A mesh is in the frustum if its bounding box intersects the frustum
  90853. * @param frustumPlanes defines the frustum to test
  90854. * @returns true if the mesh is in the frustum planes
  90855. */
  90856. isInFrustum(frustumPlanes: Plane[]): boolean;
  90857. /**
  90858. * Sets the mesh material by the material or multiMaterial `id` property
  90859. * @param id is a string identifying the material or the multiMaterial
  90860. * @returns the current mesh
  90861. */
  90862. setMaterialByID(id: string): Mesh;
  90863. /**
  90864. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90865. * @returns an array of IAnimatable
  90866. */
  90867. getAnimatables(): IAnimatable[];
  90868. /**
  90869. * Modifies the mesh geometry according to the passed transformation matrix.
  90870. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90871. * The mesh normals are modified using the same transformation.
  90872. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90873. * @param transform defines the transform matrix to use
  90874. * @see http://doc.babylonjs.com/resources/baking_transformations
  90875. * @returns the current mesh
  90876. */
  90877. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90878. /**
  90879. * Modifies the mesh geometry according to its own current World Matrix.
  90880. * The mesh World Matrix is then reset.
  90881. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90882. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90883. * @see http://doc.babylonjs.com/resources/baking_transformations
  90884. * @returns the current mesh
  90885. */
  90886. bakeCurrentTransformIntoVertices(): Mesh;
  90887. /** @hidden */
  90888. readonly _positions: Nullable<Vector3[]>;
  90889. /** @hidden */
  90890. _resetPointsArrayCache(): Mesh;
  90891. /** @hidden */
  90892. _generatePointsArray(): boolean;
  90893. /**
  90894. * Returns a new Mesh object generated from the current mesh properties.
  90895. * This method must not get confused with createInstance()
  90896. * @param name is a string, the name given to the new mesh
  90897. * @param newParent can be any Node object (default `null`)
  90898. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90899. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90900. * @returns a new mesh
  90901. */
  90902. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90903. /**
  90904. * Releases resources associated with this mesh.
  90905. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90906. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90907. */
  90908. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90909. /**
  90910. * Modifies the mesh geometry according to a displacement map.
  90911. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  90912. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90913. * @param url is a string, the URL from the image file is to be downloaded.
  90914. * @param minHeight is the lower limit of the displacement.
  90915. * @param maxHeight is the upper limit of the displacement.
  90916. * @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.
  90917. * @param uvOffset is an optional vector2 used to offset UV.
  90918. * @param uvScale is an optional vector2 used to scale UV.
  90919. * @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.
  90920. * @returns the Mesh.
  90921. */
  90922. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90923. /**
  90924. * Modifies the mesh geometry according to a displacementMap buffer.
  90925. * 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.
  90926. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  90927. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  90928. * @param heightMapWidth is the width of the buffer image.
  90929. * @param heightMapHeight is the height of the buffer image.
  90930. * @param minHeight is the lower limit of the displacement.
  90931. * @param maxHeight is the upper limit of the displacement.
  90932. * @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.
  90933. * @param uvOffset is an optional vector2 used to offset UV.
  90934. * @param uvScale is an optional vector2 used to scale UV.
  90935. * @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.
  90936. * @returns the Mesh.
  90937. */
  90938. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  90939. /**
  90940. * Modify the mesh to get a flat shading rendering.
  90941. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  90942. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  90943. * @returns current mesh
  90944. */
  90945. convertToFlatShadedMesh(): Mesh;
  90946. /**
  90947. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  90948. * In other words, more vertices, no more indices and a single bigger VBO.
  90949. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  90950. * @returns current mesh
  90951. */
  90952. convertToUnIndexedMesh(): Mesh;
  90953. /**
  90954. * Inverses facet orientations.
  90955. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90956. * @param flipNormals will also inverts the normals
  90957. * @returns current mesh
  90958. */
  90959. flipFaces(flipNormals?: boolean): Mesh;
  90960. /**
  90961. * Increase the number of facets and hence vertices in a mesh
  90962. * Vertex normals are interpolated from existing vertex normals
  90963. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90964. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  90965. */
  90966. increaseVertices(numberPerEdge: number): void;
  90967. /**
  90968. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  90969. * This will undo any application of covertToFlatShadedMesh
  90970. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  90971. */
  90972. forceSharedVertices(): void;
  90973. /** @hidden */
  90974. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  90975. /** @hidden */
  90976. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  90977. /**
  90978. * Creates a new InstancedMesh object from the mesh model.
  90979. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90980. * @param name defines the name of the new instance
  90981. * @returns a new InstancedMesh
  90982. */
  90983. createInstance(name: string): InstancedMesh;
  90984. /**
  90985. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  90986. * After this call, all the mesh instances have the same submeshes than the current mesh.
  90987. * @returns the current mesh
  90988. */
  90989. synchronizeInstances(): Mesh;
  90990. /**
  90991. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  90992. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  90993. * This should be used together with the simplification to avoid disappearing triangles.
  90994. * @param successCallback an optional success callback to be called after the optimization finished.
  90995. * @returns the current mesh
  90996. */
  90997. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  90998. /**
  90999. * Serialize current mesh
  91000. * @param serializationObject defines the object which will receive the serialization data
  91001. */
  91002. serialize(serializationObject: any): void;
  91003. /** @hidden */
  91004. _syncGeometryWithMorphTargetManager(): void;
  91005. /** @hidden */
  91006. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91007. /**
  91008. * Returns a new Mesh object parsed from the source provided.
  91009. * @param parsedMesh is the source
  91010. * @param scene defines the hosting scene
  91011. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91012. * @returns a new Mesh
  91013. */
  91014. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91015. /**
  91016. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91017. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91018. * @param name defines the name of the mesh to create
  91019. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91020. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91021. * @param closePath creates a seam between the first and the last points of each path of the path array
  91022. * @param offset is taken in account only if the `pathArray` is containing a single path
  91023. * @param scene defines the hosting scene
  91024. * @param updatable defines if the mesh must be flagged as updatable
  91025. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91026. * @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)
  91027. * @returns a new Mesh
  91028. */
  91029. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91030. /**
  91031. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91032. * @param name defines the name of the mesh to create
  91033. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91034. * @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
  91035. * @param scene defines the hosting scene
  91036. * @param updatable defines if the mesh must be flagged as updatable
  91037. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91038. * @returns a new Mesh
  91039. */
  91040. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91041. /**
  91042. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91043. * @param name defines the name of the mesh to create
  91044. * @param size sets the size (float) of each box side (default 1)
  91045. * @param scene defines the hosting scene
  91046. * @param updatable defines if the mesh must be flagged as updatable
  91047. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91048. * @returns a new Mesh
  91049. */
  91050. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91051. /**
  91052. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91053. * @param name defines the name of the mesh to create
  91054. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91055. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91056. * @param scene defines the hosting scene
  91057. * @param updatable defines if the mesh must be flagged as updatable
  91058. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91059. * @returns a new Mesh
  91060. */
  91061. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91062. /**
  91063. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91064. * @param name defines the name of the mesh to create
  91065. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91066. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91067. * @param scene defines the hosting scene
  91068. * @returns a new Mesh
  91069. */
  91070. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91071. /**
  91072. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91073. * @param name defines the name of the mesh to create
  91074. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91075. * @param diameterTop set the top cap diameter (floats, default 1)
  91076. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91077. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91078. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91079. * @param scene defines the hosting scene
  91080. * @param updatable defines if the mesh must be flagged as updatable
  91081. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91082. * @returns a new Mesh
  91083. */
  91084. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91085. /**
  91086. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91087. * @param name defines the name of the mesh to create
  91088. * @param diameter sets the diameter size (float) of the torus (default 1)
  91089. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91090. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91091. * @param scene defines the hosting scene
  91092. * @param updatable defines if the mesh must be flagged as updatable
  91093. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91094. * @returns a new Mesh
  91095. */
  91096. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91097. /**
  91098. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91099. * @param name defines the name of the mesh to create
  91100. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91101. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91102. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91103. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91104. * @param p the number of windings on X axis (positive integers, default 2)
  91105. * @param q the number of windings on Y axis (positive integers, default 3)
  91106. * @param scene defines the hosting scene
  91107. * @param updatable defines if the mesh must be flagged as updatable
  91108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91109. * @returns a new Mesh
  91110. */
  91111. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91112. /**
  91113. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91114. * @param name defines the name of the mesh to create
  91115. * @param points is an array successive Vector3
  91116. * @param scene defines the hosting scene
  91117. * @param updatable defines if the mesh must be flagged as updatable
  91118. * @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).
  91119. * @returns a new Mesh
  91120. */
  91121. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91122. /**
  91123. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91124. * @param name defines the name of the mesh to create
  91125. * @param points is an array successive Vector3
  91126. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91127. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91128. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91129. * @param scene defines the hosting scene
  91130. * @param updatable defines if the mesh must be flagged as updatable
  91131. * @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)
  91132. * @returns a new Mesh
  91133. */
  91134. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91135. /**
  91136. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91137. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91138. * 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.
  91139. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91140. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91141. * Remember you can only change the shape positions, not their number when updating a polygon.
  91142. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91143. * @param name defines the name of the mesh to create
  91144. * @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
  91145. * @param scene defines the hosting scene
  91146. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91147. * @param updatable defines if the mesh must be flagged as updatable
  91148. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91149. * @param earcutInjection can be used to inject your own earcut reference
  91150. * @returns a new Mesh
  91151. */
  91152. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91153. /**
  91154. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91155. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91156. * @param name defines the name of the mesh to create
  91157. * @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
  91158. * @param depth defines the height of extrusion
  91159. * @param scene defines the hosting scene
  91160. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91161. * @param updatable defines if the mesh must be flagged as updatable
  91162. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91163. * @param earcutInjection can be used to inject your own earcut reference
  91164. * @returns a new Mesh
  91165. */
  91166. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91167. /**
  91168. * Creates an extruded shape mesh.
  91169. * 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
  91170. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91171. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91172. * @param name defines the name of the mesh to create
  91173. * @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
  91174. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91175. * @param scale is the value to scale the shape
  91176. * @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
  91177. * @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
  91178. * @param scene defines the hosting scene
  91179. * @param updatable defines if the mesh must be flagged as updatable
  91180. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91181. * @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)
  91182. * @returns a new Mesh
  91183. */
  91184. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91185. /**
  91186. * Creates an custom extruded shape mesh.
  91187. * The custom extrusion is a parametric shape.
  91188. * It has no predefined shape. Its final shape will depend on the input parameters.
  91189. * Please consider using the same method from the MeshBuilder class instead
  91190. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91191. * @param name defines the name of the mesh to create
  91192. * @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
  91193. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91194. * @param scaleFunction is a custom Javascript function called on each path point
  91195. * @param rotationFunction is a custom Javascript function called on each path point
  91196. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91197. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91198. * @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
  91199. * @param scene defines the hosting scene
  91200. * @param updatable defines if the mesh must be flagged as updatable
  91201. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91202. * @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)
  91203. * @returns a new Mesh
  91204. */
  91205. 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;
  91206. /**
  91207. * Creates lathe mesh.
  91208. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91209. * Please consider using the same method from the MeshBuilder class instead
  91210. * @param name defines the name of the mesh to create
  91211. * @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
  91212. * @param radius is the radius value of the lathe
  91213. * @param tessellation is the side number of the lathe.
  91214. * @param scene defines the hosting scene
  91215. * @param updatable defines if the mesh must be flagged as updatable
  91216. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91217. * @returns a new Mesh
  91218. */
  91219. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91220. /**
  91221. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91222. * @param name defines the name of the mesh to create
  91223. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91224. * @param scene defines the hosting scene
  91225. * @param updatable defines if the mesh must be flagged as updatable
  91226. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91227. * @returns a new Mesh
  91228. */
  91229. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91230. /**
  91231. * Creates a ground mesh.
  91232. * Please consider using the same method from the MeshBuilder class instead
  91233. * @param name defines the name of the mesh to create
  91234. * @param width set the width of the ground
  91235. * @param height set the height of the ground
  91236. * @param subdivisions sets the number of subdivisions per side
  91237. * @param scene defines the hosting scene
  91238. * @param updatable defines if the mesh must be flagged as updatable
  91239. * @returns a new Mesh
  91240. */
  91241. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91242. /**
  91243. * Creates a tiled ground mesh.
  91244. * Please consider using the same method from the MeshBuilder class instead
  91245. * @param name defines the name of the mesh to create
  91246. * @param xmin set the ground minimum X coordinate
  91247. * @param zmin set the ground minimum Y coordinate
  91248. * @param xmax set the ground maximum X coordinate
  91249. * @param zmax set the ground maximum Z coordinate
  91250. * @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
  91251. * @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
  91252. * @param scene defines the hosting scene
  91253. * @param updatable defines if the mesh must be flagged as updatable
  91254. * @returns a new Mesh
  91255. */
  91256. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91257. w: number;
  91258. h: number;
  91259. }, precision: {
  91260. w: number;
  91261. h: number;
  91262. }, scene: Scene, updatable?: boolean): Mesh;
  91263. /**
  91264. * Creates a ground mesh from a height map.
  91265. * Please consider using the same method from the MeshBuilder class instead
  91266. * @see http://doc.babylonjs.com/babylon101/height_map
  91267. * @param name defines the name of the mesh to create
  91268. * @param url sets the URL of the height map image resource
  91269. * @param width set the ground width size
  91270. * @param height set the ground height size
  91271. * @param subdivisions sets the number of subdivision per side
  91272. * @param minHeight is the minimum altitude on the ground
  91273. * @param maxHeight is the maximum altitude on the ground
  91274. * @param scene defines the hosting scene
  91275. * @param updatable defines if the mesh must be flagged as updatable
  91276. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91277. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91278. * @returns a new Mesh
  91279. */
  91280. 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;
  91281. /**
  91282. * Creates a tube mesh.
  91283. * The tube is a parametric shape.
  91284. * It has no predefined shape. Its final shape will depend on the input parameters.
  91285. * Please consider using the same method from the MeshBuilder class instead
  91286. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91287. * @param name defines the name of the mesh to create
  91288. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91289. * @param radius sets the tube radius size
  91290. * @param tessellation is the number of sides on the tubular surface
  91291. * @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
  91292. * @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
  91293. * @param scene defines the hosting scene
  91294. * @param updatable defines if the mesh must be flagged as updatable
  91295. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91296. * @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)
  91297. * @returns a new Mesh
  91298. */
  91299. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91300. (i: number, distance: number): number;
  91301. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91302. /**
  91303. * Creates a polyhedron mesh.
  91304. * Please consider using the same method from the MeshBuilder class instead.
  91305. * * 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
  91306. * * The parameter `size` (positive float, default 1) sets the polygon size
  91307. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91308. * * 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`
  91309. * * 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
  91310. * * 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)`)
  91311. * * 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
  91312. * * 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
  91313. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91314. * * 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
  91315. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91316. * @param name defines the name of the mesh to create
  91317. * @param options defines the options used to create the mesh
  91318. * @param scene defines the hosting scene
  91319. * @returns a new Mesh
  91320. */
  91321. static CreatePolyhedron(name: string, options: {
  91322. type?: number;
  91323. size?: number;
  91324. sizeX?: number;
  91325. sizeY?: number;
  91326. sizeZ?: number;
  91327. custom?: any;
  91328. faceUV?: Vector4[];
  91329. faceColors?: Color4[];
  91330. updatable?: boolean;
  91331. sideOrientation?: number;
  91332. }, scene: Scene): Mesh;
  91333. /**
  91334. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91335. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91336. * * 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`)
  91337. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91338. * * 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
  91339. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91340. * * 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
  91341. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91342. * @param name defines the name of the mesh
  91343. * @param options defines the options used to create the mesh
  91344. * @param scene defines the hosting scene
  91345. * @returns a new Mesh
  91346. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91347. */
  91348. static CreateIcoSphere(name: string, options: {
  91349. radius?: number;
  91350. flat?: boolean;
  91351. subdivisions?: number;
  91352. sideOrientation?: number;
  91353. updatable?: boolean;
  91354. }, scene: Scene): Mesh;
  91355. /**
  91356. * Creates a decal mesh.
  91357. * Please consider using the same method from the MeshBuilder class instead.
  91358. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91359. * @param name defines the name of the mesh
  91360. * @param sourceMesh defines the mesh receiving the decal
  91361. * @param position sets the position of the decal in world coordinates
  91362. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91363. * @param size sets the decal scaling
  91364. * @param angle sets the angle to rotate the decal
  91365. * @returns a new Mesh
  91366. */
  91367. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91368. /**
  91369. * Prepare internal position array for software CPU skinning
  91370. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91371. */
  91372. setPositionsForCPUSkinning(): Float32Array;
  91373. /**
  91374. * Prepare internal normal array for software CPU skinning
  91375. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91376. */
  91377. setNormalsForCPUSkinning(): Float32Array;
  91378. /**
  91379. * Updates the vertex buffer by applying transformation from the bones
  91380. * @param skeleton defines the skeleton to apply to current mesh
  91381. * @returns the current mesh
  91382. */
  91383. applySkeleton(skeleton: Skeleton): Mesh;
  91384. /**
  91385. * 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
  91386. * @param meshes defines the list of meshes to scan
  91387. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91388. */
  91389. static MinMax(meshes: AbstractMesh[]): {
  91390. min: Vector3;
  91391. max: Vector3;
  91392. };
  91393. /**
  91394. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91395. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91396. * @returns a vector3
  91397. */
  91398. static Center(meshesOrMinMaxVector: {
  91399. min: Vector3;
  91400. max: Vector3;
  91401. } | AbstractMesh[]): Vector3;
  91402. /**
  91403. * Merge the array of meshes into a single mesh for performance reasons.
  91404. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91405. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91406. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91407. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91408. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91409. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91410. * @returns a new mesh
  91411. */
  91412. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91413. /** @hidden */
  91414. addInstance(instance: InstancedMesh): void;
  91415. /** @hidden */
  91416. removeInstance(instance: InstancedMesh): void;
  91417. }
  91418. }
  91419. declare module BABYLON {
  91420. /**
  91421. * This is the base class of all the camera used in the application.
  91422. * @see http://doc.babylonjs.com/features/cameras
  91423. */
  91424. export class Camera extends Node {
  91425. /** @hidden */
  91426. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91427. /**
  91428. * This is the default projection mode used by the cameras.
  91429. * It helps recreating a feeling of perspective and better appreciate depth.
  91430. * This is the best way to simulate real life cameras.
  91431. */
  91432. static readonly PERSPECTIVE_CAMERA: number;
  91433. /**
  91434. * This helps creating camera with an orthographic mode.
  91435. * 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.
  91436. */
  91437. static readonly ORTHOGRAPHIC_CAMERA: number;
  91438. /**
  91439. * This is the default FOV mode for perspective cameras.
  91440. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91441. */
  91442. static readonly FOVMODE_VERTICAL_FIXED: number;
  91443. /**
  91444. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91445. */
  91446. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91447. /**
  91448. * This specifies ther is no need for a camera rig.
  91449. * Basically only one eye is rendered corresponding to the camera.
  91450. */
  91451. static readonly RIG_MODE_NONE: number;
  91452. /**
  91453. * Simulates a camera Rig with one blue eye and one red eye.
  91454. * This can be use with 3d blue and red glasses.
  91455. */
  91456. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91457. /**
  91458. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91459. */
  91460. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91461. /**
  91462. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91463. */
  91464. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91465. /**
  91466. * Defines that both eyes of the camera will be rendered over under each other.
  91467. */
  91468. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91469. /**
  91470. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91471. */
  91472. static readonly RIG_MODE_VR: number;
  91473. /**
  91474. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91475. */
  91476. static readonly RIG_MODE_WEBVR: number;
  91477. /**
  91478. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91479. */
  91480. static readonly RIG_MODE_CUSTOM: number;
  91481. /**
  91482. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91483. */
  91484. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91485. /**
  91486. * Define the input manager associated with the camera.
  91487. */
  91488. inputs: CameraInputsManager<Camera>;
  91489. /** @hidden */
  91490. _position: Vector3;
  91491. /**
  91492. * Define the current local position of the camera in the scene
  91493. */
  91494. position: Vector3;
  91495. /**
  91496. * The vector the camera should consider as up.
  91497. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91498. */
  91499. upVector: Vector3;
  91500. /**
  91501. * Define the current limit on the left side for an orthographic camera
  91502. * In scene unit
  91503. */
  91504. orthoLeft: Nullable<number>;
  91505. /**
  91506. * Define the current limit on the right side for an orthographic camera
  91507. * In scene unit
  91508. */
  91509. orthoRight: Nullable<number>;
  91510. /**
  91511. * Define the current limit on the bottom side for an orthographic camera
  91512. * In scene unit
  91513. */
  91514. orthoBottom: Nullable<number>;
  91515. /**
  91516. * Define the current limit on the top side for an orthographic camera
  91517. * In scene unit
  91518. */
  91519. orthoTop: Nullable<number>;
  91520. /**
  91521. * Field Of View is set in Radians. (default is 0.8)
  91522. */
  91523. fov: number;
  91524. /**
  91525. * Define the minimum distance the camera can see from.
  91526. * This is important to note that the depth buffer are not infinite and the closer it starts
  91527. * the more your scene might encounter depth fighting issue.
  91528. */
  91529. minZ: number;
  91530. /**
  91531. * Define the maximum distance the camera can see to.
  91532. * This is important to note that the depth buffer are not infinite and the further it end
  91533. * the more your scene might encounter depth fighting issue.
  91534. */
  91535. maxZ: number;
  91536. /**
  91537. * Define the default inertia of the camera.
  91538. * This helps giving a smooth feeling to the camera movement.
  91539. */
  91540. inertia: number;
  91541. /**
  91542. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91543. */
  91544. mode: number;
  91545. /**
  91546. * Define wether the camera is intermediate.
  91547. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91548. */
  91549. isIntermediate: boolean;
  91550. /**
  91551. * Define the viewport of the camera.
  91552. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91553. */
  91554. viewport: Viewport;
  91555. /**
  91556. * Restricts the camera to viewing objects with the same layerMask.
  91557. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91558. */
  91559. layerMask: number;
  91560. /**
  91561. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91562. */
  91563. fovMode: number;
  91564. /**
  91565. * Rig mode of the camera.
  91566. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91567. * This is normally controlled byt the camera themselves as internal use.
  91568. */
  91569. cameraRigMode: number;
  91570. /**
  91571. * Defines the distance between both "eyes" in case of a RIG
  91572. */
  91573. interaxialDistance: number;
  91574. /**
  91575. * Defines if stereoscopic rendering is done side by side or over under.
  91576. */
  91577. isStereoscopicSideBySide: boolean;
  91578. /**
  91579. * 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
  91580. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91581. * else in the scene. (Eg. security camera)
  91582. *
  91583. * 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)
  91584. */
  91585. customRenderTargets: RenderTargetTexture[];
  91586. /**
  91587. * When set, the camera will render to this render target instead of the default canvas
  91588. *
  91589. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91590. */
  91591. outputRenderTarget: Nullable<RenderTargetTexture>;
  91592. /**
  91593. * Observable triggered when the camera view matrix has changed.
  91594. */
  91595. onViewMatrixChangedObservable: Observable<Camera>;
  91596. /**
  91597. * Observable triggered when the camera Projection matrix has changed.
  91598. */
  91599. onProjectionMatrixChangedObservable: Observable<Camera>;
  91600. /**
  91601. * Observable triggered when the inputs have been processed.
  91602. */
  91603. onAfterCheckInputsObservable: Observable<Camera>;
  91604. /**
  91605. * Observable triggered when reset has been called and applied to the camera.
  91606. */
  91607. onRestoreStateObservable: Observable<Camera>;
  91608. /** @hidden */
  91609. _cameraRigParams: any;
  91610. /** @hidden */
  91611. _rigCameras: Camera[];
  91612. /** @hidden */
  91613. _rigPostProcess: Nullable<PostProcess>;
  91614. protected _webvrViewMatrix: Matrix;
  91615. /** @hidden */
  91616. _skipRendering: boolean;
  91617. /** @hidden */
  91618. _projectionMatrix: Matrix;
  91619. /** @hidden */
  91620. _postProcesses: Nullable<PostProcess>[];
  91621. /** @hidden */
  91622. _activeMeshes: SmartArray<AbstractMesh>;
  91623. protected _globalPosition: Vector3;
  91624. /** @hidden */
  91625. _computedViewMatrix: Matrix;
  91626. private _doNotComputeProjectionMatrix;
  91627. private _transformMatrix;
  91628. private _frustumPlanes;
  91629. private _refreshFrustumPlanes;
  91630. private _storedFov;
  91631. private _stateStored;
  91632. /**
  91633. * Instantiates a new camera object.
  91634. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91635. * @see http://doc.babylonjs.com/features/cameras
  91636. * @param name Defines the name of the camera in the scene
  91637. * @param position Defines the position of the camera
  91638. * @param scene Defines the scene the camera belongs too
  91639. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91640. */
  91641. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91642. /**
  91643. * Store current camera state (fov, position, etc..)
  91644. * @returns the camera
  91645. */
  91646. storeState(): Camera;
  91647. /**
  91648. * Restores the camera state values if it has been stored. You must call storeState() first
  91649. */
  91650. protected _restoreStateValues(): boolean;
  91651. /**
  91652. * Restored camera state. You must call storeState() first.
  91653. * @returns true if restored and false otherwise
  91654. */
  91655. restoreState(): boolean;
  91656. /**
  91657. * Gets the class name of the camera.
  91658. * @returns the class name
  91659. */
  91660. getClassName(): string;
  91661. /** @hidden */
  91662. readonly _isCamera: boolean;
  91663. /**
  91664. * Gets a string representation of the camera useful for debug purpose.
  91665. * @param fullDetails Defines that a more verboe level of logging is required
  91666. * @returns the string representation
  91667. */
  91668. toString(fullDetails?: boolean): string;
  91669. /**
  91670. * Gets the current world space position of the camera.
  91671. */
  91672. readonly globalPosition: Vector3;
  91673. /**
  91674. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91675. * @returns the active meshe list
  91676. */
  91677. getActiveMeshes(): SmartArray<AbstractMesh>;
  91678. /**
  91679. * Check wether a mesh is part of the current active mesh list of the camera
  91680. * @param mesh Defines the mesh to check
  91681. * @returns true if active, false otherwise
  91682. */
  91683. isActiveMesh(mesh: Mesh): boolean;
  91684. /**
  91685. * Is this camera ready to be used/rendered
  91686. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91687. * @return true if the camera is ready
  91688. */
  91689. isReady(completeCheck?: boolean): boolean;
  91690. /** @hidden */
  91691. _initCache(): void;
  91692. /** @hidden */
  91693. _updateCache(ignoreParentClass?: boolean): void;
  91694. /** @hidden */
  91695. _isSynchronized(): boolean;
  91696. /** @hidden */
  91697. _isSynchronizedViewMatrix(): boolean;
  91698. /** @hidden */
  91699. _isSynchronizedProjectionMatrix(): boolean;
  91700. /**
  91701. * Attach the input controls to a specific dom element to get the input from.
  91702. * @param element Defines the element the controls should be listened from
  91703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91704. */
  91705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91706. /**
  91707. * Detach the current controls from the specified dom element.
  91708. * @param element Defines the element to stop listening the inputs from
  91709. */
  91710. detachControl(element: HTMLElement): void;
  91711. /**
  91712. * Update the camera state according to the different inputs gathered during the frame.
  91713. */
  91714. update(): void;
  91715. /** @hidden */
  91716. _checkInputs(): void;
  91717. /** @hidden */
  91718. readonly rigCameras: Camera[];
  91719. /**
  91720. * Gets the post process used by the rig cameras
  91721. */
  91722. readonly rigPostProcess: Nullable<PostProcess>;
  91723. /**
  91724. * Internal, gets the first post proces.
  91725. * @returns the first post process to be run on this camera.
  91726. */
  91727. _getFirstPostProcess(): Nullable<PostProcess>;
  91728. private _cascadePostProcessesToRigCams;
  91729. /**
  91730. * Attach a post process to the camera.
  91731. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91732. * @param postProcess The post process to attach to the camera
  91733. * @param insertAt The position of the post process in case several of them are in use in the scene
  91734. * @returns the position the post process has been inserted at
  91735. */
  91736. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91737. /**
  91738. * Detach a post process to the camera.
  91739. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91740. * @param postProcess The post process to detach from the camera
  91741. */
  91742. detachPostProcess(postProcess: PostProcess): void;
  91743. /**
  91744. * Gets the current world matrix of the camera
  91745. */
  91746. getWorldMatrix(): Matrix;
  91747. /** @hidden */
  91748. _getViewMatrix(): Matrix;
  91749. /**
  91750. * Gets the current view matrix of the camera.
  91751. * @param force forces the camera to recompute the matrix without looking at the cached state
  91752. * @returns the view matrix
  91753. */
  91754. getViewMatrix(force?: boolean): Matrix;
  91755. /**
  91756. * Freeze the projection matrix.
  91757. * It will prevent the cache check of the camera projection compute and can speed up perf
  91758. * if no parameter of the camera are meant to change
  91759. * @param projection Defines manually a projection if necessary
  91760. */
  91761. freezeProjectionMatrix(projection?: Matrix): void;
  91762. /**
  91763. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91764. */
  91765. unfreezeProjectionMatrix(): void;
  91766. /**
  91767. * Gets the current projection matrix of the camera.
  91768. * @param force forces the camera to recompute the matrix without looking at the cached state
  91769. * @returns the projection matrix
  91770. */
  91771. getProjectionMatrix(force?: boolean): Matrix;
  91772. /**
  91773. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91774. * @returns a Matrix
  91775. */
  91776. getTransformationMatrix(): Matrix;
  91777. private _updateFrustumPlanes;
  91778. /**
  91779. * Checks if a cullable object (mesh...) is in the camera frustum
  91780. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91781. * @param target The object to check
  91782. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91783. * @returns true if the object is in frustum otherwise false
  91784. */
  91785. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91786. /**
  91787. * Checks if a cullable object (mesh...) is in the camera frustum
  91788. * Unlike isInFrustum this cheks the full bounding box
  91789. * @param target The object to check
  91790. * @returns true if the object is in frustum otherwise false
  91791. */
  91792. isCompletelyInFrustum(target: ICullable): boolean;
  91793. /**
  91794. * Gets a ray in the forward direction from the camera.
  91795. * @param length Defines the length of the ray to create
  91796. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91797. * @param origin Defines the start point of the ray which defaults to the camera position
  91798. * @returns the forward ray
  91799. */
  91800. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91801. /**
  91802. * Releases resources associated with this node.
  91803. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91804. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91805. */
  91806. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91807. /** @hidden */
  91808. _isLeftCamera: boolean;
  91809. /**
  91810. * Gets the left camera of a rig setup in case of Rigged Camera
  91811. */
  91812. readonly isLeftCamera: boolean;
  91813. /** @hidden */
  91814. _isRightCamera: boolean;
  91815. /**
  91816. * Gets the right camera of a rig setup in case of Rigged Camera
  91817. */
  91818. readonly isRightCamera: boolean;
  91819. /**
  91820. * Gets the left camera of a rig setup in case of Rigged Camera
  91821. */
  91822. readonly leftCamera: Nullable<FreeCamera>;
  91823. /**
  91824. * Gets the right camera of a rig setup in case of Rigged Camera
  91825. */
  91826. readonly rightCamera: Nullable<FreeCamera>;
  91827. /**
  91828. * Gets the left camera target of a rig setup in case of Rigged Camera
  91829. * @returns the target position
  91830. */
  91831. getLeftTarget(): Nullable<Vector3>;
  91832. /**
  91833. * Gets the right camera target of a rig setup in case of Rigged Camera
  91834. * @returns the target position
  91835. */
  91836. getRightTarget(): Nullable<Vector3>;
  91837. /**
  91838. * @hidden
  91839. */
  91840. setCameraRigMode(mode: number, rigParams: any): void;
  91841. /** @hidden */
  91842. static _setStereoscopicRigMode(camera: Camera): void;
  91843. /** @hidden */
  91844. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91845. /** @hidden */
  91846. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91847. /** @hidden */
  91848. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91849. /** @hidden */
  91850. _getVRProjectionMatrix(): Matrix;
  91851. protected _updateCameraRotationMatrix(): void;
  91852. protected _updateWebVRCameraRotationMatrix(): void;
  91853. /**
  91854. * This function MUST be overwritten by the different WebVR cameras available.
  91855. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91856. * @hidden
  91857. */
  91858. _getWebVRProjectionMatrix(): Matrix;
  91859. /**
  91860. * This function MUST be overwritten by the different WebVR cameras available.
  91861. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91862. * @hidden
  91863. */
  91864. _getWebVRViewMatrix(): Matrix;
  91865. /** @hidden */
  91866. setCameraRigParameter(name: string, value: any): void;
  91867. /**
  91868. * needs to be overridden by children so sub has required properties to be copied
  91869. * @hidden
  91870. */
  91871. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91872. /**
  91873. * May need to be overridden by children
  91874. * @hidden
  91875. */
  91876. _updateRigCameras(): void;
  91877. /** @hidden */
  91878. _setupInputs(): void;
  91879. /**
  91880. * Serialiaze the camera setup to a json represention
  91881. * @returns the JSON representation
  91882. */
  91883. serialize(): any;
  91884. /**
  91885. * Clones the current camera.
  91886. * @param name The cloned camera name
  91887. * @returns the cloned camera
  91888. */
  91889. clone(name: string): Camera;
  91890. /**
  91891. * Gets the direction of the camera relative to a given local axis.
  91892. * @param localAxis Defines the reference axis to provide a relative direction.
  91893. * @return the direction
  91894. */
  91895. getDirection(localAxis: Vector3): Vector3;
  91896. /**
  91897. * Returns the current camera absolute rotation
  91898. */
  91899. readonly absoluteRotation: Quaternion;
  91900. /**
  91901. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91902. * @param localAxis Defines the reference axis to provide a relative direction.
  91903. * @param result Defines the vector to store the result in
  91904. */
  91905. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91906. /**
  91907. * Gets a camera constructor for a given camera type
  91908. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  91909. * @param name The name of the camera the result will be able to instantiate
  91910. * @param scene The scene the result will construct the camera in
  91911. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  91912. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  91913. * @returns a factory method to construc the camera
  91914. */
  91915. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  91916. /**
  91917. * Compute the world matrix of the camera.
  91918. * @returns the camera workd matrix
  91919. */
  91920. computeWorldMatrix(): Matrix;
  91921. /**
  91922. * Parse a JSON and creates the camera from the parsed information
  91923. * @param parsedCamera The JSON to parse
  91924. * @param scene The scene to instantiate the camera in
  91925. * @returns the newly constructed camera
  91926. */
  91927. static Parse(parsedCamera: any, scene: Scene): Camera;
  91928. }
  91929. }
  91930. declare module BABYLON {
  91931. /**
  91932. * Class containing static functions to help procedurally build meshes
  91933. */
  91934. export class DiscBuilder {
  91935. /**
  91936. * Creates a plane polygonal mesh. By default, this is a disc
  91937. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  91938. * * 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
  91939. * * 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
  91940. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  91941. * * 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
  91942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91943. * @param name defines the name of the mesh
  91944. * @param options defines the options used to create the mesh
  91945. * @param scene defines the hosting scene
  91946. * @returns the plane polygonal mesh
  91947. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  91948. */
  91949. static CreateDisc(name: string, options: {
  91950. radius?: number;
  91951. tessellation?: number;
  91952. arc?: number;
  91953. updatable?: boolean;
  91954. sideOrientation?: number;
  91955. frontUVs?: Vector4;
  91956. backUVs?: Vector4;
  91957. }, scene?: Nullable<Scene>): Mesh;
  91958. }
  91959. }
  91960. declare module BABYLON {
  91961. /**
  91962. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  91963. *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.
  91964. * The SPS is also a particle system. It provides some methods to manage the particles.
  91965. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  91966. *
  91967. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  91968. */
  91969. export class SolidParticleSystem implements IDisposable {
  91970. /**
  91971. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  91972. * Example : var p = SPS.particles[i];
  91973. */
  91974. particles: SolidParticle[];
  91975. /**
  91976. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  91977. */
  91978. nbParticles: number;
  91979. /**
  91980. * If the particles must ever face the camera (default false). Useful for planar particles.
  91981. */
  91982. billboard: boolean;
  91983. /**
  91984. * Recompute normals when adding a shape
  91985. */
  91986. recomputeNormals: boolean;
  91987. /**
  91988. * This a counter ofr your own usage. It's not set by any SPS functions.
  91989. */
  91990. counter: number;
  91991. /**
  91992. * The SPS name. This name is also given to the underlying mesh.
  91993. */
  91994. name: string;
  91995. /**
  91996. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  91997. */
  91998. mesh: Mesh;
  91999. /**
  92000. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92001. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92002. */
  92003. vars: any;
  92004. /**
  92005. * This array is populated when the SPS is set as 'pickable'.
  92006. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92007. * Each element of this array is an object `{idx: int, faceId: int}`.
  92008. * `idx` is the picked particle index in the `SPS.particles` array
  92009. * `faceId` is the picked face index counted within this particle.
  92010. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92011. */
  92012. pickedParticles: {
  92013. idx: number;
  92014. faceId: number;
  92015. }[];
  92016. /**
  92017. * This array is populated when `enableDepthSort` is set to true.
  92018. * Each element of this array is an instance of the class DepthSortedParticle.
  92019. */
  92020. depthSortedParticles: DepthSortedParticle[];
  92021. /**
  92022. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92023. * @hidden
  92024. */
  92025. _bSphereOnly: boolean;
  92026. /**
  92027. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92028. * @hidden
  92029. */
  92030. _bSphereRadiusFactor: number;
  92031. private _scene;
  92032. private _positions;
  92033. private _indices;
  92034. private _normals;
  92035. private _colors;
  92036. private _uvs;
  92037. private _indices32;
  92038. private _positions32;
  92039. private _normals32;
  92040. private _fixedNormal32;
  92041. private _colors32;
  92042. private _uvs32;
  92043. private _index;
  92044. private _updatable;
  92045. private _pickable;
  92046. private _isVisibilityBoxLocked;
  92047. private _alwaysVisible;
  92048. private _depthSort;
  92049. private _expandable;
  92050. private _shapeCounter;
  92051. private _copy;
  92052. private _color;
  92053. private _computeParticleColor;
  92054. private _computeParticleTexture;
  92055. private _computeParticleRotation;
  92056. private _computeParticleVertex;
  92057. private _computeBoundingBox;
  92058. private _depthSortParticles;
  92059. private _camera;
  92060. private _mustUnrotateFixedNormals;
  92061. private _particlesIntersect;
  92062. private _needs32Bits;
  92063. /**
  92064. * Creates a SPS (Solid Particle System) object.
  92065. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92066. * @param scene (Scene) is the scene in which the SPS is added.
  92067. * @param options defines the options of the sps e.g.
  92068. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92069. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92070. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92071. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  92072. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92073. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92074. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92075. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92076. */
  92077. constructor(name: string, scene: Scene, options?: {
  92078. updatable?: boolean;
  92079. isPickable?: boolean;
  92080. enableDepthSort?: boolean;
  92081. particleIntersection?: boolean;
  92082. boundingSphereOnly?: boolean;
  92083. bSphereRadiusFactor?: number;
  92084. expandable?: boolean;
  92085. });
  92086. /**
  92087. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92088. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92089. * @returns the created mesh
  92090. */
  92091. buildMesh(): Mesh;
  92092. /**
  92093. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92094. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92095. * Thus the particles generated from `digest()` have their property `position` set yet.
  92096. * @param mesh ( Mesh ) is the mesh to be digested
  92097. * @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
  92098. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92099. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92100. * @returns the current SPS
  92101. */
  92102. digest(mesh: Mesh, options?: {
  92103. facetNb?: number;
  92104. number?: number;
  92105. delta?: number;
  92106. }): SolidParticleSystem;
  92107. private _unrotateFixedNormals;
  92108. private _resetCopy;
  92109. private _meshBuilder;
  92110. private _posToShape;
  92111. private _uvsToShapeUV;
  92112. private _addParticle;
  92113. /**
  92114. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92115. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92116. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92117. * @param nb (positive integer) the number of particles to be created from this model
  92118. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92119. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92120. * @returns the number of shapes in the system
  92121. */
  92122. addShape(mesh: Mesh, nb: number, options?: {
  92123. positionFunction?: any;
  92124. vertexFunction?: any;
  92125. }): number;
  92126. private _rebuildParticle;
  92127. /**
  92128. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92129. * @returns the SPS.
  92130. */
  92131. rebuildMesh(): SolidParticleSystem;
  92132. /**
  92133. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92134. * This method calls `updateParticle()` for each particle of the SPS.
  92135. * For an animated SPS, it is usually called within the render loop.
  92136. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92137. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92138. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92139. * @returns the SPS.
  92140. */
  92141. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92142. /**
  92143. * Disposes the SPS.
  92144. */
  92145. dispose(): void;
  92146. /**
  92147. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92148. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92149. * @returns the SPS.
  92150. */
  92151. refreshVisibleSize(): SolidParticleSystem;
  92152. /**
  92153. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92154. * @param size the size (float) of the visibility box
  92155. * note : this doesn't lock the SPS mesh bounding box.
  92156. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92157. */
  92158. setVisibilityBox(size: number): void;
  92159. /**
  92160. * Gets whether the SPS as always visible or not
  92161. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92162. */
  92163. /**
  92164. * Sets the SPS as always visible or not
  92165. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92166. */
  92167. isAlwaysVisible: boolean;
  92168. /**
  92169. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92170. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92171. */
  92172. /**
  92173. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92174. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92175. */
  92176. isVisibilityBoxLocked: boolean;
  92177. /**
  92178. * Tells to `setParticles()` to compute the particle rotations or not.
  92179. * Default value : true. The SPS is faster when it's set to false.
  92180. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92181. */
  92182. /**
  92183. * Gets if `setParticles()` computes the particle rotations or not.
  92184. * Default value : true. The SPS is faster when it's set to false.
  92185. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92186. */
  92187. computeParticleRotation: boolean;
  92188. /**
  92189. * Tells to `setParticles()` to compute the particle colors or not.
  92190. * Default value : true. The SPS is faster when it's set to false.
  92191. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92192. */
  92193. /**
  92194. * Gets if `setParticles()` computes the particle colors or not.
  92195. * Default value : true. The SPS is faster when it's set to false.
  92196. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92197. */
  92198. computeParticleColor: boolean;
  92199. /**
  92200. * Gets if `setParticles()` computes the particle textures or not.
  92201. * Default value : true. The SPS is faster when it's set to false.
  92202. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92203. */
  92204. computeParticleTexture: boolean;
  92205. /**
  92206. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92207. * Default value : false. The SPS is faster when it's set to false.
  92208. * Note : the particle custom vertex positions aren't stored values.
  92209. */
  92210. /**
  92211. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92212. * Default value : false. The SPS is faster when it's set to false.
  92213. * Note : the particle custom vertex positions aren't stored values.
  92214. */
  92215. computeParticleVertex: boolean;
  92216. /**
  92217. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92218. */
  92219. /**
  92220. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92221. */
  92222. computeBoundingBox: boolean;
  92223. /**
  92224. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92225. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92226. * Default : `true`
  92227. */
  92228. /**
  92229. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92230. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92231. * Default : `true`
  92232. */
  92233. depthSortParticles: boolean;
  92234. /**
  92235. * Gets if the SPS is created as expandable at construction time.
  92236. * Default : `false`
  92237. */
  92238. readonly expandable: boolean;
  92239. /**
  92240. * This function does nothing. It may be overwritten to set all the particle first values.
  92241. * The SPS doesn't call this function, you may have to call it by your own.
  92242. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92243. */
  92244. initParticles(): void;
  92245. /**
  92246. * This function does nothing. It may be overwritten to recycle a particle.
  92247. * The SPS doesn't call this function, you may have to call it by your own.
  92248. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92249. * @param particle The particle to recycle
  92250. * @returns the recycled particle
  92251. */
  92252. recycleParticle(particle: SolidParticle): SolidParticle;
  92253. /**
  92254. * Updates a particle : this function should be overwritten by the user.
  92255. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92256. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92257. * @example : just set a particle position or velocity and recycle conditions
  92258. * @param particle The particle to update
  92259. * @returns the updated particle
  92260. */
  92261. updateParticle(particle: SolidParticle): SolidParticle;
  92262. /**
  92263. * Updates a vertex of a particle : it can be overwritten by the user.
  92264. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92265. * @param particle the current particle
  92266. * @param vertex the current index of the current particle
  92267. * @param pt the index of the current vertex in the particle shape
  92268. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92269. * @example : just set a vertex particle position
  92270. * @returns the updated vertex
  92271. */
  92272. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92273. /**
  92274. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92275. * This does nothing and may be overwritten by the user.
  92276. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92277. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92278. * @param update the boolean update value actually passed to setParticles()
  92279. */
  92280. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92281. /**
  92282. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92283. * This will be passed three parameters.
  92284. * This does nothing and may be overwritten by the user.
  92285. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92286. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92287. * @param update the boolean update value actually passed to setParticles()
  92288. */
  92289. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92290. }
  92291. }
  92292. declare module BABYLON {
  92293. /**
  92294. * Represents one particle of a solid particle system.
  92295. */
  92296. export class SolidParticle {
  92297. /**
  92298. * particle global index
  92299. */
  92300. idx: number;
  92301. /**
  92302. * The color of the particle
  92303. */
  92304. color: Nullable<Color4>;
  92305. /**
  92306. * The world space position of the particle.
  92307. */
  92308. position: Vector3;
  92309. /**
  92310. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92311. */
  92312. rotation: Vector3;
  92313. /**
  92314. * The world space rotation quaternion of the particle.
  92315. */
  92316. rotationQuaternion: Nullable<Quaternion>;
  92317. /**
  92318. * The scaling of the particle.
  92319. */
  92320. scaling: Vector3;
  92321. /**
  92322. * The uvs of the particle.
  92323. */
  92324. uvs: Vector4;
  92325. /**
  92326. * The current speed of the particle.
  92327. */
  92328. velocity: Vector3;
  92329. /**
  92330. * The pivot point in the particle local space.
  92331. */
  92332. pivot: Vector3;
  92333. /**
  92334. * Must the particle be translated from its pivot point in its local space ?
  92335. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92336. * Default : false
  92337. */
  92338. translateFromPivot: boolean;
  92339. /**
  92340. * Is the particle active or not ?
  92341. */
  92342. alive: boolean;
  92343. /**
  92344. * Is the particle visible or not ?
  92345. */
  92346. isVisible: boolean;
  92347. /**
  92348. * Index of this particle in the global "positions" array (Internal use)
  92349. * @hidden
  92350. */
  92351. _pos: number;
  92352. /**
  92353. * @hidden Index of this particle in the global "indices" array (Internal use)
  92354. */
  92355. _ind: number;
  92356. /**
  92357. * @hidden ModelShape of this particle (Internal use)
  92358. */
  92359. _model: ModelShape;
  92360. /**
  92361. * ModelShape id of this particle
  92362. */
  92363. shapeId: number;
  92364. /**
  92365. * Index of the particle in its shape id
  92366. */
  92367. idxInShape: number;
  92368. /**
  92369. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92370. */
  92371. _modelBoundingInfo: BoundingInfo;
  92372. /**
  92373. * @hidden Particle BoundingInfo object (Internal use)
  92374. */
  92375. _boundingInfo: BoundingInfo;
  92376. /**
  92377. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92378. */
  92379. _sps: SolidParticleSystem;
  92380. /**
  92381. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92382. */
  92383. _stillInvisible: boolean;
  92384. /**
  92385. * @hidden Last computed particle rotation matrix
  92386. */
  92387. _rotationMatrix: number[];
  92388. /**
  92389. * Parent particle Id, if any.
  92390. * Default null.
  92391. */
  92392. parentId: Nullable<number>;
  92393. /**
  92394. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92395. * The possible values are :
  92396. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92397. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92398. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92399. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92400. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92401. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92402. * */
  92403. cullingStrategy: number;
  92404. /**
  92405. * @hidden Internal global position in the SPS.
  92406. */
  92407. _globalPosition: Vector3;
  92408. /**
  92409. * Creates a Solid Particle object.
  92410. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92411. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92412. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92413. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92414. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92415. * @param shapeId (integer) is the model shape identifier in the SPS.
  92416. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92417. * @param sps defines the sps it is associated to
  92418. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92419. */
  92420. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92421. /**
  92422. * Legacy support, changed scale to scaling
  92423. */
  92424. /**
  92425. * Legacy support, changed scale to scaling
  92426. */
  92427. scale: Vector3;
  92428. /**
  92429. * Legacy support, changed quaternion to rotationQuaternion
  92430. */
  92431. /**
  92432. * Legacy support, changed quaternion to rotationQuaternion
  92433. */
  92434. quaternion: Nullable<Quaternion>;
  92435. /**
  92436. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92437. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92438. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92439. * @returns true if it intersects
  92440. */
  92441. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92442. /**
  92443. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92444. * A particle is in the frustum if its bounding box intersects the frustum
  92445. * @param frustumPlanes defines the frustum to test
  92446. * @returns true if the particle is in the frustum planes
  92447. */
  92448. isInFrustum(frustumPlanes: Plane[]): boolean;
  92449. /**
  92450. * get the rotation matrix of the particle
  92451. * @hidden
  92452. */
  92453. getRotationMatrix(m: Matrix): void;
  92454. }
  92455. /**
  92456. * Represents the shape of the model used by one particle of a solid particle system.
  92457. * SPS internal tool, don't use it manually.
  92458. */
  92459. export class ModelShape {
  92460. /**
  92461. * The shape id
  92462. * @hidden
  92463. */
  92464. shapeID: number;
  92465. /**
  92466. * flat array of model positions (internal use)
  92467. * @hidden
  92468. */
  92469. _shape: Vector3[];
  92470. /**
  92471. * flat array of model UVs (internal use)
  92472. * @hidden
  92473. */
  92474. _shapeUV: number[];
  92475. /**
  92476. * length of the shape in the model indices array (internal use)
  92477. * @hidden
  92478. */
  92479. _indicesLength: number;
  92480. /**
  92481. * Custom position function (internal use)
  92482. * @hidden
  92483. */
  92484. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92485. /**
  92486. * Custom vertex function (internal use)
  92487. * @hidden
  92488. */
  92489. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92490. /**
  92491. * 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.
  92492. * SPS internal tool, don't use it manually.
  92493. * @hidden
  92494. */
  92495. 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>);
  92496. }
  92497. /**
  92498. * Represents a Depth Sorted Particle in the solid particle system.
  92499. */
  92500. export class DepthSortedParticle {
  92501. /**
  92502. * Index of the particle in the "indices" array
  92503. */
  92504. ind: number;
  92505. /**
  92506. * Length of the particle shape in the "indices" array
  92507. */
  92508. indicesLength: number;
  92509. /**
  92510. * Squared distance from the particle to the camera
  92511. */
  92512. sqDistance: number;
  92513. }
  92514. }
  92515. declare module BABYLON {
  92516. /**
  92517. * @hidden
  92518. */
  92519. export class _MeshCollisionData {
  92520. _checkCollisions: boolean;
  92521. _collisionMask: number;
  92522. _collisionGroup: number;
  92523. _collider: Nullable<Collider>;
  92524. _oldPositionForCollisions: Vector3;
  92525. _diffPositionForCollisions: Vector3;
  92526. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92527. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92528. }
  92529. }
  92530. declare module BABYLON {
  92531. /** @hidden */
  92532. class _FacetDataStorage {
  92533. facetPositions: Vector3[];
  92534. facetNormals: Vector3[];
  92535. facetPartitioning: number[][];
  92536. facetNb: number;
  92537. partitioningSubdivisions: number;
  92538. partitioningBBoxRatio: number;
  92539. facetDataEnabled: boolean;
  92540. facetParameters: any;
  92541. bbSize: Vector3;
  92542. subDiv: {
  92543. max: number;
  92544. X: number;
  92545. Y: number;
  92546. Z: number;
  92547. };
  92548. facetDepthSort: boolean;
  92549. facetDepthSortEnabled: boolean;
  92550. depthSortedIndices: IndicesArray;
  92551. depthSortedFacets: {
  92552. ind: number;
  92553. sqDistance: number;
  92554. }[];
  92555. facetDepthSortFunction: (f1: {
  92556. ind: number;
  92557. sqDistance: number;
  92558. }, f2: {
  92559. ind: number;
  92560. sqDistance: number;
  92561. }) => number;
  92562. facetDepthSortFrom: Vector3;
  92563. facetDepthSortOrigin: Vector3;
  92564. invertedMatrix: Matrix;
  92565. }
  92566. /**
  92567. * @hidden
  92568. **/
  92569. class _InternalAbstractMeshDataInfo {
  92570. _hasVertexAlpha: boolean;
  92571. _useVertexColors: boolean;
  92572. _numBoneInfluencers: number;
  92573. _applyFog: boolean;
  92574. _receiveShadows: boolean;
  92575. _facetData: _FacetDataStorage;
  92576. _visibility: number;
  92577. _skeleton: Nullable<Skeleton>;
  92578. _layerMask: number;
  92579. _computeBonesUsingShaders: boolean;
  92580. _isActive: boolean;
  92581. _onlyForInstances: boolean;
  92582. _isActiveIntermediate: boolean;
  92583. _onlyForInstancesIntermediate: boolean;
  92584. _actAsRegularMesh: boolean;
  92585. }
  92586. /**
  92587. * Class used to store all common mesh properties
  92588. */
  92589. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92590. /** No occlusion */
  92591. static OCCLUSION_TYPE_NONE: number;
  92592. /** Occlusion set to optimisitic */
  92593. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92594. /** Occlusion set to strict */
  92595. static OCCLUSION_TYPE_STRICT: number;
  92596. /** Use an accurante occlusion algorithm */
  92597. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92598. /** Use a conservative occlusion algorithm */
  92599. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92600. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92601. * Test order :
  92602. * Is the bounding sphere outside the frustum ?
  92603. * If not, are the bounding box vertices outside the frustum ?
  92604. * It not, then the cullable object is in the frustum.
  92605. */
  92606. static readonly CULLINGSTRATEGY_STANDARD: number;
  92607. /** Culling strategy : Bounding Sphere Only.
  92608. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92609. * It's also less accurate than the standard because some not visible objects can still be selected.
  92610. * Test : is the bounding sphere outside the frustum ?
  92611. * If not, then the cullable object is in the frustum.
  92612. */
  92613. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92614. /** Culling strategy : Optimistic Inclusion.
  92615. * This in an inclusion test first, then the standard exclusion test.
  92616. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92617. * 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.
  92618. * Anyway, it's as accurate as the standard strategy.
  92619. * Test :
  92620. * Is the cullable object bounding sphere center in the frustum ?
  92621. * If not, apply the default culling strategy.
  92622. */
  92623. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92624. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92625. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92626. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92627. * 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.
  92628. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92629. * Test :
  92630. * Is the cullable object bounding sphere center in the frustum ?
  92631. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92632. */
  92633. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92634. /**
  92635. * No billboard
  92636. */
  92637. static readonly BILLBOARDMODE_NONE: number;
  92638. /** Billboard on X axis */
  92639. static readonly BILLBOARDMODE_X: number;
  92640. /** Billboard on Y axis */
  92641. static readonly BILLBOARDMODE_Y: number;
  92642. /** Billboard on Z axis */
  92643. static readonly BILLBOARDMODE_Z: number;
  92644. /** Billboard on all axes */
  92645. static readonly BILLBOARDMODE_ALL: number;
  92646. /** Billboard on using position instead of orientation */
  92647. static readonly BILLBOARDMODE_USE_POSITION: number;
  92648. /** @hidden */
  92649. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92650. /**
  92651. * The culling strategy to use to check whether the mesh must be rendered or not.
  92652. * This value can be changed at any time and will be used on the next render mesh selection.
  92653. * The possible values are :
  92654. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92655. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92656. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92657. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92658. * Please read each static variable documentation to get details about the culling process.
  92659. * */
  92660. cullingStrategy: number;
  92661. /**
  92662. * Gets the number of facets in the mesh
  92663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92664. */
  92665. readonly facetNb: number;
  92666. /**
  92667. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92669. */
  92670. partitioningSubdivisions: number;
  92671. /**
  92672. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92673. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92675. */
  92676. partitioningBBoxRatio: number;
  92677. /**
  92678. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92679. * Works only for updatable meshes.
  92680. * Doesn't work with multi-materials
  92681. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92682. */
  92683. mustDepthSortFacets: boolean;
  92684. /**
  92685. * The location (Vector3) where the facet depth sort must be computed from.
  92686. * By default, the active camera position.
  92687. * Used only when facet depth sort is enabled
  92688. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92689. */
  92690. facetDepthSortFrom: Vector3;
  92691. /**
  92692. * gets a boolean indicating if facetData is enabled
  92693. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92694. */
  92695. readonly isFacetDataEnabled: boolean;
  92696. /** @hidden */
  92697. _updateNonUniformScalingState(value: boolean): boolean;
  92698. /**
  92699. * An event triggered when this mesh collides with another one
  92700. */
  92701. onCollideObservable: Observable<AbstractMesh>;
  92702. /** Set a function to call when this mesh collides with another one */
  92703. onCollide: () => void;
  92704. /**
  92705. * An event triggered when the collision's position changes
  92706. */
  92707. onCollisionPositionChangeObservable: Observable<Vector3>;
  92708. /** Set a function to call when the collision's position changes */
  92709. onCollisionPositionChange: () => void;
  92710. /**
  92711. * An event triggered when material is changed
  92712. */
  92713. onMaterialChangedObservable: Observable<AbstractMesh>;
  92714. /**
  92715. * Gets or sets the orientation for POV movement & rotation
  92716. */
  92717. definedFacingForward: boolean;
  92718. /** @hidden */
  92719. _occlusionQuery: Nullable<WebGLQuery>;
  92720. /** @hidden */
  92721. _renderingGroup: Nullable<RenderingGroup>;
  92722. /**
  92723. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92724. */
  92725. /**
  92726. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92727. */
  92728. visibility: number;
  92729. /** Gets or sets the alpha index used to sort transparent meshes
  92730. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92731. */
  92732. alphaIndex: number;
  92733. /**
  92734. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92735. */
  92736. isVisible: boolean;
  92737. /**
  92738. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92739. */
  92740. isPickable: boolean;
  92741. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92742. showSubMeshesBoundingBox: boolean;
  92743. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92744. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92745. */
  92746. isBlocker: boolean;
  92747. /**
  92748. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92749. */
  92750. enablePointerMoveEvents: boolean;
  92751. /**
  92752. * Specifies the rendering group id for this mesh (0 by default)
  92753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92754. */
  92755. renderingGroupId: number;
  92756. private _material;
  92757. /** Gets or sets current material */
  92758. material: Nullable<Material>;
  92759. /**
  92760. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92761. * @see http://doc.babylonjs.com/babylon101/shadows
  92762. */
  92763. receiveShadows: boolean;
  92764. /** Defines color to use when rendering outline */
  92765. outlineColor: Color3;
  92766. /** Define width to use when rendering outline */
  92767. outlineWidth: number;
  92768. /** Defines color to use when rendering overlay */
  92769. overlayColor: Color3;
  92770. /** Defines alpha to use when rendering overlay */
  92771. overlayAlpha: number;
  92772. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92773. hasVertexAlpha: boolean;
  92774. /** 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) */
  92775. useVertexColors: boolean;
  92776. /**
  92777. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92778. */
  92779. computeBonesUsingShaders: boolean;
  92780. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92781. numBoneInfluencers: number;
  92782. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92783. applyFog: boolean;
  92784. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92785. useOctreeForRenderingSelection: boolean;
  92786. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92787. useOctreeForPicking: boolean;
  92788. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92789. useOctreeForCollisions: boolean;
  92790. /**
  92791. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92792. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92793. */
  92794. layerMask: number;
  92795. /**
  92796. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92797. */
  92798. alwaysSelectAsActiveMesh: boolean;
  92799. /**
  92800. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92801. */
  92802. doNotSyncBoundingInfo: boolean;
  92803. /**
  92804. * Gets or sets the current action manager
  92805. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92806. */
  92807. actionManager: Nullable<AbstractActionManager>;
  92808. private _meshCollisionData;
  92809. /**
  92810. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92811. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92812. */
  92813. ellipsoid: Vector3;
  92814. /**
  92815. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92816. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92817. */
  92818. ellipsoidOffset: Vector3;
  92819. /**
  92820. * Gets or sets a collision mask used to mask collisions (default is -1).
  92821. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92822. */
  92823. collisionMask: number;
  92824. /**
  92825. * Gets or sets the current collision group mask (-1 by default).
  92826. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92827. */
  92828. collisionGroup: number;
  92829. /**
  92830. * Defines edge width used when edgesRenderer is enabled
  92831. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92832. */
  92833. edgesWidth: number;
  92834. /**
  92835. * Defines edge color used when edgesRenderer is enabled
  92836. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92837. */
  92838. edgesColor: Color4;
  92839. /** @hidden */
  92840. _edgesRenderer: Nullable<IEdgesRenderer>;
  92841. /** @hidden */
  92842. _masterMesh: Nullable<AbstractMesh>;
  92843. /** @hidden */
  92844. _boundingInfo: Nullable<BoundingInfo>;
  92845. /** @hidden */
  92846. _renderId: number;
  92847. /**
  92848. * Gets or sets the list of subMeshes
  92849. * @see http://doc.babylonjs.com/how_to/multi_materials
  92850. */
  92851. subMeshes: SubMesh[];
  92852. /** @hidden */
  92853. _intersectionsInProgress: AbstractMesh[];
  92854. /** @hidden */
  92855. _unIndexed: boolean;
  92856. /** @hidden */
  92857. _lightSources: Light[];
  92858. /** Gets the list of lights affecting that mesh */
  92859. readonly lightSources: Light[];
  92860. /** @hidden */
  92861. readonly _positions: Nullable<Vector3[]>;
  92862. /** @hidden */
  92863. _waitingData: {
  92864. lods: Nullable<any>;
  92865. actions: Nullable<any>;
  92866. freezeWorldMatrix: Nullable<boolean>;
  92867. };
  92868. /** @hidden */
  92869. _bonesTransformMatrices: Nullable<Float32Array>;
  92870. /** @hidden */
  92871. _transformMatrixTexture: Nullable<RawTexture>;
  92872. /**
  92873. * Gets or sets a skeleton to apply skining transformations
  92874. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92875. */
  92876. skeleton: Nullable<Skeleton>;
  92877. /**
  92878. * An event triggered when the mesh is rebuilt.
  92879. */
  92880. onRebuildObservable: Observable<AbstractMesh>;
  92881. /**
  92882. * Creates a new AbstractMesh
  92883. * @param name defines the name of the mesh
  92884. * @param scene defines the hosting scene
  92885. */
  92886. constructor(name: string, scene?: Nullable<Scene>);
  92887. /**
  92888. * Returns the string "AbstractMesh"
  92889. * @returns "AbstractMesh"
  92890. */
  92891. getClassName(): string;
  92892. /**
  92893. * Gets a string representation of the current mesh
  92894. * @param fullDetails defines a boolean indicating if full details must be included
  92895. * @returns a string representation of the current mesh
  92896. */
  92897. toString(fullDetails?: boolean): string;
  92898. /**
  92899. * @hidden
  92900. */
  92901. protected _getEffectiveParent(): Nullable<Node>;
  92902. /** @hidden */
  92903. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92904. /** @hidden */
  92905. _rebuild(): void;
  92906. /** @hidden */
  92907. _resyncLightSources(): void;
  92908. /** @hidden */
  92909. _resyncLighSource(light: Light): void;
  92910. /** @hidden */
  92911. _unBindEffect(): void;
  92912. /** @hidden */
  92913. _removeLightSource(light: Light, dispose: boolean): void;
  92914. private _markSubMeshesAsDirty;
  92915. /** @hidden */
  92916. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92917. /** @hidden */
  92918. _markSubMeshesAsAttributesDirty(): void;
  92919. /** @hidden */
  92920. _markSubMeshesAsMiscDirty(): void;
  92921. /**
  92922. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  92923. */
  92924. scaling: Vector3;
  92925. /**
  92926. * Returns true if the mesh is blocked. Implemented by child classes
  92927. */
  92928. readonly isBlocked: boolean;
  92929. /**
  92930. * Returns the mesh itself by default. Implemented by child classes
  92931. * @param camera defines the camera to use to pick the right LOD level
  92932. * @returns the currentAbstractMesh
  92933. */
  92934. getLOD(camera: Camera): Nullable<AbstractMesh>;
  92935. /**
  92936. * Returns 0 by default. Implemented by child classes
  92937. * @returns an integer
  92938. */
  92939. getTotalVertices(): number;
  92940. /**
  92941. * Returns a positive integer : the total number of indices in this mesh geometry.
  92942. * @returns the numner of indices or zero if the mesh has no geometry.
  92943. */
  92944. getTotalIndices(): number;
  92945. /**
  92946. * Returns null by default. Implemented by child classes
  92947. * @returns null
  92948. */
  92949. getIndices(): Nullable<IndicesArray>;
  92950. /**
  92951. * Returns the array of the requested vertex data kind. Implemented by child classes
  92952. * @param kind defines the vertex data kind to use
  92953. * @returns null
  92954. */
  92955. getVerticesData(kind: string): Nullable<FloatArray>;
  92956. /**
  92957. * Sets the vertex data of the mesh geometry for the requested `kind`.
  92958. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  92959. * Note that a new underlying VertexBuffer object is created each call.
  92960. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  92961. * @param kind defines vertex data kind:
  92962. * * VertexBuffer.PositionKind
  92963. * * VertexBuffer.UVKind
  92964. * * VertexBuffer.UV2Kind
  92965. * * VertexBuffer.UV3Kind
  92966. * * VertexBuffer.UV4Kind
  92967. * * VertexBuffer.UV5Kind
  92968. * * VertexBuffer.UV6Kind
  92969. * * VertexBuffer.ColorKind
  92970. * * VertexBuffer.MatricesIndicesKind
  92971. * * VertexBuffer.MatricesIndicesExtraKind
  92972. * * VertexBuffer.MatricesWeightsKind
  92973. * * VertexBuffer.MatricesWeightsExtraKind
  92974. * @param data defines the data source
  92975. * @param updatable defines if the data must be flagged as updatable (or static)
  92976. * @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
  92977. * @returns the current mesh
  92978. */
  92979. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  92980. /**
  92981. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  92982. * If the mesh has no geometry, it is simply returned as it is.
  92983. * @param kind defines vertex data kind:
  92984. * * VertexBuffer.PositionKind
  92985. * * VertexBuffer.UVKind
  92986. * * VertexBuffer.UV2Kind
  92987. * * VertexBuffer.UV3Kind
  92988. * * VertexBuffer.UV4Kind
  92989. * * VertexBuffer.UV5Kind
  92990. * * VertexBuffer.UV6Kind
  92991. * * VertexBuffer.ColorKind
  92992. * * VertexBuffer.MatricesIndicesKind
  92993. * * VertexBuffer.MatricesIndicesExtraKind
  92994. * * VertexBuffer.MatricesWeightsKind
  92995. * * VertexBuffer.MatricesWeightsExtraKind
  92996. * @param data defines the data source
  92997. * @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
  92998. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  92999. * @returns the current mesh
  93000. */
  93001. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93002. /**
  93003. * Sets the mesh indices,
  93004. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93005. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93006. * @param totalVertices Defines the total number of vertices
  93007. * @returns the current mesh
  93008. */
  93009. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93010. /**
  93011. * Gets a boolean indicating if specific vertex data is present
  93012. * @param kind defines the vertex data kind to use
  93013. * @returns true is data kind is present
  93014. */
  93015. isVerticesDataPresent(kind: string): boolean;
  93016. /**
  93017. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93018. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93019. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93020. * @returns a BoundingInfo
  93021. */
  93022. getBoundingInfo(): BoundingInfo;
  93023. /**
  93024. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93025. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93026. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93027. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93028. * @returns the current mesh
  93029. */
  93030. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93031. /**
  93032. * Overwrite the current bounding info
  93033. * @param boundingInfo defines the new bounding info
  93034. * @returns the current mesh
  93035. */
  93036. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93037. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93038. readonly useBones: boolean;
  93039. /** @hidden */
  93040. _preActivate(): void;
  93041. /** @hidden */
  93042. _preActivateForIntermediateRendering(renderId: number): void;
  93043. /** @hidden */
  93044. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93045. /** @hidden */
  93046. _postActivate(): void;
  93047. /** @hidden */
  93048. _freeze(): void;
  93049. /** @hidden */
  93050. _unFreeze(): void;
  93051. /**
  93052. * Gets the current world matrix
  93053. * @returns a Matrix
  93054. */
  93055. getWorldMatrix(): Matrix;
  93056. /** @hidden */
  93057. _getWorldMatrixDeterminant(): number;
  93058. /**
  93059. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93060. */
  93061. readonly isAnInstance: boolean;
  93062. /**
  93063. * Gets a boolean indicating if this mesh has instances
  93064. */
  93065. readonly hasInstances: boolean;
  93066. /**
  93067. * Perform relative position change from the point of view of behind the front of the mesh.
  93068. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93069. * Supports definition of mesh facing forward or backward
  93070. * @param amountRight defines the distance on the right axis
  93071. * @param amountUp defines the distance on the up axis
  93072. * @param amountForward defines the distance on the forward axis
  93073. * @returns the current mesh
  93074. */
  93075. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93076. /**
  93077. * Calculate relative position change from the point of view of behind the front of the mesh.
  93078. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93079. * Supports definition of mesh facing forward or backward
  93080. * @param amountRight defines the distance on the right axis
  93081. * @param amountUp defines the distance on the up axis
  93082. * @param amountForward defines the distance on the forward axis
  93083. * @returns the new displacement vector
  93084. */
  93085. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93086. /**
  93087. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93088. * Supports definition of mesh facing forward or backward
  93089. * @param flipBack defines the flip
  93090. * @param twirlClockwise defines the twirl
  93091. * @param tiltRight defines the tilt
  93092. * @returns the current mesh
  93093. */
  93094. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93095. /**
  93096. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93097. * Supports definition of mesh facing forward or backward.
  93098. * @param flipBack defines the flip
  93099. * @param twirlClockwise defines the twirl
  93100. * @param tiltRight defines the tilt
  93101. * @returns the new rotation vector
  93102. */
  93103. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93104. /**
  93105. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93106. * This means the mesh underlying bounding box and sphere are recomputed.
  93107. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93108. * @returns the current mesh
  93109. */
  93110. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93111. /** @hidden */
  93112. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93113. /** @hidden */
  93114. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93115. /** @hidden */
  93116. _updateBoundingInfo(): AbstractMesh;
  93117. /** @hidden */
  93118. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93119. /** @hidden */
  93120. protected _afterComputeWorldMatrix(): void;
  93121. /** @hidden */
  93122. readonly _effectiveMesh: AbstractMesh;
  93123. /**
  93124. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93125. * A mesh is in the frustum if its bounding box intersects the frustum
  93126. * @param frustumPlanes defines the frustum to test
  93127. * @returns true if the mesh is in the frustum planes
  93128. */
  93129. isInFrustum(frustumPlanes: Plane[]): boolean;
  93130. /**
  93131. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93132. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93133. * @param frustumPlanes defines the frustum to test
  93134. * @returns true if the mesh is completely in the frustum planes
  93135. */
  93136. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93137. /**
  93138. * True if the mesh intersects another mesh or a SolidParticle object
  93139. * @param mesh defines a target mesh or SolidParticle to test
  93140. * @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)
  93141. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93142. * @returns true if there is an intersection
  93143. */
  93144. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93145. /**
  93146. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93147. * @param point defines the point to test
  93148. * @returns true if there is an intersection
  93149. */
  93150. intersectsPoint(point: Vector3): boolean;
  93151. /**
  93152. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93153. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93154. */
  93155. checkCollisions: boolean;
  93156. /**
  93157. * Gets Collider object used to compute collisions (not physics)
  93158. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93159. */
  93160. readonly collider: Nullable<Collider>;
  93161. /**
  93162. * Move the mesh using collision engine
  93163. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93164. * @param displacement defines the requested displacement vector
  93165. * @returns the current mesh
  93166. */
  93167. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93168. private _onCollisionPositionChange;
  93169. /** @hidden */
  93170. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93171. /** @hidden */
  93172. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93173. /** @hidden */
  93174. _checkCollision(collider: Collider): AbstractMesh;
  93175. /** @hidden */
  93176. _generatePointsArray(): boolean;
  93177. /**
  93178. * Checks if the passed Ray intersects with the mesh
  93179. * @param ray defines the ray to use
  93180. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93181. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93182. * @returns the picking info
  93183. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93184. */
  93185. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93186. /**
  93187. * Clones the current mesh
  93188. * @param name defines the mesh name
  93189. * @param newParent defines the new mesh parent
  93190. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93191. * @returns the new mesh
  93192. */
  93193. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93194. /**
  93195. * Disposes all the submeshes of the current meshnp
  93196. * @returns the current mesh
  93197. */
  93198. releaseSubMeshes(): AbstractMesh;
  93199. /**
  93200. * Releases resources associated with this abstract mesh.
  93201. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93202. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93203. */
  93204. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93205. /**
  93206. * Adds the passed mesh as a child to the current mesh
  93207. * @param mesh defines the child mesh
  93208. * @returns the current mesh
  93209. */
  93210. addChild(mesh: AbstractMesh): AbstractMesh;
  93211. /**
  93212. * Removes the passed mesh from the current mesh children list
  93213. * @param mesh defines the child mesh
  93214. * @returns the current mesh
  93215. */
  93216. removeChild(mesh: AbstractMesh): AbstractMesh;
  93217. /** @hidden */
  93218. private _initFacetData;
  93219. /**
  93220. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93221. * This method can be called within the render loop.
  93222. * 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
  93223. * @returns the current mesh
  93224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93225. */
  93226. updateFacetData(): AbstractMesh;
  93227. /**
  93228. * Returns the facetLocalNormals array.
  93229. * The normals are expressed in the mesh local spac
  93230. * @returns an array of Vector3
  93231. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93232. */
  93233. getFacetLocalNormals(): Vector3[];
  93234. /**
  93235. * Returns the facetLocalPositions array.
  93236. * The facet positions are expressed in the mesh local space
  93237. * @returns an array of Vector3
  93238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93239. */
  93240. getFacetLocalPositions(): Vector3[];
  93241. /**
  93242. * Returns the facetLocalPartioning array
  93243. * @returns an array of array of numbers
  93244. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93245. */
  93246. getFacetLocalPartitioning(): number[][];
  93247. /**
  93248. * Returns the i-th facet position in the world system.
  93249. * This method allocates a new Vector3 per call
  93250. * @param i defines the facet index
  93251. * @returns a new Vector3
  93252. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93253. */
  93254. getFacetPosition(i: number): Vector3;
  93255. /**
  93256. * Sets the reference Vector3 with the i-th facet position in the world system
  93257. * @param i defines the facet index
  93258. * @param ref defines the target vector
  93259. * @returns the current mesh
  93260. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93261. */
  93262. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93263. /**
  93264. * Returns the i-th facet normal in the world system.
  93265. * This method allocates a new Vector3 per call
  93266. * @param i defines the facet index
  93267. * @returns a new Vector3
  93268. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93269. */
  93270. getFacetNormal(i: number): Vector3;
  93271. /**
  93272. * Sets the reference Vector3 with the i-th facet normal in the world system
  93273. * @param i defines the facet index
  93274. * @param ref defines the target vector
  93275. * @returns the current mesh
  93276. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93277. */
  93278. getFacetNormalToRef(i: number, ref: Vector3): this;
  93279. /**
  93280. * 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)
  93281. * @param x defines x coordinate
  93282. * @param y defines y coordinate
  93283. * @param z defines z coordinate
  93284. * @returns the array of facet indexes
  93285. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93286. */
  93287. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93288. /**
  93289. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93290. * @param projected sets as the (x,y,z) world projection on the facet
  93291. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  93292. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  93293. * @param x defines x coordinate
  93294. * @param y defines y coordinate
  93295. * @param z defines z coordinate
  93296. * @returns the face index if found (or null instead)
  93297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93298. */
  93299. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93300. /**
  93301. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93302. * @param projected sets as the (x,y,z) local projection on the facet
  93303. * @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
  93304. * @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
  93305. * @param x defines x coordinate
  93306. * @param y defines y coordinate
  93307. * @param z defines z coordinate
  93308. * @returns the face index if found (or null instead)
  93309. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93310. */
  93311. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93312. /**
  93313. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93314. * @returns the parameters
  93315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93316. */
  93317. getFacetDataParameters(): any;
  93318. /**
  93319. * Disables the feature FacetData and frees the related memory
  93320. * @returns the current mesh
  93321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93322. */
  93323. disableFacetData(): AbstractMesh;
  93324. /**
  93325. * Updates the AbstractMesh indices array
  93326. * @param indices defines the data source
  93327. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93328. * @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)
  93329. * @returns the current mesh
  93330. */
  93331. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93332. /**
  93333. * Creates new normals data for the mesh
  93334. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93335. * @returns the current mesh
  93336. */
  93337. createNormals(updatable: boolean): AbstractMesh;
  93338. /**
  93339. * Align the mesh with a normal
  93340. * @param normal defines the normal to use
  93341. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93342. * @returns the current mesh
  93343. */
  93344. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93345. /** @hidden */
  93346. _checkOcclusionQuery(): boolean;
  93347. /**
  93348. * Disables the mesh edge rendering mode
  93349. * @returns the currentAbstractMesh
  93350. */
  93351. disableEdgesRendering(): AbstractMesh;
  93352. /**
  93353. * Enables the edge rendering mode on the mesh.
  93354. * This mode makes the mesh edges visible
  93355. * @param epsilon defines the maximal distance between two angles to detect a face
  93356. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93357. * @returns the currentAbstractMesh
  93358. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93359. */
  93360. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93361. }
  93362. }
  93363. declare module BABYLON {
  93364. /**
  93365. * Interface used to define ActionEvent
  93366. */
  93367. export interface IActionEvent {
  93368. /** The mesh or sprite that triggered the action */
  93369. source: any;
  93370. /** The X mouse cursor position at the time of the event */
  93371. pointerX: number;
  93372. /** The Y mouse cursor position at the time of the event */
  93373. pointerY: number;
  93374. /** The mesh that is currently pointed at (can be null) */
  93375. meshUnderPointer: Nullable<AbstractMesh>;
  93376. /** the original (browser) event that triggered the ActionEvent */
  93377. sourceEvent?: any;
  93378. /** additional data for the event */
  93379. additionalData?: any;
  93380. }
  93381. /**
  93382. * ActionEvent is the event being sent when an action is triggered.
  93383. */
  93384. export class ActionEvent implements IActionEvent {
  93385. /** The mesh or sprite that triggered the action */
  93386. source: any;
  93387. /** The X mouse cursor position at the time of the event */
  93388. pointerX: number;
  93389. /** The Y mouse cursor position at the time of the event */
  93390. pointerY: number;
  93391. /** The mesh that is currently pointed at (can be null) */
  93392. meshUnderPointer: Nullable<AbstractMesh>;
  93393. /** the original (browser) event that triggered the ActionEvent */
  93394. sourceEvent?: any;
  93395. /** additional data for the event */
  93396. additionalData?: any;
  93397. /**
  93398. * Creates a new ActionEvent
  93399. * @param source The mesh or sprite that triggered the action
  93400. * @param pointerX The X mouse cursor position at the time of the event
  93401. * @param pointerY The Y mouse cursor position at the time of the event
  93402. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93403. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93404. * @param additionalData additional data for the event
  93405. */
  93406. constructor(
  93407. /** The mesh or sprite that triggered the action */
  93408. source: any,
  93409. /** The X mouse cursor position at the time of the event */
  93410. pointerX: number,
  93411. /** The Y mouse cursor position at the time of the event */
  93412. pointerY: number,
  93413. /** The mesh that is currently pointed at (can be null) */
  93414. meshUnderPointer: Nullable<AbstractMesh>,
  93415. /** the original (browser) event that triggered the ActionEvent */
  93416. sourceEvent?: any,
  93417. /** additional data for the event */
  93418. additionalData?: any);
  93419. /**
  93420. * Helper function to auto-create an ActionEvent from a source mesh.
  93421. * @param source The source mesh that triggered the event
  93422. * @param evt The original (browser) event
  93423. * @param additionalData additional data for the event
  93424. * @returns the new ActionEvent
  93425. */
  93426. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93427. /**
  93428. * Helper function to auto-create an ActionEvent from a source sprite
  93429. * @param source The source sprite that triggered the event
  93430. * @param scene Scene associated with the sprite
  93431. * @param evt The original (browser) event
  93432. * @param additionalData additional data for the event
  93433. * @returns the new ActionEvent
  93434. */
  93435. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93436. /**
  93437. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93438. * @param scene the scene where the event occurred
  93439. * @param evt The original (browser) event
  93440. * @returns the new ActionEvent
  93441. */
  93442. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93443. /**
  93444. * Helper function to auto-create an ActionEvent from a primitive
  93445. * @param prim defines the target primitive
  93446. * @param pointerPos defines the pointer position
  93447. * @param evt The original (browser) event
  93448. * @param additionalData additional data for the event
  93449. * @returns the new ActionEvent
  93450. */
  93451. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93452. }
  93453. }
  93454. declare module BABYLON {
  93455. /**
  93456. * Abstract class used to decouple action Manager from scene and meshes.
  93457. * Do not instantiate.
  93458. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93459. */
  93460. export abstract class AbstractActionManager implements IDisposable {
  93461. /** Gets the list of active triggers */
  93462. static Triggers: {
  93463. [key: string]: number;
  93464. };
  93465. /** Gets the cursor to use when hovering items */
  93466. hoverCursor: string;
  93467. /** Gets the list of actions */
  93468. actions: IAction[];
  93469. /**
  93470. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93471. */
  93472. isRecursive: boolean;
  93473. /**
  93474. * Releases all associated resources
  93475. */
  93476. abstract dispose(): void;
  93477. /**
  93478. * Does this action manager has pointer triggers
  93479. */
  93480. abstract readonly hasPointerTriggers: boolean;
  93481. /**
  93482. * Does this action manager has pick triggers
  93483. */
  93484. abstract readonly hasPickTriggers: boolean;
  93485. /**
  93486. * Process a specific trigger
  93487. * @param trigger defines the trigger to process
  93488. * @param evt defines the event details to be processed
  93489. */
  93490. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93491. /**
  93492. * Does this action manager handles actions of any of the given triggers
  93493. * @param triggers defines the triggers to be tested
  93494. * @return a boolean indicating whether one (or more) of the triggers is handled
  93495. */
  93496. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93497. /**
  93498. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93499. * speed.
  93500. * @param triggerA defines the trigger to be tested
  93501. * @param triggerB defines the trigger to be tested
  93502. * @return a boolean indicating whether one (or more) of the triggers is handled
  93503. */
  93504. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93505. /**
  93506. * Does this action manager handles actions of a given trigger
  93507. * @param trigger defines the trigger to be tested
  93508. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93509. * @return whether the trigger is handled
  93510. */
  93511. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93512. /**
  93513. * Serialize this manager to a JSON object
  93514. * @param name defines the property name to store this manager
  93515. * @returns a JSON representation of this manager
  93516. */
  93517. abstract serialize(name: string): any;
  93518. /**
  93519. * Registers an action to this action manager
  93520. * @param action defines the action to be registered
  93521. * @return the action amended (prepared) after registration
  93522. */
  93523. abstract registerAction(action: IAction): Nullable<IAction>;
  93524. /**
  93525. * Unregisters an action to this action manager
  93526. * @param action defines the action to be unregistered
  93527. * @return a boolean indicating whether the action has been unregistered
  93528. */
  93529. abstract unregisterAction(action: IAction): Boolean;
  93530. /**
  93531. * Does exist one action manager with at least one trigger
  93532. **/
  93533. static readonly HasTriggers: boolean;
  93534. /**
  93535. * Does exist one action manager with at least one pick trigger
  93536. **/
  93537. static readonly HasPickTriggers: boolean;
  93538. /**
  93539. * Does exist one action manager that handles actions of a given trigger
  93540. * @param trigger defines the trigger to be tested
  93541. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93542. **/
  93543. static HasSpecificTrigger(trigger: number): boolean;
  93544. }
  93545. }
  93546. declare module BABYLON {
  93547. /**
  93548. * Defines how a node can be built from a string name.
  93549. */
  93550. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93551. /**
  93552. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93553. */
  93554. export class Node implements IBehaviorAware<Node> {
  93555. /** @hidden */
  93556. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93557. private static _NodeConstructors;
  93558. /**
  93559. * Add a new node constructor
  93560. * @param type defines the type name of the node to construct
  93561. * @param constructorFunc defines the constructor function
  93562. */
  93563. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93564. /**
  93565. * Returns a node constructor based on type name
  93566. * @param type defines the type name
  93567. * @param name defines the new node name
  93568. * @param scene defines the hosting scene
  93569. * @param options defines optional options to transmit to constructors
  93570. * @returns the new constructor or null
  93571. */
  93572. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93573. /**
  93574. * Gets or sets the name of the node
  93575. */
  93576. name: string;
  93577. /**
  93578. * Gets or sets the id of the node
  93579. */
  93580. id: string;
  93581. /**
  93582. * Gets or sets the unique id of the node
  93583. */
  93584. uniqueId: number;
  93585. /**
  93586. * Gets or sets a string used to store user defined state for the node
  93587. */
  93588. state: string;
  93589. /**
  93590. * Gets or sets an object used to store user defined information for the node
  93591. */
  93592. metadata: any;
  93593. /**
  93594. * For internal use only. Please do not use.
  93595. */
  93596. reservedDataStore: any;
  93597. /**
  93598. * List of inspectable custom properties (used by the Inspector)
  93599. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93600. */
  93601. inspectableCustomProperties: IInspectable[];
  93602. private _doNotSerialize;
  93603. /**
  93604. * Gets or sets a boolean used to define if the node must be serialized
  93605. */
  93606. doNotSerialize: boolean;
  93607. /** @hidden */
  93608. _isDisposed: boolean;
  93609. /**
  93610. * Gets a list of Animations associated with the node
  93611. */
  93612. animations: Animation[];
  93613. protected _ranges: {
  93614. [name: string]: Nullable<AnimationRange>;
  93615. };
  93616. /**
  93617. * Callback raised when the node is ready to be used
  93618. */
  93619. onReady: Nullable<(node: Node) => void>;
  93620. private _isEnabled;
  93621. private _isParentEnabled;
  93622. private _isReady;
  93623. /** @hidden */
  93624. _currentRenderId: number;
  93625. private _parentUpdateId;
  93626. /** @hidden */
  93627. _childUpdateId: number;
  93628. /** @hidden */
  93629. _waitingParentId: Nullable<string>;
  93630. /** @hidden */
  93631. _scene: Scene;
  93632. /** @hidden */
  93633. _cache: any;
  93634. private _parentNode;
  93635. private _children;
  93636. /** @hidden */
  93637. _worldMatrix: Matrix;
  93638. /** @hidden */
  93639. _worldMatrixDeterminant: number;
  93640. /** @hidden */
  93641. _worldMatrixDeterminantIsDirty: boolean;
  93642. /** @hidden */
  93643. private _sceneRootNodesIndex;
  93644. /**
  93645. * Gets a boolean indicating if the node has been disposed
  93646. * @returns true if the node was disposed
  93647. */
  93648. isDisposed(): boolean;
  93649. /**
  93650. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93651. * @see https://doc.babylonjs.com/how_to/parenting
  93652. */
  93653. parent: Nullable<Node>;
  93654. private addToSceneRootNodes;
  93655. private removeFromSceneRootNodes;
  93656. private _animationPropertiesOverride;
  93657. /**
  93658. * Gets or sets the animation properties override
  93659. */
  93660. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93661. /**
  93662. * Gets a string idenfifying the name of the class
  93663. * @returns "Node" string
  93664. */
  93665. getClassName(): string;
  93666. /** @hidden */
  93667. readonly _isNode: boolean;
  93668. /**
  93669. * An event triggered when the mesh is disposed
  93670. */
  93671. onDisposeObservable: Observable<Node>;
  93672. private _onDisposeObserver;
  93673. /**
  93674. * Sets a callback that will be raised when the node will be disposed
  93675. */
  93676. onDispose: () => void;
  93677. /**
  93678. * Creates a new Node
  93679. * @param name the name and id to be given to this node
  93680. * @param scene the scene this node will be added to
  93681. * @param addToRootNodes the node will be added to scene.rootNodes
  93682. */
  93683. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93684. /**
  93685. * Gets the scene of the node
  93686. * @returns a scene
  93687. */
  93688. getScene(): Scene;
  93689. /**
  93690. * Gets the engine of the node
  93691. * @returns a Engine
  93692. */
  93693. getEngine(): Engine;
  93694. private _behaviors;
  93695. /**
  93696. * Attach a behavior to the node
  93697. * @see http://doc.babylonjs.com/features/behaviour
  93698. * @param behavior defines the behavior to attach
  93699. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93700. * @returns the current Node
  93701. */
  93702. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93703. /**
  93704. * Remove an attached behavior
  93705. * @see http://doc.babylonjs.com/features/behaviour
  93706. * @param behavior defines the behavior to attach
  93707. * @returns the current Node
  93708. */
  93709. removeBehavior(behavior: Behavior<Node>): Node;
  93710. /**
  93711. * Gets the list of attached behaviors
  93712. * @see http://doc.babylonjs.com/features/behaviour
  93713. */
  93714. readonly behaviors: Behavior<Node>[];
  93715. /**
  93716. * Gets an attached behavior by name
  93717. * @param name defines the name of the behavior to look for
  93718. * @see http://doc.babylonjs.com/features/behaviour
  93719. * @returns null if behavior was not found else the requested behavior
  93720. */
  93721. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93722. /**
  93723. * Returns the latest update of the World matrix
  93724. * @returns a Matrix
  93725. */
  93726. getWorldMatrix(): Matrix;
  93727. /** @hidden */
  93728. _getWorldMatrixDeterminant(): number;
  93729. /**
  93730. * Returns directly the latest state of the mesh World matrix.
  93731. * A Matrix is returned.
  93732. */
  93733. readonly worldMatrixFromCache: Matrix;
  93734. /** @hidden */
  93735. _initCache(): void;
  93736. /** @hidden */
  93737. updateCache(force?: boolean): void;
  93738. /** @hidden */
  93739. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93740. /** @hidden */
  93741. _updateCache(ignoreParentClass?: boolean): void;
  93742. /** @hidden */
  93743. _isSynchronized(): boolean;
  93744. /** @hidden */
  93745. _markSyncedWithParent(): void;
  93746. /** @hidden */
  93747. isSynchronizedWithParent(): boolean;
  93748. /** @hidden */
  93749. isSynchronized(): boolean;
  93750. /**
  93751. * Is this node ready to be used/rendered
  93752. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93753. * @return true if the node is ready
  93754. */
  93755. isReady(completeCheck?: boolean): boolean;
  93756. /**
  93757. * Is this node enabled?
  93758. * 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
  93759. * @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
  93760. * @return whether this node (and its parent) is enabled
  93761. */
  93762. isEnabled(checkAncestors?: boolean): boolean;
  93763. /** @hidden */
  93764. protected _syncParentEnabledState(): void;
  93765. /**
  93766. * Set the enabled state of this node
  93767. * @param value defines the new enabled state
  93768. */
  93769. setEnabled(value: boolean): void;
  93770. /**
  93771. * Is this node a descendant of the given node?
  93772. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93773. * @param ancestor defines the parent node to inspect
  93774. * @returns a boolean indicating if this node is a descendant of the given node
  93775. */
  93776. isDescendantOf(ancestor: Node): boolean;
  93777. /** @hidden */
  93778. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93779. /**
  93780. * Will return all nodes that have this node as ascendant
  93781. * @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
  93782. * @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
  93783. * @return all children nodes of all types
  93784. */
  93785. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93786. /**
  93787. * Get all child-meshes of this node
  93788. * @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)
  93789. * @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
  93790. * @returns an array of AbstractMesh
  93791. */
  93792. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93793. /**
  93794. * Get all direct children of this node
  93795. * @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
  93796. * @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)
  93797. * @returns an array of Node
  93798. */
  93799. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93800. /** @hidden */
  93801. _setReady(state: boolean): void;
  93802. /**
  93803. * Get an animation by name
  93804. * @param name defines the name of the animation to look for
  93805. * @returns null if not found else the requested animation
  93806. */
  93807. getAnimationByName(name: string): Nullable<Animation>;
  93808. /**
  93809. * Creates an animation range for this node
  93810. * @param name defines the name of the range
  93811. * @param from defines the starting key
  93812. * @param to defines the end key
  93813. */
  93814. createAnimationRange(name: string, from: number, to: number): void;
  93815. /**
  93816. * Delete a specific animation range
  93817. * @param name defines the name of the range to delete
  93818. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93819. */
  93820. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93821. /**
  93822. * Get an animation range by name
  93823. * @param name defines the name of the animation range to look for
  93824. * @returns null if not found else the requested animation range
  93825. */
  93826. getAnimationRange(name: string): Nullable<AnimationRange>;
  93827. /**
  93828. * Gets the list of all animation ranges defined on this node
  93829. * @returns an array
  93830. */
  93831. getAnimationRanges(): Nullable<AnimationRange>[];
  93832. /**
  93833. * Will start the animation sequence
  93834. * @param name defines the range frames for animation sequence
  93835. * @param loop defines if the animation should loop (false by default)
  93836. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93837. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93838. * @returns the object created for this animation. If range does not exist, it will return null
  93839. */
  93840. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93841. /**
  93842. * Serialize animation ranges into a JSON compatible object
  93843. * @returns serialization object
  93844. */
  93845. serializeAnimationRanges(): any;
  93846. /**
  93847. * Computes the world matrix of the node
  93848. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93849. * @returns the world matrix
  93850. */
  93851. computeWorldMatrix(force?: boolean): Matrix;
  93852. /**
  93853. * Releases resources associated with this node.
  93854. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93855. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93856. */
  93857. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93858. /**
  93859. * Parse animation range data from a serialization object and store them into a given node
  93860. * @param node defines where to store the animation ranges
  93861. * @param parsedNode defines the serialization object to read data from
  93862. * @param scene defines the hosting scene
  93863. */
  93864. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93865. /**
  93866. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93867. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93868. * @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
  93869. * @returns the new bounding vectors
  93870. */
  93871. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93872. min: Vector3;
  93873. max: Vector3;
  93874. };
  93875. }
  93876. }
  93877. declare module BABYLON {
  93878. /**
  93879. * @hidden
  93880. */
  93881. export class _IAnimationState {
  93882. key: number;
  93883. repeatCount: number;
  93884. workValue?: any;
  93885. loopMode?: number;
  93886. offsetValue?: any;
  93887. highLimitValue?: any;
  93888. }
  93889. /**
  93890. * Class used to store any kind of animation
  93891. */
  93892. export class Animation {
  93893. /**Name of the animation */
  93894. name: string;
  93895. /**Property to animate */
  93896. targetProperty: string;
  93897. /**The frames per second of the animation */
  93898. framePerSecond: number;
  93899. /**The data type of the animation */
  93900. dataType: number;
  93901. /**The loop mode of the animation */
  93902. loopMode?: number | undefined;
  93903. /**Specifies if blending should be enabled */
  93904. enableBlending?: boolean | undefined;
  93905. /**
  93906. * Use matrix interpolation instead of using direct key value when animating matrices
  93907. */
  93908. static AllowMatricesInterpolation: boolean;
  93909. /**
  93910. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93911. */
  93912. static AllowMatrixDecomposeForInterpolation: boolean;
  93913. /**
  93914. * Stores the key frames of the animation
  93915. */
  93916. private _keys;
  93917. /**
  93918. * Stores the easing function of the animation
  93919. */
  93920. private _easingFunction;
  93921. /**
  93922. * @hidden Internal use only
  93923. */
  93924. _runtimeAnimations: RuntimeAnimation[];
  93925. /**
  93926. * The set of event that will be linked to this animation
  93927. */
  93928. private _events;
  93929. /**
  93930. * Stores an array of target property paths
  93931. */
  93932. targetPropertyPath: string[];
  93933. /**
  93934. * Stores the blending speed of the animation
  93935. */
  93936. blendingSpeed: number;
  93937. /**
  93938. * Stores the animation ranges for the animation
  93939. */
  93940. private _ranges;
  93941. /**
  93942. * @hidden Internal use
  93943. */
  93944. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  93945. /**
  93946. * Sets up an animation
  93947. * @param property The property to animate
  93948. * @param animationType The animation type to apply
  93949. * @param framePerSecond The frames per second of the animation
  93950. * @param easingFunction The easing function used in the animation
  93951. * @returns The created animation
  93952. */
  93953. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  93954. /**
  93955. * Create and start an animation on a node
  93956. * @param name defines the name of the global animation that will be run on all nodes
  93957. * @param node defines the root node where the animation will take place
  93958. * @param targetProperty defines property to animate
  93959. * @param framePerSecond defines the number of frame per second yo use
  93960. * @param totalFrame defines the number of frames in total
  93961. * @param from defines the initial value
  93962. * @param to defines the final value
  93963. * @param loopMode defines which loop mode you want to use (off by default)
  93964. * @param easingFunction defines the easing function to use (linear by default)
  93965. * @param onAnimationEnd defines the callback to call when animation end
  93966. * @returns the animatable created for this animation
  93967. */
  93968. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  93969. /**
  93970. * Create and start an animation on a node and its descendants
  93971. * @param name defines the name of the global animation that will be run on all nodes
  93972. * @param node defines the root node where the animation will take place
  93973. * @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
  93974. * @param targetProperty defines property to animate
  93975. * @param framePerSecond defines the number of frame per second to use
  93976. * @param totalFrame defines the number of frames in total
  93977. * @param from defines the initial value
  93978. * @param to defines the final value
  93979. * @param loopMode defines which loop mode you want to use (off by default)
  93980. * @param easingFunction defines the easing function to use (linear by default)
  93981. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  93982. * @returns the list of animatables created for all nodes
  93983. * @example https://www.babylonjs-playground.com/#MH0VLI
  93984. */
  93985. 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[]>;
  93986. /**
  93987. * Creates a new animation, merges it with the existing animations and starts it
  93988. * @param name Name of the animation
  93989. * @param node Node which contains the scene that begins the animations
  93990. * @param targetProperty Specifies which property to animate
  93991. * @param framePerSecond The frames per second of the animation
  93992. * @param totalFrame The total number of frames
  93993. * @param from The frame at the beginning of the animation
  93994. * @param to The frame at the end of the animation
  93995. * @param loopMode Specifies the loop mode of the animation
  93996. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  93997. * @param onAnimationEnd Callback to run once the animation is complete
  93998. * @returns Nullable animation
  93999. */
  94000. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94001. /**
  94002. * Transition property of an host to the target Value
  94003. * @param property The property to transition
  94004. * @param targetValue The target Value of the property
  94005. * @param host The object where the property to animate belongs
  94006. * @param scene Scene used to run the animation
  94007. * @param frameRate Framerate (in frame/s) to use
  94008. * @param transition The transition type we want to use
  94009. * @param duration The duration of the animation, in milliseconds
  94010. * @param onAnimationEnd Callback trigger at the end of the animation
  94011. * @returns Nullable animation
  94012. */
  94013. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94014. /**
  94015. * Return the array of runtime animations currently using this animation
  94016. */
  94017. readonly runtimeAnimations: RuntimeAnimation[];
  94018. /**
  94019. * Specifies if any of the runtime animations are currently running
  94020. */
  94021. readonly hasRunningRuntimeAnimations: boolean;
  94022. /**
  94023. * Initializes the animation
  94024. * @param name Name of the animation
  94025. * @param targetProperty Property to animate
  94026. * @param framePerSecond The frames per second of the animation
  94027. * @param dataType The data type of the animation
  94028. * @param loopMode The loop mode of the animation
  94029. * @param enableBlending Specifies if blending should be enabled
  94030. */
  94031. constructor(
  94032. /**Name of the animation */
  94033. name: string,
  94034. /**Property to animate */
  94035. targetProperty: string,
  94036. /**The frames per second of the animation */
  94037. framePerSecond: number,
  94038. /**The data type of the animation */
  94039. dataType: number,
  94040. /**The loop mode of the animation */
  94041. loopMode?: number | undefined,
  94042. /**Specifies if blending should be enabled */
  94043. enableBlending?: boolean | undefined);
  94044. /**
  94045. * Converts the animation to a string
  94046. * @param fullDetails support for multiple levels of logging within scene loading
  94047. * @returns String form of the animation
  94048. */
  94049. toString(fullDetails?: boolean): string;
  94050. /**
  94051. * Add an event to this animation
  94052. * @param event Event to add
  94053. */
  94054. addEvent(event: AnimationEvent): void;
  94055. /**
  94056. * Remove all events found at the given frame
  94057. * @param frame The frame to remove events from
  94058. */
  94059. removeEvents(frame: number): void;
  94060. /**
  94061. * Retrieves all the events from the animation
  94062. * @returns Events from the animation
  94063. */
  94064. getEvents(): AnimationEvent[];
  94065. /**
  94066. * Creates an animation range
  94067. * @param name Name of the animation range
  94068. * @param from Starting frame of the animation range
  94069. * @param to Ending frame of the animation
  94070. */
  94071. createRange(name: string, from: number, to: number): void;
  94072. /**
  94073. * Deletes an animation range by name
  94074. * @param name Name of the animation range to delete
  94075. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94076. */
  94077. deleteRange(name: string, deleteFrames?: boolean): void;
  94078. /**
  94079. * Gets the animation range by name, or null if not defined
  94080. * @param name Name of the animation range
  94081. * @returns Nullable animation range
  94082. */
  94083. getRange(name: string): Nullable<AnimationRange>;
  94084. /**
  94085. * Gets the key frames from the animation
  94086. * @returns The key frames of the animation
  94087. */
  94088. getKeys(): Array<IAnimationKey>;
  94089. /**
  94090. * Gets the highest frame rate of the animation
  94091. * @returns Highest frame rate of the animation
  94092. */
  94093. getHighestFrame(): number;
  94094. /**
  94095. * Gets the easing function of the animation
  94096. * @returns Easing function of the animation
  94097. */
  94098. getEasingFunction(): IEasingFunction;
  94099. /**
  94100. * Sets the easing function of the animation
  94101. * @param easingFunction A custom mathematical formula for animation
  94102. */
  94103. setEasingFunction(easingFunction: EasingFunction): void;
  94104. /**
  94105. * Interpolates a scalar linearly
  94106. * @param startValue Start value of the animation curve
  94107. * @param endValue End value of the animation curve
  94108. * @param gradient Scalar amount to interpolate
  94109. * @returns Interpolated scalar value
  94110. */
  94111. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94112. /**
  94113. * Interpolates a scalar cubically
  94114. * @param startValue Start value of the animation curve
  94115. * @param outTangent End tangent of the animation
  94116. * @param endValue End value of the animation curve
  94117. * @param inTangent Start tangent of the animation curve
  94118. * @param gradient Scalar amount to interpolate
  94119. * @returns Interpolated scalar value
  94120. */
  94121. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94122. /**
  94123. * Interpolates a quaternion using a spherical linear interpolation
  94124. * @param startValue Start value of the animation curve
  94125. * @param endValue End value of the animation curve
  94126. * @param gradient Scalar amount to interpolate
  94127. * @returns Interpolated quaternion value
  94128. */
  94129. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94130. /**
  94131. * Interpolates a quaternion cubically
  94132. * @param startValue Start value of the animation curve
  94133. * @param outTangent End tangent of the animation curve
  94134. * @param endValue End value of the animation curve
  94135. * @param inTangent Start tangent of the animation curve
  94136. * @param gradient Scalar amount to interpolate
  94137. * @returns Interpolated quaternion value
  94138. */
  94139. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94140. /**
  94141. * Interpolates a Vector3 linearl
  94142. * @param startValue Start value of the animation curve
  94143. * @param endValue End value of the animation curve
  94144. * @param gradient Scalar amount to interpolate
  94145. * @returns Interpolated scalar value
  94146. */
  94147. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94148. /**
  94149. * Interpolates a Vector3 cubically
  94150. * @param startValue Start value of the animation curve
  94151. * @param outTangent End tangent of the animation
  94152. * @param endValue End value of the animation curve
  94153. * @param inTangent Start tangent of the animation curve
  94154. * @param gradient Scalar amount to interpolate
  94155. * @returns InterpolatedVector3 value
  94156. */
  94157. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94158. /**
  94159. * Interpolates a Vector2 linearly
  94160. * @param startValue Start value of the animation curve
  94161. * @param endValue End value of the animation curve
  94162. * @param gradient Scalar amount to interpolate
  94163. * @returns Interpolated Vector2 value
  94164. */
  94165. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94166. /**
  94167. * Interpolates a Vector2 cubically
  94168. * @param startValue Start value of the animation curve
  94169. * @param outTangent End tangent of the animation
  94170. * @param endValue End value of the animation curve
  94171. * @param inTangent Start tangent of the animation curve
  94172. * @param gradient Scalar amount to interpolate
  94173. * @returns Interpolated Vector2 value
  94174. */
  94175. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94176. /**
  94177. * Interpolates a size linearly
  94178. * @param startValue Start value of the animation curve
  94179. * @param endValue End value of the animation curve
  94180. * @param gradient Scalar amount to interpolate
  94181. * @returns Interpolated Size value
  94182. */
  94183. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94184. /**
  94185. * Interpolates a Color3 linearly
  94186. * @param startValue Start value of the animation curve
  94187. * @param endValue End value of the animation curve
  94188. * @param gradient Scalar amount to interpolate
  94189. * @returns Interpolated Color3 value
  94190. */
  94191. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94192. /**
  94193. * @hidden Internal use only
  94194. */
  94195. _getKeyValue(value: any): any;
  94196. /**
  94197. * @hidden Internal use only
  94198. */
  94199. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94200. /**
  94201. * Defines the function to use to interpolate matrices
  94202. * @param startValue defines the start matrix
  94203. * @param endValue defines the end matrix
  94204. * @param gradient defines the gradient between both matrices
  94205. * @param result defines an optional target matrix where to store the interpolation
  94206. * @returns the interpolated matrix
  94207. */
  94208. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94209. /**
  94210. * Makes a copy of the animation
  94211. * @returns Cloned animation
  94212. */
  94213. clone(): Animation;
  94214. /**
  94215. * Sets the key frames of the animation
  94216. * @param values The animation key frames to set
  94217. */
  94218. setKeys(values: Array<IAnimationKey>): void;
  94219. /**
  94220. * Serializes the animation to an object
  94221. * @returns Serialized object
  94222. */
  94223. serialize(): any;
  94224. /**
  94225. * Float animation type
  94226. */
  94227. private static _ANIMATIONTYPE_FLOAT;
  94228. /**
  94229. * Vector3 animation type
  94230. */
  94231. private static _ANIMATIONTYPE_VECTOR3;
  94232. /**
  94233. * Quaternion animation type
  94234. */
  94235. private static _ANIMATIONTYPE_QUATERNION;
  94236. /**
  94237. * Matrix animation type
  94238. */
  94239. private static _ANIMATIONTYPE_MATRIX;
  94240. /**
  94241. * Color3 animation type
  94242. */
  94243. private static _ANIMATIONTYPE_COLOR3;
  94244. /**
  94245. * Vector2 animation type
  94246. */
  94247. private static _ANIMATIONTYPE_VECTOR2;
  94248. /**
  94249. * Size animation type
  94250. */
  94251. private static _ANIMATIONTYPE_SIZE;
  94252. /**
  94253. * Relative Loop Mode
  94254. */
  94255. private static _ANIMATIONLOOPMODE_RELATIVE;
  94256. /**
  94257. * Cycle Loop Mode
  94258. */
  94259. private static _ANIMATIONLOOPMODE_CYCLE;
  94260. /**
  94261. * Constant Loop Mode
  94262. */
  94263. private static _ANIMATIONLOOPMODE_CONSTANT;
  94264. /**
  94265. * Get the float animation type
  94266. */
  94267. static readonly ANIMATIONTYPE_FLOAT: number;
  94268. /**
  94269. * Get the Vector3 animation type
  94270. */
  94271. static readonly ANIMATIONTYPE_VECTOR3: number;
  94272. /**
  94273. * Get the Vector2 animation type
  94274. */
  94275. static readonly ANIMATIONTYPE_VECTOR2: number;
  94276. /**
  94277. * Get the Size animation type
  94278. */
  94279. static readonly ANIMATIONTYPE_SIZE: number;
  94280. /**
  94281. * Get the Quaternion animation type
  94282. */
  94283. static readonly ANIMATIONTYPE_QUATERNION: number;
  94284. /**
  94285. * Get the Matrix animation type
  94286. */
  94287. static readonly ANIMATIONTYPE_MATRIX: number;
  94288. /**
  94289. * Get the Color3 animation type
  94290. */
  94291. static readonly ANIMATIONTYPE_COLOR3: number;
  94292. /**
  94293. * Get the Relative Loop Mode
  94294. */
  94295. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94296. /**
  94297. * Get the Cycle Loop Mode
  94298. */
  94299. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94300. /**
  94301. * Get the Constant Loop Mode
  94302. */
  94303. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94304. /** @hidden */
  94305. static _UniversalLerp(left: any, right: any, amount: number): any;
  94306. /**
  94307. * Parses an animation object and creates an animation
  94308. * @param parsedAnimation Parsed animation object
  94309. * @returns Animation object
  94310. */
  94311. static Parse(parsedAnimation: any): Animation;
  94312. /**
  94313. * Appends the serialized animations from the source animations
  94314. * @param source Source containing the animations
  94315. * @param destination Target to store the animations
  94316. */
  94317. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94318. }
  94319. }
  94320. declare module BABYLON {
  94321. /**
  94322. * Interface containing an array of animations
  94323. */
  94324. export interface IAnimatable {
  94325. /**
  94326. * Array of animations
  94327. */
  94328. animations: Nullable<Array<Animation>>;
  94329. }
  94330. }
  94331. declare module BABYLON {
  94332. /**
  94333. * This represents all the required information to add a fresnel effect on a material:
  94334. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94335. */
  94336. export class FresnelParameters {
  94337. private _isEnabled;
  94338. /**
  94339. * Define if the fresnel effect is enable or not.
  94340. */
  94341. isEnabled: boolean;
  94342. /**
  94343. * Define the color used on edges (grazing angle)
  94344. */
  94345. leftColor: Color3;
  94346. /**
  94347. * Define the color used on center
  94348. */
  94349. rightColor: Color3;
  94350. /**
  94351. * Define bias applied to computed fresnel term
  94352. */
  94353. bias: number;
  94354. /**
  94355. * Defined the power exponent applied to fresnel term
  94356. */
  94357. power: number;
  94358. /**
  94359. * Clones the current fresnel and its valuues
  94360. * @returns a clone fresnel configuration
  94361. */
  94362. clone(): FresnelParameters;
  94363. /**
  94364. * Serializes the current fresnel parameters to a JSON representation.
  94365. * @return the JSON serialization
  94366. */
  94367. serialize(): any;
  94368. /**
  94369. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94370. * @param parsedFresnelParameters Define the JSON representation
  94371. * @returns the parsed parameters
  94372. */
  94373. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94374. }
  94375. }
  94376. declare module BABYLON {
  94377. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94378. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94379. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94380. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94381. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94382. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94383. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94384. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94385. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94386. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94387. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94388. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94389. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94390. /**
  94391. * Decorator used to define property that can be serialized as reference to a camera
  94392. * @param sourceName defines the name of the property to decorate
  94393. */
  94394. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94395. /**
  94396. * Class used to help serialization objects
  94397. */
  94398. export class SerializationHelper {
  94399. /** @hidden */
  94400. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94401. /** @hidden */
  94402. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94403. /** @hidden */
  94404. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94405. /** @hidden */
  94406. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94407. /**
  94408. * Appends the serialized animations from the source animations
  94409. * @param source Source containing the animations
  94410. * @param destination Target to store the animations
  94411. */
  94412. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94413. /**
  94414. * Static function used to serialized a specific entity
  94415. * @param entity defines the entity to serialize
  94416. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94417. * @returns a JSON compatible object representing the serialization of the entity
  94418. */
  94419. static Serialize<T>(entity: T, serializationObject?: any): any;
  94420. /**
  94421. * Creates a new entity from a serialization data object
  94422. * @param creationFunction defines a function used to instanciated the new entity
  94423. * @param source defines the source serialization data
  94424. * @param scene defines the hosting scene
  94425. * @param rootUrl defines the root url for resources
  94426. * @returns a new entity
  94427. */
  94428. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94429. /**
  94430. * Clones an object
  94431. * @param creationFunction defines the function used to instanciate the new object
  94432. * @param source defines the source object
  94433. * @returns the cloned object
  94434. */
  94435. static Clone<T>(creationFunction: () => T, source: T): T;
  94436. /**
  94437. * Instanciates a new object based on a source one (some data will be shared between both object)
  94438. * @param creationFunction defines the function used to instanciate the new object
  94439. * @param source defines the source object
  94440. * @returns the new object
  94441. */
  94442. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94443. }
  94444. }
  94445. declare module BABYLON {
  94446. /**
  94447. * Class used to manipulate GUIDs
  94448. */
  94449. export class GUID {
  94450. /**
  94451. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94452. * Be aware Math.random() could cause collisions, but:
  94453. * "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"
  94454. * @returns a pseudo random id
  94455. */
  94456. static RandomId(): string;
  94457. }
  94458. }
  94459. declare module BABYLON {
  94460. /**
  94461. * Base class of all the textures in babylon.
  94462. * It groups all the common properties the materials, post process, lights... might need
  94463. * in order to make a correct use of the texture.
  94464. */
  94465. export class BaseTexture implements IAnimatable {
  94466. /**
  94467. * Default anisotropic filtering level for the application.
  94468. * It is set to 4 as a good tradeoff between perf and quality.
  94469. */
  94470. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94471. /**
  94472. * Gets or sets the unique id of the texture
  94473. */
  94474. uniqueId: number;
  94475. /**
  94476. * Define the name of the texture.
  94477. */
  94478. name: string;
  94479. /**
  94480. * Gets or sets an object used to store user defined information.
  94481. */
  94482. metadata: any;
  94483. /**
  94484. * For internal use only. Please do not use.
  94485. */
  94486. reservedDataStore: any;
  94487. private _hasAlpha;
  94488. /**
  94489. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94490. */
  94491. hasAlpha: boolean;
  94492. /**
  94493. * Defines if the alpha value should be determined via the rgb values.
  94494. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94495. */
  94496. getAlphaFromRGB: boolean;
  94497. /**
  94498. * Intensity or strength of the texture.
  94499. * It is commonly used by materials to fine tune the intensity of the texture
  94500. */
  94501. level: number;
  94502. /**
  94503. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94504. * This is part of the texture as textures usually maps to one uv set.
  94505. */
  94506. coordinatesIndex: number;
  94507. private _coordinatesMode;
  94508. /**
  94509. * How a texture is mapped.
  94510. *
  94511. * | Value | Type | Description |
  94512. * | ----- | ----------------------------------- | ----------- |
  94513. * | 0 | EXPLICIT_MODE | |
  94514. * | 1 | SPHERICAL_MODE | |
  94515. * | 2 | PLANAR_MODE | |
  94516. * | 3 | CUBIC_MODE | |
  94517. * | 4 | PROJECTION_MODE | |
  94518. * | 5 | SKYBOX_MODE | |
  94519. * | 6 | INVCUBIC_MODE | |
  94520. * | 7 | EQUIRECTANGULAR_MODE | |
  94521. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94522. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94523. */
  94524. coordinatesMode: number;
  94525. /**
  94526. * | Value | Type | Description |
  94527. * | ----- | ------------------ | ----------- |
  94528. * | 0 | CLAMP_ADDRESSMODE | |
  94529. * | 1 | WRAP_ADDRESSMODE | |
  94530. * | 2 | MIRROR_ADDRESSMODE | |
  94531. */
  94532. wrapU: number;
  94533. /**
  94534. * | Value | Type | Description |
  94535. * | ----- | ------------------ | ----------- |
  94536. * | 0 | CLAMP_ADDRESSMODE | |
  94537. * | 1 | WRAP_ADDRESSMODE | |
  94538. * | 2 | MIRROR_ADDRESSMODE | |
  94539. */
  94540. wrapV: number;
  94541. /**
  94542. * | Value | Type | Description |
  94543. * | ----- | ------------------ | ----------- |
  94544. * | 0 | CLAMP_ADDRESSMODE | |
  94545. * | 1 | WRAP_ADDRESSMODE | |
  94546. * | 2 | MIRROR_ADDRESSMODE | |
  94547. */
  94548. wrapR: number;
  94549. /**
  94550. * With compliant hardware and browser (supporting anisotropic filtering)
  94551. * this defines the level of anisotropic filtering in the texture.
  94552. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94553. */
  94554. anisotropicFilteringLevel: number;
  94555. /**
  94556. * Define if the texture is a cube texture or if false a 2d texture.
  94557. */
  94558. isCube: boolean;
  94559. /**
  94560. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94561. */
  94562. is3D: boolean;
  94563. /**
  94564. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94565. * HDR texture are usually stored in linear space.
  94566. * This only impacts the PBR and Background materials
  94567. */
  94568. gammaSpace: boolean;
  94569. /**
  94570. * Gets or sets whether or not the texture contains RGBD data.
  94571. */
  94572. isRGBD: boolean;
  94573. /**
  94574. * Is Z inverted in the texture (useful in a cube texture).
  94575. */
  94576. invertZ: boolean;
  94577. /**
  94578. * Are mip maps generated for this texture or not.
  94579. */
  94580. readonly noMipmap: boolean;
  94581. /**
  94582. * @hidden
  94583. */
  94584. lodLevelInAlpha: boolean;
  94585. /**
  94586. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94587. */
  94588. lodGenerationOffset: number;
  94589. /**
  94590. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94591. */
  94592. lodGenerationScale: number;
  94593. /**
  94594. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94595. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94596. * average roughness values.
  94597. */
  94598. linearSpecularLOD: boolean;
  94599. /**
  94600. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94601. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94602. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94603. */
  94604. irradianceTexture: Nullable<BaseTexture>;
  94605. /**
  94606. * Define if the texture is a render target.
  94607. */
  94608. isRenderTarget: boolean;
  94609. /**
  94610. * Define the unique id of the texture in the scene.
  94611. */
  94612. readonly uid: string;
  94613. /**
  94614. * Return a string representation of the texture.
  94615. * @returns the texture as a string
  94616. */
  94617. toString(): string;
  94618. /**
  94619. * Get the class name of the texture.
  94620. * @returns "BaseTexture"
  94621. */
  94622. getClassName(): string;
  94623. /**
  94624. * Define the list of animation attached to the texture.
  94625. */
  94626. animations: Animation[];
  94627. /**
  94628. * An event triggered when the texture is disposed.
  94629. */
  94630. onDisposeObservable: Observable<BaseTexture>;
  94631. private _onDisposeObserver;
  94632. /**
  94633. * Callback triggered when the texture has been disposed.
  94634. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94635. */
  94636. onDispose: () => void;
  94637. /**
  94638. * Define the current state of the loading sequence when in delayed load mode.
  94639. */
  94640. delayLoadState: number;
  94641. private _scene;
  94642. /** @hidden */
  94643. _texture: Nullable<InternalTexture>;
  94644. private _uid;
  94645. /**
  94646. * Define if the texture is preventinga material to render or not.
  94647. * If not and the texture is not ready, the engine will use a default black texture instead.
  94648. */
  94649. readonly isBlocking: boolean;
  94650. /**
  94651. * Instantiates a new BaseTexture.
  94652. * Base class of all the textures in babylon.
  94653. * It groups all the common properties the materials, post process, lights... might need
  94654. * in order to make a correct use of the texture.
  94655. * @param scene Define the scene the texture blongs to
  94656. */
  94657. constructor(scene: Nullable<Scene>);
  94658. /**
  94659. * Get the scene the texture belongs to.
  94660. * @returns the scene or null if undefined
  94661. */
  94662. getScene(): Nullable<Scene>;
  94663. /**
  94664. * Get the texture transform matrix used to offset tile the texture for istance.
  94665. * @returns the transformation matrix
  94666. */
  94667. getTextureMatrix(): Matrix;
  94668. /**
  94669. * Get the texture reflection matrix used to rotate/transform the reflection.
  94670. * @returns the reflection matrix
  94671. */
  94672. getReflectionTextureMatrix(): Matrix;
  94673. /**
  94674. * Get the underlying lower level texture from Babylon.
  94675. * @returns the insternal texture
  94676. */
  94677. getInternalTexture(): Nullable<InternalTexture>;
  94678. /**
  94679. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94680. * @returns true if ready or not blocking
  94681. */
  94682. isReadyOrNotBlocking(): boolean;
  94683. /**
  94684. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94685. * @returns true if fully ready
  94686. */
  94687. isReady(): boolean;
  94688. private _cachedSize;
  94689. /**
  94690. * Get the size of the texture.
  94691. * @returns the texture size.
  94692. */
  94693. getSize(): ISize;
  94694. /**
  94695. * Get the base size of the texture.
  94696. * It can be different from the size if the texture has been resized for POT for instance
  94697. * @returns the base size
  94698. */
  94699. getBaseSize(): ISize;
  94700. /**
  94701. * Update the sampling mode of the texture.
  94702. * Default is Trilinear mode.
  94703. *
  94704. * | Value | Type | Description |
  94705. * | ----- | ------------------ | ----------- |
  94706. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94707. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94708. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94709. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94710. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94711. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94712. * | 7 | NEAREST_LINEAR | |
  94713. * | 8 | NEAREST_NEAREST | |
  94714. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94715. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94716. * | 11 | LINEAR_LINEAR | |
  94717. * | 12 | LINEAR_NEAREST | |
  94718. *
  94719. * > _mag_: magnification filter (close to the viewer)
  94720. * > _min_: minification filter (far from the viewer)
  94721. * > _mip_: filter used between mip map levels
  94722. *@param samplingMode Define the new sampling mode of the texture
  94723. */
  94724. updateSamplingMode(samplingMode: number): void;
  94725. /**
  94726. * Scales the texture if is `canRescale()`
  94727. * @param ratio the resize factor we want to use to rescale
  94728. */
  94729. scale(ratio: number): void;
  94730. /**
  94731. * Get if the texture can rescale.
  94732. */
  94733. readonly canRescale: boolean;
  94734. /** @hidden */
  94735. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94736. /** @hidden */
  94737. _rebuild(): void;
  94738. /**
  94739. * Triggers the load sequence in delayed load mode.
  94740. */
  94741. delayLoad(): void;
  94742. /**
  94743. * Clones the texture.
  94744. * @returns the cloned texture
  94745. */
  94746. clone(): Nullable<BaseTexture>;
  94747. /**
  94748. * Get the texture underlying type (INT, FLOAT...)
  94749. */
  94750. readonly textureType: number;
  94751. /**
  94752. * Get the texture underlying format (RGB, RGBA...)
  94753. */
  94754. readonly textureFormat: number;
  94755. /**
  94756. * Indicates that textures need to be re-calculated for all materials
  94757. */
  94758. protected _markAllSubMeshesAsTexturesDirty(): void;
  94759. /**
  94760. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94761. * This will returns an RGBA array buffer containing either in values (0-255) or
  94762. * float values (0-1) depending of the underlying buffer type.
  94763. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94764. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94765. * @param buffer defines a user defined buffer to fill with data (can be null)
  94766. * @returns The Array buffer containing the pixels data.
  94767. */
  94768. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94769. /**
  94770. * Release and destroy the underlying lower level texture aka internalTexture.
  94771. */
  94772. releaseInternalTexture(): void;
  94773. /** @hidden */
  94774. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94775. /** @hidden */
  94776. readonly _lodTextureMid: Nullable<BaseTexture>;
  94777. /** @hidden */
  94778. readonly _lodTextureLow: Nullable<BaseTexture>;
  94779. /**
  94780. * Dispose the texture and release its associated resources.
  94781. */
  94782. dispose(): void;
  94783. /**
  94784. * Serialize the texture into a JSON representation that can be parsed later on.
  94785. * @returns the JSON representation of the texture
  94786. */
  94787. serialize(): any;
  94788. /**
  94789. * Helper function to be called back once a list of texture contains only ready textures.
  94790. * @param textures Define the list of textures to wait for
  94791. * @param callback Define the callback triggered once the entire list will be ready
  94792. */
  94793. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94794. }
  94795. }
  94796. declare module BABYLON {
  94797. /**
  94798. * Options to be used when creating an effect.
  94799. */
  94800. export interface IEffectCreationOptions {
  94801. /**
  94802. * Atrributes that will be used in the shader.
  94803. */
  94804. attributes: string[];
  94805. /**
  94806. * Uniform varible names that will be set in the shader.
  94807. */
  94808. uniformsNames: string[];
  94809. /**
  94810. * Uniform buffer varible names that will be set in the shader.
  94811. */
  94812. uniformBuffersNames: string[];
  94813. /**
  94814. * Sampler texture variable names that will be set in the shader.
  94815. */
  94816. samplers: string[];
  94817. /**
  94818. * Define statements that will be set in the shader.
  94819. */
  94820. defines: any;
  94821. /**
  94822. * Possible fallbacks for this effect to improve performance when needed.
  94823. */
  94824. fallbacks: Nullable<IEffectFallbacks>;
  94825. /**
  94826. * Callback that will be called when the shader is compiled.
  94827. */
  94828. onCompiled: Nullable<(effect: Effect) => void>;
  94829. /**
  94830. * Callback that will be called if an error occurs during shader compilation.
  94831. */
  94832. onError: Nullable<(effect: Effect, errors: string) => void>;
  94833. /**
  94834. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94835. */
  94836. indexParameters?: any;
  94837. /**
  94838. * Max number of lights that can be used in the shader.
  94839. */
  94840. maxSimultaneousLights?: number;
  94841. /**
  94842. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  94843. */
  94844. transformFeedbackVaryings?: Nullable<string[]>;
  94845. }
  94846. /**
  94847. * Effect containing vertex and fragment shader that can be executed on an object.
  94848. */
  94849. export class Effect implements IDisposable {
  94850. /**
  94851. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  94852. */
  94853. static ShadersRepository: string;
  94854. /**
  94855. * Name of the effect.
  94856. */
  94857. name: any;
  94858. /**
  94859. * String container all the define statements that should be set on the shader.
  94860. */
  94861. defines: string;
  94862. /**
  94863. * Callback that will be called when the shader is compiled.
  94864. */
  94865. onCompiled: Nullable<(effect: Effect) => void>;
  94866. /**
  94867. * Callback that will be called if an error occurs during shader compilation.
  94868. */
  94869. onError: Nullable<(effect: Effect, errors: string) => void>;
  94870. /**
  94871. * Callback that will be called when effect is bound.
  94872. */
  94873. onBind: Nullable<(effect: Effect) => void>;
  94874. /**
  94875. * Unique ID of the effect.
  94876. */
  94877. uniqueId: number;
  94878. /**
  94879. * Observable that will be called when the shader is compiled.
  94880. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  94881. */
  94882. onCompileObservable: Observable<Effect>;
  94883. /**
  94884. * Observable that will be called if an error occurs during shader compilation.
  94885. */
  94886. onErrorObservable: Observable<Effect>;
  94887. /** @hidden */
  94888. _onBindObservable: Nullable<Observable<Effect>>;
  94889. /**
  94890. * Observable that will be called when effect is bound.
  94891. */
  94892. readonly onBindObservable: Observable<Effect>;
  94893. /** @hidden */
  94894. _bonesComputationForcedToCPU: boolean;
  94895. private static _uniqueIdSeed;
  94896. private _engine;
  94897. private _uniformBuffersNames;
  94898. private _uniformsNames;
  94899. private _samplerList;
  94900. private _samplers;
  94901. private _isReady;
  94902. private _compilationError;
  94903. private _allFallbacksProcessed;
  94904. private _attributesNames;
  94905. private _attributes;
  94906. private _uniforms;
  94907. /**
  94908. * Key for the effect.
  94909. * @hidden
  94910. */
  94911. _key: string;
  94912. private _indexParameters;
  94913. private _fallbacks;
  94914. private _vertexSourceCode;
  94915. private _fragmentSourceCode;
  94916. private _vertexSourceCodeOverride;
  94917. private _fragmentSourceCodeOverride;
  94918. private _transformFeedbackVaryings;
  94919. /**
  94920. * Compiled shader to webGL program.
  94921. * @hidden
  94922. */
  94923. _pipelineContext: Nullable<IPipelineContext>;
  94924. private _valueCache;
  94925. private static _baseCache;
  94926. /**
  94927. * Instantiates an effect.
  94928. * An effect can be used to create/manage/execute vertex and fragment shaders.
  94929. * @param baseName Name of the effect.
  94930. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  94931. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  94932. * @param samplers List of sampler variables that will be passed to the shader.
  94933. * @param engine Engine to be used to render the effect
  94934. * @param defines Define statements to be added to the shader.
  94935. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  94936. * @param onCompiled Callback that will be called when the shader is compiled.
  94937. * @param onError Callback that will be called if an error occurs during shader compilation.
  94938. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  94939. */
  94940. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  94941. private _useFinalCode;
  94942. /**
  94943. * Unique key for this effect
  94944. */
  94945. readonly key: string;
  94946. /**
  94947. * If the effect has been compiled and prepared.
  94948. * @returns if the effect is compiled and prepared.
  94949. */
  94950. isReady(): boolean;
  94951. private _isReadyInternal;
  94952. /**
  94953. * The engine the effect was initialized with.
  94954. * @returns the engine.
  94955. */
  94956. getEngine(): Engine;
  94957. /**
  94958. * The pipeline context for this effect
  94959. * @returns the associated pipeline context
  94960. */
  94961. getPipelineContext(): Nullable<IPipelineContext>;
  94962. /**
  94963. * The set of names of attribute variables for the shader.
  94964. * @returns An array of attribute names.
  94965. */
  94966. getAttributesNames(): string[];
  94967. /**
  94968. * Returns the attribute at the given index.
  94969. * @param index The index of the attribute.
  94970. * @returns The location of the attribute.
  94971. */
  94972. getAttributeLocation(index: number): number;
  94973. /**
  94974. * Returns the attribute based on the name of the variable.
  94975. * @param name of the attribute to look up.
  94976. * @returns the attribute location.
  94977. */
  94978. getAttributeLocationByName(name: string): number;
  94979. /**
  94980. * The number of attributes.
  94981. * @returns the numnber of attributes.
  94982. */
  94983. getAttributesCount(): number;
  94984. /**
  94985. * Gets the index of a uniform variable.
  94986. * @param uniformName of the uniform to look up.
  94987. * @returns the index.
  94988. */
  94989. getUniformIndex(uniformName: string): number;
  94990. /**
  94991. * Returns the attribute based on the name of the variable.
  94992. * @param uniformName of the uniform to look up.
  94993. * @returns the location of the uniform.
  94994. */
  94995. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  94996. /**
  94997. * Returns an array of sampler variable names
  94998. * @returns The array of sampler variable neames.
  94999. */
  95000. getSamplers(): string[];
  95001. /**
  95002. * The error from the last compilation.
  95003. * @returns the error string.
  95004. */
  95005. getCompilationError(): string;
  95006. /**
  95007. * Gets a boolean indicating that all fallbacks were used during compilation
  95008. * @returns true if all fallbacks were used
  95009. */
  95010. allFallbacksProcessed(): boolean;
  95011. /**
  95012. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95013. * @param func The callback to be used.
  95014. */
  95015. executeWhenCompiled(func: (effect: Effect) => void): void;
  95016. private _checkIsReady;
  95017. private _loadShader;
  95018. /**
  95019. * Recompiles the webGL program
  95020. * @param vertexSourceCode The source code for the vertex shader.
  95021. * @param fragmentSourceCode The source code for the fragment shader.
  95022. * @param onCompiled Callback called when completed.
  95023. * @param onError Callback called on error.
  95024. * @hidden
  95025. */
  95026. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95027. /**
  95028. * Prepares the effect
  95029. * @hidden
  95030. */
  95031. _prepareEffect(): void;
  95032. private _processCompilationErrors;
  95033. /**
  95034. * Checks if the effect is supported. (Must be called after compilation)
  95035. */
  95036. readonly isSupported: boolean;
  95037. /**
  95038. * Binds a texture to the engine to be used as output of the shader.
  95039. * @param channel Name of the output variable.
  95040. * @param texture Texture to bind.
  95041. * @hidden
  95042. */
  95043. _bindTexture(channel: string, texture: InternalTexture): void;
  95044. /**
  95045. * Sets a texture on the engine to be used in the shader.
  95046. * @param channel Name of the sampler variable.
  95047. * @param texture Texture to set.
  95048. */
  95049. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95050. /**
  95051. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95052. * @param channel Name of the sampler variable.
  95053. * @param texture Texture to set.
  95054. */
  95055. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95056. /**
  95057. * Sets an array of textures on the engine to be used in the shader.
  95058. * @param channel Name of the variable.
  95059. * @param textures Textures to set.
  95060. */
  95061. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95062. /**
  95063. * 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)
  95064. * @param channel Name of the sampler variable.
  95065. * @param postProcess Post process to get the input texture from.
  95066. */
  95067. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95068. /**
  95069. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95070. * 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)
  95071. * @param channel Name of the sampler variable.
  95072. * @param postProcess Post process to get the output texture from.
  95073. */
  95074. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95075. /** @hidden */
  95076. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95077. /** @hidden */
  95078. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95079. /** @hidden */
  95080. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95081. /** @hidden */
  95082. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95083. /**
  95084. * Binds a buffer to a uniform.
  95085. * @param buffer Buffer to bind.
  95086. * @param name Name of the uniform variable to bind to.
  95087. */
  95088. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95089. /**
  95090. * Binds block to a uniform.
  95091. * @param blockName Name of the block to bind.
  95092. * @param index Index to bind.
  95093. */
  95094. bindUniformBlock(blockName: string, index: number): void;
  95095. /**
  95096. * Sets an interger value on a uniform variable.
  95097. * @param uniformName Name of the variable.
  95098. * @param value Value to be set.
  95099. * @returns this effect.
  95100. */
  95101. setInt(uniformName: string, value: number): Effect;
  95102. /**
  95103. * Sets an int array on a uniform variable.
  95104. * @param uniformName Name of the variable.
  95105. * @param array array to be set.
  95106. * @returns this effect.
  95107. */
  95108. setIntArray(uniformName: string, array: Int32Array): Effect;
  95109. /**
  95110. * 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)
  95111. * @param uniformName Name of the variable.
  95112. * @param array array to be set.
  95113. * @returns this effect.
  95114. */
  95115. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95116. /**
  95117. * 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)
  95118. * @param uniformName Name of the variable.
  95119. * @param array array to be set.
  95120. * @returns this effect.
  95121. */
  95122. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95123. /**
  95124. * 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)
  95125. * @param uniformName Name of the variable.
  95126. * @param array array to be set.
  95127. * @returns this effect.
  95128. */
  95129. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95130. /**
  95131. * Sets an float array on a uniform variable.
  95132. * @param uniformName Name of the variable.
  95133. * @param array array to be set.
  95134. * @returns this effect.
  95135. */
  95136. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95137. /**
  95138. * 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)
  95139. * @param uniformName Name of the variable.
  95140. * @param array array to be set.
  95141. * @returns this effect.
  95142. */
  95143. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95144. /**
  95145. * 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)
  95146. * @param uniformName Name of the variable.
  95147. * @param array array to be set.
  95148. * @returns this effect.
  95149. */
  95150. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95151. /**
  95152. * 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)
  95153. * @param uniformName Name of the variable.
  95154. * @param array array to be set.
  95155. * @returns this effect.
  95156. */
  95157. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95158. /**
  95159. * Sets an array on a uniform variable.
  95160. * @param uniformName Name of the variable.
  95161. * @param array array to be set.
  95162. * @returns this effect.
  95163. */
  95164. setArray(uniformName: string, array: number[]): Effect;
  95165. /**
  95166. * 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)
  95167. * @param uniformName Name of the variable.
  95168. * @param array array to be set.
  95169. * @returns this effect.
  95170. */
  95171. setArray2(uniformName: string, array: number[]): Effect;
  95172. /**
  95173. * 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)
  95174. * @param uniformName Name of the variable.
  95175. * @param array array to be set.
  95176. * @returns this effect.
  95177. */
  95178. setArray3(uniformName: string, array: number[]): Effect;
  95179. /**
  95180. * 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)
  95181. * @param uniformName Name of the variable.
  95182. * @param array array to be set.
  95183. * @returns this effect.
  95184. */
  95185. setArray4(uniformName: string, array: number[]): Effect;
  95186. /**
  95187. * Sets matrices on a uniform variable.
  95188. * @param uniformName Name of the variable.
  95189. * @param matrices matrices to be set.
  95190. * @returns this effect.
  95191. */
  95192. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95193. /**
  95194. * Sets matrix on a uniform variable.
  95195. * @param uniformName Name of the variable.
  95196. * @param matrix matrix to be set.
  95197. * @returns this effect.
  95198. */
  95199. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95200. /**
  95201. * 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)
  95202. * @param uniformName Name of the variable.
  95203. * @param matrix matrix to be set.
  95204. * @returns this effect.
  95205. */
  95206. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95207. /**
  95208. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95209. * @param uniformName Name of the variable.
  95210. * @param matrix matrix to be set.
  95211. * @returns this effect.
  95212. */
  95213. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95214. /**
  95215. * Sets a float on a uniform variable.
  95216. * @param uniformName Name of the variable.
  95217. * @param value value to be set.
  95218. * @returns this effect.
  95219. */
  95220. setFloat(uniformName: string, value: number): Effect;
  95221. /**
  95222. * Sets a boolean on a uniform variable.
  95223. * @param uniformName Name of the variable.
  95224. * @param bool value to be set.
  95225. * @returns this effect.
  95226. */
  95227. setBool(uniformName: string, bool: boolean): Effect;
  95228. /**
  95229. * Sets a Vector2 on a uniform variable.
  95230. * @param uniformName Name of the variable.
  95231. * @param vector2 vector2 to be set.
  95232. * @returns this effect.
  95233. */
  95234. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95235. /**
  95236. * Sets a float2 on a uniform variable.
  95237. * @param uniformName Name of the variable.
  95238. * @param x First float in float2.
  95239. * @param y Second float in float2.
  95240. * @returns this effect.
  95241. */
  95242. setFloat2(uniformName: string, x: number, y: number): Effect;
  95243. /**
  95244. * Sets a Vector3 on a uniform variable.
  95245. * @param uniformName Name of the variable.
  95246. * @param vector3 Value to be set.
  95247. * @returns this effect.
  95248. */
  95249. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95250. /**
  95251. * Sets a float3 on a uniform variable.
  95252. * @param uniformName Name of the variable.
  95253. * @param x First float in float3.
  95254. * @param y Second float in float3.
  95255. * @param z Third float in float3.
  95256. * @returns this effect.
  95257. */
  95258. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95259. /**
  95260. * Sets a Vector4 on a uniform variable.
  95261. * @param uniformName Name of the variable.
  95262. * @param vector4 Value to be set.
  95263. * @returns this effect.
  95264. */
  95265. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95266. /**
  95267. * Sets a float4 on a uniform variable.
  95268. * @param uniformName Name of the variable.
  95269. * @param x First float in float4.
  95270. * @param y Second float in float4.
  95271. * @param z Third float in float4.
  95272. * @param w Fourth float in float4.
  95273. * @returns this effect.
  95274. */
  95275. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95276. /**
  95277. * Sets a Color3 on a uniform variable.
  95278. * @param uniformName Name of the variable.
  95279. * @param color3 Value to be set.
  95280. * @returns this effect.
  95281. */
  95282. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95283. /**
  95284. * Sets a Color4 on a uniform variable.
  95285. * @param uniformName Name of the variable.
  95286. * @param color3 Value to be set.
  95287. * @param alpha Alpha value to be set.
  95288. * @returns this effect.
  95289. */
  95290. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95291. /**
  95292. * Sets a Color4 on a uniform variable
  95293. * @param uniformName defines the name of the variable
  95294. * @param color4 defines the value to be set
  95295. * @returns this effect.
  95296. */
  95297. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95298. /** Release all associated resources */
  95299. dispose(): void;
  95300. /**
  95301. * This function will add a new shader to the shader store
  95302. * @param name the name of the shader
  95303. * @param pixelShader optional pixel shader content
  95304. * @param vertexShader optional vertex shader content
  95305. */
  95306. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95307. /**
  95308. * Store of each shader (The can be looked up using effect.key)
  95309. */
  95310. static ShadersStore: {
  95311. [key: string]: string;
  95312. };
  95313. /**
  95314. * Store of each included file for a shader (The can be looked up using effect.key)
  95315. */
  95316. static IncludesShadersStore: {
  95317. [key: string]: string;
  95318. };
  95319. /**
  95320. * Resets the cache of effects.
  95321. */
  95322. static ResetCache(): void;
  95323. }
  95324. }
  95325. declare module BABYLON {
  95326. /**
  95327. * Class used to describe the capabilities of the engine relatively to the current browser
  95328. */
  95329. export class EngineCapabilities {
  95330. /** Maximum textures units per fragment shader */
  95331. maxTexturesImageUnits: number;
  95332. /** Maximum texture units per vertex shader */
  95333. maxVertexTextureImageUnits: number;
  95334. /** Maximum textures units in the entire pipeline */
  95335. maxCombinedTexturesImageUnits: number;
  95336. /** Maximum texture size */
  95337. maxTextureSize: number;
  95338. /** Maximum cube texture size */
  95339. maxCubemapTextureSize: number;
  95340. /** Maximum render texture size */
  95341. maxRenderTextureSize: number;
  95342. /** Maximum number of vertex attributes */
  95343. maxVertexAttribs: number;
  95344. /** Maximum number of varyings */
  95345. maxVaryingVectors: number;
  95346. /** Maximum number of uniforms per vertex shader */
  95347. maxVertexUniformVectors: number;
  95348. /** Maximum number of uniforms per fragment shader */
  95349. maxFragmentUniformVectors: number;
  95350. /** Defines if standard derivates (dx/dy) are supported */
  95351. standardDerivatives: boolean;
  95352. /** Defines if s3tc texture compression is supported */
  95353. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95354. /** Defines if pvrtc texture compression is supported */
  95355. pvrtc: any;
  95356. /** Defines if etc1 texture compression is supported */
  95357. etc1: any;
  95358. /** Defines if etc2 texture compression is supported */
  95359. etc2: any;
  95360. /** Defines if astc texture compression is supported */
  95361. astc: any;
  95362. /** Defines if float textures are supported */
  95363. textureFloat: boolean;
  95364. /** Defines if vertex array objects are supported */
  95365. vertexArrayObject: boolean;
  95366. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95367. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95368. /** Gets the maximum level of anisotropy supported */
  95369. maxAnisotropy: number;
  95370. /** Defines if instancing is supported */
  95371. instancedArrays: boolean;
  95372. /** Defines if 32 bits indices are supported */
  95373. uintIndices: boolean;
  95374. /** Defines if high precision shaders are supported */
  95375. highPrecisionShaderSupported: boolean;
  95376. /** Defines if depth reading in the fragment shader is supported */
  95377. fragmentDepthSupported: boolean;
  95378. /** Defines if float texture linear filtering is supported*/
  95379. textureFloatLinearFiltering: boolean;
  95380. /** Defines if rendering to float textures is supported */
  95381. textureFloatRender: boolean;
  95382. /** Defines if half float textures are supported*/
  95383. textureHalfFloat: boolean;
  95384. /** Defines if half float texture linear filtering is supported*/
  95385. textureHalfFloatLinearFiltering: boolean;
  95386. /** Defines if rendering to half float textures is supported */
  95387. textureHalfFloatRender: boolean;
  95388. /** Defines if textureLOD shader command is supported */
  95389. textureLOD: boolean;
  95390. /** Defines if draw buffers extension is supported */
  95391. drawBuffersExtension: boolean;
  95392. /** Defines if depth textures are supported */
  95393. depthTextureExtension: boolean;
  95394. /** Defines if float color buffer are supported */
  95395. colorBufferFloat: boolean;
  95396. /** Gets disjoint timer query extension (null if not supported) */
  95397. timerQuery: EXT_disjoint_timer_query;
  95398. /** Defines if timestamp can be used with timer query */
  95399. canUseTimestampForTimerQuery: boolean;
  95400. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95401. multiview: any;
  95402. /** Function used to let the system compiles shaders in background */
  95403. parallelShaderCompile: {
  95404. COMPLETION_STATUS_KHR: number;
  95405. };
  95406. /** Max number of texture samples for MSAA */
  95407. maxMSAASamples: number;
  95408. /** Defines if the blend min max extension is supported */
  95409. blendMinMax: boolean;
  95410. }
  95411. }
  95412. declare module BABYLON {
  95413. /**
  95414. * @hidden
  95415. **/
  95416. export class DepthCullingState {
  95417. private _isDepthTestDirty;
  95418. private _isDepthMaskDirty;
  95419. private _isDepthFuncDirty;
  95420. private _isCullFaceDirty;
  95421. private _isCullDirty;
  95422. private _isZOffsetDirty;
  95423. private _isFrontFaceDirty;
  95424. private _depthTest;
  95425. private _depthMask;
  95426. private _depthFunc;
  95427. private _cull;
  95428. private _cullFace;
  95429. private _zOffset;
  95430. private _frontFace;
  95431. /**
  95432. * Initializes the state.
  95433. */
  95434. constructor();
  95435. readonly isDirty: boolean;
  95436. zOffset: number;
  95437. cullFace: Nullable<number>;
  95438. cull: Nullable<boolean>;
  95439. depthFunc: Nullable<number>;
  95440. depthMask: boolean;
  95441. depthTest: boolean;
  95442. frontFace: Nullable<number>;
  95443. reset(): void;
  95444. apply(gl: WebGLRenderingContext): void;
  95445. }
  95446. }
  95447. declare module BABYLON {
  95448. /**
  95449. * @hidden
  95450. **/
  95451. export class StencilState {
  95452. /** 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 */
  95453. static readonly ALWAYS: number;
  95454. /** Passed to stencilOperation to specify that stencil value must be kept */
  95455. static readonly KEEP: number;
  95456. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95457. static readonly REPLACE: number;
  95458. private _isStencilTestDirty;
  95459. private _isStencilMaskDirty;
  95460. private _isStencilFuncDirty;
  95461. private _isStencilOpDirty;
  95462. private _stencilTest;
  95463. private _stencilMask;
  95464. private _stencilFunc;
  95465. private _stencilFuncRef;
  95466. private _stencilFuncMask;
  95467. private _stencilOpStencilFail;
  95468. private _stencilOpDepthFail;
  95469. private _stencilOpStencilDepthPass;
  95470. readonly isDirty: boolean;
  95471. stencilFunc: number;
  95472. stencilFuncRef: number;
  95473. stencilFuncMask: number;
  95474. stencilOpStencilFail: number;
  95475. stencilOpDepthFail: number;
  95476. stencilOpStencilDepthPass: number;
  95477. stencilMask: number;
  95478. stencilTest: boolean;
  95479. constructor();
  95480. reset(): void;
  95481. apply(gl: WebGLRenderingContext): void;
  95482. }
  95483. }
  95484. declare module BABYLON {
  95485. /**
  95486. * @hidden
  95487. **/
  95488. export class AlphaState {
  95489. private _isAlphaBlendDirty;
  95490. private _isBlendFunctionParametersDirty;
  95491. private _isBlendEquationParametersDirty;
  95492. private _isBlendConstantsDirty;
  95493. private _alphaBlend;
  95494. private _blendFunctionParameters;
  95495. private _blendEquationParameters;
  95496. private _blendConstants;
  95497. /**
  95498. * Initializes the state.
  95499. */
  95500. constructor();
  95501. readonly isDirty: boolean;
  95502. alphaBlend: boolean;
  95503. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95504. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95505. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95506. reset(): void;
  95507. apply(gl: WebGLRenderingContext): void;
  95508. }
  95509. }
  95510. declare module BABYLON {
  95511. /** @hidden */
  95512. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95513. attributeProcessor(attribute: string): string;
  95514. varyingProcessor(varying: string, isFragment: boolean): string;
  95515. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95516. }
  95517. }
  95518. declare module BABYLON {
  95519. /**
  95520. * Interface for attribute information associated with buffer instanciation
  95521. */
  95522. export class InstancingAttributeInfo {
  95523. /**
  95524. * Index/offset of the attribute in the vertex shader
  95525. */
  95526. index: number;
  95527. /**
  95528. * size of the attribute, 1, 2, 3 or 4
  95529. */
  95530. attributeSize: number;
  95531. /**
  95532. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95533. * default is FLOAT
  95534. */
  95535. attribyteType: number;
  95536. /**
  95537. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95538. */
  95539. normalized: boolean;
  95540. /**
  95541. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95542. */
  95543. offset: number;
  95544. /**
  95545. * Name of the GLSL attribute, for debugging purpose only
  95546. */
  95547. attributeName: string;
  95548. }
  95549. }
  95550. declare module BABYLON {
  95551. interface ThinEngine {
  95552. /**
  95553. * Update a video texture
  95554. * @param texture defines the texture to update
  95555. * @param video defines the video element to use
  95556. * @param invertY defines if data must be stored with Y axis inverted
  95557. */
  95558. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95559. }
  95560. }
  95561. declare module BABYLON {
  95562. /**
  95563. * Settings for finer control over video usage
  95564. */
  95565. export interface VideoTextureSettings {
  95566. /**
  95567. * Applies `autoplay` to video, if specified
  95568. */
  95569. autoPlay?: boolean;
  95570. /**
  95571. * Applies `loop` to video, if specified
  95572. */
  95573. loop?: boolean;
  95574. /**
  95575. * Automatically updates internal texture from video at every frame in the render loop
  95576. */
  95577. autoUpdateTexture: boolean;
  95578. /**
  95579. * Image src displayed during the video loading or until the user interacts with the video.
  95580. */
  95581. poster?: string;
  95582. }
  95583. /**
  95584. * If you want to display a video in your scene, this is the special texture for that.
  95585. * This special texture works similar to other textures, with the exception of a few parameters.
  95586. * @see https://doc.babylonjs.com/how_to/video_texture
  95587. */
  95588. export class VideoTexture extends Texture {
  95589. /**
  95590. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95591. */
  95592. readonly autoUpdateTexture: boolean;
  95593. /**
  95594. * The video instance used by the texture internally
  95595. */
  95596. readonly video: HTMLVideoElement;
  95597. private _onUserActionRequestedObservable;
  95598. /**
  95599. * Event triggerd when a dom action is required by the user to play the video.
  95600. * This happens due to recent changes in browser policies preventing video to auto start.
  95601. */
  95602. readonly onUserActionRequestedObservable: Observable<Texture>;
  95603. private _generateMipMaps;
  95604. private _engine;
  95605. private _stillImageCaptured;
  95606. private _displayingPosterTexture;
  95607. private _settings;
  95608. private _createInternalTextureOnEvent;
  95609. private _frameId;
  95610. /**
  95611. * Creates a video texture.
  95612. * If you want to display a video in your scene, this is the special texture for that.
  95613. * This special texture works similar to other textures, with the exception of a few parameters.
  95614. * @see https://doc.babylonjs.com/how_to/video_texture
  95615. * @param name optional name, will detect from video source, if not defined
  95616. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95617. * @param scene is obviously the current scene.
  95618. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95619. * @param invertY is false by default but can be used to invert video on Y axis
  95620. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95621. * @param settings allows finer control over video usage
  95622. */
  95623. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95624. private _getName;
  95625. private _getVideo;
  95626. private _createInternalTexture;
  95627. private reset;
  95628. /**
  95629. * @hidden Internal method to initiate `update`.
  95630. */
  95631. _rebuild(): void;
  95632. /**
  95633. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95634. */
  95635. update(): void;
  95636. /**
  95637. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95638. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95639. */
  95640. updateTexture(isVisible: boolean): void;
  95641. protected _updateInternalTexture: () => void;
  95642. /**
  95643. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95644. * @param url New url.
  95645. */
  95646. updateURL(url: string): void;
  95647. /**
  95648. * Dispose the texture and release its associated resources.
  95649. */
  95650. dispose(): void;
  95651. /**
  95652. * Creates a video texture straight from a stream.
  95653. * @param scene Define the scene the texture should be created in
  95654. * @param stream Define the stream the texture should be created from
  95655. * @returns The created video texture as a promise
  95656. */
  95657. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95658. /**
  95659. * Creates a video texture straight from your WebCam video feed.
  95660. * @param scene Define the scene the texture should be created in
  95661. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95662. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95663. * @returns The created video texture as a promise
  95664. */
  95665. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95666. minWidth: number;
  95667. maxWidth: number;
  95668. minHeight: number;
  95669. maxHeight: number;
  95670. deviceId: string;
  95671. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95672. /**
  95673. * Creates a video texture straight from your WebCam video feed.
  95674. * @param scene Define the scene the texture should be created in
  95675. * @param onReady Define a callback to triggered once the texture will be ready
  95676. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95677. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95678. */
  95679. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95680. minWidth: number;
  95681. maxWidth: number;
  95682. minHeight: number;
  95683. maxHeight: number;
  95684. deviceId: string;
  95685. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95686. }
  95687. }
  95688. declare module BABYLON {
  95689. /**
  95690. * Defines the interface used by objects working like Scene
  95691. * @hidden
  95692. */
  95693. interface ISceneLike {
  95694. _addPendingData(data: any): void;
  95695. _removePendingData(data: any): void;
  95696. offlineProvider: IOfflineProvider;
  95697. }
  95698. /** Interface defining initialization parameters for Engine class */
  95699. export interface EngineOptions extends WebGLContextAttributes {
  95700. /**
  95701. * Defines if the engine should no exceed a specified device ratio
  95702. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95703. */
  95704. limitDeviceRatio?: number;
  95705. /**
  95706. * Defines if webvr should be enabled automatically
  95707. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95708. */
  95709. autoEnableWebVR?: boolean;
  95710. /**
  95711. * Defines if webgl2 should be turned off even if supported
  95712. * @see http://doc.babylonjs.com/features/webgl2
  95713. */
  95714. disableWebGL2Support?: boolean;
  95715. /**
  95716. * Defines if webaudio should be initialized as well
  95717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95718. */
  95719. audioEngine?: boolean;
  95720. /**
  95721. * Defines if animations should run using a deterministic lock step
  95722. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95723. */
  95724. deterministicLockstep?: boolean;
  95725. /** Defines the maximum steps to use with deterministic lock step mode */
  95726. lockstepMaxSteps?: number;
  95727. /**
  95728. * Defines that engine should ignore context lost events
  95729. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95730. */
  95731. doNotHandleContextLost?: boolean;
  95732. /**
  95733. * Defines that engine should ignore modifying touch action attribute and style
  95734. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95735. */
  95736. doNotHandleTouchAction?: boolean;
  95737. /**
  95738. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95739. */
  95740. useHighPrecisionFloats?: boolean;
  95741. }
  95742. /**
  95743. * The base engine class (root of all engines)
  95744. */
  95745. export class ThinEngine {
  95746. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95747. static ExceptionList: ({
  95748. key: string;
  95749. capture: string;
  95750. captureConstraint: number;
  95751. targets: string[];
  95752. } | {
  95753. key: string;
  95754. capture: null;
  95755. captureConstraint: null;
  95756. targets: string[];
  95757. })[];
  95758. /** @hidden */
  95759. static _TextureLoaders: IInternalTextureLoader[];
  95760. /**
  95761. * Returns the current npm package of the sdk
  95762. */
  95763. static readonly NpmPackage: string;
  95764. /**
  95765. * Returns the current version of the framework
  95766. */
  95767. static readonly Version: string;
  95768. /**
  95769. * Returns a string describing the current engine
  95770. */
  95771. readonly description: string;
  95772. /**
  95773. * Gets or sets the epsilon value used by collision engine
  95774. */
  95775. static CollisionsEpsilon: number;
  95776. /**
  95777. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95778. */
  95779. static ShadersRepository: string;
  95780. /** @hidden */
  95781. _shaderProcessor: IShaderProcessor;
  95782. /**
  95783. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95784. */
  95785. forcePOTTextures: boolean;
  95786. /**
  95787. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95788. */
  95789. isFullscreen: boolean;
  95790. /**
  95791. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95792. */
  95793. cullBackFaces: boolean;
  95794. /**
  95795. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95796. */
  95797. renderEvenInBackground: boolean;
  95798. /**
  95799. * Gets or sets a boolean indicating that cache can be kept between frames
  95800. */
  95801. preventCacheWipeBetweenFrames: boolean;
  95802. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95803. validateShaderPrograms: boolean;
  95804. /**
  95805. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  95806. */
  95807. disableUniformBuffers: boolean;
  95808. /** @hidden */
  95809. _uniformBuffers: UniformBuffer[];
  95810. /**
  95811. * Gets a boolean indicating that the engine supports uniform buffers
  95812. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  95813. */
  95814. readonly supportsUniformBuffers: boolean;
  95815. /** @hidden */
  95816. _gl: WebGLRenderingContext;
  95817. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  95818. protected _windowIsBackground: boolean;
  95819. protected _webGLVersion: number;
  95820. protected _highPrecisionShadersAllowed: boolean;
  95821. /** @hidden */
  95822. readonly _shouldUseHighPrecisionShader: boolean;
  95823. /**
  95824. * Gets a boolean indicating that only power of 2 textures are supported
  95825. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  95826. */
  95827. readonly needPOTTextures: boolean;
  95828. /** @hidden */
  95829. _badOS: boolean;
  95830. /** @hidden */
  95831. _badDesktopOS: boolean;
  95832. private _hardwareScalingLevel;
  95833. /** @hidden */
  95834. _caps: EngineCapabilities;
  95835. private _isStencilEnable;
  95836. protected _colorWrite: boolean;
  95837. private _glVersion;
  95838. private _glRenderer;
  95839. private _glVendor;
  95840. /** @hidden */
  95841. _videoTextureSupported: boolean;
  95842. protected _renderingQueueLaunched: boolean;
  95843. protected _activeRenderLoops: (() => void)[];
  95844. /**
  95845. * Observable signaled when a context lost event is raised
  95846. */
  95847. onContextLostObservable: Observable<ThinEngine>;
  95848. /**
  95849. * Observable signaled when a context restored event is raised
  95850. */
  95851. onContextRestoredObservable: Observable<ThinEngine>;
  95852. private _onContextLost;
  95853. private _onContextRestored;
  95854. protected _contextWasLost: boolean;
  95855. /** @hidden */
  95856. _doNotHandleContextLost: boolean;
  95857. /**
  95858. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  95859. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  95860. */
  95861. doNotHandleContextLost: boolean;
  95862. /**
  95863. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  95864. */
  95865. disableVertexArrayObjects: boolean;
  95866. /** @hidden */
  95867. protected _depthCullingState: DepthCullingState;
  95868. /** @hidden */
  95869. protected _stencilState: StencilState;
  95870. /** @hidden */
  95871. protected _alphaState: AlphaState;
  95872. /** @hidden */
  95873. _internalTexturesCache: InternalTexture[];
  95874. /** @hidden */
  95875. protected _activeChannel: number;
  95876. private _currentTextureChannel;
  95877. /** @hidden */
  95878. protected _boundTexturesCache: {
  95879. [key: string]: Nullable<InternalTexture>;
  95880. };
  95881. /** @hidden */
  95882. protected _currentEffect: Nullable<Effect>;
  95883. /** @hidden */
  95884. protected _currentProgram: Nullable<WebGLProgram>;
  95885. private _compiledEffects;
  95886. private _vertexAttribArraysEnabled;
  95887. /** @hidden */
  95888. protected _cachedViewport: Nullable<IViewportLike>;
  95889. private _cachedVertexArrayObject;
  95890. /** @hidden */
  95891. protected _cachedVertexBuffers: any;
  95892. /** @hidden */
  95893. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  95894. /** @hidden */
  95895. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  95896. /** @hidden */
  95897. _currentRenderTarget: Nullable<InternalTexture>;
  95898. private _uintIndicesCurrentlySet;
  95899. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  95900. /** @hidden */
  95901. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  95902. private _currentBufferPointers;
  95903. private _currentInstanceLocations;
  95904. private _currentInstanceBuffers;
  95905. private _textureUnits;
  95906. /** @hidden */
  95907. _workingCanvas: Nullable<HTMLCanvasElement>;
  95908. /** @hidden */
  95909. _workingContext: Nullable<CanvasRenderingContext2D>;
  95910. /** @hidden */
  95911. _bindedRenderFunction: any;
  95912. private _vaoRecordInProgress;
  95913. private _mustWipeVertexAttributes;
  95914. private _emptyTexture;
  95915. private _emptyCubeTexture;
  95916. private _emptyTexture3D;
  95917. /** @hidden */
  95918. _frameHandler: number;
  95919. private _nextFreeTextureSlots;
  95920. private _maxSimultaneousTextures;
  95921. private _activeRequests;
  95922. protected _texturesSupported: string[];
  95923. /** @hidden */
  95924. _textureFormatInUse: Nullable<string>;
  95925. protected readonly _supportsHardwareTextureRescaling: boolean;
  95926. /**
  95927. * Gets the list of texture formats supported
  95928. */
  95929. readonly texturesSupported: Array<string>;
  95930. /**
  95931. * Gets the list of texture formats in use
  95932. */
  95933. readonly textureFormatInUse: Nullable<string>;
  95934. /**
  95935. * Gets the current viewport
  95936. */
  95937. readonly currentViewport: Nullable<IViewportLike>;
  95938. /**
  95939. * Gets the default empty texture
  95940. */
  95941. readonly emptyTexture: InternalTexture;
  95942. /**
  95943. * Gets the default empty 3D texture
  95944. */
  95945. readonly emptyTexture3D: InternalTexture;
  95946. /**
  95947. * Gets the default empty cube texture
  95948. */
  95949. readonly emptyCubeTexture: InternalTexture;
  95950. /**
  95951. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  95952. */
  95953. readonly premultipliedAlpha: boolean;
  95954. /**
  95955. * Observable event triggered before each texture is initialized
  95956. */
  95957. onBeforeTextureInitObservable: Observable<Texture>;
  95958. /**
  95959. * Creates a new engine
  95960. * @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
  95961. * @param antialias defines enable antialiasing (default: false)
  95962. * @param options defines further options to be sent to the getContext() function
  95963. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  95964. */
  95965. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  95966. private _rebuildInternalTextures;
  95967. private _rebuildEffects;
  95968. /**
  95969. * Gets a boolean indicating if all created effects are ready
  95970. * @returns true if all effects are ready
  95971. */
  95972. areAllEffectsReady(): boolean;
  95973. protected _rebuildBuffers(): void;
  95974. private _initGLContext;
  95975. /**
  95976. * Gets version of the current webGL context
  95977. */
  95978. readonly webGLVersion: number;
  95979. /**
  95980. * Gets a string idenfifying the name of the class
  95981. * @returns "Engine" string
  95982. */
  95983. getClassName(): string;
  95984. /**
  95985. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  95986. */
  95987. readonly isStencilEnable: boolean;
  95988. /** @hidden */
  95989. _prepareWorkingCanvas(): void;
  95990. /**
  95991. * Reset the texture cache to empty state
  95992. */
  95993. resetTextureCache(): void;
  95994. /**
  95995. * Gets an object containing information about the current webGL context
  95996. * @returns an object containing the vender, the renderer and the version of the current webGL context
  95997. */
  95998. getGlInfo(): {
  95999. vendor: string;
  96000. renderer: string;
  96001. version: string;
  96002. };
  96003. /**
  96004. * Defines the hardware scaling level.
  96005. * By default the hardware scaling level is computed from the window device ratio.
  96006. * 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.
  96007. * @param level defines the level to use
  96008. */
  96009. setHardwareScalingLevel(level: number): void;
  96010. /**
  96011. * Gets the current hardware scaling level.
  96012. * By default the hardware scaling level is computed from the window device ratio.
  96013. * 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.
  96014. * @returns a number indicating the current hardware scaling level
  96015. */
  96016. getHardwareScalingLevel(): number;
  96017. /**
  96018. * Gets the list of loaded textures
  96019. * @returns an array containing all loaded textures
  96020. */
  96021. getLoadedTexturesCache(): InternalTexture[];
  96022. /**
  96023. * Gets the object containing all engine capabilities
  96024. * @returns the EngineCapabilities object
  96025. */
  96026. getCaps(): EngineCapabilities;
  96027. /**
  96028. * stop executing a render loop function and remove it from the execution array
  96029. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96030. */
  96031. stopRenderLoop(renderFunction?: () => void): void;
  96032. /** @hidden */
  96033. _renderLoop(): void;
  96034. /**
  96035. * Gets the HTML canvas attached with the current webGL context
  96036. * @returns a HTML canvas
  96037. */
  96038. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96039. /**
  96040. * Gets host window
  96041. * @returns the host window object
  96042. */
  96043. getHostWindow(): Window;
  96044. /**
  96045. * Gets the current render width
  96046. * @param useScreen defines if screen size must be used (or the current render target if any)
  96047. * @returns a number defining the current render width
  96048. */
  96049. getRenderWidth(useScreen?: boolean): number;
  96050. /**
  96051. * Gets the current render height
  96052. * @param useScreen defines if screen size must be used (or the current render target if any)
  96053. * @returns a number defining the current render height
  96054. */
  96055. getRenderHeight(useScreen?: boolean): number;
  96056. /**
  96057. * Can be used to override the current requestAnimationFrame requester.
  96058. * @hidden
  96059. */
  96060. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96061. /**
  96062. * Register and execute a render loop. The engine can have more than one render function
  96063. * @param renderFunction defines the function to continuously execute
  96064. */
  96065. runRenderLoop(renderFunction: () => void): void;
  96066. /**
  96067. * Clear the current render buffer or the current render target (if any is set up)
  96068. * @param color defines the color to use
  96069. * @param backBuffer defines if the back buffer must be cleared
  96070. * @param depth defines if the depth buffer must be cleared
  96071. * @param stencil defines if the stencil buffer must be cleared
  96072. */
  96073. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96074. private _viewportCached;
  96075. /** @hidden */
  96076. _viewport(x: number, y: number, width: number, height: number): void;
  96077. /**
  96078. * Set the WebGL's viewport
  96079. * @param viewport defines the viewport element to be used
  96080. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96081. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96082. */
  96083. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96084. /**
  96085. * Begin a new frame
  96086. */
  96087. beginFrame(): void;
  96088. /**
  96089. * Enf the current frame
  96090. */
  96091. endFrame(): void;
  96092. /**
  96093. * Resize the view according to the canvas' size
  96094. */
  96095. resize(): void;
  96096. /**
  96097. * Force a specific size of the canvas
  96098. * @param width defines the new canvas' width
  96099. * @param height defines the new canvas' height
  96100. */
  96101. setSize(width: number, height: number): void;
  96102. /**
  96103. * Binds the frame buffer to the specified texture.
  96104. * @param texture The texture to render to or null for the default canvas
  96105. * @param faceIndex The face of the texture to render to in case of cube texture
  96106. * @param requiredWidth The width of the target to render to
  96107. * @param requiredHeight The height of the target to render to
  96108. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96109. * @param depthStencilTexture The depth stencil texture to use to render
  96110. * @param lodLevel defines le lod level to bind to the frame buffer
  96111. */
  96112. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96113. /** @hidden */
  96114. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96115. /**
  96116. * Unbind the current render target texture from the webGL context
  96117. * @param texture defines the render target texture to unbind
  96118. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96119. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96120. */
  96121. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96122. /**
  96123. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96124. */
  96125. flushFramebuffer(): void;
  96126. /**
  96127. * Unbind the current render target and bind the default framebuffer
  96128. */
  96129. restoreDefaultFramebuffer(): void;
  96130. private _resetVertexBufferBinding;
  96131. /**
  96132. * Creates a vertex buffer
  96133. * @param data the data for the vertex buffer
  96134. * @returns the new WebGL static buffer
  96135. */
  96136. createVertexBuffer(data: DataArray): DataBuffer;
  96137. private _createVertexBuffer;
  96138. /**
  96139. * Creates a dynamic vertex buffer
  96140. * @param data the data for the dynamic vertex buffer
  96141. * @returns the new WebGL dynamic buffer
  96142. */
  96143. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96144. /**
  96145. * Updates a dynamic vertex buffer.
  96146. * @param vertexBuffer the vertex buffer to update
  96147. * @param data the data used to update the vertex buffer
  96148. * @param byteOffset the byte offset of the data
  96149. * @param byteLength the byte length of the data
  96150. */
  96151. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96152. protected _resetIndexBufferBinding(): void;
  96153. /**
  96154. * Creates a new index buffer
  96155. * @param indices defines the content of the index buffer
  96156. * @param updatable defines if the index buffer must be updatable
  96157. * @returns a new webGL buffer
  96158. */
  96159. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96160. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96161. /**
  96162. * Bind a webGL buffer to the webGL context
  96163. * @param buffer defines the buffer to bind
  96164. */
  96165. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96166. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96167. private bindBuffer;
  96168. /**
  96169. * update the bound buffer with the given data
  96170. * @param data defines the data to update
  96171. */
  96172. updateArrayBuffer(data: Float32Array): void;
  96173. private _vertexAttribPointer;
  96174. private _bindIndexBufferWithCache;
  96175. private _bindVertexBuffersAttributes;
  96176. /**
  96177. * Records a vertex array object
  96178. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96179. * @param vertexBuffers defines the list of vertex buffers to store
  96180. * @param indexBuffer defines the index buffer to store
  96181. * @param effect defines the effect to store
  96182. * @returns the new vertex array object
  96183. */
  96184. recordVertexArrayObject(vertexBuffers: {
  96185. [key: string]: VertexBuffer;
  96186. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96187. /**
  96188. * Bind a specific vertex array object
  96189. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96190. * @param vertexArrayObject defines the vertex array object to bind
  96191. * @param indexBuffer defines the index buffer to bind
  96192. */
  96193. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96194. /**
  96195. * Bind webGl buffers directly to the webGL context
  96196. * @param vertexBuffer defines the vertex buffer to bind
  96197. * @param indexBuffer defines the index buffer to bind
  96198. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96199. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96200. * @param effect defines the effect associated with the vertex buffer
  96201. */
  96202. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96203. private _unbindVertexArrayObject;
  96204. /**
  96205. * Bind a list of vertex buffers to the webGL context
  96206. * @param vertexBuffers defines the list of vertex buffers to bind
  96207. * @param indexBuffer defines the index buffer to bind
  96208. * @param effect defines the effect associated with the vertex buffers
  96209. */
  96210. bindBuffers(vertexBuffers: {
  96211. [key: string]: Nullable<VertexBuffer>;
  96212. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96213. /**
  96214. * Unbind all instance attributes
  96215. */
  96216. unbindInstanceAttributes(): void;
  96217. /**
  96218. * Release and free the memory of a vertex array object
  96219. * @param vao defines the vertex array object to delete
  96220. */
  96221. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96222. /** @hidden */
  96223. _releaseBuffer(buffer: DataBuffer): boolean;
  96224. protected _deleteBuffer(buffer: DataBuffer): void;
  96225. /**
  96226. * Creates a webGL buffer to use with instanciation
  96227. * @param capacity defines the size of the buffer
  96228. * @returns the webGL buffer
  96229. */
  96230. createInstancesBuffer(capacity: number): DataBuffer;
  96231. /**
  96232. * Delete a webGL buffer used with instanciation
  96233. * @param buffer defines the webGL buffer to delete
  96234. */
  96235. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96236. /**
  96237. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96238. * @param instancesBuffer defines the webGL buffer to update and bind
  96239. * @param data defines the data to store in the buffer
  96240. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96241. */
  96242. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96243. /**
  96244. * Apply all cached states (depth, culling, stencil and alpha)
  96245. */
  96246. applyStates(): void;
  96247. /**
  96248. * Send a draw order
  96249. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96250. * @param indexStart defines the starting index
  96251. * @param indexCount defines the number of index to draw
  96252. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96253. */
  96254. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96255. /**
  96256. * Draw a list of points
  96257. * @param verticesStart defines the index of first vertex to draw
  96258. * @param verticesCount defines the count of vertices to draw
  96259. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96260. */
  96261. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96262. /**
  96263. * Draw a list of unindexed primitives
  96264. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96265. * @param verticesStart defines the index of first vertex to draw
  96266. * @param verticesCount defines the count of vertices to draw
  96267. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96268. */
  96269. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96270. /**
  96271. * Draw a list of indexed primitives
  96272. * @param fillMode defines the primitive to use
  96273. * @param indexStart defines the starting index
  96274. * @param indexCount defines the number of index to draw
  96275. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96276. */
  96277. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96278. /**
  96279. * Draw a list of unindexed primitives
  96280. * @param fillMode defines the primitive to use
  96281. * @param verticesStart defines the index of first vertex to draw
  96282. * @param verticesCount defines the count of vertices to draw
  96283. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96284. */
  96285. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96286. private _drawMode;
  96287. /** @hidden */
  96288. protected _reportDrawCall(): void;
  96289. /** @hidden */
  96290. _releaseEffect(effect: Effect): void;
  96291. /** @hidden */
  96292. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96293. /**
  96294. * Create a new effect (used to store vertex/fragment shaders)
  96295. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96296. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  96297. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96298. * @param samplers defines an array of string used to represent textures
  96299. * @param defines defines the string containing the defines to use to compile the shaders
  96300. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96301. * @param onCompiled defines a function to call when the effect creation is successful
  96302. * @param onError defines a function to call when the effect creation has failed
  96303. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96304. * @returns the new Effect
  96305. */
  96306. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96307. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96308. private _compileShader;
  96309. private _compileRawShader;
  96310. /**
  96311. * Directly creates a webGL program
  96312. * @param pipelineContext defines the pipeline context to attach to
  96313. * @param vertexCode defines the vertex shader code to use
  96314. * @param fragmentCode defines the fragment shader code to use
  96315. * @param context defines the webGL context to use (if not set, the current one will be used)
  96316. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96317. * @returns the new webGL program
  96318. */
  96319. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96320. /**
  96321. * Creates a webGL program
  96322. * @param pipelineContext defines the pipeline context to attach to
  96323. * @param vertexCode defines the vertex shader code to use
  96324. * @param fragmentCode defines the fragment shader code to use
  96325. * @param defines defines the string containing the defines to use to compile the shaders
  96326. * @param context defines the webGL context to use (if not set, the current one will be used)
  96327. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96328. * @returns the new webGL program
  96329. */
  96330. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96331. /**
  96332. * Creates a new pipeline context
  96333. * @returns the new pipeline
  96334. */
  96335. createPipelineContext(): IPipelineContext;
  96336. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96337. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96338. /** @hidden */
  96339. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96340. /** @hidden */
  96341. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96342. /** @hidden */
  96343. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96344. /**
  96345. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96346. * @param pipelineContext defines the pipeline context to use
  96347. * @param uniformsNames defines the list of uniform names
  96348. * @returns an array of webGL uniform locations
  96349. */
  96350. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96351. /**
  96352. * Gets the lsit of active attributes for a given webGL program
  96353. * @param pipelineContext defines the pipeline context to use
  96354. * @param attributesNames defines the list of attribute names to get
  96355. * @returns an array of indices indicating the offset of each attribute
  96356. */
  96357. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96358. /**
  96359. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96360. * @param effect defines the effect to activate
  96361. */
  96362. enableEffect(effect: Nullable<Effect>): void;
  96363. /**
  96364. * Set the value of an uniform to an array of int32
  96365. * @param uniform defines the webGL uniform location where to store the value
  96366. * @param array defines the array of int32 to store
  96367. */
  96368. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96369. /**
  96370. * Set the value of an uniform to an array of int32 (stored as vec2)
  96371. * @param uniform defines the webGL uniform location where to store the value
  96372. * @param array defines the array of int32 to store
  96373. */
  96374. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96375. /**
  96376. * Set the value of an uniform to an array of int32 (stored as vec3)
  96377. * @param uniform defines the webGL uniform location where to store the value
  96378. * @param array defines the array of int32 to store
  96379. */
  96380. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96381. /**
  96382. * Set the value of an uniform to an array of int32 (stored as vec4)
  96383. * @param uniform defines the webGL uniform location where to store the value
  96384. * @param array defines the array of int32 to store
  96385. */
  96386. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96387. /**
  96388. * Set the value of an uniform to an array of float32
  96389. * @param uniform defines the webGL uniform location where to store the value
  96390. * @param array defines the array of float32 to store
  96391. */
  96392. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96393. /**
  96394. * Set the value of an uniform to an array of float32 (stored as vec2)
  96395. * @param uniform defines the webGL uniform location where to store the value
  96396. * @param array defines the array of float32 to store
  96397. */
  96398. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96399. /**
  96400. * Set the value of an uniform to an array of float32 (stored as vec3)
  96401. * @param uniform defines the webGL uniform location where to store the value
  96402. * @param array defines the array of float32 to store
  96403. */
  96404. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96405. /**
  96406. * Set the value of an uniform to an array of float32 (stored as vec4)
  96407. * @param uniform defines the webGL uniform location where to store the value
  96408. * @param array defines the array of float32 to store
  96409. */
  96410. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96411. /**
  96412. * Set the value of an uniform to an array of number
  96413. * @param uniform defines the webGL uniform location where to store the value
  96414. * @param array defines the array of number to store
  96415. */
  96416. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96417. /**
  96418. * Set the value of an uniform to an array of number (stored as vec2)
  96419. * @param uniform defines the webGL uniform location where to store the value
  96420. * @param array defines the array of number to store
  96421. */
  96422. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96423. /**
  96424. * Set the value of an uniform to an array of number (stored as vec3)
  96425. * @param uniform defines the webGL uniform location where to store the value
  96426. * @param array defines the array of number to store
  96427. */
  96428. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96429. /**
  96430. * Set the value of an uniform to an array of number (stored as vec4)
  96431. * @param uniform defines the webGL uniform location where to store the value
  96432. * @param array defines the array of number to store
  96433. */
  96434. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96435. /**
  96436. * Set the value of an uniform to an array of float32 (stored as matrices)
  96437. * @param uniform defines the webGL uniform location where to store the value
  96438. * @param matrices defines the array of float32 to store
  96439. */
  96440. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96441. /**
  96442. * Set the value of an uniform to a matrix (3x3)
  96443. * @param uniform defines the webGL uniform location where to store the value
  96444. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96445. */
  96446. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96447. /**
  96448. * Set the value of an uniform to a matrix (2x2)
  96449. * @param uniform defines the webGL uniform location where to store the value
  96450. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96451. */
  96452. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96453. /**
  96454. * Set the value of an uniform to a number (int)
  96455. * @param uniform defines the webGL uniform location where to store the value
  96456. * @param value defines the int number to store
  96457. */
  96458. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96459. /**
  96460. * Set the value of an uniform to a number (float)
  96461. * @param uniform defines the webGL uniform location where to store the value
  96462. * @param value defines the float number to store
  96463. */
  96464. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96465. /**
  96466. * Set the value of an uniform to a vec2
  96467. * @param uniform defines the webGL uniform location where to store the value
  96468. * @param x defines the 1st component of the value
  96469. * @param y defines the 2nd component of the value
  96470. */
  96471. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96472. /**
  96473. * Set the value of an uniform to a vec3
  96474. * @param uniform defines the webGL uniform location where to store the value
  96475. * @param x defines the 1st component of the value
  96476. * @param y defines the 2nd component of the value
  96477. * @param z defines the 3rd component of the value
  96478. */
  96479. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96480. /**
  96481. * Set the value of an uniform to a boolean
  96482. * @param uniform defines the webGL uniform location where to store the value
  96483. * @param bool defines the boolean to store
  96484. */
  96485. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96486. /**
  96487. * Set the value of an uniform to a vec4
  96488. * @param uniform defines the webGL uniform location where to store the value
  96489. * @param x defines the 1st component of the value
  96490. * @param y defines the 2nd component of the value
  96491. * @param z defines the 3rd component of the value
  96492. * @param w defines the 4th component of the value
  96493. */
  96494. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96495. /**
  96496. * Sets a Color4 on a uniform variable
  96497. * @param uniform defines the uniform location
  96498. * @param color4 defines the value to be set
  96499. */
  96500. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96501. /**
  96502. * Gets the depth culling state manager
  96503. */
  96504. readonly depthCullingState: DepthCullingState;
  96505. /**
  96506. * Gets the alpha state manager
  96507. */
  96508. readonly alphaState: AlphaState;
  96509. /**
  96510. * Gets the stencil state manager
  96511. */
  96512. readonly stencilState: StencilState;
  96513. /**
  96514. * Clears the list of texture accessible through engine.
  96515. * This can help preventing texture load conflict due to name collision.
  96516. */
  96517. clearInternalTexturesCache(): void;
  96518. /**
  96519. * Force the entire cache to be cleared
  96520. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96521. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96522. */
  96523. wipeCaches(bruteForce?: boolean): void;
  96524. /** @hidden */
  96525. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96526. min: number;
  96527. mag: number;
  96528. };
  96529. /** @hidden */
  96530. _createTexture(): WebGLTexture;
  96531. /**
  96532. * Usually called from Texture.ts.
  96533. * Passed information to create a WebGLTexture
  96534. * @param urlArg defines a value which contains one of the following:
  96535. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96536. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96537. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96538. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96539. * @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)
  96540. * @param scene needed for loading to the correct scene
  96541. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96542. * @param onLoad optional callback to be called upon successful completion
  96543. * @param onError optional callback to be called upon failure
  96544. * @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
  96545. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96546. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96547. * @param forcedExtension defines the extension to use to pick the right loader
  96548. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96549. * @param mimeType defines an optional mime type
  96550. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96551. */
  96552. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  96553. /**
  96554. * @hidden
  96555. */
  96556. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96557. /**
  96558. * Creates a raw texture
  96559. * @param data defines the data to store in the texture
  96560. * @param width defines the width of the texture
  96561. * @param height defines the height of the texture
  96562. * @param format defines the format of the data
  96563. * @param generateMipMaps defines if the engine should generate the mip levels
  96564. * @param invertY defines if data must be stored with Y axis inverted
  96565. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96566. * @param compression defines the compression used (null by default)
  96567. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96568. * @returns the raw texture inside an InternalTexture
  96569. */
  96570. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96571. /**
  96572. * Creates a new raw cube texture
  96573. * @param data defines the array of data to use to create each face
  96574. * @param size defines the size of the textures
  96575. * @param format defines the format of the data
  96576. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96577. * @param generateMipMaps defines if the engine should generate the mip levels
  96578. * @param invertY defines if data must be stored with Y axis inverted
  96579. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96580. * @param compression defines the compression used (null by default)
  96581. * @returns the cube texture as an InternalTexture
  96582. */
  96583. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96584. /**
  96585. * Creates a new raw 3D texture
  96586. * @param data defines the data used to create the texture
  96587. * @param width defines the width of the texture
  96588. * @param height defines the height of the texture
  96589. * @param depth defines the depth of the texture
  96590. * @param format defines the format of the texture
  96591. * @param generateMipMaps defines if the engine must generate mip levels
  96592. * @param invertY defines if data must be stored with Y axis inverted
  96593. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96594. * @param compression defines the compressed used (can be null)
  96595. * @param textureType defines the compressed used (can be null)
  96596. * @returns a new raw 3D texture (stored in an InternalTexture)
  96597. */
  96598. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96599. private _unpackFlipYCached;
  96600. /**
  96601. * In case you are sharing the context with other applications, it might
  96602. * be interested to not cache the unpack flip y state to ensure a consistent
  96603. * value would be set.
  96604. */
  96605. enableUnpackFlipYCached: boolean;
  96606. /** @hidden */
  96607. _unpackFlipY(value: boolean): void;
  96608. /** @hidden */
  96609. _getUnpackAlignement(): number;
  96610. /**
  96611. * Update the sampling mode of a given texture
  96612. * @param samplingMode defines the required sampling mode
  96613. * @param texture defines the texture to update
  96614. */
  96615. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96616. /**
  96617. * Updates a depth texture Comparison Mode and Function.
  96618. * If the comparison Function is equal to 0, the mode will be set to none.
  96619. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96620. * @param texture The texture to set the comparison function for
  96621. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96622. */
  96623. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96624. /** @hidden */
  96625. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96626. width: number;
  96627. height: number;
  96628. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96629. /**
  96630. * Creates a depth stencil texture.
  96631. * This is only available in WebGL 2 or with the depth texture extension available.
  96632. * @param size The size of face edge in the texture.
  96633. * @param options The options defining the texture.
  96634. * @returns The texture
  96635. */
  96636. createDepthStencilTexture(size: number | {
  96637. width: number;
  96638. height: number;
  96639. }, options: DepthTextureCreationOptions): InternalTexture;
  96640. /**
  96641. * Creates a depth stencil texture.
  96642. * This is only available in WebGL 2 or with the depth texture extension available.
  96643. * @param size The size of face edge in the texture.
  96644. * @param options The options defining the texture.
  96645. * @returns The texture
  96646. */
  96647. private _createDepthStencilTexture;
  96648. /** @hidden */
  96649. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96650. /** @hidden */
  96651. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96652. /** @hidden */
  96653. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96654. /** @hidden */
  96655. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96656. /**
  96657. * @hidden
  96658. */
  96659. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96660. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96661. private _prepareWebGLTexture;
  96662. /** @hidden */
  96663. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96664. /** @hidden */
  96665. _releaseFramebufferObjects(texture: InternalTexture): void;
  96666. /** @hidden */
  96667. _releaseTexture(texture: InternalTexture): void;
  96668. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96669. protected _setProgram(program: WebGLProgram): void;
  96670. protected _boundUniforms: {
  96671. [key: number]: WebGLUniformLocation;
  96672. };
  96673. /**
  96674. * Binds an effect to the webGL context
  96675. * @param effect defines the effect to bind
  96676. */
  96677. bindSamplers(effect: Effect): void;
  96678. private _activateCurrentTexture;
  96679. /** @hidden */
  96680. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96681. /** @hidden */
  96682. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96683. /**
  96684. * Unbind all textures from the webGL context
  96685. */
  96686. unbindAllTextures(): void;
  96687. /**
  96688. * Sets a texture to the according uniform.
  96689. * @param channel The texture channel
  96690. * @param uniform The uniform to set
  96691. * @param texture The texture to apply
  96692. */
  96693. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96694. private _bindSamplerUniformToChannel;
  96695. private _getTextureWrapMode;
  96696. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96697. /**
  96698. * Sets an array of texture to the webGL context
  96699. * @param channel defines the channel where the texture array must be set
  96700. * @param uniform defines the associated uniform location
  96701. * @param textures defines the array of textures to bind
  96702. */
  96703. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96704. /** @hidden */
  96705. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96706. private _setTextureParameterFloat;
  96707. private _setTextureParameterInteger;
  96708. /**
  96709. * Unbind all vertex attributes from the webGL context
  96710. */
  96711. unbindAllAttributes(): void;
  96712. /**
  96713. * 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
  96714. */
  96715. releaseEffects(): void;
  96716. /**
  96717. * Dispose and release all associated resources
  96718. */
  96719. dispose(): void;
  96720. /**
  96721. * Attach a new callback raised when context lost event is fired
  96722. * @param callback defines the callback to call
  96723. */
  96724. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96725. /**
  96726. * Attach a new callback raised when context restored event is fired
  96727. * @param callback defines the callback to call
  96728. */
  96729. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96730. /**
  96731. * Get the current error code of the webGL context
  96732. * @returns the error code
  96733. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96734. */
  96735. getError(): number;
  96736. private _canRenderToFloatFramebuffer;
  96737. private _canRenderToHalfFloatFramebuffer;
  96738. private _canRenderToFramebuffer;
  96739. /** @hidden */
  96740. _getWebGLTextureType(type: number): number;
  96741. /** @hidden */
  96742. _getInternalFormat(format: number): number;
  96743. /** @hidden */
  96744. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96745. /** @hidden */
  96746. _getRGBAMultiSampleBufferFormat(type: number): number;
  96747. /** @hidden */
  96748. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  96749. /**
  96750. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96751. * @returns true if the engine can be created
  96752. * @ignorenaming
  96753. */
  96754. static isSupported(): boolean;
  96755. /**
  96756. * Find the next highest power of two.
  96757. * @param x Number to start search from.
  96758. * @return Next highest power of two.
  96759. */
  96760. static CeilingPOT(x: number): number;
  96761. /**
  96762. * Find the next lowest power of two.
  96763. * @param x Number to start search from.
  96764. * @return Next lowest power of two.
  96765. */
  96766. static FloorPOT(x: number): number;
  96767. /**
  96768. * Find the nearest power of two.
  96769. * @param x Number to start search from.
  96770. * @return Next nearest power of two.
  96771. */
  96772. static NearestPOT(x: number): number;
  96773. /**
  96774. * Get the closest exponent of two
  96775. * @param value defines the value to approximate
  96776. * @param max defines the maximum value to return
  96777. * @param mode defines how to define the closest value
  96778. * @returns closest exponent of two of the given value
  96779. */
  96780. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96781. /**
  96782. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96783. * @param func - the function to be called
  96784. * @param requester - the object that will request the next frame. Falls back to window.
  96785. * @returns frame number
  96786. */
  96787. static QueueNewFrame(func: () => void, requester?: any): number;
  96788. }
  96789. }
  96790. declare module BABYLON {
  96791. /**
  96792. * Class representing spherical harmonics coefficients to the 3rd degree
  96793. */
  96794. export class SphericalHarmonics {
  96795. /**
  96796. * Defines whether or not the harmonics have been prescaled for rendering.
  96797. */
  96798. preScaled: boolean;
  96799. /**
  96800. * The l0,0 coefficients of the spherical harmonics
  96801. */
  96802. l00: Vector3;
  96803. /**
  96804. * The l1,-1 coefficients of the spherical harmonics
  96805. */
  96806. l1_1: Vector3;
  96807. /**
  96808. * The l1,0 coefficients of the spherical harmonics
  96809. */
  96810. l10: Vector3;
  96811. /**
  96812. * The l1,1 coefficients of the spherical harmonics
  96813. */
  96814. l11: Vector3;
  96815. /**
  96816. * The l2,-2 coefficients of the spherical harmonics
  96817. */
  96818. l2_2: Vector3;
  96819. /**
  96820. * The l2,-1 coefficients of the spherical harmonics
  96821. */
  96822. l2_1: Vector3;
  96823. /**
  96824. * The l2,0 coefficients of the spherical harmonics
  96825. */
  96826. l20: Vector3;
  96827. /**
  96828. * The l2,1 coefficients of the spherical harmonics
  96829. */
  96830. l21: Vector3;
  96831. /**
  96832. * The l2,2 coefficients of the spherical harmonics
  96833. */
  96834. l22: Vector3;
  96835. /**
  96836. * Adds a light to the spherical harmonics
  96837. * @param direction the direction of the light
  96838. * @param color the color of the light
  96839. * @param deltaSolidAngle the delta solid angle of the light
  96840. */
  96841. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  96842. /**
  96843. * Scales the spherical harmonics by the given amount
  96844. * @param scale the amount to scale
  96845. */
  96846. scaleInPlace(scale: number): void;
  96847. /**
  96848. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  96849. *
  96850. * ```
  96851. * E_lm = A_l * L_lm
  96852. * ```
  96853. *
  96854. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  96855. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  96856. * the scaling factors are given in equation 9.
  96857. */
  96858. convertIncidentRadianceToIrradiance(): void;
  96859. /**
  96860. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  96861. *
  96862. * ```
  96863. * L = (1/pi) * E * rho
  96864. * ```
  96865. *
  96866. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  96867. */
  96868. convertIrradianceToLambertianRadiance(): void;
  96869. /**
  96870. * Integrates the reconstruction coefficients directly in to the SH preventing further
  96871. * required operations at run time.
  96872. *
  96873. * This is simply done by scaling back the SH with Ylm constants parameter.
  96874. * The trigonometric part being applied by the shader at run time.
  96875. */
  96876. preScaleForRendering(): void;
  96877. /**
  96878. * Constructs a spherical harmonics from an array.
  96879. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  96880. * @returns the spherical harmonics
  96881. */
  96882. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  96883. /**
  96884. * Gets the spherical harmonics from polynomial
  96885. * @param polynomial the spherical polynomial
  96886. * @returns the spherical harmonics
  96887. */
  96888. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  96889. }
  96890. /**
  96891. * Class representing spherical polynomial coefficients to the 3rd degree
  96892. */
  96893. export class SphericalPolynomial {
  96894. private _harmonics;
  96895. /**
  96896. * The spherical harmonics used to create the polynomials.
  96897. */
  96898. readonly preScaledHarmonics: SphericalHarmonics;
  96899. /**
  96900. * The x coefficients of the spherical polynomial
  96901. */
  96902. x: Vector3;
  96903. /**
  96904. * The y coefficients of the spherical polynomial
  96905. */
  96906. y: Vector3;
  96907. /**
  96908. * The z coefficients of the spherical polynomial
  96909. */
  96910. z: Vector3;
  96911. /**
  96912. * The xx coefficients of the spherical polynomial
  96913. */
  96914. xx: Vector3;
  96915. /**
  96916. * The yy coefficients of the spherical polynomial
  96917. */
  96918. yy: Vector3;
  96919. /**
  96920. * The zz coefficients of the spherical polynomial
  96921. */
  96922. zz: Vector3;
  96923. /**
  96924. * The xy coefficients of the spherical polynomial
  96925. */
  96926. xy: Vector3;
  96927. /**
  96928. * The yz coefficients of the spherical polynomial
  96929. */
  96930. yz: Vector3;
  96931. /**
  96932. * The zx coefficients of the spherical polynomial
  96933. */
  96934. zx: Vector3;
  96935. /**
  96936. * Adds an ambient color to the spherical polynomial
  96937. * @param color the color to add
  96938. */
  96939. addAmbient(color: Color3): void;
  96940. /**
  96941. * Scales the spherical polynomial by the given amount
  96942. * @param scale the amount to scale
  96943. */
  96944. scaleInPlace(scale: number): void;
  96945. /**
  96946. * Gets the spherical polynomial from harmonics
  96947. * @param harmonics the spherical harmonics
  96948. * @returns the spherical polynomial
  96949. */
  96950. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  96951. /**
  96952. * Constructs a spherical polynomial from an array.
  96953. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  96954. * @returns the spherical polynomial
  96955. */
  96956. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  96957. }
  96958. }
  96959. declare module BABYLON {
  96960. /**
  96961. * Defines the source of the internal texture
  96962. */
  96963. export enum InternalTextureSource {
  96964. /**
  96965. * The source of the texture data is unknown
  96966. */
  96967. Unknown = 0,
  96968. /**
  96969. * Texture data comes from an URL
  96970. */
  96971. Url = 1,
  96972. /**
  96973. * Texture data is only used for temporary storage
  96974. */
  96975. Temp = 2,
  96976. /**
  96977. * Texture data comes from raw data (ArrayBuffer)
  96978. */
  96979. Raw = 3,
  96980. /**
  96981. * Texture content is dynamic (video or dynamic texture)
  96982. */
  96983. Dynamic = 4,
  96984. /**
  96985. * Texture content is generated by rendering to it
  96986. */
  96987. RenderTarget = 5,
  96988. /**
  96989. * Texture content is part of a multi render target process
  96990. */
  96991. MultiRenderTarget = 6,
  96992. /**
  96993. * Texture data comes from a cube data file
  96994. */
  96995. Cube = 7,
  96996. /**
  96997. * Texture data comes from a raw cube data
  96998. */
  96999. CubeRaw = 8,
  97000. /**
  97001. * Texture data come from a prefiltered cube data file
  97002. */
  97003. CubePrefiltered = 9,
  97004. /**
  97005. * Texture content is raw 3D data
  97006. */
  97007. Raw3D = 10,
  97008. /**
  97009. * Texture content is a depth texture
  97010. */
  97011. Depth = 11,
  97012. /**
  97013. * Texture data comes from a raw cube data encoded with RGBD
  97014. */
  97015. CubeRawRGBD = 12
  97016. }
  97017. /**
  97018. * Class used to store data associated with WebGL texture data for the engine
  97019. * This class should not be used directly
  97020. */
  97021. export class InternalTexture {
  97022. /** @hidden */
  97023. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97024. /**
  97025. * Defines if the texture is ready
  97026. */
  97027. isReady: boolean;
  97028. /**
  97029. * Defines if the texture is a cube texture
  97030. */
  97031. isCube: boolean;
  97032. /**
  97033. * Defines if the texture contains 3D data
  97034. */
  97035. is3D: boolean;
  97036. /**
  97037. * Defines if the texture contains multiview data
  97038. */
  97039. isMultiview: boolean;
  97040. /**
  97041. * Gets the URL used to load this texture
  97042. */
  97043. url: string;
  97044. /**
  97045. * Gets the sampling mode of the texture
  97046. */
  97047. samplingMode: number;
  97048. /**
  97049. * Gets a boolean indicating if the texture needs mipmaps generation
  97050. */
  97051. generateMipMaps: boolean;
  97052. /**
  97053. * Gets the number of samples used by the texture (WebGL2+ only)
  97054. */
  97055. samples: number;
  97056. /**
  97057. * Gets the type of the texture (int, float...)
  97058. */
  97059. type: number;
  97060. /**
  97061. * Gets the format of the texture (RGB, RGBA...)
  97062. */
  97063. format: number;
  97064. /**
  97065. * Observable called when the texture is loaded
  97066. */
  97067. onLoadedObservable: Observable<InternalTexture>;
  97068. /**
  97069. * Gets the width of the texture
  97070. */
  97071. width: number;
  97072. /**
  97073. * Gets the height of the texture
  97074. */
  97075. height: number;
  97076. /**
  97077. * Gets the depth of the texture
  97078. */
  97079. depth: number;
  97080. /**
  97081. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97082. */
  97083. baseWidth: number;
  97084. /**
  97085. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97086. */
  97087. baseHeight: number;
  97088. /**
  97089. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97090. */
  97091. baseDepth: number;
  97092. /**
  97093. * Gets a boolean indicating if the texture is inverted on Y axis
  97094. */
  97095. invertY: boolean;
  97096. /** @hidden */
  97097. _invertVScale: boolean;
  97098. /** @hidden */
  97099. _associatedChannel: number;
  97100. /** @hidden */
  97101. _source: InternalTextureSource;
  97102. /** @hidden */
  97103. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97104. /** @hidden */
  97105. _bufferView: Nullable<ArrayBufferView>;
  97106. /** @hidden */
  97107. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97108. /** @hidden */
  97109. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97110. /** @hidden */
  97111. _size: number;
  97112. /** @hidden */
  97113. _extension: string;
  97114. /** @hidden */
  97115. _files: Nullable<string[]>;
  97116. /** @hidden */
  97117. _workingCanvas: Nullable<HTMLCanvasElement>;
  97118. /** @hidden */
  97119. _workingContext: Nullable<CanvasRenderingContext2D>;
  97120. /** @hidden */
  97121. _framebuffer: Nullable<WebGLFramebuffer>;
  97122. /** @hidden */
  97123. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97124. /** @hidden */
  97125. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97126. /** @hidden */
  97127. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97128. /** @hidden */
  97129. _attachments: Nullable<number[]>;
  97130. /** @hidden */
  97131. _cachedCoordinatesMode: Nullable<number>;
  97132. /** @hidden */
  97133. _cachedWrapU: Nullable<number>;
  97134. /** @hidden */
  97135. _cachedWrapV: Nullable<number>;
  97136. /** @hidden */
  97137. _cachedWrapR: Nullable<number>;
  97138. /** @hidden */
  97139. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97140. /** @hidden */
  97141. _isDisabled: boolean;
  97142. /** @hidden */
  97143. _compression: Nullable<string>;
  97144. /** @hidden */
  97145. _generateStencilBuffer: boolean;
  97146. /** @hidden */
  97147. _generateDepthBuffer: boolean;
  97148. /** @hidden */
  97149. _comparisonFunction: number;
  97150. /** @hidden */
  97151. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97152. /** @hidden */
  97153. _lodGenerationScale: number;
  97154. /** @hidden */
  97155. _lodGenerationOffset: number;
  97156. /** @hidden */
  97157. _colorTextureArray: Nullable<WebGLTexture>;
  97158. /** @hidden */
  97159. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97160. /** @hidden */
  97161. _lodTextureHigh: Nullable<BaseTexture>;
  97162. /** @hidden */
  97163. _lodTextureMid: Nullable<BaseTexture>;
  97164. /** @hidden */
  97165. _lodTextureLow: Nullable<BaseTexture>;
  97166. /** @hidden */
  97167. _isRGBD: boolean;
  97168. /** @hidden */
  97169. _linearSpecularLOD: boolean;
  97170. /** @hidden */
  97171. _irradianceTexture: Nullable<BaseTexture>;
  97172. /** @hidden */
  97173. _webGLTexture: Nullable<WebGLTexture>;
  97174. /** @hidden */
  97175. _references: number;
  97176. private _engine;
  97177. /**
  97178. * Gets the Engine the texture belongs to.
  97179. * @returns The babylon engine
  97180. */
  97181. getEngine(): ThinEngine;
  97182. /**
  97183. * Gets the data source type of the texture
  97184. */
  97185. readonly source: InternalTextureSource;
  97186. /**
  97187. * Creates a new InternalTexture
  97188. * @param engine defines the engine to use
  97189. * @param source defines the type of data that will be used
  97190. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97191. */
  97192. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97193. /**
  97194. * Increments the number of references (ie. the number of Texture that point to it)
  97195. */
  97196. incrementReferences(): void;
  97197. /**
  97198. * Change the size of the texture (not the size of the content)
  97199. * @param width defines the new width
  97200. * @param height defines the new height
  97201. * @param depth defines the new depth (1 by default)
  97202. */
  97203. updateSize(width: int, height: int, depth?: int): void;
  97204. /** @hidden */
  97205. _rebuild(): void;
  97206. /** @hidden */
  97207. _swapAndDie(target: InternalTexture): void;
  97208. /**
  97209. * Dispose the current allocated resources
  97210. */
  97211. dispose(): void;
  97212. }
  97213. }
  97214. declare module BABYLON {
  97215. /**
  97216. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97217. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97218. */
  97219. export class Analyser {
  97220. /**
  97221. * Gets or sets the smoothing
  97222. * @ignorenaming
  97223. */
  97224. SMOOTHING: number;
  97225. /**
  97226. * Gets or sets the FFT table size
  97227. * @ignorenaming
  97228. */
  97229. FFT_SIZE: number;
  97230. /**
  97231. * Gets or sets the bar graph amplitude
  97232. * @ignorenaming
  97233. */
  97234. BARGRAPHAMPLITUDE: number;
  97235. /**
  97236. * Gets or sets the position of the debug canvas
  97237. * @ignorenaming
  97238. */
  97239. DEBUGCANVASPOS: {
  97240. x: number;
  97241. y: number;
  97242. };
  97243. /**
  97244. * Gets or sets the debug canvas size
  97245. * @ignorenaming
  97246. */
  97247. DEBUGCANVASSIZE: {
  97248. width: number;
  97249. height: number;
  97250. };
  97251. private _byteFreqs;
  97252. private _byteTime;
  97253. private _floatFreqs;
  97254. private _webAudioAnalyser;
  97255. private _debugCanvas;
  97256. private _debugCanvasContext;
  97257. private _scene;
  97258. private _registerFunc;
  97259. private _audioEngine;
  97260. /**
  97261. * Creates a new analyser
  97262. * @param scene defines hosting scene
  97263. */
  97264. constructor(scene: Scene);
  97265. /**
  97266. * Get the number of data values you will have to play with for the visualization
  97267. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97268. * @returns a number
  97269. */
  97270. getFrequencyBinCount(): number;
  97271. /**
  97272. * Gets the current frequency data as a byte array
  97273. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97274. * @returns a Uint8Array
  97275. */
  97276. getByteFrequencyData(): Uint8Array;
  97277. /**
  97278. * Gets the current waveform as a byte array
  97279. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97280. * @returns a Uint8Array
  97281. */
  97282. getByteTimeDomainData(): Uint8Array;
  97283. /**
  97284. * Gets the current frequency data as a float array
  97285. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97286. * @returns a Float32Array
  97287. */
  97288. getFloatFrequencyData(): Float32Array;
  97289. /**
  97290. * Renders the debug canvas
  97291. */
  97292. drawDebugCanvas(): void;
  97293. /**
  97294. * Stops rendering the debug canvas and removes it
  97295. */
  97296. stopDebugCanvas(): void;
  97297. /**
  97298. * Connects two audio nodes
  97299. * @param inputAudioNode defines first node to connect
  97300. * @param outputAudioNode defines second node to connect
  97301. */
  97302. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97303. /**
  97304. * Releases all associated resources
  97305. */
  97306. dispose(): void;
  97307. }
  97308. }
  97309. declare module BABYLON {
  97310. /**
  97311. * This represents an audio engine and it is responsible
  97312. * to play, synchronize and analyse sounds throughout the application.
  97313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97314. */
  97315. export interface IAudioEngine extends IDisposable {
  97316. /**
  97317. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97318. */
  97319. readonly canUseWebAudio: boolean;
  97320. /**
  97321. * Gets the current AudioContext if available.
  97322. */
  97323. readonly audioContext: Nullable<AudioContext>;
  97324. /**
  97325. * The master gain node defines the global audio volume of your audio engine.
  97326. */
  97327. readonly masterGain: GainNode;
  97328. /**
  97329. * Gets whether or not mp3 are supported by your browser.
  97330. */
  97331. readonly isMP3supported: boolean;
  97332. /**
  97333. * Gets whether or not ogg are supported by your browser.
  97334. */
  97335. readonly isOGGsupported: boolean;
  97336. /**
  97337. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97338. * @ignoreNaming
  97339. */
  97340. WarnedWebAudioUnsupported: boolean;
  97341. /**
  97342. * Defines if the audio engine relies on a custom unlocked button.
  97343. * In this case, the embedded button will not be displayed.
  97344. */
  97345. useCustomUnlockedButton: boolean;
  97346. /**
  97347. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97348. */
  97349. readonly unlocked: boolean;
  97350. /**
  97351. * Event raised when audio has been unlocked on the browser.
  97352. */
  97353. onAudioUnlockedObservable: Observable<AudioEngine>;
  97354. /**
  97355. * Event raised when audio has been locked on the browser.
  97356. */
  97357. onAudioLockedObservable: Observable<AudioEngine>;
  97358. /**
  97359. * Flags the audio engine in Locked state.
  97360. * This happens due to new browser policies preventing audio to autoplay.
  97361. */
  97362. lock(): void;
  97363. /**
  97364. * Unlocks the audio engine once a user action has been done on the dom.
  97365. * This is helpful to resume play once browser policies have been satisfied.
  97366. */
  97367. unlock(): void;
  97368. }
  97369. /**
  97370. * This represents the default audio engine used in babylon.
  97371. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97372. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97373. */
  97374. export class AudioEngine implements IAudioEngine {
  97375. private _audioContext;
  97376. private _audioContextInitialized;
  97377. private _muteButton;
  97378. private _hostElement;
  97379. /**
  97380. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97381. */
  97382. canUseWebAudio: boolean;
  97383. /**
  97384. * The master gain node defines the global audio volume of your audio engine.
  97385. */
  97386. masterGain: GainNode;
  97387. /**
  97388. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97389. * @ignoreNaming
  97390. */
  97391. WarnedWebAudioUnsupported: boolean;
  97392. /**
  97393. * Gets whether or not mp3 are supported by your browser.
  97394. */
  97395. isMP3supported: boolean;
  97396. /**
  97397. * Gets whether or not ogg are supported by your browser.
  97398. */
  97399. isOGGsupported: boolean;
  97400. /**
  97401. * Gets whether audio has been unlocked on the device.
  97402. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97403. * a user interaction has happened.
  97404. */
  97405. unlocked: boolean;
  97406. /**
  97407. * Defines if the audio engine relies on a custom unlocked button.
  97408. * In this case, the embedded button will not be displayed.
  97409. */
  97410. useCustomUnlockedButton: boolean;
  97411. /**
  97412. * Event raised when audio has been unlocked on the browser.
  97413. */
  97414. onAudioUnlockedObservable: Observable<AudioEngine>;
  97415. /**
  97416. * Event raised when audio has been locked on the browser.
  97417. */
  97418. onAudioLockedObservable: Observable<AudioEngine>;
  97419. /**
  97420. * Gets the current AudioContext if available.
  97421. */
  97422. readonly audioContext: Nullable<AudioContext>;
  97423. private _connectedAnalyser;
  97424. /**
  97425. * Instantiates a new audio engine.
  97426. *
  97427. * There should be only one per page as some browsers restrict the number
  97428. * of audio contexts you can create.
  97429. * @param hostElement defines the host element where to display the mute icon if necessary
  97430. */
  97431. constructor(hostElement?: Nullable<HTMLElement>);
  97432. /**
  97433. * Flags the audio engine in Locked state.
  97434. * This happens due to new browser policies preventing audio to autoplay.
  97435. */
  97436. lock(): void;
  97437. /**
  97438. * Unlocks the audio engine once a user action has been done on the dom.
  97439. * This is helpful to resume play once browser policies have been satisfied.
  97440. */
  97441. unlock(): void;
  97442. private _resumeAudioContext;
  97443. private _initializeAudioContext;
  97444. private _tryToRun;
  97445. private _triggerRunningState;
  97446. private _triggerSuspendedState;
  97447. private _displayMuteButton;
  97448. private _moveButtonToTopLeft;
  97449. private _onResize;
  97450. private _hideMuteButton;
  97451. /**
  97452. * Destroy and release the resources associated with the audio ccontext.
  97453. */
  97454. dispose(): void;
  97455. /**
  97456. * Gets the global volume sets on the master gain.
  97457. * @returns the global volume if set or -1 otherwise
  97458. */
  97459. getGlobalVolume(): number;
  97460. /**
  97461. * Sets the global volume of your experience (sets on the master gain).
  97462. * @param newVolume Defines the new global volume of the application
  97463. */
  97464. setGlobalVolume(newVolume: number): void;
  97465. /**
  97466. * Connect the audio engine to an audio analyser allowing some amazing
  97467. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97469. * @param analyser The analyser to connect to the engine
  97470. */
  97471. connectToAnalyser(analyser: Analyser): void;
  97472. }
  97473. }
  97474. declare module BABYLON {
  97475. /**
  97476. * Interface used to present a loading screen while loading a scene
  97477. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97478. */
  97479. export interface ILoadingScreen {
  97480. /**
  97481. * Function called to display the loading screen
  97482. */
  97483. displayLoadingUI: () => void;
  97484. /**
  97485. * Function called to hide the loading screen
  97486. */
  97487. hideLoadingUI: () => void;
  97488. /**
  97489. * Gets or sets the color to use for the background
  97490. */
  97491. loadingUIBackgroundColor: string;
  97492. /**
  97493. * Gets or sets the text to display while loading
  97494. */
  97495. loadingUIText: string;
  97496. }
  97497. /**
  97498. * Class used for the default loading screen
  97499. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97500. */
  97501. export class DefaultLoadingScreen implements ILoadingScreen {
  97502. private _renderingCanvas;
  97503. private _loadingText;
  97504. private _loadingDivBackgroundColor;
  97505. private _loadingDiv;
  97506. private _loadingTextDiv;
  97507. /** Gets or sets the logo url to use for the default loading screen */
  97508. static DefaultLogoUrl: string;
  97509. /** Gets or sets the spinner url to use for the default loading screen */
  97510. static DefaultSpinnerUrl: string;
  97511. /**
  97512. * Creates a new default loading screen
  97513. * @param _renderingCanvas defines the canvas used to render the scene
  97514. * @param _loadingText defines the default text to display
  97515. * @param _loadingDivBackgroundColor defines the default background color
  97516. */
  97517. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97518. /**
  97519. * Function called to display the loading screen
  97520. */
  97521. displayLoadingUI(): void;
  97522. /**
  97523. * Function called to hide the loading screen
  97524. */
  97525. hideLoadingUI(): void;
  97526. /**
  97527. * Gets or sets the text to display while loading
  97528. */
  97529. loadingUIText: string;
  97530. /**
  97531. * Gets or sets the color to use for the background
  97532. */
  97533. loadingUIBackgroundColor: string;
  97534. private _resizeLoadingUI;
  97535. }
  97536. }
  97537. declare module BABYLON {
  97538. /**
  97539. * Interface for any object that can request an animation frame
  97540. */
  97541. export interface ICustomAnimationFrameRequester {
  97542. /**
  97543. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97544. */
  97545. renderFunction?: Function;
  97546. /**
  97547. * Called to request the next frame to render to
  97548. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97549. */
  97550. requestAnimationFrame: Function;
  97551. /**
  97552. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97553. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97554. */
  97555. requestID?: number;
  97556. }
  97557. }
  97558. declare module BABYLON {
  97559. /**
  97560. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97561. */
  97562. export class PerformanceMonitor {
  97563. private _enabled;
  97564. private _rollingFrameTime;
  97565. private _lastFrameTimeMs;
  97566. /**
  97567. * constructor
  97568. * @param frameSampleSize The number of samples required to saturate the sliding window
  97569. */
  97570. constructor(frameSampleSize?: number);
  97571. /**
  97572. * Samples current frame
  97573. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97574. */
  97575. sampleFrame(timeMs?: number): void;
  97576. /**
  97577. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97578. */
  97579. readonly averageFrameTime: number;
  97580. /**
  97581. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97582. */
  97583. readonly averageFrameTimeVariance: number;
  97584. /**
  97585. * Returns the frame time of the most recent frame
  97586. */
  97587. readonly instantaneousFrameTime: number;
  97588. /**
  97589. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97590. */
  97591. readonly averageFPS: number;
  97592. /**
  97593. * Returns the average framerate in frames per second using the most recent frame time
  97594. */
  97595. readonly instantaneousFPS: number;
  97596. /**
  97597. * Returns true if enough samples have been taken to completely fill the sliding window
  97598. */
  97599. readonly isSaturated: boolean;
  97600. /**
  97601. * Enables contributions to the sliding window sample set
  97602. */
  97603. enable(): void;
  97604. /**
  97605. * Disables contributions to the sliding window sample set
  97606. * Samples will not be interpolated over the disabled period
  97607. */
  97608. disable(): void;
  97609. /**
  97610. * Returns true if sampling is enabled
  97611. */
  97612. readonly isEnabled: boolean;
  97613. /**
  97614. * Resets performance monitor
  97615. */
  97616. reset(): void;
  97617. }
  97618. /**
  97619. * RollingAverage
  97620. *
  97621. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97622. */
  97623. export class RollingAverage {
  97624. /**
  97625. * Current average
  97626. */
  97627. average: number;
  97628. /**
  97629. * Current variance
  97630. */
  97631. variance: number;
  97632. protected _samples: Array<number>;
  97633. protected _sampleCount: number;
  97634. protected _pos: number;
  97635. protected _m2: number;
  97636. /**
  97637. * constructor
  97638. * @param length The number of samples required to saturate the sliding window
  97639. */
  97640. constructor(length: number);
  97641. /**
  97642. * Adds a sample to the sample set
  97643. * @param v The sample value
  97644. */
  97645. add(v: number): void;
  97646. /**
  97647. * Returns previously added values or null if outside of history or outside the sliding window domain
  97648. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97649. * @return Value previously recorded with add() or null if outside of range
  97650. */
  97651. history(i: number): number;
  97652. /**
  97653. * Returns true if enough samples have been taken to completely fill the sliding window
  97654. * @return true if sample-set saturated
  97655. */
  97656. isSaturated(): boolean;
  97657. /**
  97658. * Resets the rolling average (equivalent to 0 samples taken so far)
  97659. */
  97660. reset(): void;
  97661. /**
  97662. * Wraps a value around the sample range boundaries
  97663. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97664. * @return Wrapped position in sample range
  97665. */
  97666. protected _wrapPosition(i: number): number;
  97667. }
  97668. }
  97669. declare module BABYLON {
  97670. /**
  97671. * This class is used to track a performance counter which is number based.
  97672. * The user has access to many properties which give statistics of different nature.
  97673. *
  97674. * The implementer can track two kinds of Performance Counter: time and count.
  97675. * 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.
  97676. * 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.
  97677. */
  97678. export class PerfCounter {
  97679. /**
  97680. * Gets or sets a global boolean to turn on and off all the counters
  97681. */
  97682. static Enabled: boolean;
  97683. /**
  97684. * Returns the smallest value ever
  97685. */
  97686. readonly min: number;
  97687. /**
  97688. * Returns the biggest value ever
  97689. */
  97690. readonly max: number;
  97691. /**
  97692. * Returns the average value since the performance counter is running
  97693. */
  97694. readonly average: number;
  97695. /**
  97696. * Returns the average value of the last second the counter was monitored
  97697. */
  97698. readonly lastSecAverage: number;
  97699. /**
  97700. * Returns the current value
  97701. */
  97702. readonly current: number;
  97703. /**
  97704. * Gets the accumulated total
  97705. */
  97706. readonly total: number;
  97707. /**
  97708. * Gets the total value count
  97709. */
  97710. readonly count: number;
  97711. /**
  97712. * Creates a new counter
  97713. */
  97714. constructor();
  97715. /**
  97716. * Call this method to start monitoring a new frame.
  97717. * 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.
  97718. */
  97719. fetchNewFrame(): void;
  97720. /**
  97721. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  97722. * @param newCount the count value to add to the monitored count
  97723. * @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.
  97724. */
  97725. addCount(newCount: number, fetchResult: boolean): void;
  97726. /**
  97727. * Start monitoring this performance counter
  97728. */
  97729. beginMonitoring(): void;
  97730. /**
  97731. * Compute the time lapsed since the previous beginMonitoring() call.
  97732. * @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
  97733. */
  97734. endMonitoring(newFrame?: boolean): void;
  97735. private _fetchResult;
  97736. private _startMonitoringTime;
  97737. private _min;
  97738. private _max;
  97739. private _average;
  97740. private _current;
  97741. private _totalValueCount;
  97742. private _totalAccumulated;
  97743. private _lastSecAverage;
  97744. private _lastSecAccumulated;
  97745. private _lastSecTime;
  97746. private _lastSecValueCount;
  97747. }
  97748. }
  97749. declare module BABYLON {
  97750. /**
  97751. * Defines the interface used by display changed events
  97752. */
  97753. export interface IDisplayChangedEventArgs {
  97754. /** Gets the vrDisplay object (if any) */
  97755. vrDisplay: Nullable<any>;
  97756. /** Gets a boolean indicating if webVR is supported */
  97757. vrSupported: boolean;
  97758. }
  97759. /**
  97760. * Defines the interface used by objects containing a viewport (like a camera)
  97761. */
  97762. interface IViewportOwnerLike {
  97763. /**
  97764. * Gets or sets the viewport
  97765. */
  97766. viewport: IViewportLike;
  97767. }
  97768. /**
  97769. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97770. */
  97771. export class Engine extends ThinEngine {
  97772. /** Defines that alpha blending is disabled */
  97773. static readonly ALPHA_DISABLE: number;
  97774. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97775. static readonly ALPHA_ADD: number;
  97776. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97777. static readonly ALPHA_COMBINE: number;
  97778. /** Defines that alpha blending to DEST - SRC * DEST */
  97779. static readonly ALPHA_SUBTRACT: number;
  97780. /** Defines that alpha blending to SRC * DEST */
  97781. static readonly ALPHA_MULTIPLY: number;
  97782. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97783. static readonly ALPHA_MAXIMIZED: number;
  97784. /** Defines that alpha blending to SRC + DEST */
  97785. static readonly ALPHA_ONEONE: number;
  97786. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97787. static readonly ALPHA_PREMULTIPLIED: number;
  97788. /**
  97789. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97790. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97791. */
  97792. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97793. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97794. static readonly ALPHA_INTERPOLATE: number;
  97795. /**
  97796. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97797. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97798. */
  97799. static readonly ALPHA_SCREENMODE: number;
  97800. /** Defines that the ressource is not delayed*/
  97801. static readonly DELAYLOADSTATE_NONE: number;
  97802. /** Defines that the ressource was successfully delay loaded */
  97803. static readonly DELAYLOADSTATE_LOADED: number;
  97804. /** Defines that the ressource is currently delay loading */
  97805. static readonly DELAYLOADSTATE_LOADING: number;
  97806. /** Defines that the ressource is delayed and has not started loading */
  97807. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97808. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97809. static readonly NEVER: number;
  97810. /** 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 */
  97811. static readonly ALWAYS: number;
  97812. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97813. static readonly LESS: number;
  97814. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97815. static readonly EQUAL: number;
  97816. /** 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 */
  97817. static readonly LEQUAL: number;
  97818. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97819. static readonly GREATER: number;
  97820. /** 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 */
  97821. static readonly GEQUAL: number;
  97822. /** 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 */
  97823. static readonly NOTEQUAL: number;
  97824. /** Passed to stencilOperation to specify that stencil value must be kept */
  97825. static readonly KEEP: number;
  97826. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97827. static readonly REPLACE: number;
  97828. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97829. static readonly INCR: number;
  97830. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97831. static readonly DECR: number;
  97832. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97833. static readonly INVERT: number;
  97834. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97835. static readonly INCR_WRAP: number;
  97836. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97837. static readonly DECR_WRAP: number;
  97838. /** Texture is not repeating outside of 0..1 UVs */
  97839. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97840. /** Texture is repeating outside of 0..1 UVs */
  97841. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97842. /** Texture is repeating and mirrored */
  97843. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97844. /** ALPHA */
  97845. static readonly TEXTUREFORMAT_ALPHA: number;
  97846. /** LUMINANCE */
  97847. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97848. /** LUMINANCE_ALPHA */
  97849. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97850. /** RGB */
  97851. static readonly TEXTUREFORMAT_RGB: number;
  97852. /** RGBA */
  97853. static readonly TEXTUREFORMAT_RGBA: number;
  97854. /** RED */
  97855. static readonly TEXTUREFORMAT_RED: number;
  97856. /** RED (2nd reference) */
  97857. static readonly TEXTUREFORMAT_R: number;
  97858. /** RG */
  97859. static readonly TEXTUREFORMAT_RG: number;
  97860. /** RED_INTEGER */
  97861. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97862. /** RED_INTEGER (2nd reference) */
  97863. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97864. /** RG_INTEGER */
  97865. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97866. /** RGB_INTEGER */
  97867. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97868. /** RGBA_INTEGER */
  97869. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97870. /** UNSIGNED_BYTE */
  97871. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97872. /** UNSIGNED_BYTE (2nd reference) */
  97873. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97874. /** FLOAT */
  97875. static readonly TEXTURETYPE_FLOAT: number;
  97876. /** HALF_FLOAT */
  97877. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97878. /** BYTE */
  97879. static readonly TEXTURETYPE_BYTE: number;
  97880. /** SHORT */
  97881. static readonly TEXTURETYPE_SHORT: number;
  97882. /** UNSIGNED_SHORT */
  97883. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97884. /** INT */
  97885. static readonly TEXTURETYPE_INT: number;
  97886. /** UNSIGNED_INT */
  97887. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97888. /** UNSIGNED_SHORT_4_4_4_4 */
  97889. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97890. /** UNSIGNED_SHORT_5_5_5_1 */
  97891. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97892. /** UNSIGNED_SHORT_5_6_5 */
  97893. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97894. /** UNSIGNED_INT_2_10_10_10_REV */
  97895. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97896. /** UNSIGNED_INT_24_8 */
  97897. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97898. /** UNSIGNED_INT_10F_11F_11F_REV */
  97899. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97900. /** UNSIGNED_INT_5_9_9_9_REV */
  97901. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97902. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97903. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97904. /** nearest is mag = nearest and min = nearest and mip = linear */
  97905. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97906. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97907. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97908. /** Trilinear is mag = linear and min = linear and mip = linear */
  97909. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97910. /** nearest is mag = nearest and min = nearest and mip = linear */
  97911. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97912. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97913. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97914. /** Trilinear is mag = linear and min = linear and mip = linear */
  97915. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97916. /** mag = nearest and min = nearest and mip = nearest */
  97917. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97918. /** mag = nearest and min = linear and mip = nearest */
  97919. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97920. /** mag = nearest and min = linear and mip = linear */
  97921. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97922. /** mag = nearest and min = linear and mip = none */
  97923. static readonly TEXTURE_NEAREST_LINEAR: number;
  97924. /** mag = nearest and min = nearest and mip = none */
  97925. static readonly TEXTURE_NEAREST_NEAREST: number;
  97926. /** mag = linear and min = nearest and mip = nearest */
  97927. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97928. /** mag = linear and min = nearest and mip = linear */
  97929. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97930. /** mag = linear and min = linear and mip = none */
  97931. static readonly TEXTURE_LINEAR_LINEAR: number;
  97932. /** mag = linear and min = nearest and mip = none */
  97933. static readonly TEXTURE_LINEAR_NEAREST: number;
  97934. /** Explicit coordinates mode */
  97935. static readonly TEXTURE_EXPLICIT_MODE: number;
  97936. /** Spherical coordinates mode */
  97937. static readonly TEXTURE_SPHERICAL_MODE: number;
  97938. /** Planar coordinates mode */
  97939. static readonly TEXTURE_PLANAR_MODE: number;
  97940. /** Cubic coordinates mode */
  97941. static readonly TEXTURE_CUBIC_MODE: number;
  97942. /** Projection coordinates mode */
  97943. static readonly TEXTURE_PROJECTION_MODE: number;
  97944. /** Skybox coordinates mode */
  97945. static readonly TEXTURE_SKYBOX_MODE: number;
  97946. /** Inverse Cubic coordinates mode */
  97947. static readonly TEXTURE_INVCUBIC_MODE: number;
  97948. /** Equirectangular coordinates mode */
  97949. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97950. /** Equirectangular Fixed coordinates mode */
  97951. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97952. /** Equirectangular Fixed Mirrored coordinates mode */
  97953. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97954. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97955. static readonly SCALEMODE_FLOOR: number;
  97956. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97957. static readonly SCALEMODE_NEAREST: number;
  97958. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97959. static readonly SCALEMODE_CEILING: number;
  97960. /**
  97961. * Returns the current npm package of the sdk
  97962. */
  97963. static readonly NpmPackage: string;
  97964. /**
  97965. * Returns the current version of the framework
  97966. */
  97967. static readonly Version: string;
  97968. /** Gets the list of created engines */
  97969. static readonly Instances: Engine[];
  97970. /**
  97971. * Gets the latest created engine
  97972. */
  97973. static readonly LastCreatedEngine: Nullable<Engine>;
  97974. /**
  97975. * Gets the latest created scene
  97976. */
  97977. static readonly LastCreatedScene: Nullable<Scene>;
  97978. /**
  97979. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  97980. * @param flag defines which part of the materials must be marked as dirty
  97981. * @param predicate defines a predicate used to filter which materials should be affected
  97982. */
  97983. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  97984. /**
  97985. * Method called to create the default loading screen.
  97986. * This can be overriden in your own app.
  97987. * @param canvas The rendering canvas element
  97988. * @returns The loading screen
  97989. */
  97990. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  97991. /**
  97992. * Method called to create the default rescale post process on each engine.
  97993. */
  97994. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  97995. /**
  97996. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  97997. **/
  97998. enableOfflineSupport: boolean;
  97999. /**
  98000. * 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)
  98001. **/
  98002. disableManifestCheck: boolean;
  98003. /**
  98004. * Gets the list of created scenes
  98005. */
  98006. scenes: Scene[];
  98007. /**
  98008. * Event raised when a new scene is created
  98009. */
  98010. onNewSceneAddedObservable: Observable<Scene>;
  98011. /**
  98012. * Gets the list of created postprocesses
  98013. */
  98014. postProcesses: PostProcess[];
  98015. /**
  98016. * Gets a boolean indicating if the pointer is currently locked
  98017. */
  98018. isPointerLock: boolean;
  98019. /**
  98020. * Observable event triggered each time the rendering canvas is resized
  98021. */
  98022. onResizeObservable: Observable<Engine>;
  98023. /**
  98024. * Observable event triggered each time the canvas loses focus
  98025. */
  98026. onCanvasBlurObservable: Observable<Engine>;
  98027. /**
  98028. * Observable event triggered each time the canvas gains focus
  98029. */
  98030. onCanvasFocusObservable: Observable<Engine>;
  98031. /**
  98032. * Observable event triggered each time the canvas receives pointerout event
  98033. */
  98034. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98035. /**
  98036. * Observable raised when the engine begins a new frame
  98037. */
  98038. onBeginFrameObservable: Observable<Engine>;
  98039. /**
  98040. * If set, will be used to request the next animation frame for the render loop
  98041. */
  98042. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98043. /**
  98044. * Observable raised when the engine ends the current frame
  98045. */
  98046. onEndFrameObservable: Observable<Engine>;
  98047. /**
  98048. * Observable raised when the engine is about to compile a shader
  98049. */
  98050. onBeforeShaderCompilationObservable: Observable<Engine>;
  98051. /**
  98052. * Observable raised when the engine has jsut compiled a shader
  98053. */
  98054. onAfterShaderCompilationObservable: Observable<Engine>;
  98055. /**
  98056. * Gets the audio engine
  98057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98058. * @ignorenaming
  98059. */
  98060. static audioEngine: IAudioEngine;
  98061. /**
  98062. * Default AudioEngine factory responsible of creating the Audio Engine.
  98063. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98064. */
  98065. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98066. /**
  98067. * Default offline support factory responsible of creating a tool used to store data locally.
  98068. * By default, this will create a Database object if the workload has been embedded.
  98069. */
  98070. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98071. private _loadingScreen;
  98072. private _pointerLockRequested;
  98073. private _dummyFramebuffer;
  98074. private _rescalePostProcess;
  98075. /** @hidden */
  98076. protected _alphaMode: number;
  98077. /** @hidden */
  98078. protected _alphaEquation: number;
  98079. private _deterministicLockstep;
  98080. private _lockstepMaxSteps;
  98081. protected readonly _supportsHardwareTextureRescaling: boolean;
  98082. private _fps;
  98083. private _deltaTime;
  98084. /** @hidden */
  98085. _drawCalls: PerfCounter;
  98086. /**
  98087. * Turn this value on if you want to pause FPS computation when in background
  98088. */
  98089. disablePerformanceMonitorInBackground: boolean;
  98090. private _performanceMonitor;
  98091. /**
  98092. * Gets the performance monitor attached to this engine
  98093. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98094. */
  98095. readonly performanceMonitor: PerformanceMonitor;
  98096. private _onFocus;
  98097. private _onBlur;
  98098. private _onCanvasPointerOut;
  98099. private _onCanvasBlur;
  98100. private _onCanvasFocus;
  98101. private _onFullscreenChange;
  98102. private _onPointerLockChange;
  98103. /**
  98104. * Creates a new engine
  98105. * @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
  98106. * @param antialias defines enable antialiasing (default: false)
  98107. * @param options defines further options to be sent to the getContext() function
  98108. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98109. */
  98110. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98111. /**
  98112. * Gets current aspect ratio
  98113. * @param viewportOwner defines the camera to use to get the aspect ratio
  98114. * @param useScreen defines if screen size must be used (or the current render target if any)
  98115. * @returns a number defining the aspect ratio
  98116. */
  98117. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98118. /**
  98119. * Gets current screen aspect ratio
  98120. * @returns a number defining the aspect ratio
  98121. */
  98122. getScreenAspectRatio(): number;
  98123. /**
  98124. * Gets host document
  98125. * @returns the host document object
  98126. */
  98127. getHostDocument(): Document;
  98128. /**
  98129. * Gets the client rect of the HTML canvas attached with the current webGL context
  98130. * @returns a client rectanglee
  98131. */
  98132. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98133. /**
  98134. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98135. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98136. * @returns true if engine is in deterministic lock step mode
  98137. */
  98138. isDeterministicLockStep(): boolean;
  98139. /**
  98140. * Gets the max steps when engine is running in deterministic lock step
  98141. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98142. * @returns the max steps
  98143. */
  98144. getLockstepMaxSteps(): number;
  98145. /**
  98146. * Force the mipmap generation for the given render target texture
  98147. * @param texture defines the render target texture to use
  98148. */
  98149. generateMipMapsForCubemap(texture: InternalTexture): void;
  98150. /** States */
  98151. /**
  98152. * Set various states to the webGL context
  98153. * @param culling defines backface culling state
  98154. * @param zOffset defines the value to apply to zOffset (0 by default)
  98155. * @param force defines if states must be applied even if cache is up to date
  98156. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98157. */
  98158. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98159. /**
  98160. * Set the z offset to apply to current rendering
  98161. * @param value defines the offset to apply
  98162. */
  98163. setZOffset(value: number): void;
  98164. /**
  98165. * Gets the current value of the zOffset
  98166. * @returns the current zOffset state
  98167. */
  98168. getZOffset(): number;
  98169. /**
  98170. * Enable or disable depth buffering
  98171. * @param enable defines the state to set
  98172. */
  98173. setDepthBuffer(enable: boolean): void;
  98174. /**
  98175. * Gets a boolean indicating if depth writing is enabled
  98176. * @returns the current depth writing state
  98177. */
  98178. getDepthWrite(): boolean;
  98179. /**
  98180. * Enable or disable depth writing
  98181. * @param enable defines the state to set
  98182. */
  98183. setDepthWrite(enable: boolean): void;
  98184. /**
  98185. * Enable or disable color writing
  98186. * @param enable defines the state to set
  98187. */
  98188. setColorWrite(enable: boolean): void;
  98189. /**
  98190. * Gets a boolean indicating if color writing is enabled
  98191. * @returns the current color writing state
  98192. */
  98193. getColorWrite(): boolean;
  98194. /**
  98195. * Sets alpha constants used by some alpha blending modes
  98196. * @param r defines the red component
  98197. * @param g defines the green component
  98198. * @param b defines the blue component
  98199. * @param a defines the alpha component
  98200. */
  98201. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98202. /**
  98203. * Sets the current alpha mode
  98204. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98205. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98206. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98207. */
  98208. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98209. /**
  98210. * Gets the current alpha mode
  98211. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98212. * @returns the current alpha mode
  98213. */
  98214. getAlphaMode(): number;
  98215. /**
  98216. * Sets the current alpha equation
  98217. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98218. */
  98219. setAlphaEquation(equation: number): void;
  98220. /**
  98221. * Gets the current alpha equation.
  98222. * @returns the current alpha equation
  98223. */
  98224. getAlphaEquation(): number;
  98225. /**
  98226. * Gets a boolean indicating if stencil buffer is enabled
  98227. * @returns the current stencil buffer state
  98228. */
  98229. getStencilBuffer(): boolean;
  98230. /**
  98231. * Enable or disable the stencil buffer
  98232. * @param enable defines if the stencil buffer must be enabled or disabled
  98233. */
  98234. setStencilBuffer(enable: boolean): void;
  98235. /**
  98236. * Gets the current stencil mask
  98237. * @returns a number defining the new stencil mask to use
  98238. */
  98239. getStencilMask(): number;
  98240. /**
  98241. * Sets the current stencil mask
  98242. * @param mask defines the new stencil mask to use
  98243. */
  98244. setStencilMask(mask: number): void;
  98245. /**
  98246. * Gets the current stencil function
  98247. * @returns a number defining the stencil function to use
  98248. */
  98249. getStencilFunction(): number;
  98250. /**
  98251. * Gets the current stencil reference value
  98252. * @returns a number defining the stencil reference value to use
  98253. */
  98254. getStencilFunctionReference(): number;
  98255. /**
  98256. * Gets the current stencil mask
  98257. * @returns a number defining the stencil mask to use
  98258. */
  98259. getStencilFunctionMask(): number;
  98260. /**
  98261. * Sets the current stencil function
  98262. * @param stencilFunc defines the new stencil function to use
  98263. */
  98264. setStencilFunction(stencilFunc: number): void;
  98265. /**
  98266. * Sets the current stencil reference
  98267. * @param reference defines the new stencil reference to use
  98268. */
  98269. setStencilFunctionReference(reference: number): void;
  98270. /**
  98271. * Sets the current stencil mask
  98272. * @param mask defines the new stencil mask to use
  98273. */
  98274. setStencilFunctionMask(mask: number): void;
  98275. /**
  98276. * Gets the current stencil operation when stencil fails
  98277. * @returns a number defining stencil operation to use when stencil fails
  98278. */
  98279. getStencilOperationFail(): number;
  98280. /**
  98281. * Gets the current stencil operation when depth fails
  98282. * @returns a number defining stencil operation to use when depth fails
  98283. */
  98284. getStencilOperationDepthFail(): number;
  98285. /**
  98286. * Gets the current stencil operation when stencil passes
  98287. * @returns a number defining stencil operation to use when stencil passes
  98288. */
  98289. getStencilOperationPass(): number;
  98290. /**
  98291. * Sets the stencil operation to use when stencil fails
  98292. * @param operation defines the stencil operation to use when stencil fails
  98293. */
  98294. setStencilOperationFail(operation: number): void;
  98295. /**
  98296. * Sets the stencil operation to use when depth fails
  98297. * @param operation defines the stencil operation to use when depth fails
  98298. */
  98299. setStencilOperationDepthFail(operation: number): void;
  98300. /**
  98301. * Sets the stencil operation to use when stencil passes
  98302. * @param operation defines the stencil operation to use when stencil passes
  98303. */
  98304. setStencilOperationPass(operation: number): void;
  98305. /**
  98306. * Sets a boolean indicating if the dithering state is enabled or disabled
  98307. * @param value defines the dithering state
  98308. */
  98309. setDitheringState(value: boolean): void;
  98310. /**
  98311. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98312. * @param value defines the rasterizer state
  98313. */
  98314. setRasterizerState(value: boolean): void;
  98315. /**
  98316. * Gets the current depth function
  98317. * @returns a number defining the depth function
  98318. */
  98319. getDepthFunction(): Nullable<number>;
  98320. /**
  98321. * Sets the current depth function
  98322. * @param depthFunc defines the function to use
  98323. */
  98324. setDepthFunction(depthFunc: number): void;
  98325. /**
  98326. * Sets the current depth function to GREATER
  98327. */
  98328. setDepthFunctionToGreater(): void;
  98329. /**
  98330. * Sets the current depth function to GEQUAL
  98331. */
  98332. setDepthFunctionToGreaterOrEqual(): void;
  98333. /**
  98334. * Sets the current depth function to LESS
  98335. */
  98336. setDepthFunctionToLess(): void;
  98337. /**
  98338. * Sets the current depth function to LEQUAL
  98339. */
  98340. setDepthFunctionToLessOrEqual(): void;
  98341. private _cachedStencilBuffer;
  98342. private _cachedStencilFunction;
  98343. private _cachedStencilMask;
  98344. private _cachedStencilOperationPass;
  98345. private _cachedStencilOperationFail;
  98346. private _cachedStencilOperationDepthFail;
  98347. private _cachedStencilReference;
  98348. /**
  98349. * Caches the the state of the stencil buffer
  98350. */
  98351. cacheStencilState(): void;
  98352. /**
  98353. * Restores the state of the stencil buffer
  98354. */
  98355. restoreStencilState(): void;
  98356. /**
  98357. * Directly set the WebGL Viewport
  98358. * @param x defines the x coordinate of the viewport (in screen space)
  98359. * @param y defines the y coordinate of the viewport (in screen space)
  98360. * @param width defines the width of the viewport (in screen space)
  98361. * @param height defines the height of the viewport (in screen space)
  98362. * @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
  98363. */
  98364. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98365. /**
  98366. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98367. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98368. * @param y defines the y-coordinate of the corner of the clear rectangle
  98369. * @param width defines the width of the clear rectangle
  98370. * @param height defines the height of the clear rectangle
  98371. * @param clearColor defines the clear color
  98372. */
  98373. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98374. /**
  98375. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98376. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98377. * @param y defines the y-coordinate of the corner of the clear rectangle
  98378. * @param width defines the width of the clear rectangle
  98379. * @param height defines the height of the clear rectangle
  98380. */
  98381. enableScissor(x: number, y: number, width: number, height: number): void;
  98382. /**
  98383. * Disable previously set scissor test rectangle
  98384. */
  98385. disableScissor(): void;
  98386. protected _reportDrawCall(): void;
  98387. /**
  98388. * Initializes a webVR display and starts listening to display change events
  98389. * The onVRDisplayChangedObservable will be notified upon these changes
  98390. * @returns The onVRDisplayChangedObservable
  98391. */
  98392. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98393. /** @hidden */
  98394. _prepareVRComponent(): void;
  98395. /** @hidden */
  98396. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98397. /** @hidden */
  98398. _submitVRFrame(): void;
  98399. /**
  98400. * Call this function to leave webVR mode
  98401. * Will do nothing if webVR is not supported or if there is no webVR device
  98402. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98403. */
  98404. disableVR(): void;
  98405. /**
  98406. * Gets a boolean indicating that the system is in VR mode and is presenting
  98407. * @returns true if VR mode is engaged
  98408. */
  98409. isVRPresenting(): boolean;
  98410. /** @hidden */
  98411. _requestVRFrame(): void;
  98412. /** @hidden */
  98413. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98414. /**
  98415. * Gets the source code of the vertex shader associated with a specific webGL program
  98416. * @param program defines the program to use
  98417. * @returns a string containing the source code of the vertex shader associated with the program
  98418. */
  98419. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98420. /**
  98421. * Gets the source code of the fragment shader associated with a specific webGL program
  98422. * @param program defines the program to use
  98423. * @returns a string containing the source code of the fragment shader associated with the program
  98424. */
  98425. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98426. /**
  98427. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98428. * @param x defines the x coordinate of the rectangle where pixels must be read
  98429. * @param y defines the y coordinate of the rectangle where pixels must be read
  98430. * @param width defines the width of the rectangle where pixels must be read
  98431. * @param height defines the height of the rectangle where pixels must be read
  98432. * @returns a Uint8Array containing RGBA colors
  98433. */
  98434. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98435. /**
  98436. * Sets a depth stencil texture from a render target to the according uniform.
  98437. * @param channel The texture channel
  98438. * @param uniform The uniform to set
  98439. * @param texture The render target texture containing the depth stencil texture to apply
  98440. */
  98441. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98442. /**
  98443. * Sets a texture to the webGL context from a postprocess
  98444. * @param channel defines the channel to use
  98445. * @param postProcess defines the source postprocess
  98446. */
  98447. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98448. /**
  98449. * Binds the output of the passed in post process to the texture channel specified
  98450. * @param channel The channel the texture should be bound to
  98451. * @param postProcess The post process which's output should be bound
  98452. */
  98453. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98454. /** @hidden */
  98455. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98456. protected _rebuildBuffers(): void;
  98457. _renderLoop(): void;
  98458. /**
  98459. * Toggle full screen mode
  98460. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98461. */
  98462. switchFullscreen(requestPointerLock: boolean): void;
  98463. /**
  98464. * Enters full screen mode
  98465. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98466. */
  98467. enterFullscreen(requestPointerLock: boolean): void;
  98468. /**
  98469. * Exits full screen mode
  98470. */
  98471. exitFullscreen(): void;
  98472. /**
  98473. * Enters Pointerlock mode
  98474. */
  98475. enterPointerlock(): void;
  98476. /**
  98477. * Exits Pointerlock mode
  98478. */
  98479. exitPointerlock(): void;
  98480. /**
  98481. * Begin a new frame
  98482. */
  98483. beginFrame(): void;
  98484. /**
  98485. * Enf the current frame
  98486. */
  98487. endFrame(): void;
  98488. resize(): void;
  98489. /**
  98490. * Set the compressed texture format to use, based on the formats you have, and the formats
  98491. * supported by the hardware / browser.
  98492. *
  98493. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98494. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98495. * to API arguments needed to compressed textures. This puts the burden on the container
  98496. * generator to house the arcane code for determining these for current & future formats.
  98497. *
  98498. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98499. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98500. *
  98501. * Note: The result of this call is not taken into account when a texture is base64.
  98502. *
  98503. * @param formatsAvailable defines the list of those format families you have created
  98504. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98505. *
  98506. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98507. * @returns The extension selected.
  98508. */
  98509. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98510. /**
  98511. * Force a specific size of the canvas
  98512. * @param width defines the new canvas' width
  98513. * @param height defines the new canvas' height
  98514. */
  98515. setSize(width: number, height: number): void;
  98516. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98517. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98518. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98519. _releaseTexture(texture: InternalTexture): void;
  98520. /**
  98521. * @hidden
  98522. * Rescales a texture
  98523. * @param source input texutre
  98524. * @param destination destination texture
  98525. * @param scene scene to use to render the resize
  98526. * @param internalFormat format to use when resizing
  98527. * @param onComplete callback to be called when resize has completed
  98528. */
  98529. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98530. /**
  98531. * Gets the current framerate
  98532. * @returns a number representing the framerate
  98533. */
  98534. getFps(): number;
  98535. /**
  98536. * Gets the time spent between current and previous frame
  98537. * @returns a number representing the delta time in ms
  98538. */
  98539. getDeltaTime(): number;
  98540. private _measureFps;
  98541. /**
  98542. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  98543. * @param renderTarget The render target to set the frame buffer for
  98544. */
  98545. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  98546. /**
  98547. * Update a dynamic index buffer
  98548. * @param indexBuffer defines the target index buffer
  98549. * @param indices defines the data to update
  98550. * @param offset defines the offset in the target index buffer where update should start
  98551. */
  98552. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  98553. /**
  98554. * Updates the sample count of a render target texture
  98555. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98556. * @param texture defines the texture to update
  98557. * @param samples defines the sample count to set
  98558. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98559. */
  98560. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98561. /** @hidden */
  98562. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98563. dispose(): void;
  98564. private _disableTouchAction;
  98565. /**
  98566. * Display the loading screen
  98567. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98568. */
  98569. displayLoadingUI(): void;
  98570. /**
  98571. * Hide the loading screen
  98572. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98573. */
  98574. hideLoadingUI(): void;
  98575. /**
  98576. * Gets the current loading screen object
  98577. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98578. */
  98579. /**
  98580. * Sets the current loading screen object
  98581. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98582. */
  98583. loadingScreen: ILoadingScreen;
  98584. /**
  98585. * Sets the current loading screen text
  98586. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98587. */
  98588. loadingUIText: string;
  98589. /**
  98590. * Sets the current loading screen background color
  98591. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98592. */
  98593. loadingUIBackgroundColor: string;
  98594. /** Pointerlock and fullscreen */
  98595. /**
  98596. * Ask the browser to promote the current element to pointerlock mode
  98597. * @param element defines the DOM element to promote
  98598. */
  98599. static _RequestPointerlock(element: HTMLElement): void;
  98600. /**
  98601. * Asks the browser to exit pointerlock mode
  98602. */
  98603. static _ExitPointerlock(): void;
  98604. /**
  98605. * Ask the browser to promote the current element to fullscreen rendering mode
  98606. * @param element defines the DOM element to promote
  98607. */
  98608. static _RequestFullscreen(element: HTMLElement): void;
  98609. /**
  98610. * Asks the browser to exit fullscreen mode
  98611. */
  98612. static _ExitFullscreen(): void;
  98613. }
  98614. }
  98615. declare module BABYLON {
  98616. /**
  98617. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98618. * during the life time of the application.
  98619. */
  98620. export class EngineStore {
  98621. /** Gets the list of created engines */
  98622. static Instances: Engine[];
  98623. /** @hidden */
  98624. static _LastCreatedScene: Nullable<Scene>;
  98625. /**
  98626. * Gets the latest created engine
  98627. */
  98628. static readonly LastCreatedEngine: Nullable<Engine>;
  98629. /**
  98630. * Gets the latest created scene
  98631. */
  98632. static readonly LastCreatedScene: Nullable<Scene>;
  98633. /**
  98634. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98635. * @ignorenaming
  98636. */
  98637. static UseFallbackTexture: boolean;
  98638. /**
  98639. * Texture content used if a texture cannot loaded
  98640. * @ignorenaming
  98641. */
  98642. static FallbackTexture: string;
  98643. }
  98644. }
  98645. declare module BABYLON {
  98646. /**
  98647. * Helper class that provides a small promise polyfill
  98648. */
  98649. export class PromisePolyfill {
  98650. /**
  98651. * Static function used to check if the polyfill is required
  98652. * If this is the case then the function will inject the polyfill to window.Promise
  98653. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98654. */
  98655. static Apply(force?: boolean): void;
  98656. }
  98657. }
  98658. declare module BABYLON {
  98659. /**
  98660. * Interface for screenshot methods with describe argument called `size` as object with options
  98661. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98662. */
  98663. export interface IScreenshotSize {
  98664. /**
  98665. * number in pixels for canvas height
  98666. */
  98667. height?: number;
  98668. /**
  98669. * multiplier allowing render at a higher or lower resolution
  98670. * If value is defined then height and width will be ignored and taken from camera
  98671. */
  98672. precision?: number;
  98673. /**
  98674. * number in pixels for canvas width
  98675. */
  98676. width?: number;
  98677. }
  98678. }
  98679. declare module BABYLON {
  98680. interface IColor4Like {
  98681. r: float;
  98682. g: float;
  98683. b: float;
  98684. a: float;
  98685. }
  98686. /**
  98687. * Class containing a set of static utilities functions
  98688. */
  98689. export class Tools {
  98690. /**
  98691. * Gets or sets the base URL to use to load assets
  98692. */
  98693. static BaseUrl: string;
  98694. /**
  98695. * Enable/Disable Custom HTTP Request Headers globally.
  98696. * default = false
  98697. * @see CustomRequestHeaders
  98698. */
  98699. static UseCustomRequestHeaders: boolean;
  98700. /**
  98701. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98702. * i.e. when loading files, where the server/service expects an Authorization header
  98703. */
  98704. static CustomRequestHeaders: {
  98705. [key: string]: string;
  98706. };
  98707. /**
  98708. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98709. */
  98710. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98711. /**
  98712. * Default behaviour for cors in the application.
  98713. * It can be a string if the expected behavior is identical in the entire app.
  98714. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98715. */
  98716. static CorsBehavior: string | ((url: string | string[]) => string);
  98717. /**
  98718. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98719. * @ignorenaming
  98720. */
  98721. static UseFallbackTexture: boolean;
  98722. /**
  98723. * Use this object to register external classes like custom textures or material
  98724. * to allow the laoders to instantiate them
  98725. */
  98726. static RegisteredExternalClasses: {
  98727. [key: string]: Object;
  98728. };
  98729. /**
  98730. * Texture content used if a texture cannot loaded
  98731. * @ignorenaming
  98732. */
  98733. static fallbackTexture: string;
  98734. /**
  98735. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98736. * @param u defines the coordinate on X axis
  98737. * @param v defines the coordinate on Y axis
  98738. * @param width defines the width of the source data
  98739. * @param height defines the height of the source data
  98740. * @param pixels defines the source byte array
  98741. * @param color defines the output color
  98742. */
  98743. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98744. /**
  98745. * Interpolates between a and b via alpha
  98746. * @param a The lower value (returned when alpha = 0)
  98747. * @param b The upper value (returned when alpha = 1)
  98748. * @param alpha The interpolation-factor
  98749. * @return The mixed value
  98750. */
  98751. static Mix(a: number, b: number, alpha: number): number;
  98752. /**
  98753. * Tries to instantiate a new object from a given class name
  98754. * @param className defines the class name to instantiate
  98755. * @returns the new object or null if the system was not able to do the instantiation
  98756. */
  98757. static Instantiate(className: string): any;
  98758. /**
  98759. * Provides a slice function that will work even on IE
  98760. * @param data defines the array to slice
  98761. * @param start defines the start of the data (optional)
  98762. * @param end defines the end of the data (optional)
  98763. * @returns the new sliced array
  98764. */
  98765. static Slice<T>(data: T, start?: number, end?: number): T;
  98766. /**
  98767. * Polyfill for setImmediate
  98768. * @param action defines the action to execute after the current execution block
  98769. */
  98770. static SetImmediate(action: () => void): void;
  98771. /**
  98772. * Function indicating if a number is an exponent of 2
  98773. * @param value defines the value to test
  98774. * @returns true if the value is an exponent of 2
  98775. */
  98776. static IsExponentOfTwo(value: number): boolean;
  98777. private static _tmpFloatArray;
  98778. /**
  98779. * Returns the nearest 32-bit single precision float representation of a Number
  98780. * @param value A Number. If the parameter is of a different type, it will get converted
  98781. * to a number or to NaN if it cannot be converted
  98782. * @returns number
  98783. */
  98784. static FloatRound(value: number): number;
  98785. /**
  98786. * Extracts the filename from a path
  98787. * @param path defines the path to use
  98788. * @returns the filename
  98789. */
  98790. static GetFilename(path: string): string;
  98791. /**
  98792. * Extracts the "folder" part of a path (everything before the filename).
  98793. * @param uri The URI to extract the info from
  98794. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98795. * @returns The "folder" part of the path
  98796. */
  98797. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98798. /**
  98799. * Extracts text content from a DOM element hierarchy
  98800. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98801. */
  98802. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98803. /**
  98804. * Convert an angle in radians to degrees
  98805. * @param angle defines the angle to convert
  98806. * @returns the angle in degrees
  98807. */
  98808. static ToDegrees(angle: number): number;
  98809. /**
  98810. * Convert an angle in degrees to radians
  98811. * @param angle defines the angle to convert
  98812. * @returns the angle in radians
  98813. */
  98814. static ToRadians(angle: number): number;
  98815. /**
  98816. * Encode a buffer to a base64 string
  98817. * @param buffer defines the buffer to encode
  98818. * @returns the encoded string
  98819. */
  98820. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98821. /**
  98822. * Returns an array if obj is not an array
  98823. * @param obj defines the object to evaluate as an array
  98824. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98825. * @returns either obj directly if obj is an array or a new array containing obj
  98826. */
  98827. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98828. /**
  98829. * Gets the pointer prefix to use
  98830. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98831. */
  98832. static GetPointerPrefix(): string;
  98833. /**
  98834. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98835. * @param url define the url we are trying
  98836. * @param element define the dom element where to configure the cors policy
  98837. */
  98838. static SetCorsBehavior(url: string | string[], element: {
  98839. crossOrigin: string | null;
  98840. }): void;
  98841. /**
  98842. * Removes unwanted characters from an url
  98843. * @param url defines the url to clean
  98844. * @returns the cleaned url
  98845. */
  98846. static CleanUrl(url: string): string;
  98847. /**
  98848. * Gets or sets a function used to pre-process url before using them to load assets
  98849. */
  98850. static PreprocessUrl: (url: string) => string;
  98851. /**
  98852. * Loads an image as an HTMLImageElement.
  98853. * @param input url string, ArrayBuffer, or Blob to load
  98854. * @param onLoad callback called when the image successfully loads
  98855. * @param onError callback called when the image fails to load
  98856. * @param offlineProvider offline provider for caching
  98857. * @param mimeType optional mime type
  98858. * @returns the HTMLImageElement of the loaded image
  98859. */
  98860. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): HTMLImageElement;
  98861. /**
  98862. * Loads a file
  98863. * @param url url string, ArrayBuffer, or Blob to load
  98864. * @param onSuccess callback called when the file successfully loads
  98865. * @param onProgress callback called while file is loading (if the server supports this mode)
  98866. * @param offlineProvider defines the offline provider for caching
  98867. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98868. * @param onError callback called when the file fails to load
  98869. * @returns a file request object
  98870. */
  98871. 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;
  98872. /**
  98873. * Loads a file from a url
  98874. * @param url the file url to load
  98875. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98876. */
  98877. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98878. /**
  98879. * Load a script (identified by an url). When the url returns, the
  98880. * content of this file is added into a new script element, attached to the DOM (body element)
  98881. * @param scriptUrl defines the url of the script to laod
  98882. * @param onSuccess defines the callback called when the script is loaded
  98883. * @param onError defines the callback to call if an error occurs
  98884. * @param scriptId defines the id of the script element
  98885. */
  98886. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98887. /**
  98888. * Load an asynchronous script (identified by an url). When the url returns, the
  98889. * content of this file is added into a new script element, attached to the DOM (body element)
  98890. * @param scriptUrl defines the url of the script to laod
  98891. * @param scriptId defines the id of the script element
  98892. * @returns a promise request object
  98893. */
  98894. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98895. /**
  98896. * Loads a file from a blob
  98897. * @param fileToLoad defines the blob to use
  98898. * @param callback defines the callback to call when data is loaded
  98899. * @param progressCallback defines the callback to call during loading process
  98900. * @returns a file request object
  98901. */
  98902. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98903. /**
  98904. * Loads a file
  98905. * @param fileToLoad defines the file to load
  98906. * @param callback defines the callback to call when data is loaded
  98907. * @param progressCallBack defines the callback to call during loading process
  98908. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98909. * @returns a file request object
  98910. */
  98911. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98912. /**
  98913. * Creates a data url from a given string content
  98914. * @param content defines the content to convert
  98915. * @returns the new data url link
  98916. */
  98917. static FileAsURL(content: string): string;
  98918. /**
  98919. * Format the given number to a specific decimal format
  98920. * @param value defines the number to format
  98921. * @param decimals defines the number of decimals to use
  98922. * @returns the formatted string
  98923. */
  98924. static Format(value: number, decimals?: number): string;
  98925. /**
  98926. * Tries to copy an object by duplicating every property
  98927. * @param source defines the source object
  98928. * @param destination defines the target object
  98929. * @param doNotCopyList defines a list of properties to avoid
  98930. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98931. */
  98932. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98933. /**
  98934. * Gets a boolean indicating if the given object has no own property
  98935. * @param obj defines the object to test
  98936. * @returns true if object has no own property
  98937. */
  98938. static IsEmpty(obj: any): boolean;
  98939. /**
  98940. * Function used to register events at window level
  98941. * @param windowElement defines the Window object to use
  98942. * @param events defines the events to register
  98943. */
  98944. static RegisterTopRootEvents(windowElement: Window, events: {
  98945. name: string;
  98946. handler: Nullable<(e: FocusEvent) => any>;
  98947. }[]): void;
  98948. /**
  98949. * Function used to unregister events from window level
  98950. * @param windowElement defines the Window object to use
  98951. * @param events defines the events to unregister
  98952. */
  98953. static UnregisterTopRootEvents(windowElement: Window, events: {
  98954. name: string;
  98955. handler: Nullable<(e: FocusEvent) => any>;
  98956. }[]): void;
  98957. /**
  98958. * @ignore
  98959. */
  98960. static _ScreenshotCanvas: HTMLCanvasElement;
  98961. /**
  98962. * Dumps the current bound framebuffer
  98963. * @param width defines the rendering width
  98964. * @param height defines the rendering height
  98965. * @param engine defines the hosting engine
  98966. * @param successCallback defines the callback triggered once the data are available
  98967. * @param mimeType defines the mime type of the result
  98968. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  98969. */
  98970. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98971. /**
  98972. * Converts the canvas data to blob.
  98973. * This acts as a polyfill for browsers not supporting the to blob function.
  98974. * @param canvas Defines the canvas to extract the data from
  98975. * @param successCallback Defines the callback triggered once the data are available
  98976. * @param mimeType Defines the mime type of the result
  98977. */
  98978. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  98979. /**
  98980. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  98981. * @param successCallback defines the callback triggered once the data are available
  98982. * @param mimeType defines the mime type of the result
  98983. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  98984. */
  98985. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  98986. /**
  98987. * Downloads a blob in the browser
  98988. * @param blob defines the blob to download
  98989. * @param fileName defines the name of the downloaded file
  98990. */
  98991. static Download(blob: Blob, fileName: string): void;
  98992. /**
  98993. * Captures a screenshot of the current rendering
  98994. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  98995. * @param engine defines the rendering engine
  98996. * @param camera defines the source camera
  98997. * @param size This parameter can be set to a single number or to an object with the
  98998. * following (optional) properties: precision, width, height. If a single number is passed,
  98999. * it will be used for both width and height. If an object is passed, the screenshot size
  99000. * will be derived from the parameters. The precision property is a multiplier allowing
  99001. * rendering at a higher or lower resolution
  99002. * @param successCallback defines the callback receives a single parameter which contains the
  99003. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99004. * src parameter of an <img> to display it
  99005. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99006. * Check your browser for supported MIME types
  99007. */
  99008. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99009. /**
  99010. * Captures a screenshot of the current rendering
  99011. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99012. * @param engine defines the rendering engine
  99013. * @param camera defines the source camera
  99014. * @param size This parameter can be set to a single number or to an object with the
  99015. * following (optional) properties: precision, width, height. If a single number is passed,
  99016. * it will be used for both width and height. If an object is passed, the screenshot size
  99017. * will be derived from the parameters. The precision property is a multiplier allowing
  99018. * rendering at a higher or lower resolution
  99019. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99020. * Check your browser for supported MIME types
  99021. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99022. * to the src parameter of an <img> to display it
  99023. */
  99024. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99025. /**
  99026. * Generates an image screenshot from the specified camera.
  99027. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99028. * @param engine The engine to use for rendering
  99029. * @param camera The camera to use for rendering
  99030. * @param size This parameter can be set to a single number or to an object with the
  99031. * following (optional) properties: precision, width, height. If a single number is passed,
  99032. * it will be used for both width and height. If an object is passed, the screenshot size
  99033. * will be derived from the parameters. The precision property is a multiplier allowing
  99034. * rendering at a higher or lower resolution
  99035. * @param successCallback The callback receives a single parameter which contains the
  99036. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99037. * src parameter of an <img> to display it
  99038. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99039. * Check your browser for supported MIME types
  99040. * @param samples Texture samples (default: 1)
  99041. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99042. * @param fileName A name for for the downloaded file.
  99043. */
  99044. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99045. /**
  99046. * Generates an image screenshot from the specified camera.
  99047. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99048. * @param engine The engine to use for rendering
  99049. * @param camera The camera to use for rendering
  99050. * @param size This parameter can be set to a single number or to an object with the
  99051. * following (optional) properties: precision, width, height. If a single number is passed,
  99052. * it will be used for both width and height. If an object is passed, the screenshot size
  99053. * will be derived from the parameters. The precision property is a multiplier allowing
  99054. * rendering at a higher or lower resolution
  99055. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99056. * Check your browser for supported MIME types
  99057. * @param samples Texture samples (default: 1)
  99058. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99059. * @param fileName A name for for the downloaded file.
  99060. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99061. * to the src parameter of an <img> to display it
  99062. */
  99063. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99064. /**
  99065. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99066. * Be aware Math.random() could cause collisions, but:
  99067. * "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"
  99068. * @returns a pseudo random id
  99069. */
  99070. static RandomId(): string;
  99071. /**
  99072. * Test if the given uri is a base64 string
  99073. * @param uri The uri to test
  99074. * @return True if the uri is a base64 string or false otherwise
  99075. */
  99076. static IsBase64(uri: string): boolean;
  99077. /**
  99078. * Decode the given base64 uri.
  99079. * @param uri The uri to decode
  99080. * @return The decoded base64 data.
  99081. */
  99082. static DecodeBase64(uri: string): ArrayBuffer;
  99083. /**
  99084. * Gets the absolute url.
  99085. * @param url the input url
  99086. * @return the absolute url
  99087. */
  99088. static GetAbsoluteUrl(url: string): string;
  99089. /**
  99090. * No log
  99091. */
  99092. static readonly NoneLogLevel: number;
  99093. /**
  99094. * Only message logs
  99095. */
  99096. static readonly MessageLogLevel: number;
  99097. /**
  99098. * Only warning logs
  99099. */
  99100. static readonly WarningLogLevel: number;
  99101. /**
  99102. * Only error logs
  99103. */
  99104. static readonly ErrorLogLevel: number;
  99105. /**
  99106. * All logs
  99107. */
  99108. static readonly AllLogLevel: number;
  99109. /**
  99110. * Gets a value indicating the number of loading errors
  99111. * @ignorenaming
  99112. */
  99113. static readonly errorsCount: number;
  99114. /**
  99115. * Callback called when a new log is added
  99116. */
  99117. static OnNewCacheEntry: (entry: string) => void;
  99118. /**
  99119. * Log a message to the console
  99120. * @param message defines the message to log
  99121. */
  99122. static Log(message: string): void;
  99123. /**
  99124. * Write a warning message to the console
  99125. * @param message defines the message to log
  99126. */
  99127. static Warn(message: string): void;
  99128. /**
  99129. * Write an error message to the console
  99130. * @param message defines the message to log
  99131. */
  99132. static Error(message: string): void;
  99133. /**
  99134. * Gets current log cache (list of logs)
  99135. */
  99136. static readonly LogCache: string;
  99137. /**
  99138. * Clears the log cache
  99139. */
  99140. static ClearLogCache(): void;
  99141. /**
  99142. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99143. */
  99144. static LogLevels: number;
  99145. /**
  99146. * Checks if the window object exists
  99147. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99148. */
  99149. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99150. /**
  99151. * No performance log
  99152. */
  99153. static readonly PerformanceNoneLogLevel: number;
  99154. /**
  99155. * Use user marks to log performance
  99156. */
  99157. static readonly PerformanceUserMarkLogLevel: number;
  99158. /**
  99159. * Log performance to the console
  99160. */
  99161. static readonly PerformanceConsoleLogLevel: number;
  99162. private static _performance;
  99163. /**
  99164. * Sets the current performance log level
  99165. */
  99166. static PerformanceLogLevel: number;
  99167. private static _StartPerformanceCounterDisabled;
  99168. private static _EndPerformanceCounterDisabled;
  99169. private static _StartUserMark;
  99170. private static _EndUserMark;
  99171. private static _StartPerformanceConsole;
  99172. private static _EndPerformanceConsole;
  99173. /**
  99174. * Starts a performance counter
  99175. */
  99176. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99177. /**
  99178. * Ends a specific performance coutner
  99179. */
  99180. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99181. /**
  99182. * Gets either window.performance.now() if supported or Date.now() else
  99183. */
  99184. static readonly Now: number;
  99185. /**
  99186. * This method will return the name of the class used to create the instance of the given object.
  99187. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99188. * @param object the object to get the class name from
  99189. * @param isType defines if the object is actually a type
  99190. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99191. */
  99192. static GetClassName(object: any, isType?: boolean): string;
  99193. /**
  99194. * Gets the first element of an array satisfying a given predicate
  99195. * @param array defines the array to browse
  99196. * @param predicate defines the predicate to use
  99197. * @returns null if not found or the element
  99198. */
  99199. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99200. /**
  99201. * This method will return the name of the full name of the class, including its owning module (if any).
  99202. * 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).
  99203. * @param object the object to get the class name from
  99204. * @param isType defines if the object is actually a type
  99205. * @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.
  99206. * @ignorenaming
  99207. */
  99208. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99209. /**
  99210. * Returns a promise that resolves after the given amount of time.
  99211. * @param delay Number of milliseconds to delay
  99212. * @returns Promise that resolves after the given amount of time
  99213. */
  99214. static DelayAsync(delay: number): Promise<void>;
  99215. }
  99216. /**
  99217. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99218. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99219. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99220. * @param name The name of the class, case should be preserved
  99221. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99222. */
  99223. export function className(name: string, module?: string): (target: Object) => void;
  99224. /**
  99225. * An implementation of a loop for asynchronous functions.
  99226. */
  99227. export class AsyncLoop {
  99228. /**
  99229. * Defines the number of iterations for the loop
  99230. */
  99231. iterations: number;
  99232. /**
  99233. * Defines the current index of the loop.
  99234. */
  99235. index: number;
  99236. private _done;
  99237. private _fn;
  99238. private _successCallback;
  99239. /**
  99240. * Constructor.
  99241. * @param iterations the number of iterations.
  99242. * @param func the function to run each iteration
  99243. * @param successCallback the callback that will be called upon succesful execution
  99244. * @param offset starting offset.
  99245. */
  99246. constructor(
  99247. /**
  99248. * Defines the number of iterations for the loop
  99249. */
  99250. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99251. /**
  99252. * Execute the next iteration. Must be called after the last iteration was finished.
  99253. */
  99254. executeNext(): void;
  99255. /**
  99256. * Break the loop and run the success callback.
  99257. */
  99258. breakLoop(): void;
  99259. /**
  99260. * Create and run an async loop.
  99261. * @param iterations the number of iterations.
  99262. * @param fn the function to run each iteration
  99263. * @param successCallback the callback that will be called upon succesful execution
  99264. * @param offset starting offset.
  99265. * @returns the created async loop object
  99266. */
  99267. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99268. /**
  99269. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99270. * @param iterations total number of iterations
  99271. * @param syncedIterations number of synchronous iterations in each async iteration.
  99272. * @param fn the function to call each iteration.
  99273. * @param callback a success call back that will be called when iterating stops.
  99274. * @param breakFunction a break condition (optional)
  99275. * @param timeout timeout settings for the setTimeout function. default - 0.
  99276. * @returns the created async loop object
  99277. */
  99278. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99279. }
  99280. }
  99281. declare module BABYLON {
  99282. /**
  99283. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99284. * The underlying implementation relies on an associative array to ensure the best performances.
  99285. * The value can be anything including 'null' but except 'undefined'
  99286. */
  99287. export class StringDictionary<T> {
  99288. /**
  99289. * This will clear this dictionary and copy the content from the 'source' one.
  99290. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99291. * @param source the dictionary to take the content from and copy to this dictionary
  99292. */
  99293. copyFrom(source: StringDictionary<T>): void;
  99294. /**
  99295. * Get a value based from its key
  99296. * @param key the given key to get the matching value from
  99297. * @return the value if found, otherwise undefined is returned
  99298. */
  99299. get(key: string): T | undefined;
  99300. /**
  99301. * Get a value from its key or add it if it doesn't exist.
  99302. * This method will ensure you that a given key/data will be present in the dictionary.
  99303. * @param key the given key to get the matching value from
  99304. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99305. * The factory will only be invoked if there's no data for the given key.
  99306. * @return the value corresponding to the key.
  99307. */
  99308. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99309. /**
  99310. * Get a value from its key if present in the dictionary otherwise add it
  99311. * @param key the key to get the value from
  99312. * @param val if there's no such key/value pair in the dictionary add it with this value
  99313. * @return the value corresponding to the key
  99314. */
  99315. getOrAdd(key: string, val: T): T;
  99316. /**
  99317. * Check if there's a given key in the dictionary
  99318. * @param key the key to check for
  99319. * @return true if the key is present, false otherwise
  99320. */
  99321. contains(key: string): boolean;
  99322. /**
  99323. * Add a new key and its corresponding value
  99324. * @param key the key to add
  99325. * @param value the value corresponding to the key
  99326. * @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
  99327. */
  99328. add(key: string, value: T): boolean;
  99329. /**
  99330. * Update a specific value associated to a key
  99331. * @param key defines the key to use
  99332. * @param value defines the value to store
  99333. * @returns true if the value was updated (or false if the key was not found)
  99334. */
  99335. set(key: string, value: T): boolean;
  99336. /**
  99337. * Get the element of the given key and remove it from the dictionary
  99338. * @param key defines the key to search
  99339. * @returns the value associated with the key or null if not found
  99340. */
  99341. getAndRemove(key: string): Nullable<T>;
  99342. /**
  99343. * Remove a key/value from the dictionary.
  99344. * @param key the key to remove
  99345. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99346. */
  99347. remove(key: string): boolean;
  99348. /**
  99349. * Clear the whole content of the dictionary
  99350. */
  99351. clear(): void;
  99352. /**
  99353. * Gets the current count
  99354. */
  99355. readonly count: number;
  99356. /**
  99357. * Execute a callback on each key/val of the dictionary.
  99358. * Note that you can remove any element in this dictionary in the callback implementation
  99359. * @param callback the callback to execute on a given key/value pair
  99360. */
  99361. forEach(callback: (key: string, val: T) => void): void;
  99362. /**
  99363. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99364. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99365. * Note that you can remove any element in this dictionary in the callback implementation
  99366. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99367. * @returns the first item
  99368. */
  99369. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99370. private _count;
  99371. private _data;
  99372. }
  99373. }
  99374. declare module BABYLON {
  99375. /** @hidden */
  99376. export interface ICollisionCoordinator {
  99377. createCollider(): Collider;
  99378. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99379. init(scene: Scene): void;
  99380. }
  99381. /** @hidden */
  99382. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99383. private _scene;
  99384. private _scaledPosition;
  99385. private _scaledVelocity;
  99386. private _finalPosition;
  99387. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99388. createCollider(): Collider;
  99389. init(scene: Scene): void;
  99390. private _collideWithWorld;
  99391. }
  99392. }
  99393. declare module BABYLON {
  99394. /**
  99395. * Class used to manage all inputs for the scene.
  99396. */
  99397. export class InputManager {
  99398. /** The distance in pixel that you have to move to prevent some events */
  99399. static DragMovementThreshold: number;
  99400. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99401. static LongPressDelay: number;
  99402. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99403. static DoubleClickDelay: number;
  99404. /** If you need to check double click without raising a single click at first click, enable this flag */
  99405. static ExclusiveDoubleClickMode: boolean;
  99406. private _wheelEventName;
  99407. private _onPointerMove;
  99408. private _onPointerDown;
  99409. private _onPointerUp;
  99410. private _initClickEvent;
  99411. private _initActionManager;
  99412. private _delayedSimpleClick;
  99413. private _delayedSimpleClickTimeout;
  99414. private _previousDelayedSimpleClickTimeout;
  99415. private _meshPickProceed;
  99416. private _previousButtonPressed;
  99417. private _currentPickResult;
  99418. private _previousPickResult;
  99419. private _totalPointersPressed;
  99420. private _doubleClickOccured;
  99421. private _pointerOverMesh;
  99422. private _pickedDownMesh;
  99423. private _pickedUpMesh;
  99424. private _pointerX;
  99425. private _pointerY;
  99426. private _unTranslatedPointerX;
  99427. private _unTranslatedPointerY;
  99428. private _startingPointerPosition;
  99429. private _previousStartingPointerPosition;
  99430. private _startingPointerTime;
  99431. private _previousStartingPointerTime;
  99432. private _pointerCaptures;
  99433. private _onKeyDown;
  99434. private _onKeyUp;
  99435. private _onCanvasFocusObserver;
  99436. private _onCanvasBlurObserver;
  99437. private _scene;
  99438. /**
  99439. * Creates a new InputManager
  99440. * @param scene defines the hosting scene
  99441. */
  99442. constructor(scene: Scene);
  99443. /**
  99444. * Gets the mesh that is currently under the pointer
  99445. */
  99446. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99447. /**
  99448. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99449. */
  99450. readonly unTranslatedPointer: Vector2;
  99451. /**
  99452. * Gets or sets the current on-screen X position of the pointer
  99453. */
  99454. pointerX: number;
  99455. /**
  99456. * Gets or sets the current on-screen Y position of the pointer
  99457. */
  99458. pointerY: number;
  99459. private _updatePointerPosition;
  99460. private _processPointerMove;
  99461. private _setRayOnPointerInfo;
  99462. private _checkPrePointerObservable;
  99463. /**
  99464. * Use this method to simulate a pointer move on a mesh
  99465. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99466. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99467. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99468. */
  99469. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99470. /**
  99471. * Use this method to simulate a pointer down on a mesh
  99472. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99473. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99474. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99475. */
  99476. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99477. private _processPointerDown;
  99478. /** @hidden */
  99479. _isPointerSwiping(): boolean;
  99480. /**
  99481. * Use this method to simulate a pointer up on a mesh
  99482. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99483. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99484. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99485. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99486. */
  99487. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99488. private _processPointerUp;
  99489. /**
  99490. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99491. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99492. * @returns true if the pointer was captured
  99493. */
  99494. isPointerCaptured(pointerId?: number): boolean;
  99495. /**
  99496. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99497. * @param attachUp defines if you want to attach events to pointerup
  99498. * @param attachDown defines if you want to attach events to pointerdown
  99499. * @param attachMove defines if you want to attach events to pointermove
  99500. */
  99501. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99502. /**
  99503. * Detaches all event handlers
  99504. */
  99505. detachControl(): void;
  99506. /**
  99507. * Force the value of meshUnderPointer
  99508. * @param mesh defines the mesh to use
  99509. */
  99510. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99511. /**
  99512. * Gets the mesh under the pointer
  99513. * @returns a Mesh or null if no mesh is under the pointer
  99514. */
  99515. getPointerOverMesh(): Nullable<AbstractMesh>;
  99516. }
  99517. }
  99518. declare module BABYLON {
  99519. /**
  99520. * Helper class used to generate session unique ID
  99521. */
  99522. export class UniqueIdGenerator {
  99523. private static _UniqueIdCounter;
  99524. /**
  99525. * Gets an unique (relatively to the current scene) Id
  99526. */
  99527. static readonly UniqueId: number;
  99528. }
  99529. }
  99530. declare module BABYLON {
  99531. /**
  99532. * This class defines the direct association between an animation and a target
  99533. */
  99534. export class TargetedAnimation {
  99535. /**
  99536. * Animation to perform
  99537. */
  99538. animation: Animation;
  99539. /**
  99540. * Target to animate
  99541. */
  99542. target: any;
  99543. /**
  99544. * Serialize the object
  99545. * @returns the JSON object representing the current entity
  99546. */
  99547. serialize(): any;
  99548. }
  99549. /**
  99550. * Use this class to create coordinated animations on multiple targets
  99551. */
  99552. export class AnimationGroup implements IDisposable {
  99553. /** The name of the animation group */
  99554. name: string;
  99555. private _scene;
  99556. private _targetedAnimations;
  99557. private _animatables;
  99558. private _from;
  99559. private _to;
  99560. private _isStarted;
  99561. private _isPaused;
  99562. private _speedRatio;
  99563. private _loopAnimation;
  99564. /**
  99565. * Gets or sets the unique id of the node
  99566. */
  99567. uniqueId: number;
  99568. /**
  99569. * This observable will notify when one animation have ended
  99570. */
  99571. onAnimationEndObservable: Observable<TargetedAnimation>;
  99572. /**
  99573. * Observer raised when one animation loops
  99574. */
  99575. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99576. /**
  99577. * This observable will notify when all animations have ended.
  99578. */
  99579. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99580. /**
  99581. * This observable will notify when all animations have paused.
  99582. */
  99583. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99584. /**
  99585. * This observable will notify when all animations are playing.
  99586. */
  99587. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99588. /**
  99589. * Gets the first frame
  99590. */
  99591. readonly from: number;
  99592. /**
  99593. * Gets the last frame
  99594. */
  99595. readonly to: number;
  99596. /**
  99597. * Define if the animations are started
  99598. */
  99599. readonly isStarted: boolean;
  99600. /**
  99601. * Gets a value indicating that the current group is playing
  99602. */
  99603. readonly isPlaying: boolean;
  99604. /**
  99605. * Gets or sets the speed ratio to use for all animations
  99606. */
  99607. /**
  99608. * Gets or sets the speed ratio to use for all animations
  99609. */
  99610. speedRatio: number;
  99611. /**
  99612. * Gets or sets if all animations should loop or not
  99613. */
  99614. loopAnimation: boolean;
  99615. /**
  99616. * Gets the targeted animations for this animation group
  99617. */
  99618. readonly targetedAnimations: Array<TargetedAnimation>;
  99619. /**
  99620. * returning the list of animatables controlled by this animation group.
  99621. */
  99622. readonly animatables: Array<Animatable>;
  99623. /**
  99624. * Instantiates a new Animation Group.
  99625. * This helps managing several animations at once.
  99626. * @see http://doc.babylonjs.com/how_to/group
  99627. * @param name Defines the name of the group
  99628. * @param scene Defines the scene the group belongs to
  99629. */
  99630. constructor(
  99631. /** The name of the animation group */
  99632. name: string, scene?: Nullable<Scene>);
  99633. /**
  99634. * Add an animation (with its target) in the group
  99635. * @param animation defines the animation we want to add
  99636. * @param target defines the target of the animation
  99637. * @returns the TargetedAnimation object
  99638. */
  99639. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99640. /**
  99641. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99642. * It can add constant keys at begin or end
  99643. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99644. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99645. * @returns the animation group
  99646. */
  99647. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99648. /**
  99649. * Start all animations on given targets
  99650. * @param loop defines if animations must loop
  99651. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99652. * @param from defines the from key (optional)
  99653. * @param to defines the to key (optional)
  99654. * @returns the current animation group
  99655. */
  99656. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99657. /**
  99658. * Pause all animations
  99659. * @returns the animation group
  99660. */
  99661. pause(): AnimationGroup;
  99662. /**
  99663. * Play all animations to initial state
  99664. * This function will start() the animations if they were not started or will restart() them if they were paused
  99665. * @param loop defines if animations must loop
  99666. * @returns the animation group
  99667. */
  99668. play(loop?: boolean): AnimationGroup;
  99669. /**
  99670. * Reset all animations to initial state
  99671. * @returns the animation group
  99672. */
  99673. reset(): AnimationGroup;
  99674. /**
  99675. * Restart animations from key 0
  99676. * @returns the animation group
  99677. */
  99678. restart(): AnimationGroup;
  99679. /**
  99680. * Stop all animations
  99681. * @returns the animation group
  99682. */
  99683. stop(): AnimationGroup;
  99684. /**
  99685. * Set animation weight for all animatables
  99686. * @param weight defines the weight to use
  99687. * @return the animationGroup
  99688. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99689. */
  99690. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99691. /**
  99692. * Synchronize and normalize all animatables with a source animatable
  99693. * @param root defines the root animatable to synchronize with
  99694. * @return the animationGroup
  99695. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99696. */
  99697. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99698. /**
  99699. * Goes to a specific frame in this animation group
  99700. * @param frame the frame number to go to
  99701. * @return the animationGroup
  99702. */
  99703. goToFrame(frame: number): AnimationGroup;
  99704. /**
  99705. * Dispose all associated resources
  99706. */
  99707. dispose(): void;
  99708. private _checkAnimationGroupEnded;
  99709. /**
  99710. * Clone the current animation group and returns a copy
  99711. * @param newName defines the name of the new group
  99712. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99713. * @returns the new aniamtion group
  99714. */
  99715. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99716. /**
  99717. * Serializes the animationGroup to an object
  99718. * @returns Serialized object
  99719. */
  99720. serialize(): any;
  99721. /**
  99722. * Returns a new AnimationGroup object parsed from the source provided.
  99723. * @param parsedAnimationGroup defines the source
  99724. * @param scene defines the scene that will receive the animationGroup
  99725. * @returns a new AnimationGroup
  99726. */
  99727. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99728. /**
  99729. * Returns the string "AnimationGroup"
  99730. * @returns "AnimationGroup"
  99731. */
  99732. getClassName(): string;
  99733. /**
  99734. * Creates a detailled string about the object
  99735. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99736. * @returns a string representing the object
  99737. */
  99738. toString(fullDetails?: boolean): string;
  99739. }
  99740. }
  99741. declare module BABYLON {
  99742. /**
  99743. * Define an interface for all classes that will hold resources
  99744. */
  99745. export interface IDisposable {
  99746. /**
  99747. * Releases all held resources
  99748. */
  99749. dispose(): void;
  99750. }
  99751. /** Interface defining initialization parameters for Scene class */
  99752. export interface SceneOptions {
  99753. /**
  99754. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99755. * It will improve performance when the number of geometries becomes important.
  99756. */
  99757. useGeometryUniqueIdsMap?: boolean;
  99758. /**
  99759. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99760. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99761. */
  99762. useMaterialMeshMap?: boolean;
  99763. /**
  99764. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99765. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99766. */
  99767. useClonedMeshhMap?: boolean;
  99768. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99769. virtual?: boolean;
  99770. }
  99771. /**
  99772. * Represents a scene to be rendered by the engine.
  99773. * @see http://doc.babylonjs.com/features/scene
  99774. */
  99775. export class Scene extends AbstractScene implements IAnimatable {
  99776. /** The fog is deactivated */
  99777. static readonly FOGMODE_NONE: number;
  99778. /** The fog density is following an exponential function */
  99779. static readonly FOGMODE_EXP: number;
  99780. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99781. static readonly FOGMODE_EXP2: number;
  99782. /** The fog density is following a linear function. */
  99783. static readonly FOGMODE_LINEAR: number;
  99784. /**
  99785. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99786. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99787. */
  99788. static MinDeltaTime: number;
  99789. /**
  99790. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99791. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99792. */
  99793. static MaxDeltaTime: number;
  99794. /**
  99795. * Factory used to create the default material.
  99796. * @param name The name of the material to create
  99797. * @param scene The scene to create the material for
  99798. * @returns The default material
  99799. */
  99800. static DefaultMaterialFactory(scene: Scene): Material;
  99801. /**
  99802. * Factory used to create the a collision coordinator.
  99803. * @returns The collision coordinator
  99804. */
  99805. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99806. /** @hidden */
  99807. _inputManager: InputManager;
  99808. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99809. cameraToUseForPointers: Nullable<Camera>;
  99810. /** @hidden */
  99811. readonly _isScene: boolean;
  99812. /**
  99813. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99814. */
  99815. autoClear: boolean;
  99816. /**
  99817. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99818. */
  99819. autoClearDepthAndStencil: boolean;
  99820. /**
  99821. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99822. */
  99823. clearColor: Color4;
  99824. /**
  99825. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99826. */
  99827. ambientColor: Color3;
  99828. /**
  99829. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99830. * It should only be one of the following (if not the default embedded one):
  99831. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99832. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99833. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99834. * The material properties need to be setup according to the type of texture in use.
  99835. */
  99836. environmentBRDFTexture: BaseTexture;
  99837. /** @hidden */
  99838. protected _environmentTexture: Nullable<BaseTexture>;
  99839. /**
  99840. * Texture used in all pbr material as the reflection texture.
  99841. * As in the majority of the scene they are the same (exception for multi room and so on),
  99842. * this is easier to reference from here than from all the materials.
  99843. */
  99844. /**
  99845. * Texture used in all pbr material as the reflection texture.
  99846. * As in the majority of the scene they are the same (exception for multi room and so on),
  99847. * this is easier to set here than in all the materials.
  99848. */
  99849. environmentTexture: Nullable<BaseTexture>;
  99850. /** @hidden */
  99851. protected _environmentIntensity: number;
  99852. /**
  99853. * Intensity of the environment in all pbr material.
  99854. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99855. * As in the majority of the scene they are the same (exception for multi room and so on),
  99856. * this is easier to reference from here than from all the materials.
  99857. */
  99858. /**
  99859. * Intensity of the environment in all pbr material.
  99860. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99861. * As in the majority of the scene they are the same (exception for multi room and so on),
  99862. * this is easier to set here than in all the materials.
  99863. */
  99864. environmentIntensity: number;
  99865. /** @hidden */
  99866. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99867. /**
  99868. * Default image processing configuration used either in the rendering
  99869. * Forward main pass or through the imageProcessingPostProcess if present.
  99870. * As in the majority of the scene they are the same (exception for multi camera),
  99871. * this is easier to reference from here than from all the materials and post process.
  99872. *
  99873. * No setter as we it is a shared configuration, you can set the values instead.
  99874. */
  99875. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99876. private _forceWireframe;
  99877. /**
  99878. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99879. */
  99880. forceWireframe: boolean;
  99881. private _forcePointsCloud;
  99882. /**
  99883. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99884. */
  99885. forcePointsCloud: boolean;
  99886. /**
  99887. * Gets or sets the active clipplane 1
  99888. */
  99889. clipPlane: Nullable<Plane>;
  99890. /**
  99891. * Gets or sets the active clipplane 2
  99892. */
  99893. clipPlane2: Nullable<Plane>;
  99894. /**
  99895. * Gets or sets the active clipplane 3
  99896. */
  99897. clipPlane3: Nullable<Plane>;
  99898. /**
  99899. * Gets or sets the active clipplane 4
  99900. */
  99901. clipPlane4: Nullable<Plane>;
  99902. /**
  99903. * Gets or sets a boolean indicating if animations are enabled
  99904. */
  99905. animationsEnabled: boolean;
  99906. private _animationPropertiesOverride;
  99907. /**
  99908. * Gets or sets the animation properties override
  99909. */
  99910. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99911. /**
  99912. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99913. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99914. */
  99915. useConstantAnimationDeltaTime: boolean;
  99916. /**
  99917. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99918. * Please note that it requires to run a ray cast through the scene on every frame
  99919. */
  99920. constantlyUpdateMeshUnderPointer: boolean;
  99921. /**
  99922. * Defines the HTML cursor to use when hovering over interactive elements
  99923. */
  99924. hoverCursor: string;
  99925. /**
  99926. * Defines the HTML default cursor to use (empty by default)
  99927. */
  99928. defaultCursor: string;
  99929. /**
  99930. * This is used to call preventDefault() on pointer down
  99931. * in order to block unwanted artifacts like system double clicks
  99932. */
  99933. preventDefaultOnPointerDown: boolean;
  99934. /**
  99935. * This is used to call preventDefault() on pointer up
  99936. * in order to block unwanted artifacts like system double clicks
  99937. */
  99938. preventDefaultOnPointerUp: boolean;
  99939. /**
  99940. * Gets or sets user defined metadata
  99941. */
  99942. metadata: any;
  99943. /**
  99944. * For internal use only. Please do not use.
  99945. */
  99946. reservedDataStore: any;
  99947. /**
  99948. * Gets the name of the plugin used to load this scene (null by default)
  99949. */
  99950. loadingPluginName: string;
  99951. /**
  99952. * Use this array to add regular expressions used to disable offline support for specific urls
  99953. */
  99954. disableOfflineSupportExceptionRules: RegExp[];
  99955. /**
  99956. * An event triggered when the scene is disposed.
  99957. */
  99958. onDisposeObservable: Observable<Scene>;
  99959. private _onDisposeObserver;
  99960. /** Sets a function to be executed when this scene is disposed. */
  99961. onDispose: () => void;
  99962. /**
  99963. * An event triggered before rendering the scene (right after animations and physics)
  99964. */
  99965. onBeforeRenderObservable: Observable<Scene>;
  99966. private _onBeforeRenderObserver;
  99967. /** Sets a function to be executed before rendering this scene */
  99968. beforeRender: Nullable<() => void>;
  99969. /**
  99970. * An event triggered after rendering the scene
  99971. */
  99972. onAfterRenderObservable: Observable<Scene>;
  99973. /**
  99974. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  99975. */
  99976. onAfterRenderCameraObservable: Observable<Camera>;
  99977. private _onAfterRenderObserver;
  99978. /** Sets a function to be executed after rendering this scene */
  99979. afterRender: Nullable<() => void>;
  99980. /**
  99981. * An event triggered before animating the scene
  99982. */
  99983. onBeforeAnimationsObservable: Observable<Scene>;
  99984. /**
  99985. * An event triggered after animations processing
  99986. */
  99987. onAfterAnimationsObservable: Observable<Scene>;
  99988. /**
  99989. * An event triggered before draw calls are ready to be sent
  99990. */
  99991. onBeforeDrawPhaseObservable: Observable<Scene>;
  99992. /**
  99993. * An event triggered after draw calls have been sent
  99994. */
  99995. onAfterDrawPhaseObservable: Observable<Scene>;
  99996. /**
  99997. * An event triggered when the scene is ready
  99998. */
  99999. onReadyObservable: Observable<Scene>;
  100000. /**
  100001. * An event triggered before rendering a camera
  100002. */
  100003. onBeforeCameraRenderObservable: Observable<Camera>;
  100004. private _onBeforeCameraRenderObserver;
  100005. /** Sets a function to be executed before rendering a camera*/
  100006. beforeCameraRender: () => void;
  100007. /**
  100008. * An event triggered after rendering a camera
  100009. */
  100010. onAfterCameraRenderObservable: Observable<Camera>;
  100011. private _onAfterCameraRenderObserver;
  100012. /** Sets a function to be executed after rendering a camera*/
  100013. afterCameraRender: () => void;
  100014. /**
  100015. * An event triggered when active meshes evaluation is about to start
  100016. */
  100017. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100018. /**
  100019. * An event triggered when active meshes evaluation is done
  100020. */
  100021. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100022. /**
  100023. * An event triggered when particles rendering is about to start
  100024. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100025. */
  100026. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100027. /**
  100028. * An event triggered when particles rendering is done
  100029. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100030. */
  100031. onAfterParticlesRenderingObservable: Observable<Scene>;
  100032. /**
  100033. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100034. */
  100035. onDataLoadedObservable: Observable<Scene>;
  100036. /**
  100037. * An event triggered when a camera is created
  100038. */
  100039. onNewCameraAddedObservable: Observable<Camera>;
  100040. /**
  100041. * An event triggered when a camera is removed
  100042. */
  100043. onCameraRemovedObservable: Observable<Camera>;
  100044. /**
  100045. * An event triggered when a light is created
  100046. */
  100047. onNewLightAddedObservable: Observable<Light>;
  100048. /**
  100049. * An event triggered when a light is removed
  100050. */
  100051. onLightRemovedObservable: Observable<Light>;
  100052. /**
  100053. * An event triggered when a geometry is created
  100054. */
  100055. onNewGeometryAddedObservable: Observable<Geometry>;
  100056. /**
  100057. * An event triggered when a geometry is removed
  100058. */
  100059. onGeometryRemovedObservable: Observable<Geometry>;
  100060. /**
  100061. * An event triggered when a transform node is created
  100062. */
  100063. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100064. /**
  100065. * An event triggered when a transform node is removed
  100066. */
  100067. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100068. /**
  100069. * An event triggered when a mesh is created
  100070. */
  100071. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100072. /**
  100073. * An event triggered when a mesh is removed
  100074. */
  100075. onMeshRemovedObservable: Observable<AbstractMesh>;
  100076. /**
  100077. * An event triggered when a skeleton is created
  100078. */
  100079. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100080. /**
  100081. * An event triggered when a skeleton is removed
  100082. */
  100083. onSkeletonRemovedObservable: Observable<Skeleton>;
  100084. /**
  100085. * An event triggered when a material is created
  100086. */
  100087. onNewMaterialAddedObservable: Observable<Material>;
  100088. /**
  100089. * An event triggered when a material is removed
  100090. */
  100091. onMaterialRemovedObservable: Observable<Material>;
  100092. /**
  100093. * An event triggered when a texture is created
  100094. */
  100095. onNewTextureAddedObservable: Observable<BaseTexture>;
  100096. /**
  100097. * An event triggered when a texture is removed
  100098. */
  100099. onTextureRemovedObservable: Observable<BaseTexture>;
  100100. /**
  100101. * An event triggered when render targets are about to be rendered
  100102. * Can happen multiple times per frame.
  100103. */
  100104. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100105. /**
  100106. * An event triggered when render targets were rendered.
  100107. * Can happen multiple times per frame.
  100108. */
  100109. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100110. /**
  100111. * An event triggered before calculating deterministic simulation step
  100112. */
  100113. onBeforeStepObservable: Observable<Scene>;
  100114. /**
  100115. * An event triggered after calculating deterministic simulation step
  100116. */
  100117. onAfterStepObservable: Observable<Scene>;
  100118. /**
  100119. * An event triggered when the activeCamera property is updated
  100120. */
  100121. onActiveCameraChanged: Observable<Scene>;
  100122. /**
  100123. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100124. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100125. * 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)
  100126. */
  100127. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100128. /**
  100129. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100130. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100131. * 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)
  100132. */
  100133. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100134. /**
  100135. * This Observable will when a mesh has been imported into the scene.
  100136. */
  100137. onMeshImportedObservable: Observable<AbstractMesh>;
  100138. /**
  100139. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100140. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100141. */
  100142. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100143. /** @hidden */
  100144. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100145. /**
  100146. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100147. */
  100148. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100149. /**
  100150. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100151. */
  100152. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100153. /**
  100154. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100155. */
  100156. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100157. /** Callback called when a pointer move is detected */
  100158. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100159. /** Callback called when a pointer down is detected */
  100160. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100161. /** Callback called when a pointer up is detected */
  100162. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100163. /** Callback called when a pointer pick is detected */
  100164. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100165. /**
  100166. * 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).
  100167. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100168. */
  100169. onPrePointerObservable: Observable<PointerInfoPre>;
  100170. /**
  100171. * Observable event triggered each time an input event is received from the rendering canvas
  100172. */
  100173. onPointerObservable: Observable<PointerInfo>;
  100174. /**
  100175. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100176. */
  100177. readonly unTranslatedPointer: Vector2;
  100178. /**
  100179. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100180. */
  100181. static DragMovementThreshold: number;
  100182. /**
  100183. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100184. */
  100185. static LongPressDelay: number;
  100186. /**
  100187. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100188. */
  100189. static DoubleClickDelay: number;
  100190. /** If you need to check double click without raising a single click at first click, enable this flag */
  100191. static ExclusiveDoubleClickMode: boolean;
  100192. /** @hidden */
  100193. _mirroredCameraPosition: Nullable<Vector3>;
  100194. /**
  100195. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100196. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100197. */
  100198. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100199. /**
  100200. * Observable event triggered each time an keyboard event is received from the hosting window
  100201. */
  100202. onKeyboardObservable: Observable<KeyboardInfo>;
  100203. private _useRightHandedSystem;
  100204. /**
  100205. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100206. */
  100207. useRightHandedSystem: boolean;
  100208. private _timeAccumulator;
  100209. private _currentStepId;
  100210. private _currentInternalStep;
  100211. /**
  100212. * Sets the step Id used by deterministic lock step
  100213. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100214. * @param newStepId defines the step Id
  100215. */
  100216. setStepId(newStepId: number): void;
  100217. /**
  100218. * Gets the step Id used by deterministic lock step
  100219. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100220. * @returns the step Id
  100221. */
  100222. getStepId(): number;
  100223. /**
  100224. * Gets the internal step used by deterministic lock step
  100225. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100226. * @returns the internal step
  100227. */
  100228. getInternalStep(): number;
  100229. private _fogEnabled;
  100230. /**
  100231. * Gets or sets a boolean indicating if fog is enabled on this scene
  100232. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100233. * (Default is true)
  100234. */
  100235. fogEnabled: boolean;
  100236. private _fogMode;
  100237. /**
  100238. * Gets or sets the fog mode to use
  100239. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100240. * | mode | value |
  100241. * | --- | --- |
  100242. * | FOGMODE_NONE | 0 |
  100243. * | FOGMODE_EXP | 1 |
  100244. * | FOGMODE_EXP2 | 2 |
  100245. * | FOGMODE_LINEAR | 3 |
  100246. */
  100247. fogMode: number;
  100248. /**
  100249. * Gets or sets the fog color to use
  100250. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100251. * (Default is Color3(0.2, 0.2, 0.3))
  100252. */
  100253. fogColor: Color3;
  100254. /**
  100255. * Gets or sets the fog density to use
  100256. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100257. * (Default is 0.1)
  100258. */
  100259. fogDensity: number;
  100260. /**
  100261. * Gets or sets the fog start distance to use
  100262. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100263. * (Default is 0)
  100264. */
  100265. fogStart: number;
  100266. /**
  100267. * Gets or sets the fog end distance to use
  100268. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100269. * (Default is 1000)
  100270. */
  100271. fogEnd: number;
  100272. private _shadowsEnabled;
  100273. /**
  100274. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100275. */
  100276. shadowsEnabled: boolean;
  100277. private _lightsEnabled;
  100278. /**
  100279. * Gets or sets a boolean indicating if lights are enabled on this scene
  100280. */
  100281. lightsEnabled: boolean;
  100282. /** All of the active cameras added to this scene. */
  100283. activeCameras: Camera[];
  100284. /** @hidden */
  100285. _activeCamera: Nullable<Camera>;
  100286. /** Gets or sets the current active camera */
  100287. activeCamera: Nullable<Camera>;
  100288. private _defaultMaterial;
  100289. /** The default material used on meshes when no material is affected */
  100290. /** The default material used on meshes when no material is affected */
  100291. defaultMaterial: Material;
  100292. private _texturesEnabled;
  100293. /**
  100294. * Gets or sets a boolean indicating if textures are enabled on this scene
  100295. */
  100296. texturesEnabled: boolean;
  100297. /**
  100298. * Gets or sets a boolean indicating if particles are enabled on this scene
  100299. */
  100300. particlesEnabled: boolean;
  100301. /**
  100302. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100303. */
  100304. spritesEnabled: boolean;
  100305. private _skeletonsEnabled;
  100306. /**
  100307. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100308. */
  100309. skeletonsEnabled: boolean;
  100310. /**
  100311. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100312. */
  100313. lensFlaresEnabled: boolean;
  100314. /**
  100315. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100316. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100317. */
  100318. collisionsEnabled: boolean;
  100319. private _collisionCoordinator;
  100320. /** @hidden */
  100321. readonly collisionCoordinator: ICollisionCoordinator;
  100322. /**
  100323. * Defines the gravity applied to this scene (used only for collisions)
  100324. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100325. */
  100326. gravity: Vector3;
  100327. /**
  100328. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100329. */
  100330. postProcessesEnabled: boolean;
  100331. /**
  100332. * The list of postprocesses added to the scene
  100333. */
  100334. postProcesses: PostProcess[];
  100335. /**
  100336. * Gets the current postprocess manager
  100337. */
  100338. postProcessManager: PostProcessManager;
  100339. /**
  100340. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100341. */
  100342. renderTargetsEnabled: boolean;
  100343. /**
  100344. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100345. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100346. */
  100347. dumpNextRenderTargets: boolean;
  100348. /**
  100349. * The list of user defined render targets added to the scene
  100350. */
  100351. customRenderTargets: RenderTargetTexture[];
  100352. /**
  100353. * Defines if texture loading must be delayed
  100354. * If true, textures will only be loaded when they need to be rendered
  100355. */
  100356. useDelayedTextureLoading: boolean;
  100357. /**
  100358. * Gets the list of meshes imported to the scene through SceneLoader
  100359. */
  100360. importedMeshesFiles: String[];
  100361. /**
  100362. * Gets or sets a boolean indicating if probes are enabled on this scene
  100363. */
  100364. probesEnabled: boolean;
  100365. /**
  100366. * Gets or sets the current offline provider to use to store scene data
  100367. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100368. */
  100369. offlineProvider: IOfflineProvider;
  100370. /**
  100371. * Gets or sets the action manager associated with the scene
  100372. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100373. */
  100374. actionManager: AbstractActionManager;
  100375. private _meshesForIntersections;
  100376. /**
  100377. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100378. */
  100379. proceduralTexturesEnabled: boolean;
  100380. private _engine;
  100381. private _totalVertices;
  100382. /** @hidden */
  100383. _activeIndices: PerfCounter;
  100384. /** @hidden */
  100385. _activeParticles: PerfCounter;
  100386. /** @hidden */
  100387. _activeBones: PerfCounter;
  100388. private _animationRatio;
  100389. /** @hidden */
  100390. _animationTimeLast: number;
  100391. /** @hidden */
  100392. _animationTime: number;
  100393. /**
  100394. * Gets or sets a general scale for animation speed
  100395. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100396. */
  100397. animationTimeScale: number;
  100398. /** @hidden */
  100399. _cachedMaterial: Nullable<Material>;
  100400. /** @hidden */
  100401. _cachedEffect: Nullable<Effect>;
  100402. /** @hidden */
  100403. _cachedVisibility: Nullable<number>;
  100404. private _renderId;
  100405. private _frameId;
  100406. private _executeWhenReadyTimeoutId;
  100407. private _intermediateRendering;
  100408. private _viewUpdateFlag;
  100409. private _projectionUpdateFlag;
  100410. /** @hidden */
  100411. _toBeDisposed: Nullable<IDisposable>[];
  100412. private _activeRequests;
  100413. /** @hidden */
  100414. _pendingData: any[];
  100415. private _isDisposed;
  100416. /**
  100417. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100418. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100419. */
  100420. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100421. private _activeMeshes;
  100422. private _processedMaterials;
  100423. private _renderTargets;
  100424. /** @hidden */
  100425. _activeParticleSystems: SmartArray<IParticleSystem>;
  100426. private _activeSkeletons;
  100427. private _softwareSkinnedMeshes;
  100428. private _renderingManager;
  100429. /** @hidden */
  100430. _activeAnimatables: Animatable[];
  100431. private _transformMatrix;
  100432. private _sceneUbo;
  100433. /** @hidden */
  100434. _viewMatrix: Matrix;
  100435. private _projectionMatrix;
  100436. /** @hidden */
  100437. _forcedViewPosition: Nullable<Vector3>;
  100438. /** @hidden */
  100439. _frustumPlanes: Plane[];
  100440. /**
  100441. * Gets the list of frustum planes (built from the active camera)
  100442. */
  100443. readonly frustumPlanes: Plane[];
  100444. /**
  100445. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100446. * This is useful if there are more lights that the maximum simulteanous authorized
  100447. */
  100448. requireLightSorting: boolean;
  100449. /** @hidden */
  100450. readonly useMaterialMeshMap: boolean;
  100451. /** @hidden */
  100452. readonly useClonedMeshhMap: boolean;
  100453. private _externalData;
  100454. private _uid;
  100455. /**
  100456. * @hidden
  100457. * Backing store of defined scene components.
  100458. */
  100459. _components: ISceneComponent[];
  100460. /**
  100461. * @hidden
  100462. * Backing store of defined scene components.
  100463. */
  100464. _serializableComponents: ISceneSerializableComponent[];
  100465. /**
  100466. * List of components to register on the next registration step.
  100467. */
  100468. private _transientComponents;
  100469. /**
  100470. * Registers the transient components if needed.
  100471. */
  100472. private _registerTransientComponents;
  100473. /**
  100474. * @hidden
  100475. * Add a component to the scene.
  100476. * Note that the ccomponent could be registered on th next frame if this is called after
  100477. * the register component stage.
  100478. * @param component Defines the component to add to the scene
  100479. */
  100480. _addComponent(component: ISceneComponent): void;
  100481. /**
  100482. * @hidden
  100483. * Gets a component from the scene.
  100484. * @param name defines the name of the component to retrieve
  100485. * @returns the component or null if not present
  100486. */
  100487. _getComponent(name: string): Nullable<ISceneComponent>;
  100488. /**
  100489. * @hidden
  100490. * Defines the actions happening before camera updates.
  100491. */
  100492. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100493. /**
  100494. * @hidden
  100495. * Defines the actions happening before clear the canvas.
  100496. */
  100497. _beforeClearStage: Stage<SimpleStageAction>;
  100498. /**
  100499. * @hidden
  100500. * Defines the actions when collecting render targets for the frame.
  100501. */
  100502. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100503. /**
  100504. * @hidden
  100505. * Defines the actions happening for one camera in the frame.
  100506. */
  100507. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100508. /**
  100509. * @hidden
  100510. * Defines the actions happening during the per mesh ready checks.
  100511. */
  100512. _isReadyForMeshStage: Stage<MeshStageAction>;
  100513. /**
  100514. * @hidden
  100515. * Defines the actions happening before evaluate active mesh checks.
  100516. */
  100517. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100518. /**
  100519. * @hidden
  100520. * Defines the actions happening during the evaluate sub mesh checks.
  100521. */
  100522. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100523. /**
  100524. * @hidden
  100525. * Defines the actions happening during the active mesh stage.
  100526. */
  100527. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100528. /**
  100529. * @hidden
  100530. * Defines the actions happening during the per camera render target step.
  100531. */
  100532. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100533. /**
  100534. * @hidden
  100535. * Defines the actions happening just before the active camera is drawing.
  100536. */
  100537. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100538. /**
  100539. * @hidden
  100540. * Defines the actions happening just before a render target is drawing.
  100541. */
  100542. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100543. /**
  100544. * @hidden
  100545. * Defines the actions happening just before a rendering group is drawing.
  100546. */
  100547. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100548. /**
  100549. * @hidden
  100550. * Defines the actions happening just before a mesh is drawing.
  100551. */
  100552. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100553. /**
  100554. * @hidden
  100555. * Defines the actions happening just after a mesh has been drawn.
  100556. */
  100557. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100558. /**
  100559. * @hidden
  100560. * Defines the actions happening just after a rendering group has been drawn.
  100561. */
  100562. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100563. /**
  100564. * @hidden
  100565. * Defines the actions happening just after the active camera has been drawn.
  100566. */
  100567. _afterCameraDrawStage: Stage<CameraStageAction>;
  100568. /**
  100569. * @hidden
  100570. * Defines the actions happening just after a render target has been drawn.
  100571. */
  100572. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100573. /**
  100574. * @hidden
  100575. * Defines the actions happening just after rendering all cameras and computing intersections.
  100576. */
  100577. _afterRenderStage: Stage<SimpleStageAction>;
  100578. /**
  100579. * @hidden
  100580. * Defines the actions happening when a pointer move event happens.
  100581. */
  100582. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100583. /**
  100584. * @hidden
  100585. * Defines the actions happening when a pointer down event happens.
  100586. */
  100587. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100588. /**
  100589. * @hidden
  100590. * Defines the actions happening when a pointer up event happens.
  100591. */
  100592. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100593. /**
  100594. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100595. */
  100596. private geometriesByUniqueId;
  100597. /**
  100598. * Creates a new Scene
  100599. * @param engine defines the engine to use to render this scene
  100600. * @param options defines the scene options
  100601. */
  100602. constructor(engine: Engine, options?: SceneOptions);
  100603. /**
  100604. * Gets a string idenfifying the name of the class
  100605. * @returns "Scene" string
  100606. */
  100607. getClassName(): string;
  100608. private _defaultMeshCandidates;
  100609. /**
  100610. * @hidden
  100611. */
  100612. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100613. private _defaultSubMeshCandidates;
  100614. /**
  100615. * @hidden
  100616. */
  100617. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100618. /**
  100619. * Sets the default candidate providers for the scene.
  100620. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100621. * and getCollidingSubMeshCandidates to their default function
  100622. */
  100623. setDefaultCandidateProviders(): void;
  100624. /**
  100625. * Gets the mesh that is currently under the pointer
  100626. */
  100627. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100628. /**
  100629. * Gets or sets the current on-screen X position of the pointer
  100630. */
  100631. pointerX: number;
  100632. /**
  100633. * Gets or sets the current on-screen Y position of the pointer
  100634. */
  100635. pointerY: number;
  100636. /**
  100637. * Gets the cached material (ie. the latest rendered one)
  100638. * @returns the cached material
  100639. */
  100640. getCachedMaterial(): Nullable<Material>;
  100641. /**
  100642. * Gets the cached effect (ie. the latest rendered one)
  100643. * @returns the cached effect
  100644. */
  100645. getCachedEffect(): Nullable<Effect>;
  100646. /**
  100647. * Gets the cached visibility state (ie. the latest rendered one)
  100648. * @returns the cached visibility state
  100649. */
  100650. getCachedVisibility(): Nullable<number>;
  100651. /**
  100652. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100653. * @param material defines the current material
  100654. * @param effect defines the current effect
  100655. * @param visibility defines the current visibility state
  100656. * @returns true if one parameter is not cached
  100657. */
  100658. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100659. /**
  100660. * Gets the engine associated with the scene
  100661. * @returns an Engine
  100662. */
  100663. getEngine(): Engine;
  100664. /**
  100665. * Gets the total number of vertices rendered per frame
  100666. * @returns the total number of vertices rendered per frame
  100667. */
  100668. getTotalVertices(): number;
  100669. /**
  100670. * Gets the performance counter for total vertices
  100671. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100672. */
  100673. readonly totalVerticesPerfCounter: PerfCounter;
  100674. /**
  100675. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100676. * @returns the total number of active indices rendered per frame
  100677. */
  100678. getActiveIndices(): number;
  100679. /**
  100680. * Gets the performance counter for active indices
  100681. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100682. */
  100683. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100684. /**
  100685. * Gets the total number of active particles rendered per frame
  100686. * @returns the total number of active particles rendered per frame
  100687. */
  100688. getActiveParticles(): number;
  100689. /**
  100690. * Gets the performance counter for active particles
  100691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100692. */
  100693. readonly activeParticlesPerfCounter: PerfCounter;
  100694. /**
  100695. * Gets the total number of active bones rendered per frame
  100696. * @returns the total number of active bones rendered per frame
  100697. */
  100698. getActiveBones(): number;
  100699. /**
  100700. * Gets the performance counter for active bones
  100701. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100702. */
  100703. readonly activeBonesPerfCounter: PerfCounter;
  100704. /**
  100705. * Gets the array of active meshes
  100706. * @returns an array of AbstractMesh
  100707. */
  100708. getActiveMeshes(): SmartArray<AbstractMesh>;
  100709. /**
  100710. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100711. * @returns a number
  100712. */
  100713. getAnimationRatio(): number;
  100714. /**
  100715. * Gets an unique Id for the current render phase
  100716. * @returns a number
  100717. */
  100718. getRenderId(): number;
  100719. /**
  100720. * Gets an unique Id for the current frame
  100721. * @returns a number
  100722. */
  100723. getFrameId(): number;
  100724. /** Call this function if you want to manually increment the render Id*/
  100725. incrementRenderId(): void;
  100726. private _createUbo;
  100727. /**
  100728. * Use this method to simulate a pointer move on a mesh
  100729. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100730. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100731. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100732. * @returns the current scene
  100733. */
  100734. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100735. /**
  100736. * Use this method to simulate a pointer down on a mesh
  100737. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100738. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100739. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100740. * @returns the current scene
  100741. */
  100742. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100743. /**
  100744. * Use this method to simulate a pointer up on a mesh
  100745. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100746. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100747. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100748. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100749. * @returns the current scene
  100750. */
  100751. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100752. /**
  100753. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100754. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100755. * @returns true if the pointer was captured
  100756. */
  100757. isPointerCaptured(pointerId?: number): boolean;
  100758. /**
  100759. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100760. * @param attachUp defines if you want to attach events to pointerup
  100761. * @param attachDown defines if you want to attach events to pointerdown
  100762. * @param attachMove defines if you want to attach events to pointermove
  100763. */
  100764. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100765. /** Detaches all event handlers*/
  100766. detachControl(): void;
  100767. /**
  100768. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100769. * Delay loaded resources are not taking in account
  100770. * @return true if all required resources are ready
  100771. */
  100772. isReady(): boolean;
  100773. /** Resets all cached information relative to material (including effect and visibility) */
  100774. resetCachedMaterial(): void;
  100775. /**
  100776. * Registers a function to be called before every frame render
  100777. * @param func defines the function to register
  100778. */
  100779. registerBeforeRender(func: () => void): void;
  100780. /**
  100781. * Unregisters a function called before every frame render
  100782. * @param func defines the function to unregister
  100783. */
  100784. unregisterBeforeRender(func: () => void): void;
  100785. /**
  100786. * Registers a function to be called after every frame render
  100787. * @param func defines the function to register
  100788. */
  100789. registerAfterRender(func: () => void): void;
  100790. /**
  100791. * Unregisters a function called after every frame render
  100792. * @param func defines the function to unregister
  100793. */
  100794. unregisterAfterRender(func: () => void): void;
  100795. private _executeOnceBeforeRender;
  100796. /**
  100797. * The provided function will run before render once and will be disposed afterwards.
  100798. * A timeout delay can be provided so that the function will be executed in N ms.
  100799. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100800. * @param func The function to be executed.
  100801. * @param timeout optional delay in ms
  100802. */
  100803. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100804. /** @hidden */
  100805. _addPendingData(data: any): void;
  100806. /** @hidden */
  100807. _removePendingData(data: any): void;
  100808. /**
  100809. * Returns the number of items waiting to be loaded
  100810. * @returns the number of items waiting to be loaded
  100811. */
  100812. getWaitingItemsCount(): number;
  100813. /**
  100814. * Returns a boolean indicating if the scene is still loading data
  100815. */
  100816. readonly isLoading: boolean;
  100817. /**
  100818. * Registers a function to be executed when the scene is ready
  100819. * @param {Function} func - the function to be executed
  100820. */
  100821. executeWhenReady(func: () => void): void;
  100822. /**
  100823. * Returns a promise that resolves when the scene is ready
  100824. * @returns A promise that resolves when the scene is ready
  100825. */
  100826. whenReadyAsync(): Promise<void>;
  100827. /** @hidden */
  100828. _checkIsReady(): void;
  100829. /**
  100830. * Gets all animatable attached to the scene
  100831. */
  100832. readonly animatables: Animatable[];
  100833. /**
  100834. * Resets the last animation time frame.
  100835. * Useful to override when animations start running when loading a scene for the first time.
  100836. */
  100837. resetLastAnimationTimeFrame(): void;
  100838. /**
  100839. * Gets the current view matrix
  100840. * @returns a Matrix
  100841. */
  100842. getViewMatrix(): Matrix;
  100843. /**
  100844. * Gets the current projection matrix
  100845. * @returns a Matrix
  100846. */
  100847. getProjectionMatrix(): Matrix;
  100848. /**
  100849. * Gets the current transform matrix
  100850. * @returns a Matrix made of View * Projection
  100851. */
  100852. getTransformMatrix(): Matrix;
  100853. /**
  100854. * Sets the current transform matrix
  100855. * @param viewL defines the View matrix to use
  100856. * @param projectionL defines the Projection matrix to use
  100857. * @param viewR defines the right View matrix to use (if provided)
  100858. * @param projectionR defines the right Projection matrix to use (if provided)
  100859. */
  100860. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100861. /**
  100862. * Gets the uniform buffer used to store scene data
  100863. * @returns a UniformBuffer
  100864. */
  100865. getSceneUniformBuffer(): UniformBuffer;
  100866. /**
  100867. * Gets an unique (relatively to the current scene) Id
  100868. * @returns an unique number for the scene
  100869. */
  100870. getUniqueId(): number;
  100871. /**
  100872. * Add a mesh to the list of scene's meshes
  100873. * @param newMesh defines the mesh to add
  100874. * @param recursive if all child meshes should also be added to the scene
  100875. */
  100876. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100877. /**
  100878. * Remove a mesh for the list of scene's meshes
  100879. * @param toRemove defines the mesh to remove
  100880. * @param recursive if all child meshes should also be removed from the scene
  100881. * @returns the index where the mesh was in the mesh list
  100882. */
  100883. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100884. /**
  100885. * Add a transform node to the list of scene's transform nodes
  100886. * @param newTransformNode defines the transform node to add
  100887. */
  100888. addTransformNode(newTransformNode: TransformNode): void;
  100889. /**
  100890. * Remove a transform node for the list of scene's transform nodes
  100891. * @param toRemove defines the transform node to remove
  100892. * @returns the index where the transform node was in the transform node list
  100893. */
  100894. removeTransformNode(toRemove: TransformNode): number;
  100895. /**
  100896. * Remove a skeleton for the list of scene's skeletons
  100897. * @param toRemove defines the skeleton to remove
  100898. * @returns the index where the skeleton was in the skeleton list
  100899. */
  100900. removeSkeleton(toRemove: Skeleton): number;
  100901. /**
  100902. * Remove a morph target for the list of scene's morph targets
  100903. * @param toRemove defines the morph target to remove
  100904. * @returns the index where the morph target was in the morph target list
  100905. */
  100906. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100907. /**
  100908. * Remove a light for the list of scene's lights
  100909. * @param toRemove defines the light to remove
  100910. * @returns the index where the light was in the light list
  100911. */
  100912. removeLight(toRemove: Light): number;
  100913. /**
  100914. * Remove a camera for the list of scene's cameras
  100915. * @param toRemove defines the camera to remove
  100916. * @returns the index where the camera was in the camera list
  100917. */
  100918. removeCamera(toRemove: Camera): number;
  100919. /**
  100920. * Remove a particle system for the list of scene's particle systems
  100921. * @param toRemove defines the particle system to remove
  100922. * @returns the index where the particle system was in the particle system list
  100923. */
  100924. removeParticleSystem(toRemove: IParticleSystem): number;
  100925. /**
  100926. * Remove a animation for the list of scene's animations
  100927. * @param toRemove defines the animation to remove
  100928. * @returns the index where the animation was in the animation list
  100929. */
  100930. removeAnimation(toRemove: Animation): number;
  100931. /**
  100932. * Will stop the animation of the given target
  100933. * @param target - the target
  100934. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100935. * @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)
  100936. */
  100937. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100938. /**
  100939. * Removes the given animation group from this scene.
  100940. * @param toRemove The animation group to remove
  100941. * @returns The index of the removed animation group
  100942. */
  100943. removeAnimationGroup(toRemove: AnimationGroup): number;
  100944. /**
  100945. * Removes the given multi-material from this scene.
  100946. * @param toRemove The multi-material to remove
  100947. * @returns The index of the removed multi-material
  100948. */
  100949. removeMultiMaterial(toRemove: MultiMaterial): number;
  100950. /**
  100951. * Removes the given material from this scene.
  100952. * @param toRemove The material to remove
  100953. * @returns The index of the removed material
  100954. */
  100955. removeMaterial(toRemove: Material): number;
  100956. /**
  100957. * Removes the given action manager from this scene.
  100958. * @param toRemove The action manager to remove
  100959. * @returns The index of the removed action manager
  100960. */
  100961. removeActionManager(toRemove: AbstractActionManager): number;
  100962. /**
  100963. * Removes the given texture from this scene.
  100964. * @param toRemove The texture to remove
  100965. * @returns The index of the removed texture
  100966. */
  100967. removeTexture(toRemove: BaseTexture): number;
  100968. /**
  100969. * Adds the given light to this scene
  100970. * @param newLight The light to add
  100971. */
  100972. addLight(newLight: Light): void;
  100973. /**
  100974. * Sorts the list list based on light priorities
  100975. */
  100976. sortLightsByPriority(): void;
  100977. /**
  100978. * Adds the given camera to this scene
  100979. * @param newCamera The camera to add
  100980. */
  100981. addCamera(newCamera: Camera): void;
  100982. /**
  100983. * Adds the given skeleton to this scene
  100984. * @param newSkeleton The skeleton to add
  100985. */
  100986. addSkeleton(newSkeleton: Skeleton): void;
  100987. /**
  100988. * Adds the given particle system to this scene
  100989. * @param newParticleSystem The particle system to add
  100990. */
  100991. addParticleSystem(newParticleSystem: IParticleSystem): void;
  100992. /**
  100993. * Adds the given animation to this scene
  100994. * @param newAnimation The animation to add
  100995. */
  100996. addAnimation(newAnimation: Animation): void;
  100997. /**
  100998. * Adds the given animation group to this scene.
  100999. * @param newAnimationGroup The animation group to add
  101000. */
  101001. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101002. /**
  101003. * Adds the given multi-material to this scene
  101004. * @param newMultiMaterial The multi-material to add
  101005. */
  101006. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101007. /**
  101008. * Adds the given material to this scene
  101009. * @param newMaterial The material to add
  101010. */
  101011. addMaterial(newMaterial: Material): void;
  101012. /**
  101013. * Adds the given morph target to this scene
  101014. * @param newMorphTargetManager The morph target to add
  101015. */
  101016. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101017. /**
  101018. * Adds the given geometry to this scene
  101019. * @param newGeometry The geometry to add
  101020. */
  101021. addGeometry(newGeometry: Geometry): void;
  101022. /**
  101023. * Adds the given action manager to this scene
  101024. * @param newActionManager The action manager to add
  101025. */
  101026. addActionManager(newActionManager: AbstractActionManager): void;
  101027. /**
  101028. * Adds the given texture to this scene.
  101029. * @param newTexture The texture to add
  101030. */
  101031. addTexture(newTexture: BaseTexture): void;
  101032. /**
  101033. * Switch active camera
  101034. * @param newCamera defines the new active camera
  101035. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101036. */
  101037. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101038. /**
  101039. * sets the active camera of the scene using its ID
  101040. * @param id defines the camera's ID
  101041. * @return the new active camera or null if none found.
  101042. */
  101043. setActiveCameraByID(id: string): Nullable<Camera>;
  101044. /**
  101045. * sets the active camera of the scene using its name
  101046. * @param name defines the camera's name
  101047. * @returns the new active camera or null if none found.
  101048. */
  101049. setActiveCameraByName(name: string): Nullable<Camera>;
  101050. /**
  101051. * get an animation group using its name
  101052. * @param name defines the material's name
  101053. * @return the animation group or null if none found.
  101054. */
  101055. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101056. /**
  101057. * Get a material using its unique id
  101058. * @param uniqueId defines the material's unique id
  101059. * @return the material or null if none found.
  101060. */
  101061. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101062. /**
  101063. * get a material using its id
  101064. * @param id defines the material's ID
  101065. * @return the material or null if none found.
  101066. */
  101067. getMaterialByID(id: string): Nullable<Material>;
  101068. /**
  101069. * Gets a the last added material using a given id
  101070. * @param id defines the material's ID
  101071. * @return the last material with the given id or null if none found.
  101072. */
  101073. getLastMaterialByID(id: string): Nullable<Material>;
  101074. /**
  101075. * Gets a material using its name
  101076. * @param name defines the material's name
  101077. * @return the material or null if none found.
  101078. */
  101079. getMaterialByName(name: string): Nullable<Material>;
  101080. /**
  101081. * Get a texture using its unique id
  101082. * @param uniqueId defines the texture's unique id
  101083. * @return the texture or null if none found.
  101084. */
  101085. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101086. /**
  101087. * Gets a camera using its id
  101088. * @param id defines the id to look for
  101089. * @returns the camera or null if not found
  101090. */
  101091. getCameraByID(id: string): Nullable<Camera>;
  101092. /**
  101093. * Gets a camera using its unique id
  101094. * @param uniqueId defines the unique id to look for
  101095. * @returns the camera or null if not found
  101096. */
  101097. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101098. /**
  101099. * Gets a camera using its name
  101100. * @param name defines the camera's name
  101101. * @return the camera or null if none found.
  101102. */
  101103. getCameraByName(name: string): Nullable<Camera>;
  101104. /**
  101105. * Gets a bone using its id
  101106. * @param id defines the bone's id
  101107. * @return the bone or null if not found
  101108. */
  101109. getBoneByID(id: string): Nullable<Bone>;
  101110. /**
  101111. * Gets a bone using its id
  101112. * @param name defines the bone's name
  101113. * @return the bone or null if not found
  101114. */
  101115. getBoneByName(name: string): Nullable<Bone>;
  101116. /**
  101117. * Gets a light node using its name
  101118. * @param name defines the the light's name
  101119. * @return the light or null if none found.
  101120. */
  101121. getLightByName(name: string): Nullable<Light>;
  101122. /**
  101123. * Gets a light node using its id
  101124. * @param id defines the light's id
  101125. * @return the light or null if none found.
  101126. */
  101127. getLightByID(id: string): Nullable<Light>;
  101128. /**
  101129. * Gets a light node using its scene-generated unique ID
  101130. * @param uniqueId defines the light's unique id
  101131. * @return the light or null if none found.
  101132. */
  101133. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101134. /**
  101135. * Gets a particle system by id
  101136. * @param id defines the particle system id
  101137. * @return the corresponding system or null if none found
  101138. */
  101139. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101140. /**
  101141. * Gets a geometry using its ID
  101142. * @param id defines the geometry's id
  101143. * @return the geometry or null if none found.
  101144. */
  101145. getGeometryByID(id: string): Nullable<Geometry>;
  101146. private _getGeometryByUniqueID;
  101147. /**
  101148. * Add a new geometry to this scene
  101149. * @param geometry defines the geometry to be added to the scene.
  101150. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101151. * @return a boolean defining if the geometry was added or not
  101152. */
  101153. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101154. /**
  101155. * Removes an existing geometry
  101156. * @param geometry defines the geometry to be removed from the scene
  101157. * @return a boolean defining if the geometry was removed or not
  101158. */
  101159. removeGeometry(geometry: Geometry): boolean;
  101160. /**
  101161. * Gets the list of geometries attached to the scene
  101162. * @returns an array of Geometry
  101163. */
  101164. getGeometries(): Geometry[];
  101165. /**
  101166. * Gets the first added mesh found of a given ID
  101167. * @param id defines the id to search for
  101168. * @return the mesh found or null if not found at all
  101169. */
  101170. getMeshByID(id: string): Nullable<AbstractMesh>;
  101171. /**
  101172. * Gets a list of meshes using their id
  101173. * @param id defines the id to search for
  101174. * @returns a list of meshes
  101175. */
  101176. getMeshesByID(id: string): Array<AbstractMesh>;
  101177. /**
  101178. * Gets the first added transform node found of a given ID
  101179. * @param id defines the id to search for
  101180. * @return the found transform node or null if not found at all.
  101181. */
  101182. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101183. /**
  101184. * Gets a transform node with its auto-generated unique id
  101185. * @param uniqueId efines the unique id to search for
  101186. * @return the found transform node or null if not found at all.
  101187. */
  101188. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101189. /**
  101190. * Gets a list of transform nodes using their id
  101191. * @param id defines the id to search for
  101192. * @returns a list of transform nodes
  101193. */
  101194. getTransformNodesByID(id: string): Array<TransformNode>;
  101195. /**
  101196. * Gets a mesh with its auto-generated unique id
  101197. * @param uniqueId defines the unique id to search for
  101198. * @return the found mesh or null if not found at all.
  101199. */
  101200. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101201. /**
  101202. * Gets a the last added mesh using a given id
  101203. * @param id defines the id to search for
  101204. * @return the found mesh or null if not found at all.
  101205. */
  101206. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101207. /**
  101208. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101209. * @param id defines the id to search for
  101210. * @return the found node or null if not found at all
  101211. */
  101212. getLastEntryByID(id: string): Nullable<Node>;
  101213. /**
  101214. * Gets a node (Mesh, Camera, Light) using a given id
  101215. * @param id defines the id to search for
  101216. * @return the found node or null if not found at all
  101217. */
  101218. getNodeByID(id: string): Nullable<Node>;
  101219. /**
  101220. * Gets a node (Mesh, Camera, Light) using a given name
  101221. * @param name defines the name to search for
  101222. * @return the found node or null if not found at all.
  101223. */
  101224. getNodeByName(name: string): Nullable<Node>;
  101225. /**
  101226. * Gets a mesh using a given name
  101227. * @param name defines the name to search for
  101228. * @return the found mesh or null if not found at all.
  101229. */
  101230. getMeshByName(name: string): Nullable<AbstractMesh>;
  101231. /**
  101232. * Gets a transform node using a given name
  101233. * @param name defines the name to search for
  101234. * @return the found transform node or null if not found at all.
  101235. */
  101236. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101237. /**
  101238. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101239. * @param id defines the id to search for
  101240. * @return the found skeleton or null if not found at all.
  101241. */
  101242. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101243. /**
  101244. * Gets a skeleton using a given auto generated unique id
  101245. * @param uniqueId defines the unique id to search for
  101246. * @return the found skeleton or null if not found at all.
  101247. */
  101248. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101249. /**
  101250. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101251. * @param id defines the id to search for
  101252. * @return the found skeleton or null if not found at all.
  101253. */
  101254. getSkeletonById(id: string): Nullable<Skeleton>;
  101255. /**
  101256. * Gets a skeleton using a given name
  101257. * @param name defines the name to search for
  101258. * @return the found skeleton or null if not found at all.
  101259. */
  101260. getSkeletonByName(name: string): Nullable<Skeleton>;
  101261. /**
  101262. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101263. * @param id defines the id to search for
  101264. * @return the found morph target manager or null if not found at all.
  101265. */
  101266. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101267. /**
  101268. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101269. * @param id defines the id to search for
  101270. * @return the found morph target or null if not found at all.
  101271. */
  101272. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101273. /**
  101274. * Gets a boolean indicating if the given mesh is active
  101275. * @param mesh defines the mesh to look for
  101276. * @returns true if the mesh is in the active list
  101277. */
  101278. isActiveMesh(mesh: AbstractMesh): boolean;
  101279. /**
  101280. * Return a unique id as a string which can serve as an identifier for the scene
  101281. */
  101282. readonly uid: string;
  101283. /**
  101284. * Add an externaly attached data from its key.
  101285. * This method call will fail and return false, if such key already exists.
  101286. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101287. * @param key the unique key that identifies the data
  101288. * @param data the data object to associate to the key for this Engine instance
  101289. * @return true if no such key were already present and the data was added successfully, false otherwise
  101290. */
  101291. addExternalData<T>(key: string, data: T): boolean;
  101292. /**
  101293. * Get an externaly attached data from its key
  101294. * @param key the unique key that identifies the data
  101295. * @return the associated data, if present (can be null), or undefined if not present
  101296. */
  101297. getExternalData<T>(key: string): Nullable<T>;
  101298. /**
  101299. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101300. * @param key the unique key that identifies the data
  101301. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101302. * @return the associated data, can be null if the factory returned null.
  101303. */
  101304. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101305. /**
  101306. * Remove an externaly attached data from the Engine instance
  101307. * @param key the unique key that identifies the data
  101308. * @return true if the data was successfully removed, false if it doesn't exist
  101309. */
  101310. removeExternalData(key: string): boolean;
  101311. private _evaluateSubMesh;
  101312. /**
  101313. * Clear the processed materials smart array preventing retention point in material dispose.
  101314. */
  101315. freeProcessedMaterials(): void;
  101316. private _preventFreeActiveMeshesAndRenderingGroups;
  101317. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101318. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101319. * when disposing several meshes in a row or a hierarchy of meshes.
  101320. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101321. */
  101322. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101323. /**
  101324. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101325. */
  101326. freeActiveMeshes(): void;
  101327. /**
  101328. * Clear the info related to rendering groups preventing retention points during dispose.
  101329. */
  101330. freeRenderingGroups(): void;
  101331. /** @hidden */
  101332. _isInIntermediateRendering(): boolean;
  101333. /**
  101334. * Lambda returning the list of potentially active meshes.
  101335. */
  101336. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101337. /**
  101338. * Lambda returning the list of potentially active sub meshes.
  101339. */
  101340. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101341. /**
  101342. * Lambda returning the list of potentially intersecting sub meshes.
  101343. */
  101344. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101345. /**
  101346. * Lambda returning the list of potentially colliding sub meshes.
  101347. */
  101348. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101349. private _activeMeshesFrozen;
  101350. /**
  101351. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101352. * @returns the current scene
  101353. */
  101354. freezeActiveMeshes(): Scene;
  101355. /**
  101356. * Use this function to restart evaluating active meshes on every frame
  101357. * @returns the current scene
  101358. */
  101359. unfreezeActiveMeshes(): Scene;
  101360. private _evaluateActiveMeshes;
  101361. private _activeMesh;
  101362. /**
  101363. * Update the transform matrix to update from the current active camera
  101364. * @param force defines a boolean used to force the update even if cache is up to date
  101365. */
  101366. updateTransformMatrix(force?: boolean): void;
  101367. private _bindFrameBuffer;
  101368. /** @hidden */
  101369. _allowPostProcessClearColor: boolean;
  101370. /** @hidden */
  101371. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101372. private _processSubCameras;
  101373. private _checkIntersections;
  101374. /** @hidden */
  101375. _advancePhysicsEngineStep(step: number): void;
  101376. /**
  101377. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101378. */
  101379. getDeterministicFrameTime: () => number;
  101380. /** @hidden */
  101381. _animate(): void;
  101382. /** Execute all animations (for a frame) */
  101383. animate(): void;
  101384. /**
  101385. * Render the scene
  101386. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101387. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101388. */
  101389. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101390. /**
  101391. * Freeze all materials
  101392. * A frozen material will not be updatable but should be faster to render
  101393. */
  101394. freezeMaterials(): void;
  101395. /**
  101396. * Unfreeze all materials
  101397. * A frozen material will not be updatable but should be faster to render
  101398. */
  101399. unfreezeMaterials(): void;
  101400. /**
  101401. * Releases all held ressources
  101402. */
  101403. dispose(): void;
  101404. /**
  101405. * Gets if the scene is already disposed
  101406. */
  101407. readonly isDisposed: boolean;
  101408. /**
  101409. * Call this function to reduce memory footprint of the scene.
  101410. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101411. */
  101412. clearCachedVertexData(): void;
  101413. /**
  101414. * This function will remove the local cached buffer data from texture.
  101415. * It will save memory but will prevent the texture from being rebuilt
  101416. */
  101417. cleanCachedTextureBuffer(): void;
  101418. /**
  101419. * Get the world extend vectors with an optional filter
  101420. *
  101421. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101422. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101423. */
  101424. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101425. min: Vector3;
  101426. max: Vector3;
  101427. };
  101428. /**
  101429. * Creates a ray that can be used to pick in the scene
  101430. * @param x defines the x coordinate of the origin (on-screen)
  101431. * @param y defines the y coordinate of the origin (on-screen)
  101432. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101433. * @param camera defines the camera to use for the picking
  101434. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101435. * @returns a Ray
  101436. */
  101437. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101438. /**
  101439. * Creates a ray that can be used to pick in the scene
  101440. * @param x defines the x coordinate of the origin (on-screen)
  101441. * @param y defines the y coordinate of the origin (on-screen)
  101442. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101443. * @param result defines the ray where to store the picking ray
  101444. * @param camera defines the camera to use for the picking
  101445. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101446. * @returns the current scene
  101447. */
  101448. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101449. /**
  101450. * Creates a ray that can be used to pick in the scene
  101451. * @param x defines the x coordinate of the origin (on-screen)
  101452. * @param y defines the y coordinate of the origin (on-screen)
  101453. * @param camera defines the camera to use for the picking
  101454. * @returns a Ray
  101455. */
  101456. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101457. /**
  101458. * Creates a ray that can be used to pick in the scene
  101459. * @param x defines the x coordinate of the origin (on-screen)
  101460. * @param y defines the y coordinate of the origin (on-screen)
  101461. * @param result defines the ray where to store the picking ray
  101462. * @param camera defines the camera to use for the picking
  101463. * @returns the current scene
  101464. */
  101465. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101466. /** Launch a ray to try to pick a mesh in the scene
  101467. * @param x position on screen
  101468. * @param y position on screen
  101469. * @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
  101470. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101471. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101472. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101473. * @returns a PickingInfo
  101474. */
  101475. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101476. /** Use the given ray to pick a mesh in the scene
  101477. * @param ray The ray to use to pick meshes
  101478. * @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
  101479. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101480. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101481. * @returns a PickingInfo
  101482. */
  101483. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101484. /**
  101485. * Launch a ray to try to pick a mesh in the scene
  101486. * @param x X position on screen
  101487. * @param y Y position on screen
  101488. * @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
  101489. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101490. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101491. * @returns an array of PickingInfo
  101492. */
  101493. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101494. /**
  101495. * Launch a ray to try to pick a mesh in the scene
  101496. * @param ray Ray to use
  101497. * @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
  101498. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101499. * @returns an array of PickingInfo
  101500. */
  101501. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101502. /**
  101503. * Force the value of meshUnderPointer
  101504. * @param mesh defines the mesh to use
  101505. */
  101506. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101507. /**
  101508. * Gets the mesh under the pointer
  101509. * @returns a Mesh or null if no mesh is under the pointer
  101510. */
  101511. getPointerOverMesh(): Nullable<AbstractMesh>;
  101512. /** @hidden */
  101513. _rebuildGeometries(): void;
  101514. /** @hidden */
  101515. _rebuildTextures(): void;
  101516. private _getByTags;
  101517. /**
  101518. * Get a list of meshes by tags
  101519. * @param tagsQuery defines the tags query to use
  101520. * @param forEach defines a predicate used to filter results
  101521. * @returns an array of Mesh
  101522. */
  101523. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101524. /**
  101525. * Get a list of cameras by tags
  101526. * @param tagsQuery defines the tags query to use
  101527. * @param forEach defines a predicate used to filter results
  101528. * @returns an array of Camera
  101529. */
  101530. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101531. /**
  101532. * Get a list of lights by tags
  101533. * @param tagsQuery defines the tags query to use
  101534. * @param forEach defines a predicate used to filter results
  101535. * @returns an array of Light
  101536. */
  101537. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101538. /**
  101539. * Get a list of materials by tags
  101540. * @param tagsQuery defines the tags query to use
  101541. * @param forEach defines a predicate used to filter results
  101542. * @returns an array of Material
  101543. */
  101544. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101545. /**
  101546. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101547. * This allowed control for front to back rendering or reversly depending of the special needs.
  101548. *
  101549. * @param renderingGroupId The rendering group id corresponding to its index
  101550. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101551. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101552. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101553. */
  101554. 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;
  101555. /**
  101556. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101557. *
  101558. * @param renderingGroupId The rendering group id corresponding to its index
  101559. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101560. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101561. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101562. */
  101563. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101564. /**
  101565. * Gets the current auto clear configuration for one rendering group of the rendering
  101566. * manager.
  101567. * @param index the rendering group index to get the information for
  101568. * @returns The auto clear setup for the requested rendering group
  101569. */
  101570. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101571. private _blockMaterialDirtyMechanism;
  101572. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101573. blockMaterialDirtyMechanism: boolean;
  101574. /**
  101575. * Will flag all materials as dirty to trigger new shader compilation
  101576. * @param flag defines the flag used to specify which material part must be marked as dirty
  101577. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101578. */
  101579. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101580. /** @hidden */
  101581. _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;
  101582. /** @hidden */
  101583. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101584. }
  101585. }
  101586. declare module BABYLON {
  101587. /**
  101588. * Set of assets to keep when moving a scene into an asset container.
  101589. */
  101590. export class KeepAssets extends AbstractScene {
  101591. }
  101592. /**
  101593. * Container with a set of assets that can be added or removed from a scene.
  101594. */
  101595. export class AssetContainer extends AbstractScene {
  101596. /**
  101597. * The scene the AssetContainer belongs to.
  101598. */
  101599. scene: Scene;
  101600. /**
  101601. * Instantiates an AssetContainer.
  101602. * @param scene The scene the AssetContainer belongs to.
  101603. */
  101604. constructor(scene: Scene);
  101605. /**
  101606. * Adds all the assets from the container to the scene.
  101607. */
  101608. addAllToScene(): void;
  101609. /**
  101610. * Removes all the assets in the container from the scene
  101611. */
  101612. removeAllFromScene(): void;
  101613. /**
  101614. * Disposes all the assets in the container
  101615. */
  101616. dispose(): void;
  101617. private _moveAssets;
  101618. /**
  101619. * Removes all the assets contained in the scene and adds them to the container.
  101620. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101621. */
  101622. moveAllFromScene(keepAssets?: KeepAssets): void;
  101623. /**
  101624. * 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.
  101625. * @returns the root mesh
  101626. */
  101627. createRootMesh(): Mesh;
  101628. }
  101629. }
  101630. declare module BABYLON {
  101631. /**
  101632. * Defines how the parser contract is defined.
  101633. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101634. */
  101635. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101636. /**
  101637. * Defines how the individual parser contract is defined.
  101638. * These parser can parse an individual asset
  101639. */
  101640. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101641. /**
  101642. * Base class of the scene acting as a container for the different elements composing a scene.
  101643. * This class is dynamically extended by the different components of the scene increasing
  101644. * flexibility and reducing coupling
  101645. */
  101646. export abstract class AbstractScene {
  101647. /**
  101648. * Stores the list of available parsers in the application.
  101649. */
  101650. private static _BabylonFileParsers;
  101651. /**
  101652. * Stores the list of available individual parsers in the application.
  101653. */
  101654. private static _IndividualBabylonFileParsers;
  101655. /**
  101656. * Adds a parser in the list of available ones
  101657. * @param name Defines the name of the parser
  101658. * @param parser Defines the parser to add
  101659. */
  101660. static AddParser(name: string, parser: BabylonFileParser): void;
  101661. /**
  101662. * Gets a general parser from the list of avaialble ones
  101663. * @param name Defines the name of the parser
  101664. * @returns the requested parser or null
  101665. */
  101666. static GetParser(name: string): Nullable<BabylonFileParser>;
  101667. /**
  101668. * Adds n individual parser in the list of available ones
  101669. * @param name Defines the name of the parser
  101670. * @param parser Defines the parser to add
  101671. */
  101672. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101673. /**
  101674. * Gets an individual parser from the list of avaialble ones
  101675. * @param name Defines the name of the parser
  101676. * @returns the requested parser or null
  101677. */
  101678. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101679. /**
  101680. * Parser json data and populate both a scene and its associated container object
  101681. * @param jsonData Defines the data to parse
  101682. * @param scene Defines the scene to parse the data for
  101683. * @param container Defines the container attached to the parsing sequence
  101684. * @param rootUrl Defines the root url of the data
  101685. */
  101686. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101687. /**
  101688. * Gets the list of root nodes (ie. nodes with no parent)
  101689. */
  101690. rootNodes: Node[];
  101691. /** All of the cameras added to this scene
  101692. * @see http://doc.babylonjs.com/babylon101/cameras
  101693. */
  101694. cameras: Camera[];
  101695. /**
  101696. * All of the lights added to this scene
  101697. * @see http://doc.babylonjs.com/babylon101/lights
  101698. */
  101699. lights: Light[];
  101700. /**
  101701. * All of the (abstract) meshes added to this scene
  101702. */
  101703. meshes: AbstractMesh[];
  101704. /**
  101705. * The list of skeletons added to the scene
  101706. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101707. */
  101708. skeletons: Skeleton[];
  101709. /**
  101710. * All of the particle systems added to this scene
  101711. * @see http://doc.babylonjs.com/babylon101/particles
  101712. */
  101713. particleSystems: IParticleSystem[];
  101714. /**
  101715. * Gets a list of Animations associated with the scene
  101716. */
  101717. animations: Animation[];
  101718. /**
  101719. * All of the animation groups added to this scene
  101720. * @see http://doc.babylonjs.com/how_to/group
  101721. */
  101722. animationGroups: AnimationGroup[];
  101723. /**
  101724. * All of the multi-materials added to this scene
  101725. * @see http://doc.babylonjs.com/how_to/multi_materials
  101726. */
  101727. multiMaterials: MultiMaterial[];
  101728. /**
  101729. * All of the materials added to this scene
  101730. * In the context of a Scene, it is not supposed to be modified manually.
  101731. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101732. * Note also that the order of the Material wihin the array is not significant and might change.
  101733. * @see http://doc.babylonjs.com/babylon101/materials
  101734. */
  101735. materials: Material[];
  101736. /**
  101737. * The list of morph target managers added to the scene
  101738. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101739. */
  101740. morphTargetManagers: MorphTargetManager[];
  101741. /**
  101742. * The list of geometries used in the scene.
  101743. */
  101744. geometries: Geometry[];
  101745. /**
  101746. * All of the tranform nodes added to this scene
  101747. * In the context of a Scene, it is not supposed to be modified manually.
  101748. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101749. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101750. * @see http://doc.babylonjs.com/how_to/transformnode
  101751. */
  101752. transformNodes: TransformNode[];
  101753. /**
  101754. * ActionManagers available on the scene.
  101755. */
  101756. actionManagers: AbstractActionManager[];
  101757. /**
  101758. * Textures to keep.
  101759. */
  101760. textures: BaseTexture[];
  101761. /**
  101762. * Environment texture for the scene
  101763. */
  101764. environmentTexture: Nullable<BaseTexture>;
  101765. }
  101766. }
  101767. declare module BABYLON {
  101768. /**
  101769. * Interface used to define options for Sound class
  101770. */
  101771. export interface ISoundOptions {
  101772. /**
  101773. * Does the sound autoplay once loaded.
  101774. */
  101775. autoplay?: boolean;
  101776. /**
  101777. * Does the sound loop after it finishes playing once.
  101778. */
  101779. loop?: boolean;
  101780. /**
  101781. * Sound's volume
  101782. */
  101783. volume?: number;
  101784. /**
  101785. * Is it a spatial sound?
  101786. */
  101787. spatialSound?: boolean;
  101788. /**
  101789. * Maximum distance to hear that sound
  101790. */
  101791. maxDistance?: number;
  101792. /**
  101793. * Uses user defined attenuation function
  101794. */
  101795. useCustomAttenuation?: boolean;
  101796. /**
  101797. * Define the roll off factor of spatial sounds.
  101798. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101799. */
  101800. rolloffFactor?: number;
  101801. /**
  101802. * Define the reference distance the sound should be heard perfectly.
  101803. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101804. */
  101805. refDistance?: number;
  101806. /**
  101807. * Define the distance attenuation model the sound will follow.
  101808. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101809. */
  101810. distanceModel?: string;
  101811. /**
  101812. * Defines the playback speed (1 by default)
  101813. */
  101814. playbackRate?: number;
  101815. /**
  101816. * Defines if the sound is from a streaming source
  101817. */
  101818. streaming?: boolean;
  101819. /**
  101820. * Defines an optional length (in seconds) inside the sound file
  101821. */
  101822. length?: number;
  101823. /**
  101824. * Defines an optional offset (in seconds) inside the sound file
  101825. */
  101826. offset?: number;
  101827. /**
  101828. * If true, URLs will not be required to state the audio file codec to use.
  101829. */
  101830. skipCodecCheck?: boolean;
  101831. }
  101832. /**
  101833. * Defines a sound that can be played in the application.
  101834. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101835. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101836. */
  101837. export class Sound {
  101838. /**
  101839. * The name of the sound in the scene.
  101840. */
  101841. name: string;
  101842. /**
  101843. * Does the sound autoplay once loaded.
  101844. */
  101845. autoplay: boolean;
  101846. /**
  101847. * Does the sound loop after it finishes playing once.
  101848. */
  101849. loop: boolean;
  101850. /**
  101851. * Does the sound use a custom attenuation curve to simulate the falloff
  101852. * happening when the source gets further away from the camera.
  101853. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101854. */
  101855. useCustomAttenuation: boolean;
  101856. /**
  101857. * The sound track id this sound belongs to.
  101858. */
  101859. soundTrackId: number;
  101860. /**
  101861. * Is this sound currently played.
  101862. */
  101863. isPlaying: boolean;
  101864. /**
  101865. * Is this sound currently paused.
  101866. */
  101867. isPaused: boolean;
  101868. /**
  101869. * Does this sound enables spatial sound.
  101870. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101871. */
  101872. spatialSound: boolean;
  101873. /**
  101874. * Define the reference distance the sound should be heard perfectly.
  101875. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101876. */
  101877. refDistance: number;
  101878. /**
  101879. * Define the roll off factor of spatial sounds.
  101880. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101881. */
  101882. rolloffFactor: number;
  101883. /**
  101884. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101885. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101886. */
  101887. maxDistance: number;
  101888. /**
  101889. * Define the distance attenuation model the sound will follow.
  101890. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101891. */
  101892. distanceModel: string;
  101893. /**
  101894. * @hidden
  101895. * Back Compat
  101896. **/
  101897. onended: () => any;
  101898. /**
  101899. * Observable event when the current playing sound finishes.
  101900. */
  101901. onEndedObservable: Observable<Sound>;
  101902. private _panningModel;
  101903. private _playbackRate;
  101904. private _streaming;
  101905. private _startTime;
  101906. private _startOffset;
  101907. private _position;
  101908. /** @hidden */
  101909. _positionInEmitterSpace: boolean;
  101910. private _localDirection;
  101911. private _volume;
  101912. private _isReadyToPlay;
  101913. private _isDirectional;
  101914. private _readyToPlayCallback;
  101915. private _audioBuffer;
  101916. private _soundSource;
  101917. private _streamingSource;
  101918. private _soundPanner;
  101919. private _soundGain;
  101920. private _inputAudioNode;
  101921. private _outputAudioNode;
  101922. private _coneInnerAngle;
  101923. private _coneOuterAngle;
  101924. private _coneOuterGain;
  101925. private _scene;
  101926. private _connectedTransformNode;
  101927. private _customAttenuationFunction;
  101928. private _registerFunc;
  101929. private _isOutputConnected;
  101930. private _htmlAudioElement;
  101931. private _urlType;
  101932. private _length?;
  101933. private _offset?;
  101934. /** @hidden */
  101935. static _SceneComponentInitialization: (scene: Scene) => void;
  101936. /**
  101937. * Create a sound and attach it to a scene
  101938. * @param name Name of your sound
  101939. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101940. * @param scene defines the scene the sound belongs to
  101941. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101942. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101943. */
  101944. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101945. /**
  101946. * Release the sound and its associated resources
  101947. */
  101948. dispose(): void;
  101949. /**
  101950. * Gets if the sounds is ready to be played or not.
  101951. * @returns true if ready, otherwise false
  101952. */
  101953. isReady(): boolean;
  101954. private _soundLoaded;
  101955. /**
  101956. * Sets the data of the sound from an audiobuffer
  101957. * @param audioBuffer The audioBuffer containing the data
  101958. */
  101959. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101960. /**
  101961. * Updates the current sounds options such as maxdistance, loop...
  101962. * @param options A JSON object containing values named as the object properties
  101963. */
  101964. updateOptions(options: ISoundOptions): void;
  101965. private _createSpatialParameters;
  101966. private _updateSpatialParameters;
  101967. /**
  101968. * Switch the panning model to HRTF:
  101969. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  101970. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101971. */
  101972. switchPanningModelToHRTF(): void;
  101973. /**
  101974. * Switch the panning model to Equal Power:
  101975. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  101976. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101977. */
  101978. switchPanningModelToEqualPower(): void;
  101979. private _switchPanningModel;
  101980. /**
  101981. * Connect this sound to a sound track audio node like gain...
  101982. * @param soundTrackAudioNode the sound track audio node to connect to
  101983. */
  101984. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  101985. /**
  101986. * Transform this sound into a directional source
  101987. * @param coneInnerAngle Size of the inner cone in degree
  101988. * @param coneOuterAngle Size of the outer cone in degree
  101989. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  101990. */
  101991. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  101992. /**
  101993. * Gets or sets the inner angle for the directional cone.
  101994. */
  101995. /**
  101996. * Gets or sets the inner angle for the directional cone.
  101997. */
  101998. directionalConeInnerAngle: number;
  101999. /**
  102000. * Gets or sets the outer angle for the directional cone.
  102001. */
  102002. /**
  102003. * Gets or sets the outer angle for the directional cone.
  102004. */
  102005. directionalConeOuterAngle: number;
  102006. /**
  102007. * Sets the position of the emitter if spatial sound is enabled
  102008. * @param newPosition Defines the new posisiton
  102009. */
  102010. setPosition(newPosition: Vector3): void;
  102011. /**
  102012. * Sets the local direction of the emitter if spatial sound is enabled
  102013. * @param newLocalDirection Defines the new local direction
  102014. */
  102015. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102016. private _updateDirection;
  102017. /** @hidden */
  102018. updateDistanceFromListener(): void;
  102019. /**
  102020. * Sets a new custom attenuation function for the sound.
  102021. * @param callback Defines the function used for the attenuation
  102022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102023. */
  102024. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102025. /**
  102026. * Play the sound
  102027. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102028. * @param offset (optional) Start the sound at a specific time in seconds
  102029. * @param length (optional) Sound duration (in seconds)
  102030. */
  102031. play(time?: number, offset?: number, length?: number): void;
  102032. private _onended;
  102033. /**
  102034. * Stop the sound
  102035. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102036. */
  102037. stop(time?: number): void;
  102038. /**
  102039. * Put the sound in pause
  102040. */
  102041. pause(): void;
  102042. /**
  102043. * Sets a dedicated volume for this sounds
  102044. * @param newVolume Define the new volume of the sound
  102045. * @param time Define time for gradual change to new volume
  102046. */
  102047. setVolume(newVolume: number, time?: number): void;
  102048. /**
  102049. * Set the sound play back rate
  102050. * @param newPlaybackRate Define the playback rate the sound should be played at
  102051. */
  102052. setPlaybackRate(newPlaybackRate: number): void;
  102053. /**
  102054. * Gets the volume of the sound.
  102055. * @returns the volume of the sound
  102056. */
  102057. getVolume(): number;
  102058. /**
  102059. * Attach the sound to a dedicated mesh
  102060. * @param transformNode The transform node to connect the sound with
  102061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102062. */
  102063. attachToMesh(transformNode: TransformNode): void;
  102064. /**
  102065. * Detach the sound from the previously attached mesh
  102066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102067. */
  102068. detachFromMesh(): void;
  102069. private _onRegisterAfterWorldMatrixUpdate;
  102070. /**
  102071. * Clone the current sound in the scene.
  102072. * @returns the new sound clone
  102073. */
  102074. clone(): Nullable<Sound>;
  102075. /**
  102076. * Gets the current underlying audio buffer containing the data
  102077. * @returns the audio buffer
  102078. */
  102079. getAudioBuffer(): Nullable<AudioBuffer>;
  102080. /**
  102081. * Serializes the Sound in a JSON representation
  102082. * @returns the JSON representation of the sound
  102083. */
  102084. serialize(): any;
  102085. /**
  102086. * Parse a JSON representation of a sound to innstantiate in a given scene
  102087. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102088. * @param scene Define the scene the new parsed sound should be created in
  102089. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102090. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102091. * @returns the newly parsed sound
  102092. */
  102093. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102094. }
  102095. }
  102096. declare module BABYLON {
  102097. /**
  102098. * This defines an action helpful to play a defined sound on a triggered action.
  102099. */
  102100. export class PlaySoundAction extends Action {
  102101. private _sound;
  102102. /**
  102103. * Instantiate the action
  102104. * @param triggerOptions defines the trigger options
  102105. * @param sound defines the sound to play
  102106. * @param condition defines the trigger related conditions
  102107. */
  102108. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102109. /** @hidden */
  102110. _prepare(): void;
  102111. /**
  102112. * Execute the action and play the sound.
  102113. */
  102114. execute(): void;
  102115. /**
  102116. * Serializes the actions and its related information.
  102117. * @param parent defines the object to serialize in
  102118. * @returns the serialized object
  102119. */
  102120. serialize(parent: any): any;
  102121. }
  102122. /**
  102123. * This defines an action helpful to stop a defined sound on a triggered action.
  102124. */
  102125. export class StopSoundAction extends Action {
  102126. private _sound;
  102127. /**
  102128. * Instantiate the action
  102129. * @param triggerOptions defines the trigger options
  102130. * @param sound defines the sound to stop
  102131. * @param condition defines the trigger related conditions
  102132. */
  102133. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102134. /** @hidden */
  102135. _prepare(): void;
  102136. /**
  102137. * Execute the action and stop the sound.
  102138. */
  102139. execute(): void;
  102140. /**
  102141. * Serializes the actions and its related information.
  102142. * @param parent defines the object to serialize in
  102143. * @returns the serialized object
  102144. */
  102145. serialize(parent: any): any;
  102146. }
  102147. }
  102148. declare module BABYLON {
  102149. /**
  102150. * This defines an action responsible to change the value of a property
  102151. * by interpolating between its current value and the newly set one once triggered.
  102152. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102153. */
  102154. export class InterpolateValueAction extends Action {
  102155. /**
  102156. * Defines the path of the property where the value should be interpolated
  102157. */
  102158. propertyPath: string;
  102159. /**
  102160. * Defines the target value at the end of the interpolation.
  102161. */
  102162. value: any;
  102163. /**
  102164. * Defines the time it will take for the property to interpolate to the value.
  102165. */
  102166. duration: number;
  102167. /**
  102168. * Defines if the other scene animations should be stopped when the action has been triggered
  102169. */
  102170. stopOtherAnimations?: boolean;
  102171. /**
  102172. * Defines a callback raised once the interpolation animation has been done.
  102173. */
  102174. onInterpolationDone?: () => void;
  102175. /**
  102176. * Observable triggered once the interpolation animation has been done.
  102177. */
  102178. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102179. private _target;
  102180. private _effectiveTarget;
  102181. private _property;
  102182. /**
  102183. * Instantiate the action
  102184. * @param triggerOptions defines the trigger options
  102185. * @param target defines the object containing the value to interpolate
  102186. * @param propertyPath defines the path to the property in the target object
  102187. * @param value defines the target value at the end of the interpolation
  102188. * @param duration deines the time it will take for the property to interpolate to the value.
  102189. * @param condition defines the trigger related conditions
  102190. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102191. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102192. */
  102193. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102194. /** @hidden */
  102195. _prepare(): void;
  102196. /**
  102197. * Execute the action starts the value interpolation.
  102198. */
  102199. execute(): void;
  102200. /**
  102201. * Serializes the actions and its related information.
  102202. * @param parent defines the object to serialize in
  102203. * @returns the serialized object
  102204. */
  102205. serialize(parent: any): any;
  102206. }
  102207. }
  102208. declare module BABYLON {
  102209. /**
  102210. * Options allowed during the creation of a sound track.
  102211. */
  102212. export interface ISoundTrackOptions {
  102213. /**
  102214. * The volume the sound track should take during creation
  102215. */
  102216. volume?: number;
  102217. /**
  102218. * Define if the sound track is the main sound track of the scene
  102219. */
  102220. mainTrack?: boolean;
  102221. }
  102222. /**
  102223. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102224. * It will be also used in a future release to apply effects on a specific track.
  102225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102226. */
  102227. export class SoundTrack {
  102228. /**
  102229. * The unique identifier of the sound track in the scene.
  102230. */
  102231. id: number;
  102232. /**
  102233. * The list of sounds included in the sound track.
  102234. */
  102235. soundCollection: Array<Sound>;
  102236. private _outputAudioNode;
  102237. private _scene;
  102238. private _isMainTrack;
  102239. private _connectedAnalyser;
  102240. private _options;
  102241. private _isInitialized;
  102242. /**
  102243. * Creates a new sound track.
  102244. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102245. * @param scene Define the scene the sound track belongs to
  102246. * @param options
  102247. */
  102248. constructor(scene: Scene, options?: ISoundTrackOptions);
  102249. private _initializeSoundTrackAudioGraph;
  102250. /**
  102251. * Release the sound track and its associated resources
  102252. */
  102253. dispose(): void;
  102254. /**
  102255. * Adds a sound to this sound track
  102256. * @param sound define the cound to add
  102257. * @ignoreNaming
  102258. */
  102259. AddSound(sound: Sound): void;
  102260. /**
  102261. * Removes a sound to this sound track
  102262. * @param sound define the cound to remove
  102263. * @ignoreNaming
  102264. */
  102265. RemoveSound(sound: Sound): void;
  102266. /**
  102267. * Set a global volume for the full sound track.
  102268. * @param newVolume Define the new volume of the sound track
  102269. */
  102270. setVolume(newVolume: number): void;
  102271. /**
  102272. * Switch the panning model to HRTF:
  102273. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102274. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102275. */
  102276. switchPanningModelToHRTF(): void;
  102277. /**
  102278. * Switch the panning model to Equal Power:
  102279. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102281. */
  102282. switchPanningModelToEqualPower(): void;
  102283. /**
  102284. * Connect the sound track to an audio analyser allowing some amazing
  102285. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102286. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102287. * @param analyser The analyser to connect to the engine
  102288. */
  102289. connectToAnalyser(analyser: Analyser): void;
  102290. }
  102291. }
  102292. declare module BABYLON {
  102293. interface AbstractScene {
  102294. /**
  102295. * The list of sounds used in the scene.
  102296. */
  102297. sounds: Nullable<Array<Sound>>;
  102298. }
  102299. interface Scene {
  102300. /**
  102301. * @hidden
  102302. * Backing field
  102303. */
  102304. _mainSoundTrack: SoundTrack;
  102305. /**
  102306. * The main sound track played by the scene.
  102307. * It cotains your primary collection of sounds.
  102308. */
  102309. mainSoundTrack: SoundTrack;
  102310. /**
  102311. * The list of sound tracks added to the scene
  102312. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102313. */
  102314. soundTracks: Nullable<Array<SoundTrack>>;
  102315. /**
  102316. * Gets a sound using a given name
  102317. * @param name defines the name to search for
  102318. * @return the found sound or null if not found at all.
  102319. */
  102320. getSoundByName(name: string): Nullable<Sound>;
  102321. /**
  102322. * Gets or sets if audio support is enabled
  102323. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102324. */
  102325. audioEnabled: boolean;
  102326. /**
  102327. * Gets or sets if audio will be output to headphones
  102328. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102329. */
  102330. headphone: boolean;
  102331. /**
  102332. * Gets or sets custom audio listener position provider
  102333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102334. */
  102335. audioListenerPositionProvider: Nullable<() => Vector3>;
  102336. }
  102337. /**
  102338. * Defines the sound scene component responsible to manage any sounds
  102339. * in a given scene.
  102340. */
  102341. export class AudioSceneComponent implements ISceneSerializableComponent {
  102342. /**
  102343. * The component name helpfull to identify the component in the list of scene components.
  102344. */
  102345. readonly name: string;
  102346. /**
  102347. * The scene the component belongs to.
  102348. */
  102349. scene: Scene;
  102350. private _audioEnabled;
  102351. /**
  102352. * Gets whether audio is enabled or not.
  102353. * Please use related enable/disable method to switch state.
  102354. */
  102355. readonly audioEnabled: boolean;
  102356. private _headphone;
  102357. /**
  102358. * Gets whether audio is outputing to headphone or not.
  102359. * Please use the according Switch methods to change output.
  102360. */
  102361. readonly headphone: boolean;
  102362. private _audioListenerPositionProvider;
  102363. /**
  102364. * Gets the current audio listener position provider
  102365. */
  102366. /**
  102367. * Sets a custom listener position for all sounds in the scene
  102368. * By default, this is the position of the first active camera
  102369. */
  102370. audioListenerPositionProvider: Nullable<() => Vector3>;
  102371. /**
  102372. * Creates a new instance of the component for the given scene
  102373. * @param scene Defines the scene to register the component in
  102374. */
  102375. constructor(scene: Scene);
  102376. /**
  102377. * Registers the component in a given scene
  102378. */
  102379. register(): void;
  102380. /**
  102381. * Rebuilds the elements related to this component in case of
  102382. * context lost for instance.
  102383. */
  102384. rebuild(): void;
  102385. /**
  102386. * Serializes the component data to the specified json object
  102387. * @param serializationObject The object to serialize to
  102388. */
  102389. serialize(serializationObject: any): void;
  102390. /**
  102391. * Adds all the elements from the container to the scene
  102392. * @param container the container holding the elements
  102393. */
  102394. addFromContainer(container: AbstractScene): void;
  102395. /**
  102396. * Removes all the elements in the container from the scene
  102397. * @param container contains the elements to remove
  102398. * @param dispose if the removed element should be disposed (default: false)
  102399. */
  102400. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102401. /**
  102402. * Disposes the component and the associated ressources.
  102403. */
  102404. dispose(): void;
  102405. /**
  102406. * Disables audio in the associated scene.
  102407. */
  102408. disableAudio(): void;
  102409. /**
  102410. * Enables audio in the associated scene.
  102411. */
  102412. enableAudio(): void;
  102413. /**
  102414. * Switch audio to headphone output.
  102415. */
  102416. switchAudioModeForHeadphones(): void;
  102417. /**
  102418. * Switch audio to normal speakers.
  102419. */
  102420. switchAudioModeForNormalSpeakers(): void;
  102421. private _afterRender;
  102422. }
  102423. }
  102424. declare module BABYLON {
  102425. /**
  102426. * Wraps one or more Sound objects and selects one with random weight for playback.
  102427. */
  102428. export class WeightedSound {
  102429. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102430. loop: boolean;
  102431. private _coneInnerAngle;
  102432. private _coneOuterAngle;
  102433. private _volume;
  102434. /** A Sound is currently playing. */
  102435. isPlaying: boolean;
  102436. /** A Sound is currently paused. */
  102437. isPaused: boolean;
  102438. private _sounds;
  102439. private _weights;
  102440. private _currentIndex?;
  102441. /**
  102442. * Creates a new WeightedSound from the list of sounds given.
  102443. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102444. * @param sounds Array of Sounds that will be selected from.
  102445. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102446. */
  102447. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102448. /**
  102449. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102450. */
  102451. /**
  102452. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102453. */
  102454. directionalConeInnerAngle: number;
  102455. /**
  102456. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102457. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102458. */
  102459. /**
  102460. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102461. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102462. */
  102463. directionalConeOuterAngle: number;
  102464. /**
  102465. * Playback volume.
  102466. */
  102467. /**
  102468. * Playback volume.
  102469. */
  102470. volume: number;
  102471. private _onended;
  102472. /**
  102473. * Suspend playback
  102474. */
  102475. pause(): void;
  102476. /**
  102477. * Stop playback
  102478. */
  102479. stop(): void;
  102480. /**
  102481. * Start playback.
  102482. * @param startOffset Position the clip head at a specific time in seconds.
  102483. */
  102484. play(startOffset?: number): void;
  102485. }
  102486. }
  102487. declare module BABYLON {
  102488. /**
  102489. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102490. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102491. */
  102492. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102493. /**
  102494. * Gets the name of the behavior.
  102495. */
  102496. readonly name: string;
  102497. /**
  102498. * The easing function used by animations
  102499. */
  102500. static EasingFunction: BackEase;
  102501. /**
  102502. * The easing mode used by animations
  102503. */
  102504. static EasingMode: number;
  102505. /**
  102506. * The duration of the animation, in milliseconds
  102507. */
  102508. transitionDuration: number;
  102509. /**
  102510. * Length of the distance animated by the transition when lower radius is reached
  102511. */
  102512. lowerRadiusTransitionRange: number;
  102513. /**
  102514. * Length of the distance animated by the transition when upper radius is reached
  102515. */
  102516. upperRadiusTransitionRange: number;
  102517. private _autoTransitionRange;
  102518. /**
  102519. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102520. */
  102521. /**
  102522. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102523. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102524. */
  102525. autoTransitionRange: boolean;
  102526. private _attachedCamera;
  102527. private _onAfterCheckInputsObserver;
  102528. private _onMeshTargetChangedObserver;
  102529. /**
  102530. * Initializes the behavior.
  102531. */
  102532. init(): void;
  102533. /**
  102534. * Attaches the behavior to its arc rotate camera.
  102535. * @param camera Defines the camera to attach the behavior to
  102536. */
  102537. attach(camera: ArcRotateCamera): void;
  102538. /**
  102539. * Detaches the behavior from its current arc rotate camera.
  102540. */
  102541. detach(): void;
  102542. private _radiusIsAnimating;
  102543. private _radiusBounceTransition;
  102544. private _animatables;
  102545. private _cachedWheelPrecision;
  102546. /**
  102547. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102548. * @param radiusLimit The limit to check against.
  102549. * @return Bool to indicate if at limit.
  102550. */
  102551. private _isRadiusAtLimit;
  102552. /**
  102553. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102554. * @param radiusDelta The delta by which to animate to. Can be negative.
  102555. */
  102556. private _applyBoundRadiusAnimation;
  102557. /**
  102558. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102559. */
  102560. protected _clearAnimationLocks(): void;
  102561. /**
  102562. * Stops and removes all animations that have been applied to the camera
  102563. */
  102564. stopAllAnimations(): void;
  102565. }
  102566. }
  102567. declare module BABYLON {
  102568. /**
  102569. * 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.
  102570. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102571. */
  102572. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102573. /**
  102574. * Gets the name of the behavior.
  102575. */
  102576. readonly name: string;
  102577. private _mode;
  102578. private _radiusScale;
  102579. private _positionScale;
  102580. private _defaultElevation;
  102581. private _elevationReturnTime;
  102582. private _elevationReturnWaitTime;
  102583. private _zoomStopsAnimation;
  102584. private _framingTime;
  102585. /**
  102586. * The easing function used by animations
  102587. */
  102588. static EasingFunction: ExponentialEase;
  102589. /**
  102590. * The easing mode used by animations
  102591. */
  102592. static EasingMode: number;
  102593. /**
  102594. * Sets the current mode used by the behavior
  102595. */
  102596. /**
  102597. * Gets current mode used by the behavior.
  102598. */
  102599. mode: number;
  102600. /**
  102601. * Sets the scale applied to the radius (1 by default)
  102602. */
  102603. /**
  102604. * Gets the scale applied to the radius
  102605. */
  102606. radiusScale: number;
  102607. /**
  102608. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102609. */
  102610. /**
  102611. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102612. */
  102613. positionScale: number;
  102614. /**
  102615. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102616. * behaviour is triggered, in radians.
  102617. */
  102618. /**
  102619. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102620. * behaviour is triggered, in radians.
  102621. */
  102622. defaultElevation: number;
  102623. /**
  102624. * Sets the time (in milliseconds) taken to return to the default beta position.
  102625. * Negative value indicates camera should not return to default.
  102626. */
  102627. /**
  102628. * Gets the time (in milliseconds) taken to return to the default beta position.
  102629. * Negative value indicates camera should not return to default.
  102630. */
  102631. elevationReturnTime: number;
  102632. /**
  102633. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102634. */
  102635. /**
  102636. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102637. */
  102638. elevationReturnWaitTime: number;
  102639. /**
  102640. * Sets the flag that indicates if user zooming should stop animation.
  102641. */
  102642. /**
  102643. * Gets the flag that indicates if user zooming should stop animation.
  102644. */
  102645. zoomStopsAnimation: boolean;
  102646. /**
  102647. * Sets the transition time when framing the mesh, in milliseconds
  102648. */
  102649. /**
  102650. * Gets the transition time when framing the mesh, in milliseconds
  102651. */
  102652. framingTime: number;
  102653. /**
  102654. * Define if the behavior should automatically change the configured
  102655. * camera limits and sensibilities.
  102656. */
  102657. autoCorrectCameraLimitsAndSensibility: boolean;
  102658. private _onPrePointerObservableObserver;
  102659. private _onAfterCheckInputsObserver;
  102660. private _onMeshTargetChangedObserver;
  102661. private _attachedCamera;
  102662. private _isPointerDown;
  102663. private _lastInteractionTime;
  102664. /**
  102665. * Initializes the behavior.
  102666. */
  102667. init(): void;
  102668. /**
  102669. * Attaches the behavior to its arc rotate camera.
  102670. * @param camera Defines the camera to attach the behavior to
  102671. */
  102672. attach(camera: ArcRotateCamera): void;
  102673. /**
  102674. * Detaches the behavior from its current arc rotate camera.
  102675. */
  102676. detach(): void;
  102677. private _animatables;
  102678. private _betaIsAnimating;
  102679. private _betaTransition;
  102680. private _radiusTransition;
  102681. private _vectorTransition;
  102682. /**
  102683. * Targets the given mesh and updates zoom level accordingly.
  102684. * @param mesh The mesh to target.
  102685. * @param radius Optional. If a cached radius position already exists, overrides default.
  102686. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102687. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102688. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102689. */
  102690. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102691. /**
  102692. * Targets the given mesh with its children and updates zoom level accordingly.
  102693. * @param mesh The mesh to target.
  102694. * @param radius Optional. If a cached radius position already exists, overrides default.
  102695. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102696. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102697. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102698. */
  102699. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102700. /**
  102701. * Targets the given meshes with their children and updates zoom level accordingly.
  102702. * @param meshes The mesh to target.
  102703. * @param radius Optional. If a cached radius position already exists, overrides default.
  102704. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102705. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102706. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102707. */
  102708. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102709. /**
  102710. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102711. * @param minimumWorld Determines the smaller position of the bounding box extend
  102712. * @param maximumWorld Determines the bigger position of the bounding box extend
  102713. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102714. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102715. */
  102716. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102717. /**
  102718. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102719. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102720. * frustum width.
  102721. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102722. * to fully enclose the mesh in the viewing frustum.
  102723. */
  102724. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102725. /**
  102726. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102727. * is automatically returned to its default position (expected to be above ground plane).
  102728. */
  102729. private _maintainCameraAboveGround;
  102730. /**
  102731. * Returns the frustum slope based on the canvas ratio and camera FOV
  102732. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102733. */
  102734. private _getFrustumSlope;
  102735. /**
  102736. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102737. */
  102738. private _clearAnimationLocks;
  102739. /**
  102740. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102741. */
  102742. private _applyUserInteraction;
  102743. /**
  102744. * Stops and removes all animations that have been applied to the camera
  102745. */
  102746. stopAllAnimations(): void;
  102747. /**
  102748. * Gets a value indicating if the user is moving the camera
  102749. */
  102750. readonly isUserIsMoving: boolean;
  102751. /**
  102752. * The camera can move all the way towards the mesh.
  102753. */
  102754. static IgnoreBoundsSizeMode: number;
  102755. /**
  102756. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102757. */
  102758. static FitFrustumSidesMode: number;
  102759. }
  102760. }
  102761. declare module BABYLON {
  102762. /**
  102763. * Base class for Camera Pointer Inputs.
  102764. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102765. * for example usage.
  102766. */
  102767. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102768. /**
  102769. * Defines the camera the input is attached to.
  102770. */
  102771. abstract camera: Camera;
  102772. /**
  102773. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102774. */
  102775. protected _altKey: boolean;
  102776. protected _ctrlKey: boolean;
  102777. protected _metaKey: boolean;
  102778. protected _shiftKey: boolean;
  102779. /**
  102780. * Which mouse buttons were pressed at time of last mouse event.
  102781. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102782. */
  102783. protected _buttonsPressed: number;
  102784. /**
  102785. * Defines the buttons associated with the input to handle camera move.
  102786. */
  102787. buttons: number[];
  102788. /**
  102789. * Attach the input controls to a specific dom element to get the input from.
  102790. * @param element Defines the element the controls should be listened from
  102791. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102792. */
  102793. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102794. /**
  102795. * Detach the current controls from the specified dom element.
  102796. * @param element Defines the element to stop listening the inputs from
  102797. */
  102798. detachControl(element: Nullable<HTMLElement>): void;
  102799. /**
  102800. * Gets the class name of the current input.
  102801. * @returns the class name
  102802. */
  102803. getClassName(): string;
  102804. /**
  102805. * Get the friendly name associated with the input class.
  102806. * @returns the input friendly name
  102807. */
  102808. getSimpleName(): string;
  102809. /**
  102810. * Called on pointer POINTERDOUBLETAP event.
  102811. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102812. */
  102813. protected onDoubleTap(type: string): void;
  102814. /**
  102815. * Called on pointer POINTERMOVE event if only a single touch is active.
  102816. * Override this method to provide functionality.
  102817. */
  102818. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102819. /**
  102820. * Called on pointer POINTERMOVE event if multiple touches are active.
  102821. * Override this method to provide functionality.
  102822. */
  102823. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102824. /**
  102825. * Called on JS contextmenu event.
  102826. * Override this method to provide functionality.
  102827. */
  102828. protected onContextMenu(evt: PointerEvent): void;
  102829. /**
  102830. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102831. * press.
  102832. * Override this method to provide functionality.
  102833. */
  102834. protected onButtonDown(evt: PointerEvent): void;
  102835. /**
  102836. * Called each time a new POINTERUP event occurs. Ie, for each button
  102837. * release.
  102838. * Override this method to provide functionality.
  102839. */
  102840. protected onButtonUp(evt: PointerEvent): void;
  102841. /**
  102842. * Called when window becomes inactive.
  102843. * Override this method to provide functionality.
  102844. */
  102845. protected onLostFocus(): void;
  102846. private _pointerInput;
  102847. private _observer;
  102848. private _onLostFocus;
  102849. private pointA;
  102850. private pointB;
  102851. }
  102852. }
  102853. declare module BABYLON {
  102854. /**
  102855. * Manage the pointers inputs to control an arc rotate camera.
  102856. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102857. */
  102858. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102859. /**
  102860. * Defines the camera the input is attached to.
  102861. */
  102862. camera: ArcRotateCamera;
  102863. /**
  102864. * Gets the class name of the current input.
  102865. * @returns the class name
  102866. */
  102867. getClassName(): string;
  102868. /**
  102869. * Defines the buttons associated with the input to handle camera move.
  102870. */
  102871. buttons: number[];
  102872. /**
  102873. * Defines the pointer angular sensibility along the X axis or how fast is
  102874. * the camera rotating.
  102875. */
  102876. angularSensibilityX: number;
  102877. /**
  102878. * Defines the pointer angular sensibility along the Y axis or how fast is
  102879. * the camera rotating.
  102880. */
  102881. angularSensibilityY: number;
  102882. /**
  102883. * Defines the pointer pinch precision or how fast is the camera zooming.
  102884. */
  102885. pinchPrecision: number;
  102886. /**
  102887. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102888. * from 0.
  102889. * It defines the percentage of current camera.radius to use as delta when
  102890. * pinch zoom is used.
  102891. */
  102892. pinchDeltaPercentage: number;
  102893. /**
  102894. * Defines the pointer panning sensibility or how fast is the camera moving.
  102895. */
  102896. panningSensibility: number;
  102897. /**
  102898. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102899. */
  102900. multiTouchPanning: boolean;
  102901. /**
  102902. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102903. * zoom (pinch) through multitouch.
  102904. */
  102905. multiTouchPanAndZoom: boolean;
  102906. /**
  102907. * Revers pinch action direction.
  102908. */
  102909. pinchInwards: boolean;
  102910. private _isPanClick;
  102911. private _twoFingerActivityCount;
  102912. private _isPinching;
  102913. /**
  102914. * Called on pointer POINTERMOVE event if only a single touch is active.
  102915. */
  102916. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102917. /**
  102918. * Called on pointer POINTERDOUBLETAP event.
  102919. */
  102920. protected onDoubleTap(type: string): void;
  102921. /**
  102922. * Called on pointer POINTERMOVE event if multiple touches are active.
  102923. */
  102924. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102925. /**
  102926. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102927. * press.
  102928. */
  102929. protected onButtonDown(evt: PointerEvent): void;
  102930. /**
  102931. * Called each time a new POINTERUP event occurs. Ie, for each button
  102932. * release.
  102933. */
  102934. protected onButtonUp(evt: PointerEvent): void;
  102935. /**
  102936. * Called when window becomes inactive.
  102937. */
  102938. protected onLostFocus(): void;
  102939. }
  102940. }
  102941. declare module BABYLON {
  102942. /**
  102943. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102945. */
  102946. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102947. /**
  102948. * Defines the camera the input is attached to.
  102949. */
  102950. camera: ArcRotateCamera;
  102951. /**
  102952. * Defines the list of key codes associated with the up action (increase alpha)
  102953. */
  102954. keysUp: number[];
  102955. /**
  102956. * Defines the list of key codes associated with the down action (decrease alpha)
  102957. */
  102958. keysDown: number[];
  102959. /**
  102960. * Defines the list of key codes associated with the left action (increase beta)
  102961. */
  102962. keysLeft: number[];
  102963. /**
  102964. * Defines the list of key codes associated with the right action (decrease beta)
  102965. */
  102966. keysRight: number[];
  102967. /**
  102968. * Defines the list of key codes associated with the reset action.
  102969. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  102970. */
  102971. keysReset: number[];
  102972. /**
  102973. * Defines the panning sensibility of the inputs.
  102974. * (How fast is the camera paning)
  102975. */
  102976. panningSensibility: number;
  102977. /**
  102978. * Defines the zooming sensibility of the inputs.
  102979. * (How fast is the camera zooming)
  102980. */
  102981. zoomingSensibility: number;
  102982. /**
  102983. * Defines wether maintaining the alt key down switch the movement mode from
  102984. * orientation to zoom.
  102985. */
  102986. useAltToZoom: boolean;
  102987. /**
  102988. * Rotation speed of the camera
  102989. */
  102990. angularSpeed: number;
  102991. private _keys;
  102992. private _ctrlPressed;
  102993. private _altPressed;
  102994. private _onCanvasBlurObserver;
  102995. private _onKeyboardObserver;
  102996. private _engine;
  102997. private _scene;
  102998. /**
  102999. * Attach the input controls to a specific dom element to get the input from.
  103000. * @param element Defines the element the controls should be listened from
  103001. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103002. */
  103003. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103004. /**
  103005. * Detach the current controls from the specified dom element.
  103006. * @param element Defines the element to stop listening the inputs from
  103007. */
  103008. detachControl(element: Nullable<HTMLElement>): void;
  103009. /**
  103010. * Update the current camera state depending on the inputs that have been used this frame.
  103011. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103012. */
  103013. checkInputs(): void;
  103014. /**
  103015. * Gets the class name of the current intput.
  103016. * @returns the class name
  103017. */
  103018. getClassName(): string;
  103019. /**
  103020. * Get the friendly name associated with the input class.
  103021. * @returns the input friendly name
  103022. */
  103023. getSimpleName(): string;
  103024. }
  103025. }
  103026. declare module BABYLON {
  103027. /**
  103028. * Manage the mouse wheel inputs to control an arc rotate camera.
  103029. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103030. */
  103031. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103032. /**
  103033. * Defines the camera the input is attached to.
  103034. */
  103035. camera: ArcRotateCamera;
  103036. /**
  103037. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103038. */
  103039. wheelPrecision: number;
  103040. /**
  103041. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103042. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103043. */
  103044. wheelDeltaPercentage: number;
  103045. private _wheel;
  103046. private _observer;
  103047. private computeDeltaFromMouseWheelLegacyEvent;
  103048. /**
  103049. * Attach the input controls to a specific dom element to get the input from.
  103050. * @param element Defines the element the controls should be listened from
  103051. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103052. */
  103053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103054. /**
  103055. * Detach the current controls from the specified dom element.
  103056. * @param element Defines the element to stop listening the inputs from
  103057. */
  103058. detachControl(element: Nullable<HTMLElement>): void;
  103059. /**
  103060. * Gets the class name of the current intput.
  103061. * @returns the class name
  103062. */
  103063. getClassName(): string;
  103064. /**
  103065. * Get the friendly name associated with the input class.
  103066. * @returns the input friendly name
  103067. */
  103068. getSimpleName(): string;
  103069. }
  103070. }
  103071. declare module BABYLON {
  103072. /**
  103073. * Default Inputs manager for the ArcRotateCamera.
  103074. * It groups all the default supported inputs for ease of use.
  103075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103076. */
  103077. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103078. /**
  103079. * Instantiates a new ArcRotateCameraInputsManager.
  103080. * @param camera Defines the camera the inputs belong to
  103081. */
  103082. constructor(camera: ArcRotateCamera);
  103083. /**
  103084. * Add mouse wheel input support to the input manager.
  103085. * @returns the current input manager
  103086. */
  103087. addMouseWheel(): ArcRotateCameraInputsManager;
  103088. /**
  103089. * Add pointers input support to the input manager.
  103090. * @returns the current input manager
  103091. */
  103092. addPointers(): ArcRotateCameraInputsManager;
  103093. /**
  103094. * Add keyboard input support to the input manager.
  103095. * @returns the current input manager
  103096. */
  103097. addKeyboard(): ArcRotateCameraInputsManager;
  103098. }
  103099. }
  103100. declare module BABYLON {
  103101. /**
  103102. * This represents an orbital type of camera.
  103103. *
  103104. * 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.
  103105. * 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.
  103106. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103107. */
  103108. export class ArcRotateCamera extends TargetCamera {
  103109. /**
  103110. * Defines the rotation angle of the camera along the longitudinal axis.
  103111. */
  103112. alpha: number;
  103113. /**
  103114. * Defines the rotation angle of the camera along the latitudinal axis.
  103115. */
  103116. beta: number;
  103117. /**
  103118. * Defines the radius of the camera from it s target point.
  103119. */
  103120. radius: number;
  103121. protected _target: Vector3;
  103122. protected _targetHost: Nullable<AbstractMesh>;
  103123. /**
  103124. * Defines the target point of the camera.
  103125. * The camera looks towards it form the radius distance.
  103126. */
  103127. target: Vector3;
  103128. /**
  103129. * Define the current local position of the camera in the scene
  103130. */
  103131. position: Vector3;
  103132. protected _upVector: Vector3;
  103133. protected _upToYMatrix: Matrix;
  103134. protected _YToUpMatrix: Matrix;
  103135. /**
  103136. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103137. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103138. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103139. */
  103140. upVector: Vector3;
  103141. /**
  103142. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103143. */
  103144. setMatUp(): void;
  103145. /**
  103146. * Current inertia value on the longitudinal axis.
  103147. * The bigger this number the longer it will take for the camera to stop.
  103148. */
  103149. inertialAlphaOffset: number;
  103150. /**
  103151. * Current inertia value on the latitudinal axis.
  103152. * The bigger this number the longer it will take for the camera to stop.
  103153. */
  103154. inertialBetaOffset: number;
  103155. /**
  103156. * Current inertia value on the radius axis.
  103157. * The bigger this number the longer it will take for the camera to stop.
  103158. */
  103159. inertialRadiusOffset: number;
  103160. /**
  103161. * Minimum allowed angle on the longitudinal axis.
  103162. * This can help limiting how the Camera is able to move in the scene.
  103163. */
  103164. lowerAlphaLimit: Nullable<number>;
  103165. /**
  103166. * Maximum allowed angle on the longitudinal axis.
  103167. * This can help limiting how the Camera is able to move in the scene.
  103168. */
  103169. upperAlphaLimit: Nullable<number>;
  103170. /**
  103171. * Minimum allowed angle on the latitudinal axis.
  103172. * This can help limiting how the Camera is able to move in the scene.
  103173. */
  103174. lowerBetaLimit: number;
  103175. /**
  103176. * Maximum allowed angle on the latitudinal axis.
  103177. * This can help limiting how the Camera is able to move in the scene.
  103178. */
  103179. upperBetaLimit: number;
  103180. /**
  103181. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103182. * This can help limiting how the Camera is able to move in the scene.
  103183. */
  103184. lowerRadiusLimit: Nullable<number>;
  103185. /**
  103186. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103187. * This can help limiting how the Camera is able to move in the scene.
  103188. */
  103189. upperRadiusLimit: Nullable<number>;
  103190. /**
  103191. * Defines the current inertia value used during panning of the camera along the X axis.
  103192. */
  103193. inertialPanningX: number;
  103194. /**
  103195. * Defines the current inertia value used during panning of the camera along the Y axis.
  103196. */
  103197. inertialPanningY: number;
  103198. /**
  103199. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103200. * Basically if your fingers moves away from more than this distance you will be considered
  103201. * in pinch mode.
  103202. */
  103203. pinchToPanMaxDistance: number;
  103204. /**
  103205. * Defines the maximum distance the camera can pan.
  103206. * This could help keeping the cammera always in your scene.
  103207. */
  103208. panningDistanceLimit: Nullable<number>;
  103209. /**
  103210. * Defines the target of the camera before paning.
  103211. */
  103212. panningOriginTarget: Vector3;
  103213. /**
  103214. * Defines the value of the inertia used during panning.
  103215. * 0 would mean stop inertia and one would mean no decelleration at all.
  103216. */
  103217. panningInertia: number;
  103218. /**
  103219. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103220. */
  103221. angularSensibilityX: number;
  103222. /**
  103223. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103224. */
  103225. angularSensibilityY: number;
  103226. /**
  103227. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103228. */
  103229. pinchPrecision: number;
  103230. /**
  103231. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103232. * It will be used instead of pinchDeltaPrecision if different from 0.
  103233. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103234. */
  103235. pinchDeltaPercentage: number;
  103236. /**
  103237. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103238. */
  103239. panningSensibility: number;
  103240. /**
  103241. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103242. */
  103243. keysUp: number[];
  103244. /**
  103245. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103246. */
  103247. keysDown: number[];
  103248. /**
  103249. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103250. */
  103251. keysLeft: number[];
  103252. /**
  103253. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103254. */
  103255. keysRight: number[];
  103256. /**
  103257. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103258. */
  103259. wheelPrecision: number;
  103260. /**
  103261. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103262. * It will be used instead of pinchDeltaPrecision if different from 0.
  103263. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103264. */
  103265. wheelDeltaPercentage: number;
  103266. /**
  103267. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103268. */
  103269. zoomOnFactor: number;
  103270. /**
  103271. * Defines a screen offset for the camera position.
  103272. */
  103273. targetScreenOffset: Vector2;
  103274. /**
  103275. * Allows the camera to be completely reversed.
  103276. * If false the camera can not arrive upside down.
  103277. */
  103278. allowUpsideDown: boolean;
  103279. /**
  103280. * Define if double tap/click is used to restore the previously saved state of the camera.
  103281. */
  103282. useInputToRestoreState: boolean;
  103283. /** @hidden */
  103284. _viewMatrix: Matrix;
  103285. /** @hidden */
  103286. _useCtrlForPanning: boolean;
  103287. /** @hidden */
  103288. _panningMouseButton: number;
  103289. /**
  103290. * Defines the input associated to the camera.
  103291. */
  103292. inputs: ArcRotateCameraInputsManager;
  103293. /** @hidden */
  103294. _reset: () => void;
  103295. /**
  103296. * Defines the allowed panning axis.
  103297. */
  103298. panningAxis: Vector3;
  103299. protected _localDirection: Vector3;
  103300. protected _transformedDirection: Vector3;
  103301. private _bouncingBehavior;
  103302. /**
  103303. * Gets the bouncing behavior of the camera if it has been enabled.
  103304. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103305. */
  103306. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103307. /**
  103308. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103309. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103310. */
  103311. useBouncingBehavior: boolean;
  103312. private _framingBehavior;
  103313. /**
  103314. * Gets the framing behavior of the camera if it has been enabled.
  103315. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103316. */
  103317. readonly framingBehavior: Nullable<FramingBehavior>;
  103318. /**
  103319. * Defines if the framing behavior of the camera is enabled on the camera.
  103320. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103321. */
  103322. useFramingBehavior: boolean;
  103323. private _autoRotationBehavior;
  103324. /**
  103325. * Gets the auto rotation behavior of the camera if it has been enabled.
  103326. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103327. */
  103328. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103329. /**
  103330. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103331. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103332. */
  103333. useAutoRotationBehavior: boolean;
  103334. /**
  103335. * Observable triggered when the mesh target has been changed on the camera.
  103336. */
  103337. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103338. /**
  103339. * Event raised when the camera is colliding with a mesh.
  103340. */
  103341. onCollide: (collidedMesh: AbstractMesh) => void;
  103342. /**
  103343. * Defines whether the camera should check collision with the objects oh the scene.
  103344. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103345. */
  103346. checkCollisions: boolean;
  103347. /**
  103348. * Defines the collision radius of the camera.
  103349. * This simulates a sphere around the camera.
  103350. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103351. */
  103352. collisionRadius: Vector3;
  103353. protected _collider: Collider;
  103354. protected _previousPosition: Vector3;
  103355. protected _collisionVelocity: Vector3;
  103356. protected _newPosition: Vector3;
  103357. protected _previousAlpha: number;
  103358. protected _previousBeta: number;
  103359. protected _previousRadius: number;
  103360. protected _collisionTriggered: boolean;
  103361. protected _targetBoundingCenter: Nullable<Vector3>;
  103362. private _computationVector;
  103363. /**
  103364. * Instantiates a new ArcRotateCamera in a given scene
  103365. * @param name Defines the name of the camera
  103366. * @param alpha Defines the camera rotation along the logitudinal axis
  103367. * @param beta Defines the camera rotation along the latitudinal axis
  103368. * @param radius Defines the camera distance from its target
  103369. * @param target Defines the camera target
  103370. * @param scene Defines the scene the camera belongs to
  103371. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103372. */
  103373. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103374. /** @hidden */
  103375. _initCache(): void;
  103376. /** @hidden */
  103377. _updateCache(ignoreParentClass?: boolean): void;
  103378. protected _getTargetPosition(): Vector3;
  103379. private _storedAlpha;
  103380. private _storedBeta;
  103381. private _storedRadius;
  103382. private _storedTarget;
  103383. private _storedTargetScreenOffset;
  103384. /**
  103385. * Stores the current state of the camera (alpha, beta, radius and target)
  103386. * @returns the camera itself
  103387. */
  103388. storeState(): Camera;
  103389. /**
  103390. * @hidden
  103391. * Restored camera state. You must call storeState() first
  103392. */
  103393. _restoreStateValues(): boolean;
  103394. /** @hidden */
  103395. _isSynchronizedViewMatrix(): boolean;
  103396. /**
  103397. * Attached controls to the current camera.
  103398. * @param element Defines the element the controls should be listened from
  103399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103400. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103401. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103402. */
  103403. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103404. /**
  103405. * Detach the current controls from the camera.
  103406. * The camera will stop reacting to inputs.
  103407. * @param element Defines the element to stop listening the inputs from
  103408. */
  103409. detachControl(element: HTMLElement): void;
  103410. /** @hidden */
  103411. _checkInputs(): void;
  103412. protected _checkLimits(): void;
  103413. /**
  103414. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103415. */
  103416. rebuildAnglesAndRadius(): void;
  103417. /**
  103418. * Use a position to define the current camera related information like alpha, beta and radius
  103419. * @param position Defines the position to set the camera at
  103420. */
  103421. setPosition(position: Vector3): void;
  103422. /**
  103423. * Defines the target the camera should look at.
  103424. * This will automatically adapt alpha beta and radius to fit within the new target.
  103425. * @param target Defines the new target as a Vector or a mesh
  103426. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103427. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103428. */
  103429. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103430. /** @hidden */
  103431. _getViewMatrix(): Matrix;
  103432. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103433. /**
  103434. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103435. * @param meshes Defines the mesh to zoom on
  103436. * @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)
  103437. */
  103438. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103439. /**
  103440. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103441. * The target will be changed but the radius
  103442. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103443. * @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)
  103444. */
  103445. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103446. min: Vector3;
  103447. max: Vector3;
  103448. distance: number;
  103449. }, doNotUpdateMaxZ?: boolean): void;
  103450. /**
  103451. * @override
  103452. * Override Camera.createRigCamera
  103453. */
  103454. createRigCamera(name: string, cameraIndex: number): Camera;
  103455. /**
  103456. * @hidden
  103457. * @override
  103458. * Override Camera._updateRigCameras
  103459. */
  103460. _updateRigCameras(): void;
  103461. /**
  103462. * Destroy the camera and release the current resources hold by it.
  103463. */
  103464. dispose(): void;
  103465. /**
  103466. * Gets the current object class name.
  103467. * @return the class name
  103468. */
  103469. getClassName(): string;
  103470. }
  103471. }
  103472. declare module BABYLON {
  103473. /**
  103474. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103475. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103476. */
  103477. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103478. /**
  103479. * Gets the name of the behavior.
  103480. */
  103481. readonly name: string;
  103482. private _zoomStopsAnimation;
  103483. private _idleRotationSpeed;
  103484. private _idleRotationWaitTime;
  103485. private _idleRotationSpinupTime;
  103486. /**
  103487. * Sets the flag that indicates if user zooming should stop animation.
  103488. */
  103489. /**
  103490. * Gets the flag that indicates if user zooming should stop animation.
  103491. */
  103492. zoomStopsAnimation: boolean;
  103493. /**
  103494. * Sets the default speed at which the camera rotates around the model.
  103495. */
  103496. /**
  103497. * Gets the default speed at which the camera rotates around the model.
  103498. */
  103499. idleRotationSpeed: number;
  103500. /**
  103501. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103502. */
  103503. /**
  103504. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103505. */
  103506. idleRotationWaitTime: number;
  103507. /**
  103508. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103509. */
  103510. /**
  103511. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103512. */
  103513. idleRotationSpinupTime: number;
  103514. /**
  103515. * Gets a value indicating if the camera is currently rotating because of this behavior
  103516. */
  103517. readonly rotationInProgress: boolean;
  103518. private _onPrePointerObservableObserver;
  103519. private _onAfterCheckInputsObserver;
  103520. private _attachedCamera;
  103521. private _isPointerDown;
  103522. private _lastFrameTime;
  103523. private _lastInteractionTime;
  103524. private _cameraRotationSpeed;
  103525. /**
  103526. * Initializes the behavior.
  103527. */
  103528. init(): void;
  103529. /**
  103530. * Attaches the behavior to its arc rotate camera.
  103531. * @param camera Defines the camera to attach the behavior to
  103532. */
  103533. attach(camera: ArcRotateCamera): void;
  103534. /**
  103535. * Detaches the behavior from its current arc rotate camera.
  103536. */
  103537. detach(): void;
  103538. /**
  103539. * Returns true if user is scrolling.
  103540. * @return true if user is scrolling.
  103541. */
  103542. private _userIsZooming;
  103543. private _lastFrameRadius;
  103544. private _shouldAnimationStopForInteraction;
  103545. /**
  103546. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103547. */
  103548. private _applyUserInteraction;
  103549. private _userIsMoving;
  103550. }
  103551. }
  103552. declare module BABYLON {
  103553. /**
  103554. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103555. */
  103556. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103557. private ui;
  103558. /**
  103559. * The name of the behavior
  103560. */
  103561. name: string;
  103562. /**
  103563. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103564. */
  103565. distanceAwayFromFace: number;
  103566. /**
  103567. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103568. */
  103569. distanceAwayFromBottomOfFace: number;
  103570. private _faceVectors;
  103571. private _target;
  103572. private _scene;
  103573. private _onRenderObserver;
  103574. private _tmpMatrix;
  103575. private _tmpVector;
  103576. /**
  103577. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103578. * @param ui The transform node that should be attched to the mesh
  103579. */
  103580. constructor(ui: TransformNode);
  103581. /**
  103582. * Initializes the behavior
  103583. */
  103584. init(): void;
  103585. private _closestFace;
  103586. private _zeroVector;
  103587. private _lookAtTmpMatrix;
  103588. private _lookAtToRef;
  103589. /**
  103590. * Attaches the AttachToBoxBehavior to the passed in mesh
  103591. * @param target The mesh that the specified node will be attached to
  103592. */
  103593. attach(target: Mesh): void;
  103594. /**
  103595. * Detaches the behavior from the mesh
  103596. */
  103597. detach(): void;
  103598. }
  103599. }
  103600. declare module BABYLON {
  103601. /**
  103602. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103603. */
  103604. export class FadeInOutBehavior implements Behavior<Mesh> {
  103605. /**
  103606. * Time in milliseconds to delay before fading in (Default: 0)
  103607. */
  103608. delay: number;
  103609. /**
  103610. * Time in milliseconds for the mesh to fade in (Default: 300)
  103611. */
  103612. fadeInTime: number;
  103613. private _millisecondsPerFrame;
  103614. private _hovered;
  103615. private _hoverValue;
  103616. private _ownerNode;
  103617. /**
  103618. * Instatiates the FadeInOutBehavior
  103619. */
  103620. constructor();
  103621. /**
  103622. * The name of the behavior
  103623. */
  103624. readonly name: string;
  103625. /**
  103626. * Initializes the behavior
  103627. */
  103628. init(): void;
  103629. /**
  103630. * Attaches the fade behavior on the passed in mesh
  103631. * @param ownerNode The mesh that will be faded in/out once attached
  103632. */
  103633. attach(ownerNode: Mesh): void;
  103634. /**
  103635. * Detaches the behavior from the mesh
  103636. */
  103637. detach(): void;
  103638. /**
  103639. * Triggers the mesh to begin fading in or out
  103640. * @param value if the object should fade in or out (true to fade in)
  103641. */
  103642. fadeIn(value: boolean): void;
  103643. private _update;
  103644. private _setAllVisibility;
  103645. }
  103646. }
  103647. declare module BABYLON {
  103648. /**
  103649. * Class containing a set of static utilities functions for managing Pivots
  103650. * @hidden
  103651. */
  103652. export class PivotTools {
  103653. private static _PivotCached;
  103654. private static _OldPivotPoint;
  103655. private static _PivotTranslation;
  103656. private static _PivotTmpVector;
  103657. /** @hidden */
  103658. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103659. /** @hidden */
  103660. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103661. }
  103662. }
  103663. declare module BABYLON {
  103664. /**
  103665. * Class containing static functions to help procedurally build meshes
  103666. */
  103667. export class PlaneBuilder {
  103668. /**
  103669. * Creates a plane mesh
  103670. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103671. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103672. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103673. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103674. * * 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
  103675. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103676. * @param name defines the name of the mesh
  103677. * @param options defines the options used to create the mesh
  103678. * @param scene defines the hosting scene
  103679. * @returns the plane mesh
  103680. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103681. */
  103682. static CreatePlane(name: string, options: {
  103683. size?: number;
  103684. width?: number;
  103685. height?: number;
  103686. sideOrientation?: number;
  103687. frontUVs?: Vector4;
  103688. backUVs?: Vector4;
  103689. updatable?: boolean;
  103690. sourcePlane?: Plane;
  103691. }, scene?: Nullable<Scene>): Mesh;
  103692. }
  103693. }
  103694. declare module BABYLON {
  103695. /**
  103696. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103697. */
  103698. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103699. private static _AnyMouseID;
  103700. /**
  103701. * Abstract mesh the behavior is set on
  103702. */
  103703. attachedNode: AbstractMesh;
  103704. private _dragPlane;
  103705. private _scene;
  103706. private _pointerObserver;
  103707. private _beforeRenderObserver;
  103708. private static _planeScene;
  103709. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103710. /**
  103711. * 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)
  103712. */
  103713. maxDragAngle: number;
  103714. /**
  103715. * @hidden
  103716. */
  103717. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103718. /**
  103719. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103720. */
  103721. currentDraggingPointerID: number;
  103722. /**
  103723. * The last position where the pointer hit the drag plane in world space
  103724. */
  103725. lastDragPosition: Vector3;
  103726. /**
  103727. * If the behavior is currently in a dragging state
  103728. */
  103729. dragging: boolean;
  103730. /**
  103731. * 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)
  103732. */
  103733. dragDeltaRatio: number;
  103734. /**
  103735. * If the drag plane orientation should be updated during the dragging (Default: true)
  103736. */
  103737. updateDragPlane: boolean;
  103738. private _debugMode;
  103739. private _moving;
  103740. /**
  103741. * Fires each time the attached mesh is dragged with the pointer
  103742. * * delta between last drag position and current drag position in world space
  103743. * * dragDistance along the drag axis
  103744. * * dragPlaneNormal normal of the current drag plane used during the drag
  103745. * * dragPlanePoint in world space where the drag intersects the drag plane
  103746. */
  103747. onDragObservable: Observable<{
  103748. delta: Vector3;
  103749. dragPlanePoint: Vector3;
  103750. dragPlaneNormal: Vector3;
  103751. dragDistance: number;
  103752. pointerId: number;
  103753. }>;
  103754. /**
  103755. * Fires each time a drag begins (eg. mouse down on mesh)
  103756. */
  103757. onDragStartObservable: Observable<{
  103758. dragPlanePoint: Vector3;
  103759. pointerId: number;
  103760. }>;
  103761. /**
  103762. * Fires each time a drag ends (eg. mouse release after drag)
  103763. */
  103764. onDragEndObservable: Observable<{
  103765. dragPlanePoint: Vector3;
  103766. pointerId: number;
  103767. }>;
  103768. /**
  103769. * If the attached mesh should be moved when dragged
  103770. */
  103771. moveAttached: boolean;
  103772. /**
  103773. * If the drag behavior will react to drag events (Default: true)
  103774. */
  103775. enabled: boolean;
  103776. /**
  103777. * If pointer events should start and release the drag (Default: true)
  103778. */
  103779. startAndReleaseDragOnPointerEvents: boolean;
  103780. /**
  103781. * If camera controls should be detached during the drag
  103782. */
  103783. detachCameraControls: boolean;
  103784. /**
  103785. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103786. */
  103787. useObjectOrienationForDragging: boolean;
  103788. private _options;
  103789. /**
  103790. * Creates a pointer drag behavior that can be attached to a mesh
  103791. * @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)
  103792. */
  103793. constructor(options?: {
  103794. dragAxis?: Vector3;
  103795. dragPlaneNormal?: Vector3;
  103796. });
  103797. /**
  103798. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103799. */
  103800. validateDrag: (targetPosition: Vector3) => boolean;
  103801. /**
  103802. * The name of the behavior
  103803. */
  103804. readonly name: string;
  103805. /**
  103806. * Initializes the behavior
  103807. */
  103808. init(): void;
  103809. private _tmpVector;
  103810. private _alternatePickedPoint;
  103811. private _worldDragAxis;
  103812. private _targetPosition;
  103813. private _attachedElement;
  103814. /**
  103815. * Attaches the drag behavior the passed in mesh
  103816. * @param ownerNode The mesh that will be dragged around once attached
  103817. * @param predicate Predicate to use for pick filtering
  103818. */
  103819. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103820. /**
  103821. * Force relase the drag action by code.
  103822. */
  103823. releaseDrag(): void;
  103824. private _startDragRay;
  103825. private _lastPointerRay;
  103826. /**
  103827. * Simulates the start of a pointer drag event on the behavior
  103828. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103829. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103830. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103831. */
  103832. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103833. private _startDrag;
  103834. private _dragDelta;
  103835. private _moveDrag;
  103836. private _pickWithRayOnDragPlane;
  103837. private _pointA;
  103838. private _pointB;
  103839. private _pointC;
  103840. private _lineA;
  103841. private _lineB;
  103842. private _localAxis;
  103843. private _lookAt;
  103844. private _updateDragPlanePosition;
  103845. /**
  103846. * Detaches the behavior from the mesh
  103847. */
  103848. detach(): void;
  103849. }
  103850. }
  103851. declare module BABYLON {
  103852. /**
  103853. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103854. */
  103855. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103856. private _dragBehaviorA;
  103857. private _dragBehaviorB;
  103858. private _startDistance;
  103859. private _initialScale;
  103860. private _targetScale;
  103861. private _ownerNode;
  103862. private _sceneRenderObserver;
  103863. /**
  103864. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103865. */
  103866. constructor();
  103867. /**
  103868. * The name of the behavior
  103869. */
  103870. readonly name: string;
  103871. /**
  103872. * Initializes the behavior
  103873. */
  103874. init(): void;
  103875. private _getCurrentDistance;
  103876. /**
  103877. * Attaches the scale behavior the passed in mesh
  103878. * @param ownerNode The mesh that will be scaled around once attached
  103879. */
  103880. attach(ownerNode: Mesh): void;
  103881. /**
  103882. * Detaches the behavior from the mesh
  103883. */
  103884. detach(): void;
  103885. }
  103886. }
  103887. declare module BABYLON {
  103888. /**
  103889. * 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
  103890. */
  103891. export class SixDofDragBehavior implements Behavior<Mesh> {
  103892. private static _virtualScene;
  103893. private _ownerNode;
  103894. private _sceneRenderObserver;
  103895. private _scene;
  103896. private _targetPosition;
  103897. private _virtualOriginMesh;
  103898. private _virtualDragMesh;
  103899. private _pointerObserver;
  103900. private _moving;
  103901. private _startingOrientation;
  103902. /**
  103903. * 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)
  103904. */
  103905. private zDragFactor;
  103906. /**
  103907. * If the object should rotate to face the drag origin
  103908. */
  103909. rotateDraggedObject: boolean;
  103910. /**
  103911. * If the behavior is currently in a dragging state
  103912. */
  103913. dragging: boolean;
  103914. /**
  103915. * 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)
  103916. */
  103917. dragDeltaRatio: number;
  103918. /**
  103919. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103920. */
  103921. currentDraggingPointerID: number;
  103922. /**
  103923. * If camera controls should be detached during the drag
  103924. */
  103925. detachCameraControls: boolean;
  103926. /**
  103927. * Fires each time a drag starts
  103928. */
  103929. onDragStartObservable: Observable<{}>;
  103930. /**
  103931. * Fires each time a drag ends (eg. mouse release after drag)
  103932. */
  103933. onDragEndObservable: Observable<{}>;
  103934. /**
  103935. * 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
  103936. */
  103937. constructor();
  103938. /**
  103939. * The name of the behavior
  103940. */
  103941. readonly name: string;
  103942. /**
  103943. * Initializes the behavior
  103944. */
  103945. init(): void;
  103946. /**
  103947. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103948. */
  103949. private readonly _pointerCamera;
  103950. /**
  103951. * Attaches the scale behavior the passed in mesh
  103952. * @param ownerNode The mesh that will be scaled around once attached
  103953. */
  103954. attach(ownerNode: Mesh): void;
  103955. /**
  103956. * Detaches the behavior from the mesh
  103957. */
  103958. detach(): void;
  103959. }
  103960. }
  103961. declare module BABYLON {
  103962. /**
  103963. * Class used to apply inverse kinematics to bones
  103964. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103965. */
  103966. export class BoneIKController {
  103967. private static _tmpVecs;
  103968. private static _tmpQuat;
  103969. private static _tmpMats;
  103970. /**
  103971. * Gets or sets the target mesh
  103972. */
  103973. targetMesh: AbstractMesh;
  103974. /** Gets or sets the mesh used as pole */
  103975. poleTargetMesh: AbstractMesh;
  103976. /**
  103977. * Gets or sets the bone used as pole
  103978. */
  103979. poleTargetBone: Nullable<Bone>;
  103980. /**
  103981. * Gets or sets the target position
  103982. */
  103983. targetPosition: Vector3;
  103984. /**
  103985. * Gets or sets the pole target position
  103986. */
  103987. poleTargetPosition: Vector3;
  103988. /**
  103989. * Gets or sets the pole target local offset
  103990. */
  103991. poleTargetLocalOffset: Vector3;
  103992. /**
  103993. * Gets or sets the pole angle
  103994. */
  103995. poleAngle: number;
  103996. /**
  103997. * Gets or sets the mesh associated with the controller
  103998. */
  103999. mesh: AbstractMesh;
  104000. /**
  104001. * 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)
  104002. */
  104003. slerpAmount: number;
  104004. private _bone1Quat;
  104005. private _bone1Mat;
  104006. private _bone2Ang;
  104007. private _bone1;
  104008. private _bone2;
  104009. private _bone1Length;
  104010. private _bone2Length;
  104011. private _maxAngle;
  104012. private _maxReach;
  104013. private _rightHandedSystem;
  104014. private _bendAxis;
  104015. private _slerping;
  104016. private _adjustRoll;
  104017. /**
  104018. * Gets or sets maximum allowed angle
  104019. */
  104020. maxAngle: number;
  104021. /**
  104022. * Creates a new BoneIKController
  104023. * @param mesh defines the mesh to control
  104024. * @param bone defines the bone to control
  104025. * @param options defines options to set up the controller
  104026. */
  104027. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104028. targetMesh?: AbstractMesh;
  104029. poleTargetMesh?: AbstractMesh;
  104030. poleTargetBone?: Bone;
  104031. poleTargetLocalOffset?: Vector3;
  104032. poleAngle?: number;
  104033. bendAxis?: Vector3;
  104034. maxAngle?: number;
  104035. slerpAmount?: number;
  104036. });
  104037. private _setMaxAngle;
  104038. /**
  104039. * Force the controller to update the bones
  104040. */
  104041. update(): void;
  104042. }
  104043. }
  104044. declare module BABYLON {
  104045. /**
  104046. * Class used to make a bone look toward a point in space
  104047. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104048. */
  104049. export class BoneLookController {
  104050. private static _tmpVecs;
  104051. private static _tmpQuat;
  104052. private static _tmpMats;
  104053. /**
  104054. * The target Vector3 that the bone will look at
  104055. */
  104056. target: Vector3;
  104057. /**
  104058. * The mesh that the bone is attached to
  104059. */
  104060. mesh: AbstractMesh;
  104061. /**
  104062. * The bone that will be looking to the target
  104063. */
  104064. bone: Bone;
  104065. /**
  104066. * The up axis of the coordinate system that is used when the bone is rotated
  104067. */
  104068. upAxis: Vector3;
  104069. /**
  104070. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104071. */
  104072. upAxisSpace: Space;
  104073. /**
  104074. * Used to make an adjustment to the yaw of the bone
  104075. */
  104076. adjustYaw: number;
  104077. /**
  104078. * Used to make an adjustment to the pitch of the bone
  104079. */
  104080. adjustPitch: number;
  104081. /**
  104082. * Used to make an adjustment to the roll of the bone
  104083. */
  104084. adjustRoll: number;
  104085. /**
  104086. * 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)
  104087. */
  104088. slerpAmount: number;
  104089. private _minYaw;
  104090. private _maxYaw;
  104091. private _minPitch;
  104092. private _maxPitch;
  104093. private _minYawSin;
  104094. private _minYawCos;
  104095. private _maxYawSin;
  104096. private _maxYawCos;
  104097. private _midYawConstraint;
  104098. private _minPitchTan;
  104099. private _maxPitchTan;
  104100. private _boneQuat;
  104101. private _slerping;
  104102. private _transformYawPitch;
  104103. private _transformYawPitchInv;
  104104. private _firstFrameSkipped;
  104105. private _yawRange;
  104106. private _fowardAxis;
  104107. /**
  104108. * Gets or sets the minimum yaw angle that the bone can look to
  104109. */
  104110. minYaw: number;
  104111. /**
  104112. * Gets or sets the maximum yaw angle that the bone can look to
  104113. */
  104114. maxYaw: number;
  104115. /**
  104116. * Gets or sets the minimum pitch angle that the bone can look to
  104117. */
  104118. minPitch: number;
  104119. /**
  104120. * Gets or sets the maximum pitch angle that the bone can look to
  104121. */
  104122. maxPitch: number;
  104123. /**
  104124. * Create a BoneLookController
  104125. * @param mesh the mesh that the bone belongs to
  104126. * @param bone the bone that will be looking to the target
  104127. * @param target the target Vector3 to look at
  104128. * @param options optional settings:
  104129. * * maxYaw: the maximum angle the bone will yaw to
  104130. * * minYaw: the minimum angle the bone will yaw to
  104131. * * maxPitch: the maximum angle the bone will pitch to
  104132. * * minPitch: the minimum angle the bone will yaw to
  104133. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104134. * * upAxis: the up axis of the coordinate system
  104135. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104136. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104137. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104138. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104139. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104140. * * adjustRoll: used to make an adjustment to the roll of the bone
  104141. **/
  104142. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104143. maxYaw?: number;
  104144. minYaw?: number;
  104145. maxPitch?: number;
  104146. minPitch?: number;
  104147. slerpAmount?: number;
  104148. upAxis?: Vector3;
  104149. upAxisSpace?: Space;
  104150. yawAxis?: Vector3;
  104151. pitchAxis?: Vector3;
  104152. adjustYaw?: number;
  104153. adjustPitch?: number;
  104154. adjustRoll?: number;
  104155. });
  104156. /**
  104157. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104158. */
  104159. update(): void;
  104160. private _getAngleDiff;
  104161. private _getAngleBetween;
  104162. private _isAngleBetween;
  104163. }
  104164. }
  104165. declare module BABYLON {
  104166. /**
  104167. * Manage the gamepad inputs to control an arc rotate camera.
  104168. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104169. */
  104170. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104171. /**
  104172. * Defines the camera the input is attached to.
  104173. */
  104174. camera: ArcRotateCamera;
  104175. /**
  104176. * Defines the gamepad the input is gathering event from.
  104177. */
  104178. gamepad: Nullable<Gamepad>;
  104179. /**
  104180. * Defines the gamepad rotation sensiblity.
  104181. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104182. */
  104183. gamepadRotationSensibility: number;
  104184. /**
  104185. * Defines the gamepad move sensiblity.
  104186. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104187. */
  104188. gamepadMoveSensibility: number;
  104189. private _yAxisScale;
  104190. /**
  104191. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  104192. */
  104193. invertYAxis: boolean;
  104194. private _onGamepadConnectedObserver;
  104195. private _onGamepadDisconnectedObserver;
  104196. /**
  104197. * Attach the input controls to a specific dom element to get the input from.
  104198. * @param element Defines the element the controls should be listened from
  104199. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104200. */
  104201. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104202. /**
  104203. * Detach the current controls from the specified dom element.
  104204. * @param element Defines the element to stop listening the inputs from
  104205. */
  104206. detachControl(element: Nullable<HTMLElement>): void;
  104207. /**
  104208. * Update the current camera state depending on the inputs that have been used this frame.
  104209. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104210. */
  104211. checkInputs(): void;
  104212. /**
  104213. * Gets the class name of the current intput.
  104214. * @returns the class name
  104215. */
  104216. getClassName(): string;
  104217. /**
  104218. * Get the friendly name associated with the input class.
  104219. * @returns the input friendly name
  104220. */
  104221. getSimpleName(): string;
  104222. }
  104223. }
  104224. declare module BABYLON {
  104225. interface ArcRotateCameraInputsManager {
  104226. /**
  104227. * Add orientation input support to the input manager.
  104228. * @returns the current input manager
  104229. */
  104230. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104231. }
  104232. /**
  104233. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104234. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104235. */
  104236. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104237. /**
  104238. * Defines the camera the input is attached to.
  104239. */
  104240. camera: ArcRotateCamera;
  104241. /**
  104242. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104243. */
  104244. alphaCorrection: number;
  104245. /**
  104246. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104247. */
  104248. gammaCorrection: number;
  104249. private _alpha;
  104250. private _gamma;
  104251. private _dirty;
  104252. private _deviceOrientationHandler;
  104253. /**
  104254. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104255. */
  104256. constructor();
  104257. /**
  104258. * Attach the input controls to a specific dom element to get the input from.
  104259. * @param element Defines the element the controls should be listened from
  104260. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104261. */
  104262. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104263. /** @hidden */
  104264. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104265. /**
  104266. * Update the current camera state depending on the inputs that have been used this frame.
  104267. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104268. */
  104269. checkInputs(): void;
  104270. /**
  104271. * Detach the current controls from the specified dom element.
  104272. * @param element Defines the element to stop listening the inputs from
  104273. */
  104274. detachControl(element: Nullable<HTMLElement>): void;
  104275. /**
  104276. * Gets the class name of the current intput.
  104277. * @returns the class name
  104278. */
  104279. getClassName(): string;
  104280. /**
  104281. * Get the friendly name associated with the input class.
  104282. * @returns the input friendly name
  104283. */
  104284. getSimpleName(): string;
  104285. }
  104286. }
  104287. declare module BABYLON {
  104288. /**
  104289. * Listen to mouse events to control the camera.
  104290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104291. */
  104292. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104293. /**
  104294. * Defines the camera the input is attached to.
  104295. */
  104296. camera: FlyCamera;
  104297. /**
  104298. * Defines if touch is enabled. (Default is true.)
  104299. */
  104300. touchEnabled: boolean;
  104301. /**
  104302. * Defines the buttons associated with the input to handle camera rotation.
  104303. */
  104304. buttons: number[];
  104305. /**
  104306. * Assign buttons for Yaw control.
  104307. */
  104308. buttonsYaw: number[];
  104309. /**
  104310. * Assign buttons for Pitch control.
  104311. */
  104312. buttonsPitch: number[];
  104313. /**
  104314. * Assign buttons for Roll control.
  104315. */
  104316. buttonsRoll: number[];
  104317. /**
  104318. * Detect if any button is being pressed while mouse is moved.
  104319. * -1 = Mouse locked.
  104320. * 0 = Left button.
  104321. * 1 = Middle Button.
  104322. * 2 = Right Button.
  104323. */
  104324. activeButton: number;
  104325. /**
  104326. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104327. * Higher values reduce its sensitivity.
  104328. */
  104329. angularSensibility: number;
  104330. private _mousemoveCallback;
  104331. private _observer;
  104332. private _rollObserver;
  104333. private previousPosition;
  104334. private noPreventDefault;
  104335. private element;
  104336. /**
  104337. * Listen to mouse events to control the camera.
  104338. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104339. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104340. */
  104341. constructor(touchEnabled?: boolean);
  104342. /**
  104343. * Attach the mouse control to the HTML DOM element.
  104344. * @param element Defines the element that listens to the input events.
  104345. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104346. */
  104347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104348. /**
  104349. * Detach the current controls from the specified dom element.
  104350. * @param element Defines the element to stop listening the inputs from
  104351. */
  104352. detachControl(element: Nullable<HTMLElement>): void;
  104353. /**
  104354. * Gets the class name of the current input.
  104355. * @returns the class name.
  104356. */
  104357. getClassName(): string;
  104358. /**
  104359. * Get the friendly name associated with the input class.
  104360. * @returns the input's friendly name.
  104361. */
  104362. getSimpleName(): string;
  104363. private _pointerInput;
  104364. private _onMouseMove;
  104365. /**
  104366. * Rotate camera by mouse offset.
  104367. */
  104368. private rotateCamera;
  104369. }
  104370. }
  104371. declare module BABYLON {
  104372. /**
  104373. * Default Inputs manager for the FlyCamera.
  104374. * It groups all the default supported inputs for ease of use.
  104375. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104376. */
  104377. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104378. /**
  104379. * Instantiates a new FlyCameraInputsManager.
  104380. * @param camera Defines the camera the inputs belong to.
  104381. */
  104382. constructor(camera: FlyCamera);
  104383. /**
  104384. * Add keyboard input support to the input manager.
  104385. * @returns the new FlyCameraKeyboardMoveInput().
  104386. */
  104387. addKeyboard(): FlyCameraInputsManager;
  104388. /**
  104389. * Add mouse input support to the input manager.
  104390. * @param touchEnabled Enable touch screen support.
  104391. * @returns the new FlyCameraMouseInput().
  104392. */
  104393. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104394. }
  104395. }
  104396. declare module BABYLON {
  104397. /**
  104398. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104399. * such as in a 3D Space Shooter or a Flight Simulator.
  104400. */
  104401. export class FlyCamera extends TargetCamera {
  104402. /**
  104403. * Define the collision ellipsoid of the camera.
  104404. * This is helpful for simulating a camera body, like a player's body.
  104405. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104406. */
  104407. ellipsoid: Vector3;
  104408. /**
  104409. * Define an offset for the position of the ellipsoid around the camera.
  104410. * This can be helpful if the camera is attached away from the player's body center,
  104411. * such as at its head.
  104412. */
  104413. ellipsoidOffset: Vector3;
  104414. /**
  104415. * Enable or disable collisions of the camera with the rest of the scene objects.
  104416. */
  104417. checkCollisions: boolean;
  104418. /**
  104419. * Enable or disable gravity on the camera.
  104420. */
  104421. applyGravity: boolean;
  104422. /**
  104423. * Define the current direction the camera is moving to.
  104424. */
  104425. cameraDirection: Vector3;
  104426. /**
  104427. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104428. * This overrides and empties cameraRotation.
  104429. */
  104430. rotationQuaternion: Quaternion;
  104431. /**
  104432. * Track Roll to maintain the wanted Rolling when looking around.
  104433. */
  104434. _trackRoll: number;
  104435. /**
  104436. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104437. */
  104438. rollCorrect: number;
  104439. /**
  104440. * Mimic a banked turn, Rolling the camera when Yawing.
  104441. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104442. */
  104443. bankedTurn: boolean;
  104444. /**
  104445. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104446. */
  104447. bankedTurnLimit: number;
  104448. /**
  104449. * Value of 0 disables the banked Roll.
  104450. * Value of 1 is equal to the Yaw angle in radians.
  104451. */
  104452. bankedTurnMultiplier: number;
  104453. /**
  104454. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104455. */
  104456. inputs: FlyCameraInputsManager;
  104457. /**
  104458. * Gets the input sensibility for mouse input.
  104459. * Higher values reduce sensitivity.
  104460. */
  104461. /**
  104462. * Sets the input sensibility for a mouse input.
  104463. * Higher values reduce sensitivity.
  104464. */
  104465. angularSensibility: number;
  104466. /**
  104467. * Get the keys for camera movement forward.
  104468. */
  104469. /**
  104470. * Set the keys for camera movement forward.
  104471. */
  104472. keysForward: number[];
  104473. /**
  104474. * Get the keys for camera movement backward.
  104475. */
  104476. keysBackward: number[];
  104477. /**
  104478. * Get the keys for camera movement up.
  104479. */
  104480. /**
  104481. * Set the keys for camera movement up.
  104482. */
  104483. keysUp: number[];
  104484. /**
  104485. * Get the keys for camera movement down.
  104486. */
  104487. /**
  104488. * Set the keys for camera movement down.
  104489. */
  104490. keysDown: number[];
  104491. /**
  104492. * Get the keys for camera movement left.
  104493. */
  104494. /**
  104495. * Set the keys for camera movement left.
  104496. */
  104497. keysLeft: number[];
  104498. /**
  104499. * Set the keys for camera movement right.
  104500. */
  104501. /**
  104502. * Set the keys for camera movement right.
  104503. */
  104504. keysRight: number[];
  104505. /**
  104506. * Event raised when the camera collides with a mesh in the scene.
  104507. */
  104508. onCollide: (collidedMesh: AbstractMesh) => void;
  104509. private _collider;
  104510. private _needMoveForGravity;
  104511. private _oldPosition;
  104512. private _diffPosition;
  104513. private _newPosition;
  104514. /** @hidden */
  104515. _localDirection: Vector3;
  104516. /** @hidden */
  104517. _transformedDirection: Vector3;
  104518. /**
  104519. * Instantiates a FlyCamera.
  104520. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104521. * such as in a 3D Space Shooter or a Flight Simulator.
  104522. * @param name Define the name of the camera in the scene.
  104523. * @param position Define the starting position of the camera in the scene.
  104524. * @param scene Define the scene the camera belongs to.
  104525. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104526. */
  104527. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104528. /**
  104529. * Attach a control to the HTML DOM element.
  104530. * @param element Defines the element that listens to the input events.
  104531. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104532. */
  104533. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104534. /**
  104535. * Detach a control from the HTML DOM element.
  104536. * The camera will stop reacting to that input.
  104537. * @param element Defines the element that listens to the input events.
  104538. */
  104539. detachControl(element: HTMLElement): void;
  104540. private _collisionMask;
  104541. /**
  104542. * Get the mask that the camera ignores in collision events.
  104543. */
  104544. /**
  104545. * Set the mask that the camera ignores in collision events.
  104546. */
  104547. collisionMask: number;
  104548. /** @hidden */
  104549. _collideWithWorld(displacement: Vector3): void;
  104550. /** @hidden */
  104551. private _onCollisionPositionChange;
  104552. /** @hidden */
  104553. _checkInputs(): void;
  104554. /** @hidden */
  104555. _decideIfNeedsToMove(): boolean;
  104556. /** @hidden */
  104557. _updatePosition(): void;
  104558. /**
  104559. * Restore the Roll to its target value at the rate specified.
  104560. * @param rate - Higher means slower restoring.
  104561. * @hidden
  104562. */
  104563. restoreRoll(rate: number): void;
  104564. /**
  104565. * Destroy the camera and release the current resources held by it.
  104566. */
  104567. dispose(): void;
  104568. /**
  104569. * Get the current object class name.
  104570. * @returns the class name.
  104571. */
  104572. getClassName(): string;
  104573. }
  104574. }
  104575. declare module BABYLON {
  104576. /**
  104577. * Listen to keyboard events to control the camera.
  104578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104579. */
  104580. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104581. /**
  104582. * Defines the camera the input is attached to.
  104583. */
  104584. camera: FlyCamera;
  104585. /**
  104586. * The list of keyboard keys used to control the forward move of the camera.
  104587. */
  104588. keysForward: number[];
  104589. /**
  104590. * The list of keyboard keys used to control the backward move of the camera.
  104591. */
  104592. keysBackward: number[];
  104593. /**
  104594. * The list of keyboard keys used to control the forward move of the camera.
  104595. */
  104596. keysUp: number[];
  104597. /**
  104598. * The list of keyboard keys used to control the backward move of the camera.
  104599. */
  104600. keysDown: number[];
  104601. /**
  104602. * The list of keyboard keys used to control the right strafe move of the camera.
  104603. */
  104604. keysRight: number[];
  104605. /**
  104606. * The list of keyboard keys used to control the left strafe move of the camera.
  104607. */
  104608. keysLeft: number[];
  104609. private _keys;
  104610. private _onCanvasBlurObserver;
  104611. private _onKeyboardObserver;
  104612. private _engine;
  104613. private _scene;
  104614. /**
  104615. * Attach the input controls to a specific dom element to get the input from.
  104616. * @param element Defines the element the controls should be listened from
  104617. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104618. */
  104619. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104620. /**
  104621. * Detach the current controls from the specified dom element.
  104622. * @param element Defines the element to stop listening the inputs from
  104623. */
  104624. detachControl(element: Nullable<HTMLElement>): void;
  104625. /**
  104626. * Gets the class name of the current intput.
  104627. * @returns the class name
  104628. */
  104629. getClassName(): string;
  104630. /** @hidden */
  104631. _onLostFocus(e: FocusEvent): void;
  104632. /**
  104633. * Get the friendly name associated with the input class.
  104634. * @returns the input friendly name
  104635. */
  104636. getSimpleName(): string;
  104637. /**
  104638. * Update the current camera state depending on the inputs that have been used this frame.
  104639. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104640. */
  104641. checkInputs(): void;
  104642. }
  104643. }
  104644. declare module BABYLON {
  104645. /**
  104646. * Manage the mouse wheel inputs to control a follow camera.
  104647. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104648. */
  104649. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104650. /**
  104651. * Defines the camera the input is attached to.
  104652. */
  104653. camera: FollowCamera;
  104654. /**
  104655. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104656. */
  104657. axisControlRadius: boolean;
  104658. /**
  104659. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104660. */
  104661. axisControlHeight: boolean;
  104662. /**
  104663. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104664. */
  104665. axisControlRotation: boolean;
  104666. /**
  104667. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104668. * relation to mouseWheel events.
  104669. */
  104670. wheelPrecision: number;
  104671. /**
  104672. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104673. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104674. */
  104675. wheelDeltaPercentage: number;
  104676. private _wheel;
  104677. private _observer;
  104678. /**
  104679. * Attach the input controls to a specific dom element to get the input from.
  104680. * @param element Defines the element the controls should be listened from
  104681. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104682. */
  104683. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104684. /**
  104685. * Detach the current controls from the specified dom element.
  104686. * @param element Defines the element to stop listening the inputs from
  104687. */
  104688. detachControl(element: Nullable<HTMLElement>): void;
  104689. /**
  104690. * Gets the class name of the current intput.
  104691. * @returns the class name
  104692. */
  104693. getClassName(): string;
  104694. /**
  104695. * Get the friendly name associated with the input class.
  104696. * @returns the input friendly name
  104697. */
  104698. getSimpleName(): string;
  104699. }
  104700. }
  104701. declare module BABYLON {
  104702. /**
  104703. * Manage the pointers inputs to control an follow camera.
  104704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104705. */
  104706. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104707. /**
  104708. * Defines the camera the input is attached to.
  104709. */
  104710. camera: FollowCamera;
  104711. /**
  104712. * Gets the class name of the current input.
  104713. * @returns the class name
  104714. */
  104715. getClassName(): string;
  104716. /**
  104717. * Defines the pointer angular sensibility along the X axis or how fast is
  104718. * the camera rotating.
  104719. * A negative number will reverse the axis direction.
  104720. */
  104721. angularSensibilityX: number;
  104722. /**
  104723. * Defines the pointer angular sensibility along the Y axis or how fast is
  104724. * the camera rotating.
  104725. * A negative number will reverse the axis direction.
  104726. */
  104727. angularSensibilityY: number;
  104728. /**
  104729. * Defines the pointer pinch precision or how fast is the camera zooming.
  104730. * A negative number will reverse the axis direction.
  104731. */
  104732. pinchPrecision: number;
  104733. /**
  104734. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104735. * from 0.
  104736. * It defines the percentage of current camera.radius to use as delta when
  104737. * pinch zoom is used.
  104738. */
  104739. pinchDeltaPercentage: number;
  104740. /**
  104741. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104742. */
  104743. axisXControlRadius: boolean;
  104744. /**
  104745. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104746. */
  104747. axisXControlHeight: boolean;
  104748. /**
  104749. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104750. */
  104751. axisXControlRotation: boolean;
  104752. /**
  104753. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104754. */
  104755. axisYControlRadius: boolean;
  104756. /**
  104757. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104758. */
  104759. axisYControlHeight: boolean;
  104760. /**
  104761. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104762. */
  104763. axisYControlRotation: boolean;
  104764. /**
  104765. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104766. */
  104767. axisPinchControlRadius: boolean;
  104768. /**
  104769. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104770. */
  104771. axisPinchControlHeight: boolean;
  104772. /**
  104773. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104774. */
  104775. axisPinchControlRotation: boolean;
  104776. /**
  104777. * Log error messages if basic misconfiguration has occurred.
  104778. */
  104779. warningEnable: boolean;
  104780. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104781. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104782. private _warningCounter;
  104783. private _warning;
  104784. }
  104785. }
  104786. declare module BABYLON {
  104787. /**
  104788. * Default Inputs manager for the FollowCamera.
  104789. * It groups all the default supported inputs for ease of use.
  104790. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104791. */
  104792. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104793. /**
  104794. * Instantiates a new FollowCameraInputsManager.
  104795. * @param camera Defines the camera the inputs belong to
  104796. */
  104797. constructor(camera: FollowCamera);
  104798. /**
  104799. * Add keyboard input support to the input manager.
  104800. * @returns the current input manager
  104801. */
  104802. addKeyboard(): FollowCameraInputsManager;
  104803. /**
  104804. * Add mouse wheel input support to the input manager.
  104805. * @returns the current input manager
  104806. */
  104807. addMouseWheel(): FollowCameraInputsManager;
  104808. /**
  104809. * Add pointers input support to the input manager.
  104810. * @returns the current input manager
  104811. */
  104812. addPointers(): FollowCameraInputsManager;
  104813. /**
  104814. * Add orientation input support to the input manager.
  104815. * @returns the current input manager
  104816. */
  104817. addVRDeviceOrientation(): FollowCameraInputsManager;
  104818. }
  104819. }
  104820. declare module BABYLON {
  104821. /**
  104822. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104823. * an arc rotate version arcFollowCamera are available.
  104824. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104825. */
  104826. export class FollowCamera extends TargetCamera {
  104827. /**
  104828. * Distance the follow camera should follow an object at
  104829. */
  104830. radius: number;
  104831. /**
  104832. * Minimum allowed distance of the camera to the axis of rotation
  104833. * (The camera can not get closer).
  104834. * This can help limiting how the Camera is able to move in the scene.
  104835. */
  104836. lowerRadiusLimit: Nullable<number>;
  104837. /**
  104838. * Maximum allowed distance of the camera to the axis of rotation
  104839. * (The camera can not get further).
  104840. * This can help limiting how the Camera is able to move in the scene.
  104841. */
  104842. upperRadiusLimit: Nullable<number>;
  104843. /**
  104844. * Define a rotation offset between the camera and the object it follows
  104845. */
  104846. rotationOffset: number;
  104847. /**
  104848. * Minimum allowed angle to camera position relative to target object.
  104849. * This can help limiting how the Camera is able to move in the scene.
  104850. */
  104851. lowerRotationOffsetLimit: Nullable<number>;
  104852. /**
  104853. * Maximum allowed angle to camera position relative to target object.
  104854. * This can help limiting how the Camera is able to move in the scene.
  104855. */
  104856. upperRotationOffsetLimit: Nullable<number>;
  104857. /**
  104858. * Define a height offset between the camera and the object it follows.
  104859. * It can help following an object from the top (like a car chaing a plane)
  104860. */
  104861. heightOffset: number;
  104862. /**
  104863. * Minimum allowed height of camera position relative to target object.
  104864. * This can help limiting how the Camera is able to move in the scene.
  104865. */
  104866. lowerHeightOffsetLimit: Nullable<number>;
  104867. /**
  104868. * Maximum allowed height of camera position relative to target object.
  104869. * This can help limiting how the Camera is able to move in the scene.
  104870. */
  104871. upperHeightOffsetLimit: Nullable<number>;
  104872. /**
  104873. * Define how fast the camera can accelerate to follow it s target.
  104874. */
  104875. cameraAcceleration: number;
  104876. /**
  104877. * Define the speed limit of the camera following an object.
  104878. */
  104879. maxCameraSpeed: number;
  104880. /**
  104881. * Define the target of the camera.
  104882. */
  104883. lockedTarget: Nullable<AbstractMesh>;
  104884. /**
  104885. * Defines the input associated with the camera.
  104886. */
  104887. inputs: FollowCameraInputsManager;
  104888. /**
  104889. * Instantiates the follow camera.
  104890. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104891. * @param name Define the name of the camera in the scene
  104892. * @param position Define the position of the camera
  104893. * @param scene Define the scene the camera belong to
  104894. * @param lockedTarget Define the target of the camera
  104895. */
  104896. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104897. private _follow;
  104898. /**
  104899. * Attached controls to the current camera.
  104900. * @param element Defines the element the controls should be listened from
  104901. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104902. */
  104903. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104904. /**
  104905. * Detach the current controls from the camera.
  104906. * The camera will stop reacting to inputs.
  104907. * @param element Defines the element to stop listening the inputs from
  104908. */
  104909. detachControl(element: HTMLElement): void;
  104910. /** @hidden */
  104911. _checkInputs(): void;
  104912. private _checkLimits;
  104913. /**
  104914. * Gets the camera class name.
  104915. * @returns the class name
  104916. */
  104917. getClassName(): string;
  104918. }
  104919. /**
  104920. * Arc Rotate version of the follow camera.
  104921. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104922. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104923. */
  104924. export class ArcFollowCamera extends TargetCamera {
  104925. /** The longitudinal angle of the camera */
  104926. alpha: number;
  104927. /** The latitudinal angle of the camera */
  104928. beta: number;
  104929. /** The radius of the camera from its target */
  104930. radius: number;
  104931. /** Define the camera target (the messh it should follow) */
  104932. target: Nullable<AbstractMesh>;
  104933. private _cartesianCoordinates;
  104934. /**
  104935. * Instantiates a new ArcFollowCamera
  104936. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104937. * @param name Define the name of the camera
  104938. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104939. * @param beta Define the rotation angle of the camera around the elevation axis
  104940. * @param radius Define the radius of the camera from its target point
  104941. * @param target Define the target of the camera
  104942. * @param scene Define the scene the camera belongs to
  104943. */
  104944. constructor(name: string,
  104945. /** The longitudinal angle of the camera */
  104946. alpha: number,
  104947. /** The latitudinal angle of the camera */
  104948. beta: number,
  104949. /** The radius of the camera from its target */
  104950. radius: number,
  104951. /** Define the camera target (the messh it should follow) */
  104952. target: Nullable<AbstractMesh>, scene: Scene);
  104953. private _follow;
  104954. /** @hidden */
  104955. _checkInputs(): void;
  104956. /**
  104957. * Returns the class name of the object.
  104958. * It is mostly used internally for serialization purposes.
  104959. */
  104960. getClassName(): string;
  104961. }
  104962. }
  104963. declare module BABYLON {
  104964. /**
  104965. * Manage the keyboard inputs to control the movement of a follow camera.
  104966. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104967. */
  104968. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104969. /**
  104970. * Defines the camera the input is attached to.
  104971. */
  104972. camera: FollowCamera;
  104973. /**
  104974. * Defines the list of key codes associated with the up action (increase heightOffset)
  104975. */
  104976. keysHeightOffsetIncr: number[];
  104977. /**
  104978. * Defines the list of key codes associated with the down action (decrease heightOffset)
  104979. */
  104980. keysHeightOffsetDecr: number[];
  104981. /**
  104982. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  104983. */
  104984. keysHeightOffsetModifierAlt: boolean;
  104985. /**
  104986. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  104987. */
  104988. keysHeightOffsetModifierCtrl: boolean;
  104989. /**
  104990. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  104991. */
  104992. keysHeightOffsetModifierShift: boolean;
  104993. /**
  104994. * Defines the list of key codes associated with the left action (increase rotationOffset)
  104995. */
  104996. keysRotationOffsetIncr: number[];
  104997. /**
  104998. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  104999. */
  105000. keysRotationOffsetDecr: number[];
  105001. /**
  105002. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  105003. */
  105004. keysRotationOffsetModifierAlt: boolean;
  105005. /**
  105006. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  105007. */
  105008. keysRotationOffsetModifierCtrl: boolean;
  105009. /**
  105010. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  105011. */
  105012. keysRotationOffsetModifierShift: boolean;
  105013. /**
  105014. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105015. */
  105016. keysRadiusIncr: number[];
  105017. /**
  105018. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105019. */
  105020. keysRadiusDecr: number[];
  105021. /**
  105022. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105023. */
  105024. keysRadiusModifierAlt: boolean;
  105025. /**
  105026. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105027. */
  105028. keysRadiusModifierCtrl: boolean;
  105029. /**
  105030. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105031. */
  105032. keysRadiusModifierShift: boolean;
  105033. /**
  105034. * Defines the rate of change of heightOffset.
  105035. */
  105036. heightSensibility: number;
  105037. /**
  105038. * Defines the rate of change of rotationOffset.
  105039. */
  105040. rotationSensibility: number;
  105041. /**
  105042. * Defines the rate of change of radius.
  105043. */
  105044. radiusSensibility: number;
  105045. private _keys;
  105046. private _ctrlPressed;
  105047. private _altPressed;
  105048. private _shiftPressed;
  105049. private _onCanvasBlurObserver;
  105050. private _onKeyboardObserver;
  105051. private _engine;
  105052. private _scene;
  105053. /**
  105054. * Attach the input controls to a specific dom element to get the input from.
  105055. * @param element Defines the element the controls should be listened from
  105056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105057. */
  105058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105059. /**
  105060. * Detach the current controls from the specified dom element.
  105061. * @param element Defines the element to stop listening the inputs from
  105062. */
  105063. detachControl(element: Nullable<HTMLElement>): void;
  105064. /**
  105065. * Update the current camera state depending on the inputs that have been used this frame.
  105066. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105067. */
  105068. checkInputs(): void;
  105069. /**
  105070. * Gets the class name of the current input.
  105071. * @returns the class name
  105072. */
  105073. getClassName(): string;
  105074. /**
  105075. * Get the friendly name associated with the input class.
  105076. * @returns the input friendly name
  105077. */
  105078. getSimpleName(): string;
  105079. /**
  105080. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105081. * allow modification of the heightOffset value.
  105082. */
  105083. private _modifierHeightOffset;
  105084. /**
  105085. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105086. * allow modification of the rotationOffset value.
  105087. */
  105088. private _modifierRotationOffset;
  105089. /**
  105090. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105091. * allow modification of the radius value.
  105092. */
  105093. private _modifierRadius;
  105094. }
  105095. }
  105096. declare module BABYLON {
  105097. interface FreeCameraInputsManager {
  105098. /**
  105099. * @hidden
  105100. */
  105101. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105102. /**
  105103. * Add orientation input support to the input manager.
  105104. * @returns the current input manager
  105105. */
  105106. addDeviceOrientation(): FreeCameraInputsManager;
  105107. }
  105108. /**
  105109. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105110. * Screen rotation is taken into account.
  105111. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105112. */
  105113. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105114. private _camera;
  105115. private _screenOrientationAngle;
  105116. private _constantTranform;
  105117. private _screenQuaternion;
  105118. private _alpha;
  105119. private _beta;
  105120. private _gamma;
  105121. /**
  105122. * Can be used to detect if a device orientation sensor is availible on a device
  105123. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105124. * @returns a promise that will resolve on orientation change
  105125. */
  105126. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105127. /**
  105128. * @hidden
  105129. */
  105130. _onDeviceOrientationChangedObservable: Observable<void>;
  105131. /**
  105132. * Instantiates a new input
  105133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105134. */
  105135. constructor();
  105136. /**
  105137. * Define the camera controlled by the input.
  105138. */
  105139. camera: FreeCamera;
  105140. /**
  105141. * Attach the input controls to a specific dom element to get the input from.
  105142. * @param element Defines the element the controls should be listened from
  105143. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105144. */
  105145. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105146. private _orientationChanged;
  105147. private _deviceOrientation;
  105148. /**
  105149. * Detach the current controls from the specified dom element.
  105150. * @param element Defines the element to stop listening the inputs from
  105151. */
  105152. detachControl(element: Nullable<HTMLElement>): void;
  105153. /**
  105154. * Update the current camera state depending on the inputs that have been used this frame.
  105155. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105156. */
  105157. checkInputs(): void;
  105158. /**
  105159. * Gets the class name of the current intput.
  105160. * @returns the class name
  105161. */
  105162. getClassName(): string;
  105163. /**
  105164. * Get the friendly name associated with the input class.
  105165. * @returns the input friendly name
  105166. */
  105167. getSimpleName(): string;
  105168. }
  105169. }
  105170. declare module BABYLON {
  105171. /**
  105172. * Manage the gamepad inputs to control a free camera.
  105173. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105174. */
  105175. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105176. /**
  105177. * Define the camera the input is attached to.
  105178. */
  105179. camera: FreeCamera;
  105180. /**
  105181. * Define the Gamepad controlling the input
  105182. */
  105183. gamepad: Nullable<Gamepad>;
  105184. /**
  105185. * Defines the gamepad rotation sensiblity.
  105186. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105187. */
  105188. gamepadAngularSensibility: number;
  105189. /**
  105190. * Defines the gamepad move sensiblity.
  105191. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105192. */
  105193. gamepadMoveSensibility: number;
  105194. private _yAxisScale;
  105195. /**
  105196. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  105197. */
  105198. invertYAxis: boolean;
  105199. private _onGamepadConnectedObserver;
  105200. private _onGamepadDisconnectedObserver;
  105201. private _cameraTransform;
  105202. private _deltaTransform;
  105203. private _vector3;
  105204. private _vector2;
  105205. /**
  105206. * Attach the input controls to a specific dom element to get the input from.
  105207. * @param element Defines the element the controls should be listened from
  105208. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105209. */
  105210. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105211. /**
  105212. * Detach the current controls from the specified dom element.
  105213. * @param element Defines the element to stop listening the inputs from
  105214. */
  105215. detachControl(element: Nullable<HTMLElement>): void;
  105216. /**
  105217. * Update the current camera state depending on the inputs that have been used this frame.
  105218. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105219. */
  105220. checkInputs(): void;
  105221. /**
  105222. * Gets the class name of the current intput.
  105223. * @returns the class name
  105224. */
  105225. getClassName(): string;
  105226. /**
  105227. * Get the friendly name associated with the input class.
  105228. * @returns the input friendly name
  105229. */
  105230. getSimpleName(): string;
  105231. }
  105232. }
  105233. declare module BABYLON {
  105234. /**
  105235. * Defines the potential axis of a Joystick
  105236. */
  105237. export enum JoystickAxis {
  105238. /** X axis */
  105239. X = 0,
  105240. /** Y axis */
  105241. Y = 1,
  105242. /** Z axis */
  105243. Z = 2
  105244. }
  105245. /**
  105246. * Class used to define virtual joystick (used in touch mode)
  105247. */
  105248. export class VirtualJoystick {
  105249. /**
  105250. * Gets or sets a boolean indicating that left and right values must be inverted
  105251. */
  105252. reverseLeftRight: boolean;
  105253. /**
  105254. * Gets or sets a boolean indicating that up and down values must be inverted
  105255. */
  105256. reverseUpDown: boolean;
  105257. /**
  105258. * Gets the offset value for the position (ie. the change of the position value)
  105259. */
  105260. deltaPosition: Vector3;
  105261. /**
  105262. * Gets a boolean indicating if the virtual joystick was pressed
  105263. */
  105264. pressed: boolean;
  105265. /**
  105266. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105267. */
  105268. static Canvas: Nullable<HTMLCanvasElement>;
  105269. private static _globalJoystickIndex;
  105270. private static vjCanvasContext;
  105271. private static vjCanvasWidth;
  105272. private static vjCanvasHeight;
  105273. private static halfWidth;
  105274. private _action;
  105275. private _axisTargetedByLeftAndRight;
  105276. private _axisTargetedByUpAndDown;
  105277. private _joystickSensibility;
  105278. private _inversedSensibility;
  105279. private _joystickPointerID;
  105280. private _joystickColor;
  105281. private _joystickPointerPos;
  105282. private _joystickPreviousPointerPos;
  105283. private _joystickPointerStartPos;
  105284. private _deltaJoystickVector;
  105285. private _leftJoystick;
  105286. private _touches;
  105287. private _onPointerDownHandlerRef;
  105288. private _onPointerMoveHandlerRef;
  105289. private _onPointerUpHandlerRef;
  105290. private _onResize;
  105291. /**
  105292. * Creates a new virtual joystick
  105293. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105294. */
  105295. constructor(leftJoystick?: boolean);
  105296. /**
  105297. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105298. * @param newJoystickSensibility defines the new sensibility
  105299. */
  105300. setJoystickSensibility(newJoystickSensibility: number): void;
  105301. private _onPointerDown;
  105302. private _onPointerMove;
  105303. private _onPointerUp;
  105304. /**
  105305. * Change the color of the virtual joystick
  105306. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105307. */
  105308. setJoystickColor(newColor: string): void;
  105309. /**
  105310. * Defines a callback to call when the joystick is touched
  105311. * @param action defines the callback
  105312. */
  105313. setActionOnTouch(action: () => any): void;
  105314. /**
  105315. * Defines which axis you'd like to control for left & right
  105316. * @param axis defines the axis to use
  105317. */
  105318. setAxisForLeftRight(axis: JoystickAxis): void;
  105319. /**
  105320. * Defines which axis you'd like to control for up & down
  105321. * @param axis defines the axis to use
  105322. */
  105323. setAxisForUpDown(axis: JoystickAxis): void;
  105324. private _drawVirtualJoystick;
  105325. /**
  105326. * Release internal HTML canvas
  105327. */
  105328. releaseCanvas(): void;
  105329. }
  105330. }
  105331. declare module BABYLON {
  105332. interface FreeCameraInputsManager {
  105333. /**
  105334. * Add virtual joystick input support to the input manager.
  105335. * @returns the current input manager
  105336. */
  105337. addVirtualJoystick(): FreeCameraInputsManager;
  105338. }
  105339. /**
  105340. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105341. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105342. */
  105343. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105344. /**
  105345. * Defines the camera the input is attached to.
  105346. */
  105347. camera: FreeCamera;
  105348. private _leftjoystick;
  105349. private _rightjoystick;
  105350. /**
  105351. * Gets the left stick of the virtual joystick.
  105352. * @returns The virtual Joystick
  105353. */
  105354. getLeftJoystick(): VirtualJoystick;
  105355. /**
  105356. * Gets the right stick of the virtual joystick.
  105357. * @returns The virtual Joystick
  105358. */
  105359. getRightJoystick(): VirtualJoystick;
  105360. /**
  105361. * Update the current camera state depending on the inputs that have been used this frame.
  105362. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105363. */
  105364. checkInputs(): void;
  105365. /**
  105366. * Attach the input controls to a specific dom element to get the input from.
  105367. * @param element Defines the element the controls should be listened from
  105368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105369. */
  105370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105371. /**
  105372. * Detach the current controls from the specified dom element.
  105373. * @param element Defines the element to stop listening the inputs from
  105374. */
  105375. detachControl(element: Nullable<HTMLElement>): void;
  105376. /**
  105377. * Gets the class name of the current intput.
  105378. * @returns the class name
  105379. */
  105380. getClassName(): string;
  105381. /**
  105382. * Get the friendly name associated with the input class.
  105383. * @returns the input friendly name
  105384. */
  105385. getSimpleName(): string;
  105386. }
  105387. }
  105388. declare module BABYLON {
  105389. /**
  105390. * This represents a FPS type of camera controlled by touch.
  105391. * This is like a universal camera minus the Gamepad controls.
  105392. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105393. */
  105394. export class TouchCamera extends FreeCamera {
  105395. /**
  105396. * Defines the touch sensibility for rotation.
  105397. * The higher the faster.
  105398. */
  105399. touchAngularSensibility: number;
  105400. /**
  105401. * Defines the touch sensibility for move.
  105402. * The higher the faster.
  105403. */
  105404. touchMoveSensibility: number;
  105405. /**
  105406. * Instantiates a new touch camera.
  105407. * This represents a FPS type of camera controlled by touch.
  105408. * This is like a universal camera minus the Gamepad controls.
  105409. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105410. * @param name Define the name of the camera in the scene
  105411. * @param position Define the start position of the camera in the scene
  105412. * @param scene Define the scene the camera belongs to
  105413. */
  105414. constructor(name: string, position: Vector3, scene: Scene);
  105415. /**
  105416. * Gets the current object class name.
  105417. * @return the class name
  105418. */
  105419. getClassName(): string;
  105420. /** @hidden */
  105421. _setupInputs(): void;
  105422. }
  105423. }
  105424. declare module BABYLON {
  105425. /**
  105426. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105427. * being tilted forward or back and left or right.
  105428. */
  105429. export class DeviceOrientationCamera extends FreeCamera {
  105430. private _initialQuaternion;
  105431. private _quaternionCache;
  105432. private _tmpDragQuaternion;
  105433. private _disablePointerInputWhenUsingDeviceOrientation;
  105434. /**
  105435. * Creates a new device orientation camera
  105436. * @param name The name of the camera
  105437. * @param position The start position camera
  105438. * @param scene The scene the camera belongs to
  105439. */
  105440. constructor(name: string, position: Vector3, scene: Scene);
  105441. /**
  105442. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105443. */
  105444. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105445. private _dragFactor;
  105446. /**
  105447. * Enabled turning on the y axis when the orientation sensor is active
  105448. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105449. */
  105450. enableHorizontalDragging(dragFactor?: number): void;
  105451. /**
  105452. * Gets the current instance class name ("DeviceOrientationCamera").
  105453. * This helps avoiding instanceof at run time.
  105454. * @returns the class name
  105455. */
  105456. getClassName(): string;
  105457. /**
  105458. * @hidden
  105459. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105460. */
  105461. _checkInputs(): void;
  105462. /**
  105463. * Reset the camera to its default orientation on the specified axis only.
  105464. * @param axis The axis to reset
  105465. */
  105466. resetToCurrentRotation(axis?: Axis): void;
  105467. }
  105468. }
  105469. declare module BABYLON {
  105470. /**
  105471. * Defines supported buttons for XBox360 compatible gamepads
  105472. */
  105473. export enum Xbox360Button {
  105474. /** A */
  105475. A = 0,
  105476. /** B */
  105477. B = 1,
  105478. /** X */
  105479. X = 2,
  105480. /** Y */
  105481. Y = 3,
  105482. /** Start */
  105483. Start = 4,
  105484. /** Back */
  105485. Back = 5,
  105486. /** Left button */
  105487. LB = 6,
  105488. /** Right button */
  105489. RB = 7,
  105490. /** Left stick */
  105491. LeftStick = 8,
  105492. /** Right stick */
  105493. RightStick = 9
  105494. }
  105495. /** Defines values for XBox360 DPad */
  105496. export enum Xbox360Dpad {
  105497. /** Up */
  105498. Up = 0,
  105499. /** Down */
  105500. Down = 1,
  105501. /** Left */
  105502. Left = 2,
  105503. /** Right */
  105504. Right = 3
  105505. }
  105506. /**
  105507. * Defines a XBox360 gamepad
  105508. */
  105509. export class Xbox360Pad extends Gamepad {
  105510. private _leftTrigger;
  105511. private _rightTrigger;
  105512. private _onlefttriggerchanged;
  105513. private _onrighttriggerchanged;
  105514. private _onbuttondown;
  105515. private _onbuttonup;
  105516. private _ondpaddown;
  105517. private _ondpadup;
  105518. /** Observable raised when a button is pressed */
  105519. onButtonDownObservable: Observable<Xbox360Button>;
  105520. /** Observable raised when a button is released */
  105521. onButtonUpObservable: Observable<Xbox360Button>;
  105522. /** Observable raised when a pad is pressed */
  105523. onPadDownObservable: Observable<Xbox360Dpad>;
  105524. /** Observable raised when a pad is released */
  105525. onPadUpObservable: Observable<Xbox360Dpad>;
  105526. private _buttonA;
  105527. private _buttonB;
  105528. private _buttonX;
  105529. private _buttonY;
  105530. private _buttonBack;
  105531. private _buttonStart;
  105532. private _buttonLB;
  105533. private _buttonRB;
  105534. private _buttonLeftStick;
  105535. private _buttonRightStick;
  105536. private _dPadUp;
  105537. private _dPadDown;
  105538. private _dPadLeft;
  105539. private _dPadRight;
  105540. private _isXboxOnePad;
  105541. /**
  105542. * Creates a new XBox360 gamepad object
  105543. * @param id defines the id of this gamepad
  105544. * @param index defines its index
  105545. * @param gamepad defines the internal HTML gamepad object
  105546. * @param xboxOne defines if it is a XBox One gamepad
  105547. */
  105548. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105549. /**
  105550. * Defines the callback to call when left trigger is pressed
  105551. * @param callback defines the callback to use
  105552. */
  105553. onlefttriggerchanged(callback: (value: number) => void): void;
  105554. /**
  105555. * Defines the callback to call when right trigger is pressed
  105556. * @param callback defines the callback to use
  105557. */
  105558. onrighttriggerchanged(callback: (value: number) => void): void;
  105559. /**
  105560. * Gets the left trigger value
  105561. */
  105562. /**
  105563. * Sets the left trigger value
  105564. */
  105565. leftTrigger: number;
  105566. /**
  105567. * Gets the right trigger value
  105568. */
  105569. /**
  105570. * Sets the right trigger value
  105571. */
  105572. rightTrigger: number;
  105573. /**
  105574. * Defines the callback to call when a button is pressed
  105575. * @param callback defines the callback to use
  105576. */
  105577. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105578. /**
  105579. * Defines the callback to call when a button is released
  105580. * @param callback defines the callback to use
  105581. */
  105582. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105583. /**
  105584. * Defines the callback to call when a pad is pressed
  105585. * @param callback defines the callback to use
  105586. */
  105587. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105588. /**
  105589. * Defines the callback to call when a pad is released
  105590. * @param callback defines the callback to use
  105591. */
  105592. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105593. private _setButtonValue;
  105594. private _setDPadValue;
  105595. /**
  105596. * Gets the value of the `A` button
  105597. */
  105598. /**
  105599. * Sets the value of the `A` button
  105600. */
  105601. buttonA: number;
  105602. /**
  105603. * Gets the value of the `B` button
  105604. */
  105605. /**
  105606. * Sets the value of the `B` button
  105607. */
  105608. buttonB: number;
  105609. /**
  105610. * Gets the value of the `X` button
  105611. */
  105612. /**
  105613. * Sets the value of the `X` button
  105614. */
  105615. buttonX: number;
  105616. /**
  105617. * Gets the value of the `Y` button
  105618. */
  105619. /**
  105620. * Sets the value of the `Y` button
  105621. */
  105622. buttonY: number;
  105623. /**
  105624. * Gets the value of the `Start` button
  105625. */
  105626. /**
  105627. * Sets the value of the `Start` button
  105628. */
  105629. buttonStart: number;
  105630. /**
  105631. * Gets the value of the `Back` button
  105632. */
  105633. /**
  105634. * Sets the value of the `Back` button
  105635. */
  105636. buttonBack: number;
  105637. /**
  105638. * Gets the value of the `Left` button
  105639. */
  105640. /**
  105641. * Sets the value of the `Left` button
  105642. */
  105643. buttonLB: number;
  105644. /**
  105645. * Gets the value of the `Right` button
  105646. */
  105647. /**
  105648. * Sets the value of the `Right` button
  105649. */
  105650. buttonRB: number;
  105651. /**
  105652. * Gets the value of the Left joystick
  105653. */
  105654. /**
  105655. * Sets the value of the Left joystick
  105656. */
  105657. buttonLeftStick: number;
  105658. /**
  105659. * Gets the value of the Right joystick
  105660. */
  105661. /**
  105662. * Sets the value of the Right joystick
  105663. */
  105664. buttonRightStick: number;
  105665. /**
  105666. * Gets the value of D-pad up
  105667. */
  105668. /**
  105669. * Sets the value of D-pad up
  105670. */
  105671. dPadUp: number;
  105672. /**
  105673. * Gets the value of D-pad down
  105674. */
  105675. /**
  105676. * Sets the value of D-pad down
  105677. */
  105678. dPadDown: number;
  105679. /**
  105680. * Gets the value of D-pad left
  105681. */
  105682. /**
  105683. * Sets the value of D-pad left
  105684. */
  105685. dPadLeft: number;
  105686. /**
  105687. * Gets the value of D-pad right
  105688. */
  105689. /**
  105690. * Sets the value of D-pad right
  105691. */
  105692. dPadRight: number;
  105693. /**
  105694. * Force the gamepad to synchronize with device values
  105695. */
  105696. update(): void;
  105697. /**
  105698. * Disposes the gamepad
  105699. */
  105700. dispose(): void;
  105701. }
  105702. }
  105703. declare module BABYLON {
  105704. /**
  105705. * Defines supported buttons for DualShock compatible gamepads
  105706. */
  105707. export enum DualShockButton {
  105708. /** Cross */
  105709. Cross = 0,
  105710. /** Circle */
  105711. Circle = 1,
  105712. /** Square */
  105713. Square = 2,
  105714. /** Triangle */
  105715. Triangle = 3,
  105716. /** Options */
  105717. Options = 4,
  105718. /** Share */
  105719. Share = 5,
  105720. /** L1 */
  105721. L1 = 6,
  105722. /** R1 */
  105723. R1 = 7,
  105724. /** Left stick */
  105725. LeftStick = 8,
  105726. /** Right stick */
  105727. RightStick = 9
  105728. }
  105729. /** Defines values for DualShock DPad */
  105730. export enum DualShockDpad {
  105731. /** Up */
  105732. Up = 0,
  105733. /** Down */
  105734. Down = 1,
  105735. /** Left */
  105736. Left = 2,
  105737. /** Right */
  105738. Right = 3
  105739. }
  105740. /**
  105741. * Defines a DualShock gamepad
  105742. */
  105743. export class DualShockPad extends Gamepad {
  105744. private _leftTrigger;
  105745. private _rightTrigger;
  105746. private _onlefttriggerchanged;
  105747. private _onrighttriggerchanged;
  105748. private _onbuttondown;
  105749. private _onbuttonup;
  105750. private _ondpaddown;
  105751. private _ondpadup;
  105752. /** Observable raised when a button is pressed */
  105753. onButtonDownObservable: Observable<DualShockButton>;
  105754. /** Observable raised when a button is released */
  105755. onButtonUpObservable: Observable<DualShockButton>;
  105756. /** Observable raised when a pad is pressed */
  105757. onPadDownObservable: Observable<DualShockDpad>;
  105758. /** Observable raised when a pad is released */
  105759. onPadUpObservable: Observable<DualShockDpad>;
  105760. private _buttonCross;
  105761. private _buttonCircle;
  105762. private _buttonSquare;
  105763. private _buttonTriangle;
  105764. private _buttonShare;
  105765. private _buttonOptions;
  105766. private _buttonL1;
  105767. private _buttonR1;
  105768. private _buttonLeftStick;
  105769. private _buttonRightStick;
  105770. private _dPadUp;
  105771. private _dPadDown;
  105772. private _dPadLeft;
  105773. private _dPadRight;
  105774. /**
  105775. * Creates a new DualShock gamepad object
  105776. * @param id defines the id of this gamepad
  105777. * @param index defines its index
  105778. * @param gamepad defines the internal HTML gamepad object
  105779. */
  105780. constructor(id: string, index: number, gamepad: any);
  105781. /**
  105782. * Defines the callback to call when left trigger is pressed
  105783. * @param callback defines the callback to use
  105784. */
  105785. onlefttriggerchanged(callback: (value: number) => void): void;
  105786. /**
  105787. * Defines the callback to call when right trigger is pressed
  105788. * @param callback defines the callback to use
  105789. */
  105790. onrighttriggerchanged(callback: (value: number) => void): void;
  105791. /**
  105792. * Gets the left trigger value
  105793. */
  105794. /**
  105795. * Sets the left trigger value
  105796. */
  105797. leftTrigger: number;
  105798. /**
  105799. * Gets the right trigger value
  105800. */
  105801. /**
  105802. * Sets the right trigger value
  105803. */
  105804. rightTrigger: number;
  105805. /**
  105806. * Defines the callback to call when a button is pressed
  105807. * @param callback defines the callback to use
  105808. */
  105809. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105810. /**
  105811. * Defines the callback to call when a button is released
  105812. * @param callback defines the callback to use
  105813. */
  105814. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105815. /**
  105816. * Defines the callback to call when a pad is pressed
  105817. * @param callback defines the callback to use
  105818. */
  105819. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105820. /**
  105821. * Defines the callback to call when a pad is released
  105822. * @param callback defines the callback to use
  105823. */
  105824. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105825. private _setButtonValue;
  105826. private _setDPadValue;
  105827. /**
  105828. * Gets the value of the `Cross` button
  105829. */
  105830. /**
  105831. * Sets the value of the `Cross` button
  105832. */
  105833. buttonCross: number;
  105834. /**
  105835. * Gets the value of the `Circle` button
  105836. */
  105837. /**
  105838. * Sets the value of the `Circle` button
  105839. */
  105840. buttonCircle: number;
  105841. /**
  105842. * Gets the value of the `Square` button
  105843. */
  105844. /**
  105845. * Sets the value of the `Square` button
  105846. */
  105847. buttonSquare: number;
  105848. /**
  105849. * Gets the value of the `Triangle` button
  105850. */
  105851. /**
  105852. * Sets the value of the `Triangle` button
  105853. */
  105854. buttonTriangle: number;
  105855. /**
  105856. * Gets the value of the `Options` button
  105857. */
  105858. /**
  105859. * Sets the value of the `Options` button
  105860. */
  105861. buttonOptions: number;
  105862. /**
  105863. * Gets the value of the `Share` button
  105864. */
  105865. /**
  105866. * Sets the value of the `Share` button
  105867. */
  105868. buttonShare: number;
  105869. /**
  105870. * Gets the value of the `L1` button
  105871. */
  105872. /**
  105873. * Sets the value of the `L1` button
  105874. */
  105875. buttonL1: number;
  105876. /**
  105877. * Gets the value of the `R1` button
  105878. */
  105879. /**
  105880. * Sets the value of the `R1` button
  105881. */
  105882. buttonR1: number;
  105883. /**
  105884. * Gets the value of the Left joystick
  105885. */
  105886. /**
  105887. * Sets the value of the Left joystick
  105888. */
  105889. buttonLeftStick: number;
  105890. /**
  105891. * Gets the value of the Right joystick
  105892. */
  105893. /**
  105894. * Sets the value of the Right joystick
  105895. */
  105896. buttonRightStick: number;
  105897. /**
  105898. * Gets the value of D-pad up
  105899. */
  105900. /**
  105901. * Sets the value of D-pad up
  105902. */
  105903. dPadUp: number;
  105904. /**
  105905. * Gets the value of D-pad down
  105906. */
  105907. /**
  105908. * Sets the value of D-pad down
  105909. */
  105910. dPadDown: number;
  105911. /**
  105912. * Gets the value of D-pad left
  105913. */
  105914. /**
  105915. * Sets the value of D-pad left
  105916. */
  105917. dPadLeft: number;
  105918. /**
  105919. * Gets the value of D-pad right
  105920. */
  105921. /**
  105922. * Sets the value of D-pad right
  105923. */
  105924. dPadRight: number;
  105925. /**
  105926. * Force the gamepad to synchronize with device values
  105927. */
  105928. update(): void;
  105929. /**
  105930. * Disposes the gamepad
  105931. */
  105932. dispose(): void;
  105933. }
  105934. }
  105935. declare module BABYLON {
  105936. /**
  105937. * Manager for handling gamepads
  105938. */
  105939. export class GamepadManager {
  105940. private _scene?;
  105941. private _babylonGamepads;
  105942. private _oneGamepadConnected;
  105943. /** @hidden */
  105944. _isMonitoring: boolean;
  105945. private _gamepadEventSupported;
  105946. private _gamepadSupport;
  105947. /**
  105948. * observable to be triggered when the gamepad controller has been connected
  105949. */
  105950. onGamepadConnectedObservable: Observable<Gamepad>;
  105951. /**
  105952. * observable to be triggered when the gamepad controller has been disconnected
  105953. */
  105954. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105955. private _onGamepadConnectedEvent;
  105956. private _onGamepadDisconnectedEvent;
  105957. /**
  105958. * Initializes the gamepad manager
  105959. * @param _scene BabylonJS scene
  105960. */
  105961. constructor(_scene?: Scene | undefined);
  105962. /**
  105963. * The gamepads in the game pad manager
  105964. */
  105965. readonly gamepads: Gamepad[];
  105966. /**
  105967. * Get the gamepad controllers based on type
  105968. * @param type The type of gamepad controller
  105969. * @returns Nullable gamepad
  105970. */
  105971. getGamepadByType(type?: number): Nullable<Gamepad>;
  105972. /**
  105973. * Disposes the gamepad manager
  105974. */
  105975. dispose(): void;
  105976. private _addNewGamepad;
  105977. private _startMonitoringGamepads;
  105978. private _stopMonitoringGamepads;
  105979. /** @hidden */
  105980. _checkGamepadsStatus(): void;
  105981. private _updateGamepadObjects;
  105982. }
  105983. }
  105984. declare module BABYLON {
  105985. interface Scene {
  105986. /** @hidden */
  105987. _gamepadManager: Nullable<GamepadManager>;
  105988. /**
  105989. * Gets the gamepad manager associated with the scene
  105990. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  105991. */
  105992. gamepadManager: GamepadManager;
  105993. }
  105994. /**
  105995. * Interface representing a free camera inputs manager
  105996. */
  105997. interface FreeCameraInputsManager {
  105998. /**
  105999. * Adds gamepad input support to the FreeCameraInputsManager.
  106000. * @returns the FreeCameraInputsManager
  106001. */
  106002. addGamepad(): FreeCameraInputsManager;
  106003. }
  106004. /**
  106005. * Interface representing an arc rotate camera inputs manager
  106006. */
  106007. interface ArcRotateCameraInputsManager {
  106008. /**
  106009. * Adds gamepad input support to the ArcRotateCamera InputManager.
  106010. * @returns the camera inputs manager
  106011. */
  106012. addGamepad(): ArcRotateCameraInputsManager;
  106013. }
  106014. /**
  106015. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106016. */
  106017. export class GamepadSystemSceneComponent implements ISceneComponent {
  106018. /**
  106019. * The component name helpfull to identify the component in the list of scene components.
  106020. */
  106021. readonly name: string;
  106022. /**
  106023. * The scene the component belongs to.
  106024. */
  106025. scene: Scene;
  106026. /**
  106027. * Creates a new instance of the component for the given scene
  106028. * @param scene Defines the scene to register the component in
  106029. */
  106030. constructor(scene: Scene);
  106031. /**
  106032. * Registers the component in a given scene
  106033. */
  106034. register(): void;
  106035. /**
  106036. * Rebuilds the elements related to this component in case of
  106037. * context lost for instance.
  106038. */
  106039. rebuild(): void;
  106040. /**
  106041. * Disposes the component and the associated ressources
  106042. */
  106043. dispose(): void;
  106044. private _beforeCameraUpdate;
  106045. }
  106046. }
  106047. declare module BABYLON {
  106048. /**
  106049. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  106050. * which still works and will still be found in many Playgrounds.
  106051. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106052. */
  106053. export class UniversalCamera extends TouchCamera {
  106054. /**
  106055. * Defines the gamepad rotation sensiblity.
  106056. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106057. */
  106058. gamepadAngularSensibility: number;
  106059. /**
  106060. * Defines the gamepad move sensiblity.
  106061. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106062. */
  106063. gamepadMoveSensibility: number;
  106064. /**
  106065. * 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,
  106066. * which still works and will still be found in many Playgrounds.
  106067. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106068. * @param name Define the name of the camera in the scene
  106069. * @param position Define the start position of the camera in the scene
  106070. * @param scene Define the scene the camera belongs to
  106071. */
  106072. constructor(name: string, position: Vector3, scene: Scene);
  106073. /**
  106074. * Gets the current object class name.
  106075. * @return the class name
  106076. */
  106077. getClassName(): string;
  106078. }
  106079. }
  106080. declare module BABYLON {
  106081. /**
  106082. * This represents a FPS type of camera. This is only here for back compat purpose.
  106083. * Please use the UniversalCamera instead as both are identical.
  106084. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106085. */
  106086. export class GamepadCamera extends UniversalCamera {
  106087. /**
  106088. * Instantiates a new Gamepad Camera
  106089. * This represents a FPS type of camera. This is only here for back compat purpose.
  106090. * Please use the UniversalCamera instead as both are identical.
  106091. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106092. * @param name Define the name of the camera in the scene
  106093. * @param position Define the start position of the camera in the scene
  106094. * @param scene Define the scene the camera belongs to
  106095. */
  106096. constructor(name: string, position: Vector3, scene: Scene);
  106097. /**
  106098. * Gets the current object class name.
  106099. * @return the class name
  106100. */
  106101. getClassName(): string;
  106102. }
  106103. }
  106104. declare module BABYLON {
  106105. /** @hidden */
  106106. export var passPixelShader: {
  106107. name: string;
  106108. shader: string;
  106109. };
  106110. }
  106111. declare module BABYLON {
  106112. /** @hidden */
  106113. export var passCubePixelShader: {
  106114. name: string;
  106115. shader: string;
  106116. };
  106117. }
  106118. declare module BABYLON {
  106119. /**
  106120. * PassPostProcess which produces an output the same as it's input
  106121. */
  106122. export class PassPostProcess extends PostProcess {
  106123. /**
  106124. * Creates the PassPostProcess
  106125. * @param name The name of the effect.
  106126. * @param options The required width/height ratio to downsize to before computing the render pass.
  106127. * @param camera The camera to apply the render pass to.
  106128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106129. * @param engine The engine which the post process will be applied. (default: current engine)
  106130. * @param reusable If the post process can be reused on the same frame. (default: false)
  106131. * @param textureType The type of texture to be used when performing the post processing.
  106132. * @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)
  106133. */
  106134. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106135. }
  106136. /**
  106137. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106138. */
  106139. export class PassCubePostProcess extends PostProcess {
  106140. private _face;
  106141. /**
  106142. * Gets or sets the cube face to display.
  106143. * * 0 is +X
  106144. * * 1 is -X
  106145. * * 2 is +Y
  106146. * * 3 is -Y
  106147. * * 4 is +Z
  106148. * * 5 is -Z
  106149. */
  106150. face: number;
  106151. /**
  106152. * Creates the PassCubePostProcess
  106153. * @param name The name of the effect.
  106154. * @param options The required width/height ratio to downsize to before computing the render pass.
  106155. * @param camera The camera to apply the render pass to.
  106156. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106157. * @param engine The engine which the post process will be applied. (default: current engine)
  106158. * @param reusable If the post process can be reused on the same frame. (default: false)
  106159. * @param textureType The type of texture to be used when performing the post processing.
  106160. * @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)
  106161. */
  106162. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106163. }
  106164. }
  106165. declare module BABYLON {
  106166. /** @hidden */
  106167. export var anaglyphPixelShader: {
  106168. name: string;
  106169. shader: string;
  106170. };
  106171. }
  106172. declare module BABYLON {
  106173. /**
  106174. * Postprocess used to generate anaglyphic rendering
  106175. */
  106176. export class AnaglyphPostProcess extends PostProcess {
  106177. private _passedProcess;
  106178. /**
  106179. * Creates a new AnaglyphPostProcess
  106180. * @param name defines postprocess name
  106181. * @param options defines creation options or target ratio scale
  106182. * @param rigCameras defines cameras using this postprocess
  106183. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106184. * @param engine defines hosting engine
  106185. * @param reusable defines if the postprocess will be reused multiple times per frame
  106186. */
  106187. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106188. }
  106189. }
  106190. declare module BABYLON {
  106191. /**
  106192. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106193. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106194. */
  106195. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106196. /**
  106197. * Creates a new AnaglyphArcRotateCamera
  106198. * @param name defines camera name
  106199. * @param alpha defines alpha angle (in radians)
  106200. * @param beta defines beta angle (in radians)
  106201. * @param radius defines radius
  106202. * @param target defines camera target
  106203. * @param interaxialDistance defines distance between each color axis
  106204. * @param scene defines the hosting scene
  106205. */
  106206. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106207. /**
  106208. * Gets camera class name
  106209. * @returns AnaglyphArcRotateCamera
  106210. */
  106211. getClassName(): string;
  106212. }
  106213. }
  106214. declare module BABYLON {
  106215. /**
  106216. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106217. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106218. */
  106219. export class AnaglyphFreeCamera extends FreeCamera {
  106220. /**
  106221. * Creates a new AnaglyphFreeCamera
  106222. * @param name defines camera name
  106223. * @param position defines initial position
  106224. * @param interaxialDistance defines distance between each color axis
  106225. * @param scene defines the hosting scene
  106226. */
  106227. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106228. /**
  106229. * Gets camera class name
  106230. * @returns AnaglyphFreeCamera
  106231. */
  106232. getClassName(): string;
  106233. }
  106234. }
  106235. declare module BABYLON {
  106236. /**
  106237. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106238. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106239. */
  106240. export class AnaglyphGamepadCamera extends GamepadCamera {
  106241. /**
  106242. * Creates a new AnaglyphGamepadCamera
  106243. * @param name defines camera name
  106244. * @param position defines initial position
  106245. * @param interaxialDistance defines distance between each color axis
  106246. * @param scene defines the hosting scene
  106247. */
  106248. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106249. /**
  106250. * Gets camera class name
  106251. * @returns AnaglyphGamepadCamera
  106252. */
  106253. getClassName(): string;
  106254. }
  106255. }
  106256. declare module BABYLON {
  106257. /**
  106258. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106259. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106260. */
  106261. export class AnaglyphUniversalCamera extends UniversalCamera {
  106262. /**
  106263. * Creates a new AnaglyphUniversalCamera
  106264. * @param name defines camera name
  106265. * @param position defines initial position
  106266. * @param interaxialDistance defines distance between each color axis
  106267. * @param scene defines the hosting scene
  106268. */
  106269. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106270. /**
  106271. * Gets camera class name
  106272. * @returns AnaglyphUniversalCamera
  106273. */
  106274. getClassName(): string;
  106275. }
  106276. }
  106277. declare module BABYLON {
  106278. /** @hidden */
  106279. export var stereoscopicInterlacePixelShader: {
  106280. name: string;
  106281. shader: string;
  106282. };
  106283. }
  106284. declare module BABYLON {
  106285. /**
  106286. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106287. */
  106288. export class StereoscopicInterlacePostProcess extends PostProcess {
  106289. private _stepSize;
  106290. private _passedProcess;
  106291. /**
  106292. * Initializes a StereoscopicInterlacePostProcess
  106293. * @param name The name of the effect.
  106294. * @param rigCameras The rig cameras to be appled to the post process
  106295. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106296. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106297. * @param engine The engine which the post process will be applied. (default: current engine)
  106298. * @param reusable If the post process can be reused on the same frame. (default: false)
  106299. */
  106300. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106301. }
  106302. }
  106303. declare module BABYLON {
  106304. /**
  106305. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106306. * @see http://doc.babylonjs.com/features/cameras
  106307. */
  106308. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106309. /**
  106310. * Creates a new StereoscopicArcRotateCamera
  106311. * @param name defines camera name
  106312. * @param alpha defines alpha angle (in radians)
  106313. * @param beta defines beta angle (in radians)
  106314. * @param radius defines radius
  106315. * @param target defines camera target
  106316. * @param interaxialDistance defines distance between each color axis
  106317. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106318. * @param scene defines the hosting scene
  106319. */
  106320. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106321. /**
  106322. * Gets camera class name
  106323. * @returns StereoscopicArcRotateCamera
  106324. */
  106325. getClassName(): string;
  106326. }
  106327. }
  106328. declare module BABYLON {
  106329. /**
  106330. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106331. * @see http://doc.babylonjs.com/features/cameras
  106332. */
  106333. export class StereoscopicFreeCamera extends FreeCamera {
  106334. /**
  106335. * Creates a new StereoscopicFreeCamera
  106336. * @param name defines camera name
  106337. * @param position defines initial position
  106338. * @param interaxialDistance defines distance between each color axis
  106339. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106340. * @param scene defines the hosting scene
  106341. */
  106342. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106343. /**
  106344. * Gets camera class name
  106345. * @returns StereoscopicFreeCamera
  106346. */
  106347. getClassName(): string;
  106348. }
  106349. }
  106350. declare module BABYLON {
  106351. /**
  106352. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106353. * @see http://doc.babylonjs.com/features/cameras
  106354. */
  106355. export class StereoscopicGamepadCamera extends GamepadCamera {
  106356. /**
  106357. * Creates a new StereoscopicGamepadCamera
  106358. * @param name defines camera name
  106359. * @param position defines initial position
  106360. * @param interaxialDistance defines distance between each color axis
  106361. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106362. * @param scene defines the hosting scene
  106363. */
  106364. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106365. /**
  106366. * Gets camera class name
  106367. * @returns StereoscopicGamepadCamera
  106368. */
  106369. getClassName(): string;
  106370. }
  106371. }
  106372. declare module BABYLON {
  106373. /**
  106374. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106375. * @see http://doc.babylonjs.com/features/cameras
  106376. */
  106377. export class StereoscopicUniversalCamera extends UniversalCamera {
  106378. /**
  106379. * Creates a new StereoscopicUniversalCamera
  106380. * @param name defines camera name
  106381. * @param position defines initial position
  106382. * @param interaxialDistance defines distance between each color axis
  106383. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106384. * @param scene defines the hosting scene
  106385. */
  106386. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106387. /**
  106388. * Gets camera class name
  106389. * @returns StereoscopicUniversalCamera
  106390. */
  106391. getClassName(): string;
  106392. }
  106393. }
  106394. declare module BABYLON {
  106395. /**
  106396. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106397. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106398. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106399. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106400. */
  106401. export class VirtualJoysticksCamera extends FreeCamera {
  106402. /**
  106403. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106404. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106405. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106406. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106407. * @param name Define the name of the camera in the scene
  106408. * @param position Define the start position of the camera in the scene
  106409. * @param scene Define the scene the camera belongs to
  106410. */
  106411. constructor(name: string, position: Vector3, scene: Scene);
  106412. /**
  106413. * Gets the current object class name.
  106414. * @return the class name
  106415. */
  106416. getClassName(): string;
  106417. }
  106418. }
  106419. declare module BABYLON {
  106420. /**
  106421. * This represents all the required metrics to create a VR camera.
  106422. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106423. */
  106424. export class VRCameraMetrics {
  106425. /**
  106426. * Define the horizontal resolution off the screen.
  106427. */
  106428. hResolution: number;
  106429. /**
  106430. * Define the vertical resolution off the screen.
  106431. */
  106432. vResolution: number;
  106433. /**
  106434. * Define the horizontal screen size.
  106435. */
  106436. hScreenSize: number;
  106437. /**
  106438. * Define the vertical screen size.
  106439. */
  106440. vScreenSize: number;
  106441. /**
  106442. * Define the vertical screen center position.
  106443. */
  106444. vScreenCenter: number;
  106445. /**
  106446. * Define the distance of the eyes to the screen.
  106447. */
  106448. eyeToScreenDistance: number;
  106449. /**
  106450. * Define the distance between both lenses
  106451. */
  106452. lensSeparationDistance: number;
  106453. /**
  106454. * Define the distance between both viewer's eyes.
  106455. */
  106456. interpupillaryDistance: number;
  106457. /**
  106458. * Define the distortion factor of the VR postprocess.
  106459. * Please, touch with care.
  106460. */
  106461. distortionK: number[];
  106462. /**
  106463. * Define the chromatic aberration correction factors for the VR post process.
  106464. */
  106465. chromaAbCorrection: number[];
  106466. /**
  106467. * Define the scale factor of the post process.
  106468. * The smaller the better but the slower.
  106469. */
  106470. postProcessScaleFactor: number;
  106471. /**
  106472. * Define an offset for the lens center.
  106473. */
  106474. lensCenterOffset: number;
  106475. /**
  106476. * Define if the current vr camera should compensate the distortion of the lense or not.
  106477. */
  106478. compensateDistortion: boolean;
  106479. /**
  106480. * Defines if multiview should be enabled when rendering (Default: false)
  106481. */
  106482. multiviewEnabled: boolean;
  106483. /**
  106484. * Gets the rendering aspect ratio based on the provided resolutions.
  106485. */
  106486. readonly aspectRatio: number;
  106487. /**
  106488. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106489. */
  106490. readonly aspectRatioFov: number;
  106491. /**
  106492. * @hidden
  106493. */
  106494. readonly leftHMatrix: Matrix;
  106495. /**
  106496. * @hidden
  106497. */
  106498. readonly rightHMatrix: Matrix;
  106499. /**
  106500. * @hidden
  106501. */
  106502. readonly leftPreViewMatrix: Matrix;
  106503. /**
  106504. * @hidden
  106505. */
  106506. readonly rightPreViewMatrix: Matrix;
  106507. /**
  106508. * Get the default VRMetrics based on the most generic setup.
  106509. * @returns the default vr metrics
  106510. */
  106511. static GetDefault(): VRCameraMetrics;
  106512. }
  106513. }
  106514. declare module BABYLON {
  106515. /** @hidden */
  106516. export var vrDistortionCorrectionPixelShader: {
  106517. name: string;
  106518. shader: string;
  106519. };
  106520. }
  106521. declare module BABYLON {
  106522. /**
  106523. * VRDistortionCorrectionPostProcess used for mobile VR
  106524. */
  106525. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106526. private _isRightEye;
  106527. private _distortionFactors;
  106528. private _postProcessScaleFactor;
  106529. private _lensCenterOffset;
  106530. private _scaleIn;
  106531. private _scaleFactor;
  106532. private _lensCenter;
  106533. /**
  106534. * Initializes the VRDistortionCorrectionPostProcess
  106535. * @param name The name of the effect.
  106536. * @param camera The camera to apply the render pass to.
  106537. * @param isRightEye If this is for the right eye distortion
  106538. * @param vrMetrics All the required metrics for the VR camera
  106539. */
  106540. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106541. }
  106542. }
  106543. declare module BABYLON {
  106544. /**
  106545. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106546. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106547. */
  106548. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106549. /**
  106550. * Creates a new VRDeviceOrientationArcRotateCamera
  106551. * @param name defines camera name
  106552. * @param alpha defines the camera rotation along the logitudinal axis
  106553. * @param beta defines the camera rotation along the latitudinal axis
  106554. * @param radius defines the camera distance from its target
  106555. * @param target defines the camera target
  106556. * @param scene defines the scene the camera belongs to
  106557. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106558. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106559. */
  106560. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106561. /**
  106562. * Gets camera class name
  106563. * @returns VRDeviceOrientationArcRotateCamera
  106564. */
  106565. getClassName(): string;
  106566. }
  106567. }
  106568. declare module BABYLON {
  106569. /**
  106570. * Camera used to simulate VR rendering (based on FreeCamera)
  106571. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106572. */
  106573. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106574. /**
  106575. * Creates a new VRDeviceOrientationFreeCamera
  106576. * @param name defines camera name
  106577. * @param position defines the start position of the camera
  106578. * @param scene defines the scene the camera belongs to
  106579. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106580. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106581. */
  106582. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106583. /**
  106584. * Gets camera class name
  106585. * @returns VRDeviceOrientationFreeCamera
  106586. */
  106587. getClassName(): string;
  106588. }
  106589. }
  106590. declare module BABYLON {
  106591. /**
  106592. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106593. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106594. */
  106595. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106596. /**
  106597. * Creates a new VRDeviceOrientationGamepadCamera
  106598. * @param name defines camera name
  106599. * @param position defines the start position of the camera
  106600. * @param scene defines the scene the camera belongs to
  106601. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106602. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106603. */
  106604. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106605. /**
  106606. * Gets camera class name
  106607. * @returns VRDeviceOrientationGamepadCamera
  106608. */
  106609. getClassName(): string;
  106610. }
  106611. }
  106612. declare module BABYLON {
  106613. /**
  106614. * Base class of materials working in push mode in babylon JS
  106615. * @hidden
  106616. */
  106617. export class PushMaterial extends Material {
  106618. protected _activeEffect: Effect;
  106619. protected _normalMatrix: Matrix;
  106620. /**
  106621. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106622. * This means that the material can keep using a previous shader while a new one is being compiled.
  106623. * This is mostly used when shader parallel compilation is supported (true by default)
  106624. */
  106625. allowShaderHotSwapping: boolean;
  106626. constructor(name: string, scene: Scene);
  106627. getEffect(): Effect;
  106628. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106629. /**
  106630. * Binds the given world matrix to the active effect
  106631. *
  106632. * @param world the matrix to bind
  106633. */
  106634. bindOnlyWorldMatrix(world: Matrix): void;
  106635. /**
  106636. * Binds the given normal matrix to the active effect
  106637. *
  106638. * @param normalMatrix the matrix to bind
  106639. */
  106640. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106641. bind(world: Matrix, mesh?: Mesh): void;
  106642. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106643. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106644. }
  106645. }
  106646. declare module BABYLON {
  106647. /**
  106648. * This groups all the flags used to control the materials channel.
  106649. */
  106650. export class MaterialFlags {
  106651. private static _DiffuseTextureEnabled;
  106652. /**
  106653. * Are diffuse textures enabled in the application.
  106654. */
  106655. static DiffuseTextureEnabled: boolean;
  106656. private static _AmbientTextureEnabled;
  106657. /**
  106658. * Are ambient textures enabled in the application.
  106659. */
  106660. static AmbientTextureEnabled: boolean;
  106661. private static _OpacityTextureEnabled;
  106662. /**
  106663. * Are opacity textures enabled in the application.
  106664. */
  106665. static OpacityTextureEnabled: boolean;
  106666. private static _ReflectionTextureEnabled;
  106667. /**
  106668. * Are reflection textures enabled in the application.
  106669. */
  106670. static ReflectionTextureEnabled: boolean;
  106671. private static _EmissiveTextureEnabled;
  106672. /**
  106673. * Are emissive textures enabled in the application.
  106674. */
  106675. static EmissiveTextureEnabled: boolean;
  106676. private static _SpecularTextureEnabled;
  106677. /**
  106678. * Are specular textures enabled in the application.
  106679. */
  106680. static SpecularTextureEnabled: boolean;
  106681. private static _BumpTextureEnabled;
  106682. /**
  106683. * Are bump textures enabled in the application.
  106684. */
  106685. static BumpTextureEnabled: boolean;
  106686. private static _LightmapTextureEnabled;
  106687. /**
  106688. * Are lightmap textures enabled in the application.
  106689. */
  106690. static LightmapTextureEnabled: boolean;
  106691. private static _RefractionTextureEnabled;
  106692. /**
  106693. * Are refraction textures enabled in the application.
  106694. */
  106695. static RefractionTextureEnabled: boolean;
  106696. private static _ColorGradingTextureEnabled;
  106697. /**
  106698. * Are color grading textures enabled in the application.
  106699. */
  106700. static ColorGradingTextureEnabled: boolean;
  106701. private static _FresnelEnabled;
  106702. /**
  106703. * Are fresnels enabled in the application.
  106704. */
  106705. static FresnelEnabled: boolean;
  106706. private static _ClearCoatTextureEnabled;
  106707. /**
  106708. * Are clear coat textures enabled in the application.
  106709. */
  106710. static ClearCoatTextureEnabled: boolean;
  106711. private static _ClearCoatBumpTextureEnabled;
  106712. /**
  106713. * Are clear coat bump textures enabled in the application.
  106714. */
  106715. static ClearCoatBumpTextureEnabled: boolean;
  106716. private static _ClearCoatTintTextureEnabled;
  106717. /**
  106718. * Are clear coat tint textures enabled in the application.
  106719. */
  106720. static ClearCoatTintTextureEnabled: boolean;
  106721. private static _SheenTextureEnabled;
  106722. /**
  106723. * Are sheen textures enabled in the application.
  106724. */
  106725. static SheenTextureEnabled: boolean;
  106726. private static _AnisotropicTextureEnabled;
  106727. /**
  106728. * Are anisotropic textures enabled in the application.
  106729. */
  106730. static AnisotropicTextureEnabled: boolean;
  106731. private static _ThicknessTextureEnabled;
  106732. /**
  106733. * Are thickness textures enabled in the application.
  106734. */
  106735. static ThicknessTextureEnabled: boolean;
  106736. }
  106737. }
  106738. declare module BABYLON {
  106739. /** @hidden */
  106740. export var defaultFragmentDeclaration: {
  106741. name: string;
  106742. shader: string;
  106743. };
  106744. }
  106745. declare module BABYLON {
  106746. /** @hidden */
  106747. export var defaultUboDeclaration: {
  106748. name: string;
  106749. shader: string;
  106750. };
  106751. }
  106752. declare module BABYLON {
  106753. /** @hidden */
  106754. export var lightFragmentDeclaration: {
  106755. name: string;
  106756. shader: string;
  106757. };
  106758. }
  106759. declare module BABYLON {
  106760. /** @hidden */
  106761. export var lightUboDeclaration: {
  106762. name: string;
  106763. shader: string;
  106764. };
  106765. }
  106766. declare module BABYLON {
  106767. /** @hidden */
  106768. export var lightsFragmentFunctions: {
  106769. name: string;
  106770. shader: string;
  106771. };
  106772. }
  106773. declare module BABYLON {
  106774. /** @hidden */
  106775. export var shadowsFragmentFunctions: {
  106776. name: string;
  106777. shader: string;
  106778. };
  106779. }
  106780. declare module BABYLON {
  106781. /** @hidden */
  106782. export var fresnelFunction: {
  106783. name: string;
  106784. shader: string;
  106785. };
  106786. }
  106787. declare module BABYLON {
  106788. /** @hidden */
  106789. export var reflectionFunction: {
  106790. name: string;
  106791. shader: string;
  106792. };
  106793. }
  106794. declare module BABYLON {
  106795. /** @hidden */
  106796. export var bumpFragmentFunctions: {
  106797. name: string;
  106798. shader: string;
  106799. };
  106800. }
  106801. declare module BABYLON {
  106802. /** @hidden */
  106803. export var logDepthDeclaration: {
  106804. name: string;
  106805. shader: string;
  106806. };
  106807. }
  106808. declare module BABYLON {
  106809. /** @hidden */
  106810. export var bumpFragment: {
  106811. name: string;
  106812. shader: string;
  106813. };
  106814. }
  106815. declare module BABYLON {
  106816. /** @hidden */
  106817. export var depthPrePass: {
  106818. name: string;
  106819. shader: string;
  106820. };
  106821. }
  106822. declare module BABYLON {
  106823. /** @hidden */
  106824. export var lightFragment: {
  106825. name: string;
  106826. shader: string;
  106827. };
  106828. }
  106829. declare module BABYLON {
  106830. /** @hidden */
  106831. export var logDepthFragment: {
  106832. name: string;
  106833. shader: string;
  106834. };
  106835. }
  106836. declare module BABYLON {
  106837. /** @hidden */
  106838. export var defaultPixelShader: {
  106839. name: string;
  106840. shader: string;
  106841. };
  106842. }
  106843. declare module BABYLON {
  106844. /** @hidden */
  106845. export var defaultVertexDeclaration: {
  106846. name: string;
  106847. shader: string;
  106848. };
  106849. }
  106850. declare module BABYLON {
  106851. /** @hidden */
  106852. export var bumpVertexDeclaration: {
  106853. name: string;
  106854. shader: string;
  106855. };
  106856. }
  106857. declare module BABYLON {
  106858. /** @hidden */
  106859. export var bumpVertex: {
  106860. name: string;
  106861. shader: string;
  106862. };
  106863. }
  106864. declare module BABYLON {
  106865. /** @hidden */
  106866. export var fogVertex: {
  106867. name: string;
  106868. shader: string;
  106869. };
  106870. }
  106871. declare module BABYLON {
  106872. /** @hidden */
  106873. export var shadowsVertex: {
  106874. name: string;
  106875. shader: string;
  106876. };
  106877. }
  106878. declare module BABYLON {
  106879. /** @hidden */
  106880. export var pointCloudVertex: {
  106881. name: string;
  106882. shader: string;
  106883. };
  106884. }
  106885. declare module BABYLON {
  106886. /** @hidden */
  106887. export var logDepthVertex: {
  106888. name: string;
  106889. shader: string;
  106890. };
  106891. }
  106892. declare module BABYLON {
  106893. /** @hidden */
  106894. export var defaultVertexShader: {
  106895. name: string;
  106896. shader: string;
  106897. };
  106898. }
  106899. declare module BABYLON {
  106900. /** @hidden */
  106901. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106902. MAINUV1: boolean;
  106903. MAINUV2: boolean;
  106904. DIFFUSE: boolean;
  106905. DIFFUSEDIRECTUV: number;
  106906. AMBIENT: boolean;
  106907. AMBIENTDIRECTUV: number;
  106908. OPACITY: boolean;
  106909. OPACITYDIRECTUV: number;
  106910. OPACITYRGB: boolean;
  106911. REFLECTION: boolean;
  106912. EMISSIVE: boolean;
  106913. EMISSIVEDIRECTUV: number;
  106914. SPECULAR: boolean;
  106915. SPECULARDIRECTUV: number;
  106916. BUMP: boolean;
  106917. BUMPDIRECTUV: number;
  106918. PARALLAX: boolean;
  106919. PARALLAXOCCLUSION: boolean;
  106920. SPECULAROVERALPHA: boolean;
  106921. CLIPPLANE: boolean;
  106922. CLIPPLANE2: boolean;
  106923. CLIPPLANE3: boolean;
  106924. CLIPPLANE4: boolean;
  106925. ALPHATEST: boolean;
  106926. DEPTHPREPASS: boolean;
  106927. ALPHAFROMDIFFUSE: boolean;
  106928. POINTSIZE: boolean;
  106929. FOG: boolean;
  106930. SPECULARTERM: boolean;
  106931. DIFFUSEFRESNEL: boolean;
  106932. OPACITYFRESNEL: boolean;
  106933. REFLECTIONFRESNEL: boolean;
  106934. REFRACTIONFRESNEL: boolean;
  106935. EMISSIVEFRESNEL: boolean;
  106936. FRESNEL: boolean;
  106937. NORMAL: boolean;
  106938. UV1: boolean;
  106939. UV2: boolean;
  106940. VERTEXCOLOR: boolean;
  106941. VERTEXALPHA: boolean;
  106942. NUM_BONE_INFLUENCERS: number;
  106943. BonesPerMesh: number;
  106944. BONETEXTURE: boolean;
  106945. INSTANCES: boolean;
  106946. GLOSSINESS: boolean;
  106947. ROUGHNESS: boolean;
  106948. EMISSIVEASILLUMINATION: boolean;
  106949. LINKEMISSIVEWITHDIFFUSE: boolean;
  106950. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106951. LIGHTMAP: boolean;
  106952. LIGHTMAPDIRECTUV: number;
  106953. OBJECTSPACE_NORMALMAP: boolean;
  106954. USELIGHTMAPASSHADOWMAP: boolean;
  106955. REFLECTIONMAP_3D: boolean;
  106956. REFLECTIONMAP_SPHERICAL: boolean;
  106957. REFLECTIONMAP_PLANAR: boolean;
  106958. REFLECTIONMAP_CUBIC: boolean;
  106959. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106960. REFLECTIONMAP_PROJECTION: boolean;
  106961. REFLECTIONMAP_SKYBOX: boolean;
  106962. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106963. REFLECTIONMAP_EXPLICIT: boolean;
  106964. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106965. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106966. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106967. INVERTCUBICMAP: boolean;
  106968. LOGARITHMICDEPTH: boolean;
  106969. REFRACTION: boolean;
  106970. REFRACTIONMAP_3D: boolean;
  106971. REFLECTIONOVERALPHA: boolean;
  106972. TWOSIDEDLIGHTING: boolean;
  106973. SHADOWFLOAT: boolean;
  106974. MORPHTARGETS: boolean;
  106975. MORPHTARGETS_NORMAL: boolean;
  106976. MORPHTARGETS_TANGENT: boolean;
  106977. MORPHTARGETS_UV: boolean;
  106978. NUM_MORPH_INFLUENCERS: number;
  106979. NONUNIFORMSCALING: boolean;
  106980. PREMULTIPLYALPHA: boolean;
  106981. IMAGEPROCESSING: boolean;
  106982. VIGNETTE: boolean;
  106983. VIGNETTEBLENDMODEMULTIPLY: boolean;
  106984. VIGNETTEBLENDMODEOPAQUE: boolean;
  106985. TONEMAPPING: boolean;
  106986. TONEMAPPING_ACES: boolean;
  106987. CONTRAST: boolean;
  106988. COLORCURVES: boolean;
  106989. COLORGRADING: boolean;
  106990. COLORGRADING3D: boolean;
  106991. SAMPLER3DGREENDEPTH: boolean;
  106992. SAMPLER3DBGRMAP: boolean;
  106993. IMAGEPROCESSINGPOSTPROCESS: boolean;
  106994. MULTIVIEW: boolean;
  106995. /**
  106996. * If the reflection texture on this material is in linear color space
  106997. * @hidden
  106998. */
  106999. IS_REFLECTION_LINEAR: boolean;
  107000. /**
  107001. * If the refraction texture on this material is in linear color space
  107002. * @hidden
  107003. */
  107004. IS_REFRACTION_LINEAR: boolean;
  107005. EXPOSURE: boolean;
  107006. constructor();
  107007. setReflectionMode(modeToEnable: string): void;
  107008. }
  107009. /**
  107010. * This is the default material used in Babylon. It is the best trade off between quality
  107011. * and performances.
  107012. * @see http://doc.babylonjs.com/babylon101/materials
  107013. */
  107014. export class StandardMaterial extends PushMaterial {
  107015. private _diffuseTexture;
  107016. /**
  107017. * The basic texture of the material as viewed under a light.
  107018. */
  107019. diffuseTexture: Nullable<BaseTexture>;
  107020. private _ambientTexture;
  107021. /**
  107022. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107023. */
  107024. ambientTexture: Nullable<BaseTexture>;
  107025. private _opacityTexture;
  107026. /**
  107027. * Define the transparency of the material from a texture.
  107028. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107029. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107030. */
  107031. opacityTexture: Nullable<BaseTexture>;
  107032. private _reflectionTexture;
  107033. /**
  107034. * Define the texture used to display the reflection.
  107035. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107036. */
  107037. reflectionTexture: Nullable<BaseTexture>;
  107038. private _emissiveTexture;
  107039. /**
  107040. * Define texture of the material as if self lit.
  107041. * This will be mixed in the final result even in the absence of light.
  107042. */
  107043. emissiveTexture: Nullable<BaseTexture>;
  107044. private _specularTexture;
  107045. /**
  107046. * Define how the color and intensity of the highlight given by the light in the material.
  107047. */
  107048. specularTexture: Nullable<BaseTexture>;
  107049. private _bumpTexture;
  107050. /**
  107051. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107052. * 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.
  107053. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107054. */
  107055. bumpTexture: Nullable<BaseTexture>;
  107056. private _lightmapTexture;
  107057. /**
  107058. * Complex lighting can be computationally expensive to compute at runtime.
  107059. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107060. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107061. */
  107062. lightmapTexture: Nullable<BaseTexture>;
  107063. private _refractionTexture;
  107064. /**
  107065. * Define the texture used to display the refraction.
  107066. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107067. */
  107068. refractionTexture: Nullable<BaseTexture>;
  107069. /**
  107070. * The color of the material lit by the environmental background lighting.
  107071. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107072. */
  107073. ambientColor: Color3;
  107074. /**
  107075. * The basic color of the material as viewed under a light.
  107076. */
  107077. diffuseColor: Color3;
  107078. /**
  107079. * Define how the color and intensity of the highlight given by the light in the material.
  107080. */
  107081. specularColor: Color3;
  107082. /**
  107083. * Define the color of the material as if self lit.
  107084. * This will be mixed in the final result even in the absence of light.
  107085. */
  107086. emissiveColor: Color3;
  107087. /**
  107088. * Defines how sharp are the highlights in the material.
  107089. * The bigger the value the sharper giving a more glossy feeling to the result.
  107090. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107091. */
  107092. specularPower: number;
  107093. private _useAlphaFromDiffuseTexture;
  107094. /**
  107095. * Does the transparency come from the diffuse texture alpha channel.
  107096. */
  107097. useAlphaFromDiffuseTexture: boolean;
  107098. private _useEmissiveAsIllumination;
  107099. /**
  107100. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107101. */
  107102. useEmissiveAsIllumination: boolean;
  107103. private _linkEmissiveWithDiffuse;
  107104. /**
  107105. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107106. * the emissive level when the final color is close to one.
  107107. */
  107108. linkEmissiveWithDiffuse: boolean;
  107109. private _useSpecularOverAlpha;
  107110. /**
  107111. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107112. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107113. */
  107114. useSpecularOverAlpha: boolean;
  107115. private _useReflectionOverAlpha;
  107116. /**
  107117. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107118. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107119. */
  107120. useReflectionOverAlpha: boolean;
  107121. private _disableLighting;
  107122. /**
  107123. * Does lights from the scene impacts this material.
  107124. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107125. */
  107126. disableLighting: boolean;
  107127. private _useObjectSpaceNormalMap;
  107128. /**
  107129. * Allows using an object space normal map (instead of tangent space).
  107130. */
  107131. useObjectSpaceNormalMap: boolean;
  107132. private _useParallax;
  107133. /**
  107134. * Is parallax enabled or not.
  107135. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107136. */
  107137. useParallax: boolean;
  107138. private _useParallaxOcclusion;
  107139. /**
  107140. * Is parallax occlusion enabled or not.
  107141. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107142. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107143. */
  107144. useParallaxOcclusion: boolean;
  107145. /**
  107146. * 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.
  107147. */
  107148. parallaxScaleBias: number;
  107149. private _roughness;
  107150. /**
  107151. * Helps to define how blurry the reflections should appears in the material.
  107152. */
  107153. roughness: number;
  107154. /**
  107155. * In case of refraction, define the value of the index of refraction.
  107156. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107157. */
  107158. indexOfRefraction: number;
  107159. /**
  107160. * Invert the refraction texture alongside the y axis.
  107161. * It can be useful with procedural textures or probe for instance.
  107162. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107163. */
  107164. invertRefractionY: boolean;
  107165. /**
  107166. * Defines the alpha limits in alpha test mode.
  107167. */
  107168. alphaCutOff: number;
  107169. private _useLightmapAsShadowmap;
  107170. /**
  107171. * In case of light mapping, define whether the map contains light or shadow informations.
  107172. */
  107173. useLightmapAsShadowmap: boolean;
  107174. private _diffuseFresnelParameters;
  107175. /**
  107176. * Define the diffuse fresnel parameters of the material.
  107177. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107178. */
  107179. diffuseFresnelParameters: FresnelParameters;
  107180. private _opacityFresnelParameters;
  107181. /**
  107182. * Define the opacity fresnel parameters of the material.
  107183. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107184. */
  107185. opacityFresnelParameters: FresnelParameters;
  107186. private _reflectionFresnelParameters;
  107187. /**
  107188. * Define the reflection fresnel parameters of the material.
  107189. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107190. */
  107191. reflectionFresnelParameters: FresnelParameters;
  107192. private _refractionFresnelParameters;
  107193. /**
  107194. * Define the refraction fresnel parameters of the material.
  107195. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107196. */
  107197. refractionFresnelParameters: FresnelParameters;
  107198. private _emissiveFresnelParameters;
  107199. /**
  107200. * Define the emissive fresnel parameters of the material.
  107201. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107202. */
  107203. emissiveFresnelParameters: FresnelParameters;
  107204. private _useReflectionFresnelFromSpecular;
  107205. /**
  107206. * If true automatically deducts the fresnels values from the material specularity.
  107207. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107208. */
  107209. useReflectionFresnelFromSpecular: boolean;
  107210. private _useGlossinessFromSpecularMapAlpha;
  107211. /**
  107212. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107213. */
  107214. useGlossinessFromSpecularMapAlpha: boolean;
  107215. private _maxSimultaneousLights;
  107216. /**
  107217. * Defines the maximum number of lights that can be used in the material
  107218. */
  107219. maxSimultaneousLights: number;
  107220. private _invertNormalMapX;
  107221. /**
  107222. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107223. */
  107224. invertNormalMapX: boolean;
  107225. private _invertNormalMapY;
  107226. /**
  107227. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107228. */
  107229. invertNormalMapY: boolean;
  107230. private _twoSidedLighting;
  107231. /**
  107232. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107233. */
  107234. twoSidedLighting: boolean;
  107235. /**
  107236. * Default configuration related to image processing available in the standard Material.
  107237. */
  107238. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107239. /**
  107240. * Gets the image processing configuration used either in this material.
  107241. */
  107242. /**
  107243. * Sets the Default image processing configuration used either in the this material.
  107244. *
  107245. * If sets to null, the scene one is in use.
  107246. */
  107247. imageProcessingConfiguration: ImageProcessingConfiguration;
  107248. /**
  107249. * Keep track of the image processing observer to allow dispose and replace.
  107250. */
  107251. private _imageProcessingObserver;
  107252. /**
  107253. * Attaches a new image processing configuration to the Standard Material.
  107254. * @param configuration
  107255. */
  107256. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107257. /**
  107258. * Gets wether the color curves effect is enabled.
  107259. */
  107260. /**
  107261. * Sets wether the color curves effect is enabled.
  107262. */
  107263. cameraColorCurvesEnabled: boolean;
  107264. /**
  107265. * Gets wether the color grading effect is enabled.
  107266. */
  107267. /**
  107268. * Gets wether the color grading effect is enabled.
  107269. */
  107270. cameraColorGradingEnabled: boolean;
  107271. /**
  107272. * Gets wether tonemapping is enabled or not.
  107273. */
  107274. /**
  107275. * Sets wether tonemapping is enabled or not
  107276. */
  107277. cameraToneMappingEnabled: boolean;
  107278. /**
  107279. * The camera exposure used on this material.
  107280. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107281. * This corresponds to a photographic exposure.
  107282. */
  107283. /**
  107284. * The camera exposure used on this material.
  107285. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107286. * This corresponds to a photographic exposure.
  107287. */
  107288. cameraExposure: number;
  107289. /**
  107290. * Gets The camera contrast used on this material.
  107291. */
  107292. /**
  107293. * Sets The camera contrast used on this material.
  107294. */
  107295. cameraContrast: number;
  107296. /**
  107297. * Gets the Color Grading 2D Lookup Texture.
  107298. */
  107299. /**
  107300. * Sets the Color Grading 2D Lookup Texture.
  107301. */
  107302. cameraColorGradingTexture: Nullable<BaseTexture>;
  107303. /**
  107304. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107305. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107306. * 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;
  107307. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107308. */
  107309. /**
  107310. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107311. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107312. * 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;
  107313. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107314. */
  107315. cameraColorCurves: Nullable<ColorCurves>;
  107316. /**
  107317. * Custom callback helping to override the default shader used in the material.
  107318. */
  107319. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107320. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107321. protected _worldViewProjectionMatrix: Matrix;
  107322. protected _globalAmbientColor: Color3;
  107323. protected _useLogarithmicDepth: boolean;
  107324. protected _rebuildInParallel: boolean;
  107325. /**
  107326. * Instantiates a new standard material.
  107327. * This is the default material used in Babylon. It is the best trade off between quality
  107328. * and performances.
  107329. * @see http://doc.babylonjs.com/babylon101/materials
  107330. * @param name Define the name of the material in the scene
  107331. * @param scene Define the scene the material belong to
  107332. */
  107333. constructor(name: string, scene: Scene);
  107334. /**
  107335. * Gets a boolean indicating that current material needs to register RTT
  107336. */
  107337. readonly hasRenderTargetTextures: boolean;
  107338. /**
  107339. * Gets the current class name of the material e.g. "StandardMaterial"
  107340. * Mainly use in serialization.
  107341. * @returns the class name
  107342. */
  107343. getClassName(): string;
  107344. /**
  107345. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107346. * You can try switching to logarithmic depth.
  107347. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107348. */
  107349. useLogarithmicDepth: boolean;
  107350. /**
  107351. * Specifies if the material will require alpha blending
  107352. * @returns a boolean specifying if alpha blending is needed
  107353. */
  107354. needAlphaBlending(): boolean;
  107355. /**
  107356. * Specifies if this material should be rendered in alpha test mode
  107357. * @returns a boolean specifying if an alpha test is needed.
  107358. */
  107359. needAlphaTesting(): boolean;
  107360. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107361. /**
  107362. * Get the texture used for alpha test purpose.
  107363. * @returns the diffuse texture in case of the standard material.
  107364. */
  107365. getAlphaTestTexture(): Nullable<BaseTexture>;
  107366. /**
  107367. * Get if the submesh is ready to be used and all its information available.
  107368. * Child classes can use it to update shaders
  107369. * @param mesh defines the mesh to check
  107370. * @param subMesh defines which submesh to check
  107371. * @param useInstances specifies that instances should be used
  107372. * @returns a boolean indicating that the submesh is ready or not
  107373. */
  107374. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107375. /**
  107376. * Builds the material UBO layouts.
  107377. * Used internally during the effect preparation.
  107378. */
  107379. buildUniformLayout(): void;
  107380. /**
  107381. * Unbinds the material from the mesh
  107382. */
  107383. unbind(): void;
  107384. /**
  107385. * Binds the submesh to this material by preparing the effect and shader to draw
  107386. * @param world defines the world transformation matrix
  107387. * @param mesh defines the mesh containing the submesh
  107388. * @param subMesh defines the submesh to bind the material to
  107389. */
  107390. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107391. /**
  107392. * Get the list of animatables in the material.
  107393. * @returns the list of animatables object used in the material
  107394. */
  107395. getAnimatables(): IAnimatable[];
  107396. /**
  107397. * Gets the active textures from the material
  107398. * @returns an array of textures
  107399. */
  107400. getActiveTextures(): BaseTexture[];
  107401. /**
  107402. * Specifies if the material uses a texture
  107403. * @param texture defines the texture to check against the material
  107404. * @returns a boolean specifying if the material uses the texture
  107405. */
  107406. hasTexture(texture: BaseTexture): boolean;
  107407. /**
  107408. * Disposes the material
  107409. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107410. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107411. */
  107412. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107413. /**
  107414. * Makes a duplicate of the material, and gives it a new name
  107415. * @param name defines the new name for the duplicated material
  107416. * @returns the cloned material
  107417. */
  107418. clone(name: string): StandardMaterial;
  107419. /**
  107420. * Serializes this material in a JSON representation
  107421. * @returns the serialized material object
  107422. */
  107423. serialize(): any;
  107424. /**
  107425. * Creates a standard material from parsed material data
  107426. * @param source defines the JSON representation of the material
  107427. * @param scene defines the hosting scene
  107428. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107429. * @returns a new standard material
  107430. */
  107431. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107432. /**
  107433. * Are diffuse textures enabled in the application.
  107434. */
  107435. static DiffuseTextureEnabled: boolean;
  107436. /**
  107437. * Are ambient textures enabled in the application.
  107438. */
  107439. static AmbientTextureEnabled: boolean;
  107440. /**
  107441. * Are opacity textures enabled in the application.
  107442. */
  107443. static OpacityTextureEnabled: boolean;
  107444. /**
  107445. * Are reflection textures enabled in the application.
  107446. */
  107447. static ReflectionTextureEnabled: boolean;
  107448. /**
  107449. * Are emissive textures enabled in the application.
  107450. */
  107451. static EmissiveTextureEnabled: boolean;
  107452. /**
  107453. * Are specular textures enabled in the application.
  107454. */
  107455. static SpecularTextureEnabled: boolean;
  107456. /**
  107457. * Are bump textures enabled in the application.
  107458. */
  107459. static BumpTextureEnabled: boolean;
  107460. /**
  107461. * Are lightmap textures enabled in the application.
  107462. */
  107463. static LightmapTextureEnabled: boolean;
  107464. /**
  107465. * Are refraction textures enabled in the application.
  107466. */
  107467. static RefractionTextureEnabled: boolean;
  107468. /**
  107469. * Are color grading textures enabled in the application.
  107470. */
  107471. static ColorGradingTextureEnabled: boolean;
  107472. /**
  107473. * Are fresnels enabled in the application.
  107474. */
  107475. static FresnelEnabled: boolean;
  107476. }
  107477. }
  107478. declare module BABYLON {
  107479. /** @hidden */
  107480. export var imageProcessingPixelShader: {
  107481. name: string;
  107482. shader: string;
  107483. };
  107484. }
  107485. declare module BABYLON {
  107486. /**
  107487. * ImageProcessingPostProcess
  107488. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107489. */
  107490. export class ImageProcessingPostProcess extends PostProcess {
  107491. /**
  107492. * Default configuration related to image processing available in the PBR Material.
  107493. */
  107494. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107495. /**
  107496. * Gets the image processing configuration used either in this material.
  107497. */
  107498. /**
  107499. * Sets the Default image processing configuration used either in the this material.
  107500. *
  107501. * If sets to null, the scene one is in use.
  107502. */
  107503. imageProcessingConfiguration: ImageProcessingConfiguration;
  107504. /**
  107505. * Keep track of the image processing observer to allow dispose and replace.
  107506. */
  107507. private _imageProcessingObserver;
  107508. /**
  107509. * Attaches a new image processing configuration to the PBR Material.
  107510. * @param configuration
  107511. */
  107512. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107513. /**
  107514. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107515. */
  107516. /**
  107517. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107518. */
  107519. colorCurves: Nullable<ColorCurves>;
  107520. /**
  107521. * Gets wether the color curves effect is enabled.
  107522. */
  107523. /**
  107524. * Sets wether the color curves effect is enabled.
  107525. */
  107526. colorCurvesEnabled: boolean;
  107527. /**
  107528. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107529. */
  107530. /**
  107531. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107532. */
  107533. colorGradingTexture: Nullable<BaseTexture>;
  107534. /**
  107535. * Gets wether the color grading effect is enabled.
  107536. */
  107537. /**
  107538. * Gets wether the color grading effect is enabled.
  107539. */
  107540. colorGradingEnabled: boolean;
  107541. /**
  107542. * Gets exposure used in the effect.
  107543. */
  107544. /**
  107545. * Sets exposure used in the effect.
  107546. */
  107547. exposure: number;
  107548. /**
  107549. * Gets wether tonemapping is enabled or not.
  107550. */
  107551. /**
  107552. * Sets wether tonemapping is enabled or not
  107553. */
  107554. toneMappingEnabled: boolean;
  107555. /**
  107556. * Gets the type of tone mapping effect.
  107557. */
  107558. /**
  107559. * Sets the type of tone mapping effect.
  107560. */
  107561. toneMappingType: number;
  107562. /**
  107563. * Gets contrast used in the effect.
  107564. */
  107565. /**
  107566. * Sets contrast used in the effect.
  107567. */
  107568. contrast: number;
  107569. /**
  107570. * Gets Vignette stretch size.
  107571. */
  107572. /**
  107573. * Sets Vignette stretch size.
  107574. */
  107575. vignetteStretch: number;
  107576. /**
  107577. * Gets Vignette centre X Offset.
  107578. */
  107579. /**
  107580. * Sets Vignette centre X Offset.
  107581. */
  107582. vignetteCentreX: number;
  107583. /**
  107584. * Gets Vignette centre Y Offset.
  107585. */
  107586. /**
  107587. * Sets Vignette centre Y Offset.
  107588. */
  107589. vignetteCentreY: number;
  107590. /**
  107591. * Gets Vignette weight or intensity of the vignette effect.
  107592. */
  107593. /**
  107594. * Sets Vignette weight or intensity of the vignette effect.
  107595. */
  107596. vignetteWeight: number;
  107597. /**
  107598. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107599. * if vignetteEnabled is set to true.
  107600. */
  107601. /**
  107602. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107603. * if vignetteEnabled is set to true.
  107604. */
  107605. vignetteColor: Color4;
  107606. /**
  107607. * Gets Camera field of view used by the Vignette effect.
  107608. */
  107609. /**
  107610. * Sets Camera field of view used by the Vignette effect.
  107611. */
  107612. vignetteCameraFov: number;
  107613. /**
  107614. * Gets the vignette blend mode allowing different kind of effect.
  107615. */
  107616. /**
  107617. * Sets the vignette blend mode allowing different kind of effect.
  107618. */
  107619. vignetteBlendMode: number;
  107620. /**
  107621. * Gets wether the vignette effect is enabled.
  107622. */
  107623. /**
  107624. * Sets wether the vignette effect is enabled.
  107625. */
  107626. vignetteEnabled: boolean;
  107627. private _fromLinearSpace;
  107628. /**
  107629. * Gets wether the input of the processing is in Gamma or Linear Space.
  107630. */
  107631. /**
  107632. * Sets wether the input of the processing is in Gamma or Linear Space.
  107633. */
  107634. fromLinearSpace: boolean;
  107635. /**
  107636. * Defines cache preventing GC.
  107637. */
  107638. private _defines;
  107639. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107640. /**
  107641. * "ImageProcessingPostProcess"
  107642. * @returns "ImageProcessingPostProcess"
  107643. */
  107644. getClassName(): string;
  107645. protected _updateParameters(): void;
  107646. dispose(camera?: Camera): void;
  107647. }
  107648. }
  107649. declare module BABYLON {
  107650. /**
  107651. * Class containing static functions to help procedurally build meshes
  107652. */
  107653. export class GroundBuilder {
  107654. /**
  107655. * Creates a ground mesh
  107656. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107657. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107659. * @param name defines the name of the mesh
  107660. * @param options defines the options used to create the mesh
  107661. * @param scene defines the hosting scene
  107662. * @returns the ground mesh
  107663. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107664. */
  107665. static CreateGround(name: string, options: {
  107666. width?: number;
  107667. height?: number;
  107668. subdivisions?: number;
  107669. subdivisionsX?: number;
  107670. subdivisionsY?: number;
  107671. updatable?: boolean;
  107672. }, scene: any): Mesh;
  107673. /**
  107674. * Creates a tiled ground mesh
  107675. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107676. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107677. * * 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
  107678. * * 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
  107679. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107680. * @param name defines the name of the mesh
  107681. * @param options defines the options used to create the mesh
  107682. * @param scene defines the hosting scene
  107683. * @returns the tiled ground mesh
  107684. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107685. */
  107686. static CreateTiledGround(name: string, options: {
  107687. xmin: number;
  107688. zmin: number;
  107689. xmax: number;
  107690. zmax: number;
  107691. subdivisions?: {
  107692. w: number;
  107693. h: number;
  107694. };
  107695. precision?: {
  107696. w: number;
  107697. h: number;
  107698. };
  107699. updatable?: boolean;
  107700. }, scene?: Nullable<Scene>): Mesh;
  107701. /**
  107702. * Creates a ground mesh from a height map
  107703. * * The parameter `url` sets the URL of the height map image resource.
  107704. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107705. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107706. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107707. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107708. * * 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.
  107709. * * 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).
  107710. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107712. * @param name defines the name of the mesh
  107713. * @param url defines the url to the height map
  107714. * @param options defines the options used to create the mesh
  107715. * @param scene defines the hosting scene
  107716. * @returns the ground mesh
  107717. * @see https://doc.babylonjs.com/babylon101/height_map
  107718. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107719. */
  107720. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107721. width?: number;
  107722. height?: number;
  107723. subdivisions?: number;
  107724. minHeight?: number;
  107725. maxHeight?: number;
  107726. colorFilter?: Color3;
  107727. alphaFilter?: number;
  107728. updatable?: boolean;
  107729. onReady?: (mesh: GroundMesh) => void;
  107730. }, scene?: Nullable<Scene>): GroundMesh;
  107731. }
  107732. }
  107733. declare module BABYLON {
  107734. /**
  107735. * Class containing static functions to help procedurally build meshes
  107736. */
  107737. export class TorusBuilder {
  107738. /**
  107739. * Creates a torus mesh
  107740. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107741. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107742. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107744. * * 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
  107745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107746. * @param name defines the name of the mesh
  107747. * @param options defines the options used to create the mesh
  107748. * @param scene defines the hosting scene
  107749. * @returns the torus mesh
  107750. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107751. */
  107752. static CreateTorus(name: string, options: {
  107753. diameter?: number;
  107754. thickness?: number;
  107755. tessellation?: number;
  107756. updatable?: boolean;
  107757. sideOrientation?: number;
  107758. frontUVs?: Vector4;
  107759. backUVs?: Vector4;
  107760. }, scene: any): Mesh;
  107761. }
  107762. }
  107763. declare module BABYLON {
  107764. /**
  107765. * Class containing static functions to help procedurally build meshes
  107766. */
  107767. export class CylinderBuilder {
  107768. /**
  107769. * Creates a cylinder or a cone mesh
  107770. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107771. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107772. * * 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.
  107773. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107774. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107775. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107776. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107777. * * 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).
  107778. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107779. * * 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).
  107780. * * 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
  107781. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107782. * * 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
  107783. * * 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.
  107784. * * If `enclose` is false, a ring surface is one element.
  107785. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107786. * * 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
  107787. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107788. * * 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
  107789. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107790. * @param name defines the name of the mesh
  107791. * @param options defines the options used to create the mesh
  107792. * @param scene defines the hosting scene
  107793. * @returns the cylinder mesh
  107794. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107795. */
  107796. static CreateCylinder(name: string, options: {
  107797. height?: number;
  107798. diameterTop?: number;
  107799. diameterBottom?: number;
  107800. diameter?: number;
  107801. tessellation?: number;
  107802. subdivisions?: number;
  107803. arc?: number;
  107804. faceColors?: Color4[];
  107805. faceUV?: Vector4[];
  107806. updatable?: boolean;
  107807. hasRings?: boolean;
  107808. enclose?: boolean;
  107809. cap?: number;
  107810. sideOrientation?: number;
  107811. frontUVs?: Vector4;
  107812. backUVs?: Vector4;
  107813. }, scene: any): Mesh;
  107814. }
  107815. }
  107816. declare module BABYLON {
  107817. /**
  107818. * Options to modify the vr teleportation behavior.
  107819. */
  107820. export interface VRTeleportationOptions {
  107821. /**
  107822. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107823. */
  107824. floorMeshName?: string;
  107825. /**
  107826. * A list of meshes to be used as the teleportation floor. (default: empty)
  107827. */
  107828. floorMeshes?: Mesh[];
  107829. }
  107830. /**
  107831. * Options to modify the vr experience helper's behavior.
  107832. */
  107833. export interface VRExperienceHelperOptions extends WebVROptions {
  107834. /**
  107835. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107836. */
  107837. createDeviceOrientationCamera?: boolean;
  107838. /**
  107839. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107840. */
  107841. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107842. /**
  107843. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107844. */
  107845. laserToggle?: boolean;
  107846. /**
  107847. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107848. */
  107849. floorMeshes?: Mesh[];
  107850. /**
  107851. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107852. */
  107853. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107854. }
  107855. /**
  107856. * Event containing information after VR has been entered
  107857. */
  107858. export class OnAfterEnteringVRObservableEvent {
  107859. /**
  107860. * If entering vr was successful
  107861. */
  107862. success: boolean;
  107863. }
  107864. /**
  107865. * Helps to quickly add VR support to an existing scene.
  107866. * See http://doc.babylonjs.com/how_to/webvr_helper
  107867. */
  107868. export class VRExperienceHelper {
  107869. /** Options to modify the vr experience helper's behavior. */
  107870. webVROptions: VRExperienceHelperOptions;
  107871. private _scene;
  107872. private _position;
  107873. private _btnVR;
  107874. private _btnVRDisplayed;
  107875. private _webVRsupported;
  107876. private _webVRready;
  107877. private _webVRrequesting;
  107878. private _webVRpresenting;
  107879. private _hasEnteredVR;
  107880. private _fullscreenVRpresenting;
  107881. private _canvas;
  107882. private _webVRCamera;
  107883. private _vrDeviceOrientationCamera;
  107884. private _deviceOrientationCamera;
  107885. private _existingCamera;
  107886. private _onKeyDown;
  107887. private _onVrDisplayPresentChange;
  107888. private _onVRDisplayChanged;
  107889. private _onVRRequestPresentStart;
  107890. private _onVRRequestPresentComplete;
  107891. /**
  107892. * 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)
  107893. */
  107894. enableGazeEvenWhenNoPointerLock: boolean;
  107895. /**
  107896. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107897. */
  107898. exitVROnDoubleTap: boolean;
  107899. /**
  107900. * Observable raised right before entering VR.
  107901. */
  107902. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107903. /**
  107904. * Observable raised when entering VR has completed.
  107905. */
  107906. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107907. /**
  107908. * Observable raised when exiting VR.
  107909. */
  107910. onExitingVRObservable: Observable<VRExperienceHelper>;
  107911. /**
  107912. * Observable raised when controller mesh is loaded.
  107913. */
  107914. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107915. /** Return this.onEnteringVRObservable
  107916. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107917. */
  107918. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107919. /** Return this.onExitingVRObservable
  107920. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107921. */
  107922. readonly onExitingVR: Observable<VRExperienceHelper>;
  107923. /** Return this.onControllerMeshLoadedObservable
  107924. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107925. */
  107926. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107927. private _rayLength;
  107928. private _useCustomVRButton;
  107929. private _teleportationRequested;
  107930. private _teleportActive;
  107931. private _floorMeshName;
  107932. private _floorMeshesCollection;
  107933. private _rotationAllowed;
  107934. private _teleportBackwardsVector;
  107935. private _teleportationTarget;
  107936. private _isDefaultTeleportationTarget;
  107937. private _postProcessMove;
  107938. private _teleportationFillColor;
  107939. private _teleportationBorderColor;
  107940. private _rotationAngle;
  107941. private _haloCenter;
  107942. private _cameraGazer;
  107943. private _padSensibilityUp;
  107944. private _padSensibilityDown;
  107945. private _leftController;
  107946. private _rightController;
  107947. /**
  107948. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107949. */
  107950. onNewMeshSelected: Observable<AbstractMesh>;
  107951. /**
  107952. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107953. * This observable will provide the mesh and the controller used to select the mesh
  107954. */
  107955. onMeshSelectedWithController: Observable<{
  107956. mesh: AbstractMesh;
  107957. controller: WebVRController;
  107958. }>;
  107959. /**
  107960. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107961. */
  107962. onNewMeshPicked: Observable<PickingInfo>;
  107963. private _circleEase;
  107964. /**
  107965. * Observable raised before camera teleportation
  107966. */
  107967. onBeforeCameraTeleport: Observable<Vector3>;
  107968. /**
  107969. * Observable raised after camera teleportation
  107970. */
  107971. onAfterCameraTeleport: Observable<Vector3>;
  107972. /**
  107973. * Observable raised when current selected mesh gets unselected
  107974. */
  107975. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107976. private _raySelectionPredicate;
  107977. /**
  107978. * To be optionaly changed by user to define custom ray selection
  107979. */
  107980. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  107981. /**
  107982. * To be optionaly changed by user to define custom selection logic (after ray selection)
  107983. */
  107984. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  107985. /**
  107986. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  107987. */
  107988. teleportationEnabled: boolean;
  107989. private _defaultHeight;
  107990. private _teleportationInitialized;
  107991. private _interactionsEnabled;
  107992. private _interactionsRequested;
  107993. private _displayGaze;
  107994. private _displayLaserPointer;
  107995. /**
  107996. * The mesh used to display where the user is going to teleport.
  107997. */
  107998. /**
  107999. * Sets the mesh to be used to display where the user is going to teleport.
  108000. */
  108001. teleportationTarget: Mesh;
  108002. /**
  108003. * 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
  108004. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  108005. * See http://doc.babylonjs.com/resources/baking_transformations
  108006. */
  108007. gazeTrackerMesh: Mesh;
  108008. /**
  108009. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  108010. */
  108011. updateGazeTrackerScale: boolean;
  108012. /**
  108013. * If the gaze trackers color should be updated when selecting meshes
  108014. */
  108015. updateGazeTrackerColor: boolean;
  108016. /**
  108017. * If the controller laser color should be updated when selecting meshes
  108018. */
  108019. updateControllerLaserColor: boolean;
  108020. /**
  108021. * The gaze tracking mesh corresponding to the left controller
  108022. */
  108023. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108024. /**
  108025. * The gaze tracking mesh corresponding to the right controller
  108026. */
  108027. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108028. /**
  108029. * If the ray of the gaze should be displayed.
  108030. */
  108031. /**
  108032. * Sets if the ray of the gaze should be displayed.
  108033. */
  108034. displayGaze: boolean;
  108035. /**
  108036. * If the ray of the LaserPointer should be displayed.
  108037. */
  108038. /**
  108039. * Sets if the ray of the LaserPointer should be displayed.
  108040. */
  108041. displayLaserPointer: boolean;
  108042. /**
  108043. * The deviceOrientationCamera used as the camera when not in VR.
  108044. */
  108045. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108046. /**
  108047. * Based on the current WebVR support, returns the current VR camera used.
  108048. */
  108049. readonly currentVRCamera: Nullable<Camera>;
  108050. /**
  108051. * The webVRCamera which is used when in VR.
  108052. */
  108053. readonly webVRCamera: WebVRFreeCamera;
  108054. /**
  108055. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108056. */
  108057. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108058. /**
  108059. * The html button that is used to trigger entering into VR.
  108060. */
  108061. readonly vrButton: Nullable<HTMLButtonElement>;
  108062. private readonly _teleportationRequestInitiated;
  108063. /**
  108064. * Defines wether or not Pointer lock should be requested when switching to
  108065. * full screen.
  108066. */
  108067. requestPointerLockOnFullScreen: boolean;
  108068. /**
  108069. * Instantiates a VRExperienceHelper.
  108070. * Helps to quickly add VR support to an existing scene.
  108071. * @param scene The scene the VRExperienceHelper belongs to.
  108072. * @param webVROptions Options to modify the vr experience helper's behavior.
  108073. */
  108074. constructor(scene: Scene,
  108075. /** Options to modify the vr experience helper's behavior. */
  108076. webVROptions?: VRExperienceHelperOptions);
  108077. private _onDefaultMeshLoaded;
  108078. private _onResize;
  108079. private _onFullscreenChange;
  108080. /**
  108081. * Gets a value indicating if we are currently in VR mode.
  108082. */
  108083. readonly isInVRMode: boolean;
  108084. private onVrDisplayPresentChange;
  108085. private onVRDisplayChanged;
  108086. private moveButtonToBottomRight;
  108087. private displayVRButton;
  108088. private updateButtonVisibility;
  108089. private _cachedAngularSensibility;
  108090. /**
  108091. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108092. * Otherwise, will use the fullscreen API.
  108093. */
  108094. enterVR(): void;
  108095. /**
  108096. * Attempt to exit VR, or fullscreen.
  108097. */
  108098. exitVR(): void;
  108099. /**
  108100. * The position of the vr experience helper.
  108101. */
  108102. /**
  108103. * Sets the position of the vr experience helper.
  108104. */
  108105. position: Vector3;
  108106. /**
  108107. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108108. */
  108109. enableInteractions(): void;
  108110. private readonly _noControllerIsActive;
  108111. private beforeRender;
  108112. private _isTeleportationFloor;
  108113. /**
  108114. * Adds a floor mesh to be used for teleportation.
  108115. * @param floorMesh the mesh to be used for teleportation.
  108116. */
  108117. addFloorMesh(floorMesh: Mesh): void;
  108118. /**
  108119. * Removes a floor mesh from being used for teleportation.
  108120. * @param floorMesh the mesh to be removed.
  108121. */
  108122. removeFloorMesh(floorMesh: Mesh): void;
  108123. /**
  108124. * Enables interactions and teleportation using the VR controllers and gaze.
  108125. * @param vrTeleportationOptions options to modify teleportation behavior.
  108126. */
  108127. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108128. private _onNewGamepadConnected;
  108129. private _tryEnableInteractionOnController;
  108130. private _onNewGamepadDisconnected;
  108131. private _enableInteractionOnController;
  108132. private _checkTeleportWithRay;
  108133. private _checkRotate;
  108134. private _checkTeleportBackwards;
  108135. private _enableTeleportationOnController;
  108136. private _createTeleportationCircles;
  108137. private _displayTeleportationTarget;
  108138. private _hideTeleportationTarget;
  108139. private _rotateCamera;
  108140. private _moveTeleportationSelectorTo;
  108141. private _workingVector;
  108142. private _workingQuaternion;
  108143. private _workingMatrix;
  108144. /**
  108145. * Teleports the users feet to the desired location
  108146. * @param location The location where the user's feet should be placed
  108147. */
  108148. teleportCamera(location: Vector3): void;
  108149. private _convertNormalToDirectionOfRay;
  108150. private _castRayAndSelectObject;
  108151. private _notifySelectedMeshUnselected;
  108152. /**
  108153. * Sets the color of the laser ray from the vr controllers.
  108154. * @param color new color for the ray.
  108155. */
  108156. changeLaserColor(color: Color3): void;
  108157. /**
  108158. * Sets the color of the ray from the vr headsets gaze.
  108159. * @param color new color for the ray.
  108160. */
  108161. changeGazeColor(color: Color3): void;
  108162. /**
  108163. * Exits VR and disposes of the vr experience helper
  108164. */
  108165. dispose(): void;
  108166. /**
  108167. * Gets the name of the VRExperienceHelper class
  108168. * @returns "VRExperienceHelper"
  108169. */
  108170. getClassName(): string;
  108171. }
  108172. }
  108173. declare module BABYLON {
  108174. /**
  108175. * Manages an XRSession to work with Babylon's engine
  108176. * @see https://doc.babylonjs.com/how_to/webxr
  108177. */
  108178. export class WebXRSessionManager implements IDisposable {
  108179. private scene;
  108180. /**
  108181. * Fires every time a new xrFrame arrives which can be used to update the camera
  108182. */
  108183. onXRFrameObservable: Observable<any>;
  108184. /**
  108185. * Fires when the xr session is ended either by the device or manually done
  108186. */
  108187. onXRSessionEnded: Observable<any>;
  108188. /**
  108189. * Underlying xr session
  108190. */
  108191. session: XRSession;
  108192. /**
  108193. * Type of reference space used when creating the session
  108194. */
  108195. referenceSpace: XRReferenceSpace;
  108196. /** @hidden */
  108197. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108198. /**
  108199. * Current XR frame
  108200. */
  108201. currentFrame: Nullable<XRFrame>;
  108202. private _xrNavigator;
  108203. private baseLayer;
  108204. /**
  108205. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108206. * @param scene The scene which the session should be created for
  108207. */
  108208. constructor(scene: Scene);
  108209. /**
  108210. * Initializes the manager
  108211. * After initialization enterXR can be called to start an XR session
  108212. * @returns Promise which resolves after it is initialized
  108213. */
  108214. initializeAsync(): Promise<void>;
  108215. /**
  108216. * Initializes an xr session
  108217. * @param xrSessionMode mode to initialize
  108218. * @returns a promise which will resolve once the session has been initialized
  108219. */
  108220. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108221. /**
  108222. * Sets the reference space on the xr session
  108223. * @param referenceSpace space to set
  108224. * @returns a promise that will resolve once the reference space has been set
  108225. */
  108226. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108227. /**
  108228. * Updates the render state of the session
  108229. * @param state state to set
  108230. * @returns a promise that resolves once the render state has been updated
  108231. */
  108232. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108233. /**
  108234. * Starts rendering to the xr layer
  108235. * @returns a promise that will resolve once rendering has started
  108236. */
  108237. startRenderingToXRAsync(): Promise<void>;
  108238. /**
  108239. * Stops the xrSession and restores the renderloop
  108240. * @returns Promise which resolves after it exits XR
  108241. */
  108242. exitXRAsync(): Promise<unknown>;
  108243. /**
  108244. * Checks if a session would be supported for the creation options specified
  108245. * @param sessionMode session mode to check if supported eg. immersive-vr
  108246. * @returns true if supported
  108247. */
  108248. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108249. /**
  108250. * @hidden
  108251. * Converts the render layer of xrSession to a render target
  108252. * @param session session to create render target for
  108253. * @param scene scene the new render target should be created for
  108254. */
  108255. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108256. /**
  108257. * Disposes of the session manager
  108258. */
  108259. dispose(): void;
  108260. }
  108261. }
  108262. declare module BABYLON {
  108263. /**
  108264. * WebXR Camera which holds the views for the xrSession
  108265. * @see https://doc.babylonjs.com/how_to/webxr
  108266. */
  108267. export class WebXRCamera extends FreeCamera {
  108268. private static _TmpMatrix;
  108269. /**
  108270. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108271. * @param name the name of the camera
  108272. * @param scene the scene to add the camera to
  108273. */
  108274. constructor(name: string, scene: Scene);
  108275. private _updateNumberOfRigCameras;
  108276. /** @hidden */
  108277. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108278. /**
  108279. * Updates the cameras position from the current pose information of the XR session
  108280. * @param xrSessionManager the session containing pose information
  108281. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108282. */
  108283. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108284. }
  108285. }
  108286. declare module BABYLON {
  108287. /**
  108288. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108289. */
  108290. export class WebXRManagedOutputCanvas implements IDisposable {
  108291. private helper;
  108292. private _canvas;
  108293. /**
  108294. * xrpresent context of the canvas which can be used to display/mirror xr content
  108295. */
  108296. canvasContext: WebGLRenderingContext;
  108297. /**
  108298. * xr layer for the canvas
  108299. */
  108300. xrLayer: Nullable<XRWebGLLayer>;
  108301. /**
  108302. * Initializes the xr layer for the session
  108303. * @param xrSession xr session
  108304. * @returns a promise that will resolve once the XR Layer has been created
  108305. */
  108306. initializeXRLayerAsync(xrSession: any): any;
  108307. /**
  108308. * Initializes the canvas to be added/removed upon entering/exiting xr
  108309. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108310. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108311. */
  108312. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108313. /**
  108314. * Disposes of the object
  108315. */
  108316. dispose(): void;
  108317. private _setManagedOutputCanvas;
  108318. private _addCanvas;
  108319. private _removeCanvas;
  108320. }
  108321. }
  108322. declare module BABYLON {
  108323. /**
  108324. * States of the webXR experience
  108325. */
  108326. export enum WebXRState {
  108327. /**
  108328. * Transitioning to being in XR mode
  108329. */
  108330. ENTERING_XR = 0,
  108331. /**
  108332. * Transitioning to non XR mode
  108333. */
  108334. EXITING_XR = 1,
  108335. /**
  108336. * In XR mode and presenting
  108337. */
  108338. IN_XR = 2,
  108339. /**
  108340. * Not entered XR mode
  108341. */
  108342. NOT_IN_XR = 3
  108343. }
  108344. /**
  108345. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108346. * @see https://doc.babylonjs.com/how_to/webxr
  108347. */
  108348. export class WebXRExperienceHelper implements IDisposable {
  108349. private scene;
  108350. /**
  108351. * 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
  108352. */
  108353. container: AbstractMesh;
  108354. /**
  108355. * Camera used to render xr content
  108356. */
  108357. camera: WebXRCamera;
  108358. /**
  108359. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108360. */
  108361. state: WebXRState;
  108362. private _setState;
  108363. private static _TmpVector;
  108364. /**
  108365. * Fires when the state of the experience helper has changed
  108366. */
  108367. onStateChangedObservable: Observable<WebXRState>;
  108368. /** Session manager used to keep track of xr session */
  108369. sessionManager: WebXRSessionManager;
  108370. private _nonVRCamera;
  108371. private _originalSceneAutoClear;
  108372. private _supported;
  108373. /**
  108374. * Creates the experience helper
  108375. * @param scene the scene to attach the experience helper to
  108376. * @returns a promise for the experience helper
  108377. */
  108378. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108379. /**
  108380. * Creates a WebXRExperienceHelper
  108381. * @param scene The scene the helper should be created in
  108382. */
  108383. private constructor();
  108384. /**
  108385. * Exits XR mode and returns the scene to its original state
  108386. * @returns promise that resolves after xr mode has exited
  108387. */
  108388. exitXRAsync(): Promise<unknown>;
  108389. /**
  108390. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108391. * @param sessionCreationOptions options for the XR session
  108392. * @param referenceSpaceType frame of reference of the XR session
  108393. * @param outputCanvas the output canvas that will be used to enter XR mode
  108394. * @returns promise that resolves after xr mode has entered
  108395. */
  108396. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108397. /**
  108398. * Updates the global position of the camera by moving the camera's container
  108399. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108400. * @param position The desired global position of the camera
  108401. */
  108402. setPositionOfCameraUsingContainer(position: Vector3): void;
  108403. /**
  108404. * Rotates the xr camera by rotating the camera's container around the camera's position
  108405. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108406. * @param rotation the desired quaternion rotation to apply to the camera
  108407. */
  108408. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108409. /**
  108410. * Disposes of the experience helper
  108411. */
  108412. dispose(): void;
  108413. }
  108414. }
  108415. declare module BABYLON {
  108416. /**
  108417. * Button which can be used to enter a different mode of XR
  108418. */
  108419. export class WebXREnterExitUIButton {
  108420. /** button element */
  108421. element: HTMLElement;
  108422. /** XR initialization options for the button */
  108423. sessionMode: XRSessionMode;
  108424. /** Reference space type */
  108425. referenceSpaceType: XRReferenceSpaceType;
  108426. /**
  108427. * Creates a WebXREnterExitUIButton
  108428. * @param element button element
  108429. * @param sessionMode XR initialization session mode
  108430. * @param referenceSpaceType the type of reference space to be used
  108431. */
  108432. constructor(
  108433. /** button element */
  108434. element: HTMLElement,
  108435. /** XR initialization options for the button */
  108436. sessionMode: XRSessionMode,
  108437. /** Reference space type */
  108438. referenceSpaceType: XRReferenceSpaceType);
  108439. /**
  108440. * Overwritable function which can be used to update the button's visuals when the state changes
  108441. * @param activeButton the current active button in the UI
  108442. */
  108443. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108444. }
  108445. /**
  108446. * Options to create the webXR UI
  108447. */
  108448. export class WebXREnterExitUIOptions {
  108449. /**
  108450. * Context to enter xr with
  108451. */
  108452. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108453. /**
  108454. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108455. */
  108456. customButtons?: Array<WebXREnterExitUIButton>;
  108457. }
  108458. /**
  108459. * UI to allow the user to enter/exit XR mode
  108460. */
  108461. export class WebXREnterExitUI implements IDisposable {
  108462. private scene;
  108463. private _overlay;
  108464. private _buttons;
  108465. private _activeButton;
  108466. /**
  108467. * Fired every time the active button is changed.
  108468. *
  108469. * When xr is entered via a button that launches xr that button will be the callback parameter
  108470. *
  108471. * When exiting xr the callback parameter will be null)
  108472. */
  108473. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108474. /**
  108475. * Creates UI to allow the user to enter/exit XR mode
  108476. * @param scene the scene to add the ui to
  108477. * @param helper the xr experience helper to enter/exit xr with
  108478. * @param options options to configure the UI
  108479. * @returns the created ui
  108480. */
  108481. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108482. private constructor();
  108483. private _updateButtons;
  108484. /**
  108485. * Disposes of the object
  108486. */
  108487. dispose(): void;
  108488. }
  108489. }
  108490. declare module BABYLON {
  108491. /**
  108492. * Represents an XR input
  108493. */
  108494. export class WebXRController {
  108495. private scene;
  108496. /** The underlying input source for the controller */
  108497. inputSource: XRInputSource;
  108498. private parentContainer;
  108499. /**
  108500. * 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
  108501. */
  108502. grip?: AbstractMesh;
  108503. /**
  108504. * Pointer which can be used to select objects or attach a visible laser to
  108505. */
  108506. pointer: AbstractMesh;
  108507. /**
  108508. * Event that fires when the controller is removed/disposed
  108509. */
  108510. onDisposeObservable: Observable<{}>;
  108511. private _tmpMatrix;
  108512. private _tmpQuaternion;
  108513. private _tmpVector;
  108514. /**
  108515. * Creates the controller
  108516. * @see https://doc.babylonjs.com/how_to/webxr
  108517. * @param scene the scene which the controller should be associated to
  108518. * @param inputSource the underlying input source for the controller
  108519. * @param parentContainer parent that the controller meshes should be children of
  108520. */
  108521. constructor(scene: Scene,
  108522. /** The underlying input source for the controller */
  108523. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108524. /**
  108525. * Updates the controller pose based on the given XRFrame
  108526. * @param xrFrame xr frame to update the pose with
  108527. * @param referenceSpace reference space to use
  108528. */
  108529. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108530. /**
  108531. * Gets a world space ray coming from the controller
  108532. * @param result the resulting ray
  108533. */
  108534. getWorldPointerRayToRef(result: Ray): void;
  108535. /**
  108536. * Disposes of the object
  108537. */
  108538. dispose(): void;
  108539. }
  108540. }
  108541. declare module BABYLON {
  108542. /**
  108543. * XR input used to track XR inputs such as controllers/rays
  108544. */
  108545. export class WebXRInput implements IDisposable {
  108546. /**
  108547. * Base experience the input listens to
  108548. */
  108549. baseExperience: WebXRExperienceHelper;
  108550. /**
  108551. * XR controllers being tracked
  108552. */
  108553. controllers: Array<WebXRController>;
  108554. private _frameObserver;
  108555. private _stateObserver;
  108556. /**
  108557. * Event when a controller has been connected/added
  108558. */
  108559. onControllerAddedObservable: Observable<WebXRController>;
  108560. /**
  108561. * Event when a controller has been removed/disconnected
  108562. */
  108563. onControllerRemovedObservable: Observable<WebXRController>;
  108564. /**
  108565. * Initializes the WebXRInput
  108566. * @param baseExperience experience helper which the input should be created for
  108567. */
  108568. constructor(
  108569. /**
  108570. * Base experience the input listens to
  108571. */
  108572. baseExperience: WebXRExperienceHelper);
  108573. private _onInputSourcesChange;
  108574. private _addAndRemoveControllers;
  108575. /**
  108576. * Disposes of the object
  108577. */
  108578. dispose(): void;
  108579. }
  108580. }
  108581. declare module BABYLON {
  108582. /**
  108583. * Enables teleportation
  108584. */
  108585. export class WebXRControllerTeleportation {
  108586. private _teleportationFillColor;
  108587. private _teleportationBorderColor;
  108588. private _tmpRay;
  108589. private _tmpVector;
  108590. /**
  108591. * Creates a WebXRControllerTeleportation
  108592. * @param input input manager to add teleportation to
  108593. * @param floorMeshes floormeshes which can be teleported to
  108594. */
  108595. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108596. }
  108597. }
  108598. declare module BABYLON {
  108599. /**
  108600. * Handles pointer input automatically for the pointer of XR controllers
  108601. */
  108602. export class WebXRControllerPointerSelection {
  108603. private static _idCounter;
  108604. private _tmpRay;
  108605. /**
  108606. * Creates a WebXRControllerPointerSelection
  108607. * @param input input manager to setup pointer selection
  108608. */
  108609. constructor(input: WebXRInput);
  108610. private _convertNormalToDirectionOfRay;
  108611. private _updatePointerDistance;
  108612. }
  108613. }
  108614. declare module BABYLON {
  108615. /**
  108616. * Class used to represent data loading progression
  108617. */
  108618. export class SceneLoaderProgressEvent {
  108619. /** defines if data length to load can be evaluated */
  108620. readonly lengthComputable: boolean;
  108621. /** defines the loaded data length */
  108622. readonly loaded: number;
  108623. /** defines the data length to load */
  108624. readonly total: number;
  108625. /**
  108626. * Create a new progress event
  108627. * @param lengthComputable defines if data length to load can be evaluated
  108628. * @param loaded defines the loaded data length
  108629. * @param total defines the data length to load
  108630. */
  108631. constructor(
  108632. /** defines if data length to load can be evaluated */
  108633. lengthComputable: boolean,
  108634. /** defines the loaded data length */
  108635. loaded: number,
  108636. /** defines the data length to load */
  108637. total: number);
  108638. /**
  108639. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108640. * @param event defines the source event
  108641. * @returns a new SceneLoaderProgressEvent
  108642. */
  108643. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108644. }
  108645. /**
  108646. * Interface used by SceneLoader plugins to define supported file extensions
  108647. */
  108648. export interface ISceneLoaderPluginExtensions {
  108649. /**
  108650. * Defines the list of supported extensions
  108651. */
  108652. [extension: string]: {
  108653. isBinary: boolean;
  108654. };
  108655. }
  108656. /**
  108657. * Interface used by SceneLoader plugin factory
  108658. */
  108659. export interface ISceneLoaderPluginFactory {
  108660. /**
  108661. * Defines the name of the factory
  108662. */
  108663. name: string;
  108664. /**
  108665. * Function called to create a new plugin
  108666. * @return the new plugin
  108667. */
  108668. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108669. /**
  108670. * Boolean indicating if the plugin can direct load specific data
  108671. */
  108672. canDirectLoad?: (data: string) => boolean;
  108673. }
  108674. /**
  108675. * Interface used to define a SceneLoader plugin
  108676. */
  108677. export interface ISceneLoaderPlugin {
  108678. /**
  108679. * The friendly name of this plugin.
  108680. */
  108681. name: string;
  108682. /**
  108683. * The file extensions supported by this plugin.
  108684. */
  108685. extensions: string | ISceneLoaderPluginExtensions;
  108686. /**
  108687. * Import meshes into a scene.
  108688. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108689. * @param scene The scene to import into
  108690. * @param data The data to import
  108691. * @param rootUrl The root url for scene and resources
  108692. * @param meshes The meshes array to import into
  108693. * @param particleSystems The particle systems array to import into
  108694. * @param skeletons The skeletons array to import into
  108695. * @param onError The callback when import fails
  108696. * @returns True if successful or false otherwise
  108697. */
  108698. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108699. /**
  108700. * Load into a scene.
  108701. * @param scene The scene to load into
  108702. * @param data The data to import
  108703. * @param rootUrl The root url for scene and resources
  108704. * @param onError The callback when import fails
  108705. * @returns true if successful or false otherwise
  108706. */
  108707. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108708. /**
  108709. * The callback that returns true if the data can be directly loaded.
  108710. */
  108711. canDirectLoad?: (data: string) => boolean;
  108712. /**
  108713. * The callback that allows custom handling of the root url based on the response url.
  108714. */
  108715. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108716. /**
  108717. * Load into an asset container.
  108718. * @param scene The scene to load into
  108719. * @param data The data to import
  108720. * @param rootUrl The root url for scene and resources
  108721. * @param onError The callback when import fails
  108722. * @returns The loaded asset container
  108723. */
  108724. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108725. }
  108726. /**
  108727. * Interface used to define an async SceneLoader plugin
  108728. */
  108729. export interface ISceneLoaderPluginAsync {
  108730. /**
  108731. * The friendly name of this plugin.
  108732. */
  108733. name: string;
  108734. /**
  108735. * The file extensions supported by this plugin.
  108736. */
  108737. extensions: string | ISceneLoaderPluginExtensions;
  108738. /**
  108739. * Import meshes into a scene.
  108740. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108741. * @param scene The scene to import into
  108742. * @param data The data to import
  108743. * @param rootUrl The root url for scene and resources
  108744. * @param onProgress The callback when the load progresses
  108745. * @param fileName Defines the name of the file to load
  108746. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108747. */
  108748. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108749. meshes: AbstractMesh[];
  108750. particleSystems: IParticleSystem[];
  108751. skeletons: Skeleton[];
  108752. animationGroups: AnimationGroup[];
  108753. }>;
  108754. /**
  108755. * Load into a scene.
  108756. * @param scene The scene to load into
  108757. * @param data The data to import
  108758. * @param rootUrl The root url for scene and resources
  108759. * @param onProgress The callback when the load progresses
  108760. * @param fileName Defines the name of the file to load
  108761. * @returns Nothing
  108762. */
  108763. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108764. /**
  108765. * The callback that returns true if the data can be directly loaded.
  108766. */
  108767. canDirectLoad?: (data: string) => boolean;
  108768. /**
  108769. * The callback that allows custom handling of the root url based on the response url.
  108770. */
  108771. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108772. /**
  108773. * Load into an asset container.
  108774. * @param scene The scene to load into
  108775. * @param data The data to import
  108776. * @param rootUrl The root url for scene and resources
  108777. * @param onProgress The callback when the load progresses
  108778. * @param fileName Defines the name of the file to load
  108779. * @returns The loaded asset container
  108780. */
  108781. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108782. }
  108783. /**
  108784. * Class used to load scene from various file formats using registered plugins
  108785. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108786. */
  108787. export class SceneLoader {
  108788. /**
  108789. * No logging while loading
  108790. */
  108791. static readonly NO_LOGGING: number;
  108792. /**
  108793. * Minimal logging while loading
  108794. */
  108795. static readonly MINIMAL_LOGGING: number;
  108796. /**
  108797. * Summary logging while loading
  108798. */
  108799. static readonly SUMMARY_LOGGING: number;
  108800. /**
  108801. * Detailled logging while loading
  108802. */
  108803. static readonly DETAILED_LOGGING: number;
  108804. /**
  108805. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108806. */
  108807. static ForceFullSceneLoadingForIncremental: boolean;
  108808. /**
  108809. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108810. */
  108811. static ShowLoadingScreen: boolean;
  108812. /**
  108813. * Defines the current logging level (while loading the scene)
  108814. * @ignorenaming
  108815. */
  108816. static loggingLevel: number;
  108817. /**
  108818. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108819. */
  108820. static CleanBoneMatrixWeights: boolean;
  108821. /**
  108822. * Event raised when a plugin is used to load a scene
  108823. */
  108824. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108825. private static _registeredPlugins;
  108826. private static _getDefaultPlugin;
  108827. private static _getPluginForExtension;
  108828. private static _getPluginForDirectLoad;
  108829. private static _getPluginForFilename;
  108830. private static _getDirectLoad;
  108831. private static _loadData;
  108832. private static _getFileInfo;
  108833. /**
  108834. * Gets a plugin that can load the given extension
  108835. * @param extension defines the extension to load
  108836. * @returns a plugin or null if none works
  108837. */
  108838. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108839. /**
  108840. * Gets a boolean indicating that the given extension can be loaded
  108841. * @param extension defines the extension to load
  108842. * @returns true if the extension is supported
  108843. */
  108844. static IsPluginForExtensionAvailable(extension: string): boolean;
  108845. /**
  108846. * Adds a new plugin to the list of registered plugins
  108847. * @param plugin defines the plugin to add
  108848. */
  108849. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108850. /**
  108851. * Import meshes into a scene
  108852. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108853. * @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)
  108854. * @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)
  108855. * @param scene the instance of BABYLON.Scene to append to
  108856. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108857. * @param onProgress a callback with a progress event for each file being loaded
  108858. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108859. * @param pluginExtension the extension used to determine the plugin
  108860. * @returns The loaded plugin
  108861. */
  108862. 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>;
  108863. /**
  108864. * Import meshes into a scene
  108865. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108866. * @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)
  108867. * @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)
  108868. * @param scene the instance of BABYLON.Scene to append to
  108869. * @param onProgress a callback with a progress event for each file being loaded
  108870. * @param pluginExtension the extension used to determine the plugin
  108871. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108872. */
  108873. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108874. meshes: AbstractMesh[];
  108875. particleSystems: IParticleSystem[];
  108876. skeletons: Skeleton[];
  108877. animationGroups: AnimationGroup[];
  108878. }>;
  108879. /**
  108880. * Load a scene
  108881. * @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)
  108882. * @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)
  108883. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108884. * @param onSuccess a callback with the scene when import succeeds
  108885. * @param onProgress a callback with a progress event for each file being loaded
  108886. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108887. * @param pluginExtension the extension used to determine the plugin
  108888. * @returns The loaded plugin
  108889. */
  108890. 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>;
  108891. /**
  108892. * Load a scene
  108893. * @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)
  108894. * @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)
  108895. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108896. * @param onProgress a callback with a progress event for each file being loaded
  108897. * @param pluginExtension the extension used to determine the plugin
  108898. * @returns The loaded scene
  108899. */
  108900. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108901. /**
  108902. * Append a scene
  108903. * @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)
  108904. * @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)
  108905. * @param scene is the instance of BABYLON.Scene to append to
  108906. * @param onSuccess a callback with the scene when import succeeds
  108907. * @param onProgress a callback with a progress event for each file being loaded
  108908. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108909. * @param pluginExtension the extension used to determine the plugin
  108910. * @returns The loaded plugin
  108911. */
  108912. 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>;
  108913. /**
  108914. * Append a scene
  108915. * @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)
  108916. * @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)
  108917. * @param scene is the instance of BABYLON.Scene to append to
  108918. * @param onProgress a callback with a progress event for each file being loaded
  108919. * @param pluginExtension the extension used to determine the plugin
  108920. * @returns The given scene
  108921. */
  108922. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108923. /**
  108924. * Load a scene into an asset container
  108925. * @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)
  108926. * @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)
  108927. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108928. * @param onSuccess a callback with the scene when import succeeds
  108929. * @param onProgress a callback with a progress event for each file being loaded
  108930. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108931. * @param pluginExtension the extension used to determine the plugin
  108932. * @returns The loaded plugin
  108933. */
  108934. 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>;
  108935. /**
  108936. * Load a scene into an asset container
  108937. * @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)
  108938. * @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)
  108939. * @param scene is the instance of Scene to append to
  108940. * @param onProgress a callback with a progress event for each file being loaded
  108941. * @param pluginExtension the extension used to determine the plugin
  108942. * @returns The loaded asset container
  108943. */
  108944. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108945. }
  108946. }
  108947. declare module BABYLON {
  108948. /**
  108949. * Generic Controller
  108950. */
  108951. export class GenericController extends WebVRController {
  108952. /**
  108953. * Base Url for the controller model.
  108954. */
  108955. static readonly MODEL_BASE_URL: string;
  108956. /**
  108957. * File name for the controller model.
  108958. */
  108959. static readonly MODEL_FILENAME: string;
  108960. /**
  108961. * Creates a new GenericController from a gamepad
  108962. * @param vrGamepad the gamepad that the controller should be created from
  108963. */
  108964. constructor(vrGamepad: any);
  108965. /**
  108966. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108967. * @param scene scene in which to add meshes
  108968. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108969. */
  108970. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108971. /**
  108972. * Called once for each button that changed state since the last frame
  108973. * @param buttonIdx Which button index changed
  108974. * @param state New state of the button
  108975. * @param changes Which properties on the state changed since last frame
  108976. */
  108977. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  108978. }
  108979. }
  108980. declare module BABYLON {
  108981. /**
  108982. * Defines the WindowsMotionController object that the state of the windows motion controller
  108983. */
  108984. export class WindowsMotionController extends WebVRController {
  108985. /**
  108986. * The base url used to load the left and right controller models
  108987. */
  108988. static MODEL_BASE_URL: string;
  108989. /**
  108990. * The name of the left controller model file
  108991. */
  108992. static MODEL_LEFT_FILENAME: string;
  108993. /**
  108994. * The name of the right controller model file
  108995. */
  108996. static MODEL_RIGHT_FILENAME: string;
  108997. /**
  108998. * The controller name prefix for this controller type
  108999. */
  109000. static readonly GAMEPAD_ID_PREFIX: string;
  109001. /**
  109002. * The controller id pattern for this controller type
  109003. */
  109004. private static readonly GAMEPAD_ID_PATTERN;
  109005. private _loadedMeshInfo;
  109006. private readonly _mapping;
  109007. /**
  109008. * Fired when the trackpad on this controller is clicked
  109009. */
  109010. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  109011. /**
  109012. * Fired when the trackpad on this controller is modified
  109013. */
  109014. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109015. /**
  109016. * The current x and y values of this controller's trackpad
  109017. */
  109018. trackpad: StickValues;
  109019. /**
  109020. * Creates a new WindowsMotionController from a gamepad
  109021. * @param vrGamepad the gamepad that the controller should be created from
  109022. */
  109023. constructor(vrGamepad: any);
  109024. /**
  109025. * Fired when the trigger on this controller is modified
  109026. */
  109027. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109028. /**
  109029. * Fired when the menu button on this controller is modified
  109030. */
  109031. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109032. /**
  109033. * Fired when the grip button on this controller is modified
  109034. */
  109035. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109036. /**
  109037. * Fired when the thumbstick button on this controller is modified
  109038. */
  109039. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109040. /**
  109041. * Fired when the touchpad button on this controller is modified
  109042. */
  109043. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109044. /**
  109045. * Fired when the touchpad values on this controller are modified
  109046. */
  109047. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109048. private _updateTrackpad;
  109049. /**
  109050. * Called once per frame by the engine.
  109051. */
  109052. update(): void;
  109053. /**
  109054. * Called once for each button that changed state since the last frame
  109055. * @param buttonIdx Which button index changed
  109056. * @param state New state of the button
  109057. * @param changes Which properties on the state changed since last frame
  109058. */
  109059. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109060. /**
  109061. * Moves the buttons on the controller mesh based on their current state
  109062. * @param buttonName the name of the button to move
  109063. * @param buttonValue the value of the button which determines the buttons new position
  109064. */
  109065. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109066. /**
  109067. * Moves the axis on the controller mesh based on its current state
  109068. * @param axis the index of the axis
  109069. * @param axisValue the value of the axis which determines the meshes new position
  109070. * @hidden
  109071. */
  109072. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109073. /**
  109074. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109075. * @param scene scene in which to add meshes
  109076. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109077. */
  109078. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109079. /**
  109080. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109081. * can be transformed by button presses and axes values, based on this._mapping.
  109082. *
  109083. * @param scene scene in which the meshes exist
  109084. * @param meshes list of meshes that make up the controller model to process
  109085. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109086. */
  109087. private processModel;
  109088. private createMeshInfo;
  109089. /**
  109090. * Gets the ray of the controller in the direction the controller is pointing
  109091. * @param length the length the resulting ray should be
  109092. * @returns a ray in the direction the controller is pointing
  109093. */
  109094. getForwardRay(length?: number): Ray;
  109095. /**
  109096. * Disposes of the controller
  109097. */
  109098. dispose(): void;
  109099. }
  109100. }
  109101. declare module BABYLON {
  109102. /**
  109103. * Oculus Touch Controller
  109104. */
  109105. export class OculusTouchController extends WebVRController {
  109106. /**
  109107. * Base Url for the controller model.
  109108. */
  109109. static MODEL_BASE_URL: string;
  109110. /**
  109111. * File name for the left controller model.
  109112. */
  109113. static MODEL_LEFT_FILENAME: string;
  109114. /**
  109115. * File name for the right controller model.
  109116. */
  109117. static MODEL_RIGHT_FILENAME: string;
  109118. /**
  109119. * Base Url for the Quest controller model.
  109120. */
  109121. static QUEST_MODEL_BASE_URL: string;
  109122. /**
  109123. * @hidden
  109124. * If the controllers are running on a device that needs the updated Quest controller models
  109125. */
  109126. static _IsQuest: boolean;
  109127. /**
  109128. * Fired when the secondary trigger on this controller is modified
  109129. */
  109130. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109131. /**
  109132. * Fired when the thumb rest on this controller is modified
  109133. */
  109134. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109135. /**
  109136. * Creates a new OculusTouchController from a gamepad
  109137. * @param vrGamepad the gamepad that the controller should be created from
  109138. */
  109139. constructor(vrGamepad: any);
  109140. /**
  109141. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109142. * @param scene scene in which to add meshes
  109143. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109144. */
  109145. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109146. /**
  109147. * Fired when the A button on this controller is modified
  109148. */
  109149. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109150. /**
  109151. * Fired when the B button on this controller is modified
  109152. */
  109153. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109154. /**
  109155. * Fired when the X button on this controller is modified
  109156. */
  109157. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109158. /**
  109159. * Fired when the Y button on this controller is modified
  109160. */
  109161. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109162. /**
  109163. * Called once for each button that changed state since the last frame
  109164. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109165. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109166. * 2) secondary trigger (same)
  109167. * 3) A (right) X (left), touch, pressed = value
  109168. * 4) B / Y
  109169. * 5) thumb rest
  109170. * @param buttonIdx Which button index changed
  109171. * @param state New state of the button
  109172. * @param changes Which properties on the state changed since last frame
  109173. */
  109174. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109175. }
  109176. }
  109177. declare module BABYLON {
  109178. /**
  109179. * Vive Controller
  109180. */
  109181. export class ViveController extends WebVRController {
  109182. /**
  109183. * Base Url for the controller model.
  109184. */
  109185. static MODEL_BASE_URL: string;
  109186. /**
  109187. * File name for the controller model.
  109188. */
  109189. static MODEL_FILENAME: string;
  109190. /**
  109191. * Creates a new ViveController from a gamepad
  109192. * @param vrGamepad the gamepad that the controller should be created from
  109193. */
  109194. constructor(vrGamepad: any);
  109195. /**
  109196. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109197. * @param scene scene in which to add meshes
  109198. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109199. */
  109200. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109201. /**
  109202. * Fired when the left button on this controller is modified
  109203. */
  109204. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109205. /**
  109206. * Fired when the right button on this controller is modified
  109207. */
  109208. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109209. /**
  109210. * Fired when the menu button on this controller is modified
  109211. */
  109212. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109213. /**
  109214. * Called once for each button that changed state since the last frame
  109215. * Vive mapping:
  109216. * 0: touchpad
  109217. * 1: trigger
  109218. * 2: left AND right buttons
  109219. * 3: menu button
  109220. * @param buttonIdx Which button index changed
  109221. * @param state New state of the button
  109222. * @param changes Which properties on the state changed since last frame
  109223. */
  109224. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109225. }
  109226. }
  109227. declare module BABYLON {
  109228. /**
  109229. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109230. */
  109231. export class WebXRControllerModelLoader {
  109232. /**
  109233. * Creates the WebXRControllerModelLoader
  109234. * @param input xr input that creates the controllers
  109235. */
  109236. constructor(input: WebXRInput);
  109237. }
  109238. }
  109239. declare module BABYLON {
  109240. /**
  109241. * Contains an array of blocks representing the octree
  109242. */
  109243. export interface IOctreeContainer<T> {
  109244. /**
  109245. * Blocks within the octree
  109246. */
  109247. blocks: Array<OctreeBlock<T>>;
  109248. }
  109249. /**
  109250. * Class used to store a cell in an octree
  109251. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109252. */
  109253. export class OctreeBlock<T> {
  109254. /**
  109255. * Gets the content of the current block
  109256. */
  109257. entries: T[];
  109258. /**
  109259. * Gets the list of block children
  109260. */
  109261. blocks: Array<OctreeBlock<T>>;
  109262. private _depth;
  109263. private _maxDepth;
  109264. private _capacity;
  109265. private _minPoint;
  109266. private _maxPoint;
  109267. private _boundingVectors;
  109268. private _creationFunc;
  109269. /**
  109270. * Creates a new block
  109271. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109272. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109273. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109274. * @param depth defines the current depth of this block in the octree
  109275. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109276. * @param creationFunc defines a callback to call when an element is added to the block
  109277. */
  109278. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109279. /**
  109280. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109281. */
  109282. readonly capacity: number;
  109283. /**
  109284. * Gets the minimum vector (in world space) of the block's bounding box
  109285. */
  109286. readonly minPoint: Vector3;
  109287. /**
  109288. * Gets the maximum vector (in world space) of the block's bounding box
  109289. */
  109290. readonly maxPoint: Vector3;
  109291. /**
  109292. * Add a new element to this block
  109293. * @param entry defines the element to add
  109294. */
  109295. addEntry(entry: T): void;
  109296. /**
  109297. * Remove an element from this block
  109298. * @param entry defines the element to remove
  109299. */
  109300. removeEntry(entry: T): void;
  109301. /**
  109302. * Add an array of elements to this block
  109303. * @param entries defines the array of elements to add
  109304. */
  109305. addEntries(entries: T[]): void;
  109306. /**
  109307. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109308. * @param frustumPlanes defines the frustum planes to test
  109309. * @param selection defines the array to store current content if selection is positive
  109310. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109311. */
  109312. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109313. /**
  109314. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109315. * @param sphereCenter defines the bounding sphere center
  109316. * @param sphereRadius defines the bounding sphere radius
  109317. * @param selection defines the array to store current content if selection is positive
  109318. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109319. */
  109320. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109321. /**
  109322. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109323. * @param ray defines the ray to test with
  109324. * @param selection defines the array to store current content if selection is positive
  109325. */
  109326. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109327. /**
  109328. * Subdivide the content into child blocks (this block will then be empty)
  109329. */
  109330. createInnerBlocks(): void;
  109331. /**
  109332. * @hidden
  109333. */
  109334. 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;
  109335. }
  109336. }
  109337. declare module BABYLON {
  109338. /**
  109339. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109340. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109341. */
  109342. export class Octree<T> {
  109343. /** 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.) */
  109344. maxDepth: number;
  109345. /**
  109346. * Blocks within the octree containing objects
  109347. */
  109348. blocks: Array<OctreeBlock<T>>;
  109349. /**
  109350. * Content stored in the octree
  109351. */
  109352. dynamicContent: T[];
  109353. private _maxBlockCapacity;
  109354. private _selectionContent;
  109355. private _creationFunc;
  109356. /**
  109357. * Creates a octree
  109358. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109359. * @param creationFunc function to be used to instatiate the octree
  109360. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109361. * @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.)
  109362. */
  109363. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109364. /** 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.) */
  109365. maxDepth?: number);
  109366. /**
  109367. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109368. * @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);
  109369. * @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);
  109370. * @param entries meshes to be added to the octree blocks
  109371. */
  109372. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109373. /**
  109374. * Adds a mesh to the octree
  109375. * @param entry Mesh to add to the octree
  109376. */
  109377. addMesh(entry: T): void;
  109378. /**
  109379. * Remove an element from the octree
  109380. * @param entry defines the element to remove
  109381. */
  109382. removeMesh(entry: T): void;
  109383. /**
  109384. * Selects an array of meshes within the frustum
  109385. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109386. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109387. * @returns array of meshes within the frustum
  109388. */
  109389. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109390. /**
  109391. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109392. * @param sphereCenter defines the bounding sphere center
  109393. * @param sphereRadius defines the bounding sphere radius
  109394. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109395. * @returns an array of objects that intersect the sphere
  109396. */
  109397. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109398. /**
  109399. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109400. * @param ray defines the ray to test with
  109401. * @returns array of intersected objects
  109402. */
  109403. intersectsRay(ray: Ray): SmartArray<T>;
  109404. /**
  109405. * Adds a mesh into the octree block if it intersects the block
  109406. */
  109407. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109408. /**
  109409. * Adds a submesh into the octree block if it intersects the block
  109410. */
  109411. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109412. }
  109413. }
  109414. declare module BABYLON {
  109415. interface Scene {
  109416. /**
  109417. * @hidden
  109418. * Backing Filed
  109419. */
  109420. _selectionOctree: Octree<AbstractMesh>;
  109421. /**
  109422. * Gets the octree used to boost mesh selection (picking)
  109423. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109424. */
  109425. selectionOctree: Octree<AbstractMesh>;
  109426. /**
  109427. * Creates or updates the octree used to boost selection (picking)
  109428. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109429. * @param maxCapacity defines the maximum capacity per leaf
  109430. * @param maxDepth defines the maximum depth of the octree
  109431. * @returns an octree of AbstractMesh
  109432. */
  109433. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109434. }
  109435. interface AbstractMesh {
  109436. /**
  109437. * @hidden
  109438. * Backing Field
  109439. */
  109440. _submeshesOctree: Octree<SubMesh>;
  109441. /**
  109442. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109443. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109444. * @param maxCapacity defines the maximum size of each block (64 by default)
  109445. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109446. * @returns the new octree
  109447. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109448. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109449. */
  109450. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109451. }
  109452. /**
  109453. * Defines the octree scene component responsible to manage any octrees
  109454. * in a given scene.
  109455. */
  109456. export class OctreeSceneComponent {
  109457. /**
  109458. * The component name help to identify the component in the list of scene components.
  109459. */
  109460. readonly name: string;
  109461. /**
  109462. * The scene the component belongs to.
  109463. */
  109464. scene: Scene;
  109465. /**
  109466. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109467. */
  109468. readonly checksIsEnabled: boolean;
  109469. /**
  109470. * Creates a new instance of the component for the given scene
  109471. * @param scene Defines the scene to register the component in
  109472. */
  109473. constructor(scene: Scene);
  109474. /**
  109475. * Registers the component in a given scene
  109476. */
  109477. register(): void;
  109478. /**
  109479. * Return the list of active meshes
  109480. * @returns the list of active meshes
  109481. */
  109482. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109483. /**
  109484. * Return the list of active sub meshes
  109485. * @param mesh The mesh to get the candidates sub meshes from
  109486. * @returns the list of active sub meshes
  109487. */
  109488. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109489. private _tempRay;
  109490. /**
  109491. * Return the list of sub meshes intersecting with a given local ray
  109492. * @param mesh defines the mesh to find the submesh for
  109493. * @param localRay defines the ray in local space
  109494. * @returns the list of intersecting sub meshes
  109495. */
  109496. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109497. /**
  109498. * Return the list of sub meshes colliding with a collider
  109499. * @param mesh defines the mesh to find the submesh for
  109500. * @param collider defines the collider to evaluate the collision against
  109501. * @returns the list of colliding sub meshes
  109502. */
  109503. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109504. /**
  109505. * Rebuilds the elements related to this component in case of
  109506. * context lost for instance.
  109507. */
  109508. rebuild(): void;
  109509. /**
  109510. * Disposes the component and the associated ressources.
  109511. */
  109512. dispose(): void;
  109513. }
  109514. }
  109515. declare module BABYLON {
  109516. /**
  109517. * Renders a layer on top of an existing scene
  109518. */
  109519. export class UtilityLayerRenderer implements IDisposable {
  109520. /** the original scene that will be rendered on top of */
  109521. originalScene: Scene;
  109522. private _pointerCaptures;
  109523. private _lastPointerEvents;
  109524. private static _DefaultUtilityLayer;
  109525. private static _DefaultKeepDepthUtilityLayer;
  109526. private _sharedGizmoLight;
  109527. private _renderCamera;
  109528. /**
  109529. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109530. * @returns the camera that is used when rendering the utility layer
  109531. */
  109532. getRenderCamera(): Nullable<Camera>;
  109533. /**
  109534. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109535. * @param cam the camera that should be used when rendering the utility layer
  109536. */
  109537. setRenderCamera(cam: Nullable<Camera>): void;
  109538. /**
  109539. * @hidden
  109540. * Light which used by gizmos to get light shading
  109541. */
  109542. _getSharedGizmoLight(): HemisphericLight;
  109543. /**
  109544. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109545. */
  109546. pickUtilitySceneFirst: boolean;
  109547. /**
  109548. * 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)
  109549. */
  109550. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109551. /**
  109552. * 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)
  109553. */
  109554. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109555. /**
  109556. * The scene that is rendered on top of the original scene
  109557. */
  109558. utilityLayerScene: Scene;
  109559. /**
  109560. * If the utility layer should automatically be rendered on top of existing scene
  109561. */
  109562. shouldRender: boolean;
  109563. /**
  109564. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109565. */
  109566. onlyCheckPointerDownEvents: boolean;
  109567. /**
  109568. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109569. */
  109570. processAllEvents: boolean;
  109571. /**
  109572. * Observable raised when the pointer move from the utility layer scene to the main scene
  109573. */
  109574. onPointerOutObservable: Observable<number>;
  109575. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109576. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109577. private _afterRenderObserver;
  109578. private _sceneDisposeObserver;
  109579. private _originalPointerObserver;
  109580. /**
  109581. * Instantiates a UtilityLayerRenderer
  109582. * @param originalScene the original scene that will be rendered on top of
  109583. * @param handleEvents boolean indicating if the utility layer should handle events
  109584. */
  109585. constructor(
  109586. /** the original scene that will be rendered on top of */
  109587. originalScene: Scene, handleEvents?: boolean);
  109588. private _notifyObservers;
  109589. /**
  109590. * Renders the utility layers scene on top of the original scene
  109591. */
  109592. render(): void;
  109593. /**
  109594. * Disposes of the renderer
  109595. */
  109596. dispose(): void;
  109597. private _updateCamera;
  109598. }
  109599. }
  109600. declare module BABYLON {
  109601. /**
  109602. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109603. */
  109604. export class Gizmo implements IDisposable {
  109605. /** The utility layer the gizmo will be added to */
  109606. gizmoLayer: UtilityLayerRenderer;
  109607. /**
  109608. * The root mesh of the gizmo
  109609. */
  109610. _rootMesh: Mesh;
  109611. private _attachedMesh;
  109612. /**
  109613. * Ratio for the scale of the gizmo (Default: 1)
  109614. */
  109615. scaleRatio: number;
  109616. /**
  109617. * If a custom mesh has been set (Default: false)
  109618. */
  109619. protected _customMeshSet: boolean;
  109620. /**
  109621. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109622. * * When set, interactions will be enabled
  109623. */
  109624. attachedMesh: Nullable<AbstractMesh>;
  109625. /**
  109626. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109627. * @param mesh The mesh to replace the default mesh of the gizmo
  109628. */
  109629. setCustomMesh(mesh: Mesh): void;
  109630. /**
  109631. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109632. */
  109633. updateGizmoRotationToMatchAttachedMesh: boolean;
  109634. /**
  109635. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109636. */
  109637. updateGizmoPositionToMatchAttachedMesh: boolean;
  109638. /**
  109639. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109640. */
  109641. updateScale: boolean;
  109642. protected _interactionsEnabled: boolean;
  109643. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109644. private _beforeRenderObserver;
  109645. private _tempVector;
  109646. /**
  109647. * Creates a gizmo
  109648. * @param gizmoLayer The utility layer the gizmo will be added to
  109649. */
  109650. constructor(
  109651. /** The utility layer the gizmo will be added to */
  109652. gizmoLayer?: UtilityLayerRenderer);
  109653. /**
  109654. * Updates the gizmo to match the attached mesh's position/rotation
  109655. */
  109656. protected _update(): void;
  109657. /**
  109658. * Disposes of the gizmo
  109659. */
  109660. dispose(): void;
  109661. }
  109662. }
  109663. declare module BABYLON {
  109664. /**
  109665. * Single plane drag gizmo
  109666. */
  109667. export class PlaneDragGizmo extends Gizmo {
  109668. /**
  109669. * Drag behavior responsible for the gizmos dragging interactions
  109670. */
  109671. dragBehavior: PointerDragBehavior;
  109672. private _pointerObserver;
  109673. /**
  109674. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109675. */
  109676. snapDistance: number;
  109677. /**
  109678. * Event that fires each time the gizmo snaps to a new location.
  109679. * * snapDistance is the the change in distance
  109680. */
  109681. onSnapObservable: Observable<{
  109682. snapDistance: number;
  109683. }>;
  109684. private _plane;
  109685. private _coloredMaterial;
  109686. private _hoverMaterial;
  109687. private _isEnabled;
  109688. private _parent;
  109689. /** @hidden */
  109690. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109691. /** @hidden */
  109692. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109693. /**
  109694. * Creates a PlaneDragGizmo
  109695. * @param gizmoLayer The utility layer the gizmo will be added to
  109696. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109697. * @param color The color of the gizmo
  109698. */
  109699. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109700. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109701. /**
  109702. * If the gizmo is enabled
  109703. */
  109704. isEnabled: boolean;
  109705. /**
  109706. * Disposes of the gizmo
  109707. */
  109708. dispose(): void;
  109709. }
  109710. }
  109711. declare module BABYLON {
  109712. /**
  109713. * Gizmo that enables dragging a mesh along 3 axis
  109714. */
  109715. export class PositionGizmo extends Gizmo {
  109716. /**
  109717. * Internal gizmo used for interactions on the x axis
  109718. */
  109719. xGizmo: AxisDragGizmo;
  109720. /**
  109721. * Internal gizmo used for interactions on the y axis
  109722. */
  109723. yGizmo: AxisDragGizmo;
  109724. /**
  109725. * Internal gizmo used for interactions on the z axis
  109726. */
  109727. zGizmo: AxisDragGizmo;
  109728. /**
  109729. * Internal gizmo used for interactions on the yz plane
  109730. */
  109731. xPlaneGizmo: PlaneDragGizmo;
  109732. /**
  109733. * Internal gizmo used for interactions on the xz plane
  109734. */
  109735. yPlaneGizmo: PlaneDragGizmo;
  109736. /**
  109737. * Internal gizmo used for interactions on the xy plane
  109738. */
  109739. zPlaneGizmo: PlaneDragGizmo;
  109740. /**
  109741. * private variables
  109742. */
  109743. private _meshAttached;
  109744. private _updateGizmoRotationToMatchAttachedMesh;
  109745. private _snapDistance;
  109746. private _scaleRatio;
  109747. /** Fires an event when any of it's sub gizmos are dragged */
  109748. onDragStartObservable: Observable<unknown>;
  109749. /** Fires an event when any of it's sub gizmos are released from dragging */
  109750. onDragEndObservable: Observable<unknown>;
  109751. /**
  109752. * If set to true, planar drag is enabled
  109753. */
  109754. private _planarGizmoEnabled;
  109755. attachedMesh: Nullable<AbstractMesh>;
  109756. /**
  109757. * Creates a PositionGizmo
  109758. * @param gizmoLayer The utility layer the gizmo will be added to
  109759. */
  109760. constructor(gizmoLayer?: UtilityLayerRenderer);
  109761. /**
  109762. * If the planar drag gizmo is enabled
  109763. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109764. */
  109765. planarGizmoEnabled: boolean;
  109766. updateGizmoRotationToMatchAttachedMesh: boolean;
  109767. /**
  109768. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109769. */
  109770. snapDistance: number;
  109771. /**
  109772. * Ratio for the scale of the gizmo (Default: 1)
  109773. */
  109774. scaleRatio: number;
  109775. /**
  109776. * Disposes of the gizmo
  109777. */
  109778. dispose(): void;
  109779. /**
  109780. * CustomMeshes are not supported by this gizmo
  109781. * @param mesh The mesh to replace the default mesh of the gizmo
  109782. */
  109783. setCustomMesh(mesh: Mesh): void;
  109784. }
  109785. }
  109786. declare module BABYLON {
  109787. /**
  109788. * Single axis drag gizmo
  109789. */
  109790. export class AxisDragGizmo extends Gizmo {
  109791. /**
  109792. * Drag behavior responsible for the gizmos dragging interactions
  109793. */
  109794. dragBehavior: PointerDragBehavior;
  109795. private _pointerObserver;
  109796. /**
  109797. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109798. */
  109799. snapDistance: number;
  109800. /**
  109801. * Event that fires each time the gizmo snaps to a new location.
  109802. * * snapDistance is the the change in distance
  109803. */
  109804. onSnapObservable: Observable<{
  109805. snapDistance: number;
  109806. }>;
  109807. private _isEnabled;
  109808. private _parent;
  109809. private _arrow;
  109810. private _coloredMaterial;
  109811. private _hoverMaterial;
  109812. /** @hidden */
  109813. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109814. /** @hidden */
  109815. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109816. /**
  109817. * Creates an AxisDragGizmo
  109818. * @param gizmoLayer The utility layer the gizmo will be added to
  109819. * @param dragAxis The axis which the gizmo will be able to drag on
  109820. * @param color The color of the gizmo
  109821. */
  109822. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109823. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109824. /**
  109825. * If the gizmo is enabled
  109826. */
  109827. isEnabled: boolean;
  109828. /**
  109829. * Disposes of the gizmo
  109830. */
  109831. dispose(): void;
  109832. }
  109833. }
  109834. declare module BABYLON.Debug {
  109835. /**
  109836. * The Axes viewer will show 3 axes in a specific point in space
  109837. */
  109838. export class AxesViewer {
  109839. private _xAxis;
  109840. private _yAxis;
  109841. private _zAxis;
  109842. private _scaleLinesFactor;
  109843. private _instanced;
  109844. /**
  109845. * Gets the hosting scene
  109846. */
  109847. scene: Scene;
  109848. /**
  109849. * Gets or sets a number used to scale line length
  109850. */
  109851. scaleLines: number;
  109852. /** Gets the node hierarchy used to render x-axis */
  109853. readonly xAxis: TransformNode;
  109854. /** Gets the node hierarchy used to render y-axis */
  109855. readonly yAxis: TransformNode;
  109856. /** Gets the node hierarchy used to render z-axis */
  109857. readonly zAxis: TransformNode;
  109858. /**
  109859. * Creates a new AxesViewer
  109860. * @param scene defines the hosting scene
  109861. * @param scaleLines defines a number used to scale line length (1 by default)
  109862. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109863. * @param xAxis defines the node hierarchy used to render the x-axis
  109864. * @param yAxis defines the node hierarchy used to render the y-axis
  109865. * @param zAxis defines the node hierarchy used to render the z-axis
  109866. */
  109867. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109868. /**
  109869. * Force the viewer to update
  109870. * @param position defines the position of the viewer
  109871. * @param xaxis defines the x axis of the viewer
  109872. * @param yaxis defines the y axis of the viewer
  109873. * @param zaxis defines the z axis of the viewer
  109874. */
  109875. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109876. /**
  109877. * Creates an instance of this axes viewer.
  109878. * @returns a new axes viewer with instanced meshes
  109879. */
  109880. createInstance(): AxesViewer;
  109881. /** Releases resources */
  109882. dispose(): void;
  109883. private static _SetRenderingGroupId;
  109884. }
  109885. }
  109886. declare module BABYLON.Debug {
  109887. /**
  109888. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109889. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109890. */
  109891. export class BoneAxesViewer extends AxesViewer {
  109892. /**
  109893. * Gets or sets the target mesh where to display the axes viewer
  109894. */
  109895. mesh: Nullable<Mesh>;
  109896. /**
  109897. * Gets or sets the target bone where to display the axes viewer
  109898. */
  109899. bone: Nullable<Bone>;
  109900. /** Gets current position */
  109901. pos: Vector3;
  109902. /** Gets direction of X axis */
  109903. xaxis: Vector3;
  109904. /** Gets direction of Y axis */
  109905. yaxis: Vector3;
  109906. /** Gets direction of Z axis */
  109907. zaxis: Vector3;
  109908. /**
  109909. * Creates a new BoneAxesViewer
  109910. * @param scene defines the hosting scene
  109911. * @param bone defines the target bone
  109912. * @param mesh defines the target mesh
  109913. * @param scaleLines defines a scaling factor for line length (1 by default)
  109914. */
  109915. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109916. /**
  109917. * Force the viewer to update
  109918. */
  109919. update(): void;
  109920. /** Releases resources */
  109921. dispose(): void;
  109922. }
  109923. }
  109924. declare module BABYLON {
  109925. /**
  109926. * Interface used to define scene explorer extensibility option
  109927. */
  109928. export interface IExplorerExtensibilityOption {
  109929. /**
  109930. * Define the option label
  109931. */
  109932. label: string;
  109933. /**
  109934. * Defines the action to execute on click
  109935. */
  109936. action: (entity: any) => void;
  109937. }
  109938. /**
  109939. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109940. */
  109941. export interface IExplorerExtensibilityGroup {
  109942. /**
  109943. * Defines a predicate to test if a given type mut be extended
  109944. */
  109945. predicate: (entity: any) => boolean;
  109946. /**
  109947. * Gets the list of options added to a type
  109948. */
  109949. entries: IExplorerExtensibilityOption[];
  109950. }
  109951. /**
  109952. * Interface used to define the options to use to create the Inspector
  109953. */
  109954. export interface IInspectorOptions {
  109955. /**
  109956. * Display in overlay mode (default: false)
  109957. */
  109958. overlay?: boolean;
  109959. /**
  109960. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109961. */
  109962. globalRoot?: HTMLElement;
  109963. /**
  109964. * Display the Scene explorer
  109965. */
  109966. showExplorer?: boolean;
  109967. /**
  109968. * Display the property inspector
  109969. */
  109970. showInspector?: boolean;
  109971. /**
  109972. * Display in embed mode (both panes on the right)
  109973. */
  109974. embedMode?: boolean;
  109975. /**
  109976. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  109977. */
  109978. handleResize?: boolean;
  109979. /**
  109980. * Allow the panes to popup (default: true)
  109981. */
  109982. enablePopup?: boolean;
  109983. /**
  109984. * Allow the panes to be closed by users (default: true)
  109985. */
  109986. enableClose?: boolean;
  109987. /**
  109988. * Optional list of extensibility entries
  109989. */
  109990. explorerExtensibility?: IExplorerExtensibilityGroup[];
  109991. /**
  109992. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  109993. */
  109994. inspectorURL?: string;
  109995. }
  109996. interface Scene {
  109997. /**
  109998. * @hidden
  109999. * Backing field
  110000. */
  110001. _debugLayer: DebugLayer;
  110002. /**
  110003. * Gets the debug layer (aka Inspector) associated with the scene
  110004. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110005. */
  110006. debugLayer: DebugLayer;
  110007. }
  110008. /**
  110009. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110010. * what is happening in your scene
  110011. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110012. */
  110013. export class DebugLayer {
  110014. /**
  110015. * Define the url to get the inspector script from.
  110016. * By default it uses the babylonjs CDN.
  110017. * @ignoreNaming
  110018. */
  110019. static InspectorURL: string;
  110020. private _scene;
  110021. private BJSINSPECTOR;
  110022. private _onPropertyChangedObservable?;
  110023. /**
  110024. * Observable triggered when a property is changed through the inspector.
  110025. */
  110026. readonly onPropertyChangedObservable: any;
  110027. /**
  110028. * Instantiates a new debug layer.
  110029. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110030. * what is happening in your scene
  110031. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110032. * @param scene Defines the scene to inspect
  110033. */
  110034. constructor(scene: Scene);
  110035. /** Creates the inspector window. */
  110036. private _createInspector;
  110037. /**
  110038. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110039. * @param entity defines the entity to select
  110040. * @param lineContainerTitle defines the specific block to highlight
  110041. */
  110042. select(entity: any, lineContainerTitle?: string): void;
  110043. /** Get the inspector from bundle or global */
  110044. private _getGlobalInspector;
  110045. /**
  110046. * Get if the inspector is visible or not.
  110047. * @returns true if visible otherwise, false
  110048. */
  110049. isVisible(): boolean;
  110050. /**
  110051. * Hide the inspector and close its window.
  110052. */
  110053. hide(): void;
  110054. /**
  110055. * Launch the debugLayer.
  110056. * @param config Define the configuration of the inspector
  110057. * @return a promise fulfilled when the debug layer is visible
  110058. */
  110059. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110060. }
  110061. }
  110062. declare module BABYLON {
  110063. /**
  110064. * Class containing static functions to help procedurally build meshes
  110065. */
  110066. export class BoxBuilder {
  110067. /**
  110068. * Creates a box mesh
  110069. * * The parameter `size` sets the size (float) of each box side (default 1)
  110070. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110071. * * 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)
  110072. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110073. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110074. * * 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
  110075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110076. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110077. * @param name defines the name of the mesh
  110078. * @param options defines the options used to create the mesh
  110079. * @param scene defines the hosting scene
  110080. * @returns the box mesh
  110081. */
  110082. static CreateBox(name: string, options: {
  110083. size?: number;
  110084. width?: number;
  110085. height?: number;
  110086. depth?: number;
  110087. faceUV?: Vector4[];
  110088. faceColors?: Color4[];
  110089. sideOrientation?: number;
  110090. frontUVs?: Vector4;
  110091. backUVs?: Vector4;
  110092. wrap?: boolean;
  110093. topBaseAt?: number;
  110094. bottomBaseAt?: number;
  110095. updatable?: boolean;
  110096. }, scene?: Nullable<Scene>): Mesh;
  110097. }
  110098. }
  110099. declare module BABYLON {
  110100. /**
  110101. * Class containing static functions to help procedurally build meshes
  110102. */
  110103. export class SphereBuilder {
  110104. /**
  110105. * Creates a sphere mesh
  110106. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110107. * * 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`)
  110108. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110109. * * 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
  110110. * * 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)
  110111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110112. * * 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
  110113. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110114. * @param name defines the name of the mesh
  110115. * @param options defines the options used to create the mesh
  110116. * @param scene defines the hosting scene
  110117. * @returns the sphere mesh
  110118. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110119. */
  110120. static CreateSphere(name: string, options: {
  110121. segments?: number;
  110122. diameter?: number;
  110123. diameterX?: number;
  110124. diameterY?: number;
  110125. diameterZ?: number;
  110126. arc?: number;
  110127. slice?: number;
  110128. sideOrientation?: number;
  110129. frontUVs?: Vector4;
  110130. backUVs?: Vector4;
  110131. updatable?: boolean;
  110132. }, scene?: Nullable<Scene>): Mesh;
  110133. }
  110134. }
  110135. declare module BABYLON.Debug {
  110136. /**
  110137. * Used to show the physics impostor around the specific mesh
  110138. */
  110139. export class PhysicsViewer {
  110140. /** @hidden */
  110141. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110142. /** @hidden */
  110143. protected _meshes: Array<Nullable<AbstractMesh>>;
  110144. /** @hidden */
  110145. protected _scene: Nullable<Scene>;
  110146. /** @hidden */
  110147. protected _numMeshes: number;
  110148. /** @hidden */
  110149. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110150. private _renderFunction;
  110151. private _utilityLayer;
  110152. private _debugBoxMesh;
  110153. private _debugSphereMesh;
  110154. private _debugCylinderMesh;
  110155. private _debugMaterial;
  110156. private _debugMeshMeshes;
  110157. /**
  110158. * Creates a new PhysicsViewer
  110159. * @param scene defines the hosting scene
  110160. */
  110161. constructor(scene: Scene);
  110162. /** @hidden */
  110163. protected _updateDebugMeshes(): void;
  110164. /**
  110165. * Renders a specified physic impostor
  110166. * @param impostor defines the impostor to render
  110167. * @param targetMesh defines the mesh represented by the impostor
  110168. * @returns the new debug mesh used to render the impostor
  110169. */
  110170. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110171. /**
  110172. * Hides a specified physic impostor
  110173. * @param impostor defines the impostor to hide
  110174. */
  110175. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110176. private _getDebugMaterial;
  110177. private _getDebugBoxMesh;
  110178. private _getDebugSphereMesh;
  110179. private _getDebugCylinderMesh;
  110180. private _getDebugMeshMesh;
  110181. private _getDebugMesh;
  110182. /** Releases all resources */
  110183. dispose(): void;
  110184. }
  110185. }
  110186. declare module BABYLON {
  110187. /**
  110188. * Class containing static functions to help procedurally build meshes
  110189. */
  110190. export class LinesBuilder {
  110191. /**
  110192. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110193. * * 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
  110194. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110195. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110196. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110197. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110198. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110199. * * 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
  110200. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110202. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110203. * @param name defines the name of the new line system
  110204. * @param options defines the options used to create the line system
  110205. * @param scene defines the hosting scene
  110206. * @returns a new line system mesh
  110207. */
  110208. static CreateLineSystem(name: string, options: {
  110209. lines: Vector3[][];
  110210. updatable?: boolean;
  110211. instance?: Nullable<LinesMesh>;
  110212. colors?: Nullable<Color4[][]>;
  110213. useVertexAlpha?: boolean;
  110214. }, scene: Nullable<Scene>): LinesMesh;
  110215. /**
  110216. * Creates a line mesh
  110217. * 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
  110218. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110219. * * The parameter `points` is an array successive Vector3
  110220. * * 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
  110221. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110222. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110223. * * When updating an instance, remember that only point positions can change, not the number of points
  110224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110226. * @param name defines the name of the new line system
  110227. * @param options defines the options used to create the line system
  110228. * @param scene defines the hosting scene
  110229. * @returns a new line mesh
  110230. */
  110231. static CreateLines(name: string, options: {
  110232. points: Vector3[];
  110233. updatable?: boolean;
  110234. instance?: Nullable<LinesMesh>;
  110235. colors?: Color4[];
  110236. useVertexAlpha?: boolean;
  110237. }, scene?: Nullable<Scene>): LinesMesh;
  110238. /**
  110239. * Creates a dashed line mesh
  110240. * * 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
  110241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110242. * * The parameter `points` is an array successive Vector3
  110243. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110244. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110245. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110246. * * 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
  110247. * * When updating an instance, remember that only point positions can change, not the number of points
  110248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110249. * @param name defines the name of the mesh
  110250. * @param options defines the options used to create the mesh
  110251. * @param scene defines the hosting scene
  110252. * @returns the dashed line mesh
  110253. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110254. */
  110255. static CreateDashedLines(name: string, options: {
  110256. points: Vector3[];
  110257. dashSize?: number;
  110258. gapSize?: number;
  110259. dashNb?: number;
  110260. updatable?: boolean;
  110261. instance?: LinesMesh;
  110262. }, scene?: Nullable<Scene>): LinesMesh;
  110263. }
  110264. }
  110265. declare module BABYLON {
  110266. /**
  110267. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110268. * in order to better appreciate the issue one might have.
  110269. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110270. */
  110271. export class RayHelper {
  110272. /**
  110273. * Defines the ray we are currently tryin to visualize.
  110274. */
  110275. ray: Nullable<Ray>;
  110276. private _renderPoints;
  110277. private _renderLine;
  110278. private _renderFunction;
  110279. private _scene;
  110280. private _updateToMeshFunction;
  110281. private _attachedToMesh;
  110282. private _meshSpaceDirection;
  110283. private _meshSpaceOrigin;
  110284. /**
  110285. * Helper function to create a colored helper in a scene in one line.
  110286. * @param ray Defines the ray we are currently tryin to visualize
  110287. * @param scene Defines the scene the ray is used in
  110288. * @param color Defines the color we want to see the ray in
  110289. * @returns The newly created ray helper.
  110290. */
  110291. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110292. /**
  110293. * Instantiate a new ray helper.
  110294. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110295. * in order to better appreciate the issue one might have.
  110296. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110297. * @param ray Defines the ray we are currently tryin to visualize
  110298. */
  110299. constructor(ray: Ray);
  110300. /**
  110301. * Shows the ray we are willing to debug.
  110302. * @param scene Defines the scene the ray needs to be rendered in
  110303. * @param color Defines the color the ray needs to be rendered in
  110304. */
  110305. show(scene: Scene, color?: Color3): void;
  110306. /**
  110307. * Hides the ray we are debugging.
  110308. */
  110309. hide(): void;
  110310. private _render;
  110311. /**
  110312. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110313. * @param mesh Defines the mesh we want the helper attached to
  110314. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110315. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110316. * @param length Defines the length of the ray
  110317. */
  110318. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110319. /**
  110320. * Detach the ray helper from the mesh it has previously been attached to.
  110321. */
  110322. detachFromMesh(): void;
  110323. private _updateToMesh;
  110324. /**
  110325. * Dispose the helper and release its associated resources.
  110326. */
  110327. dispose(): void;
  110328. }
  110329. }
  110330. declare module BABYLON.Debug {
  110331. /**
  110332. * Class used to render a debug view of a given skeleton
  110333. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110334. */
  110335. export class SkeletonViewer {
  110336. /** defines the skeleton to render */
  110337. skeleton: Skeleton;
  110338. /** defines the mesh attached to the skeleton */
  110339. mesh: AbstractMesh;
  110340. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110341. autoUpdateBonesMatrices: boolean;
  110342. /** defines the rendering group id to use with the viewer */
  110343. renderingGroupId: number;
  110344. /** Gets or sets the color used to render the skeleton */
  110345. color: Color3;
  110346. private _scene;
  110347. private _debugLines;
  110348. private _debugMesh;
  110349. private _isEnabled;
  110350. private _renderFunction;
  110351. private _utilityLayer;
  110352. /**
  110353. * Returns the mesh used to render the bones
  110354. */
  110355. readonly debugMesh: Nullable<LinesMesh>;
  110356. /**
  110357. * Creates a new SkeletonViewer
  110358. * @param skeleton defines the skeleton to render
  110359. * @param mesh defines the mesh attached to the skeleton
  110360. * @param scene defines the hosting scene
  110361. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110362. * @param renderingGroupId defines the rendering group id to use with the viewer
  110363. */
  110364. constructor(
  110365. /** defines the skeleton to render */
  110366. skeleton: Skeleton,
  110367. /** defines the mesh attached to the skeleton */
  110368. mesh: AbstractMesh, scene: Scene,
  110369. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110370. autoUpdateBonesMatrices?: boolean,
  110371. /** defines the rendering group id to use with the viewer */
  110372. renderingGroupId?: number);
  110373. /** Gets or sets a boolean indicating if the viewer is enabled */
  110374. isEnabled: boolean;
  110375. private _getBonePosition;
  110376. private _getLinesForBonesWithLength;
  110377. private _getLinesForBonesNoLength;
  110378. /** Update the viewer to sync with current skeleton state */
  110379. update(): void;
  110380. /** Release associated resources */
  110381. dispose(): void;
  110382. }
  110383. }
  110384. declare module BABYLON {
  110385. /**
  110386. * Options to create the null engine
  110387. */
  110388. export class NullEngineOptions {
  110389. /**
  110390. * Render width (Default: 512)
  110391. */
  110392. renderWidth: number;
  110393. /**
  110394. * Render height (Default: 256)
  110395. */
  110396. renderHeight: number;
  110397. /**
  110398. * Texture size (Default: 512)
  110399. */
  110400. textureSize: number;
  110401. /**
  110402. * If delta time between frames should be constant
  110403. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110404. */
  110405. deterministicLockstep: boolean;
  110406. /**
  110407. * Maximum about of steps between frames (Default: 4)
  110408. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110409. */
  110410. lockstepMaxSteps: number;
  110411. }
  110412. /**
  110413. * The null engine class provides support for headless version of babylon.js.
  110414. * This can be used in server side scenario or for testing purposes
  110415. */
  110416. export class NullEngine extends Engine {
  110417. private _options;
  110418. /**
  110419. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110420. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110421. * @returns true if engine is in deterministic lock step mode
  110422. */
  110423. isDeterministicLockStep(): boolean;
  110424. /**
  110425. * Gets the max steps when engine is running in deterministic lock step
  110426. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110427. * @returns the max steps
  110428. */
  110429. getLockstepMaxSteps(): number;
  110430. /**
  110431. * Gets the current hardware scaling level.
  110432. * By default the hardware scaling level is computed from the window device ratio.
  110433. * 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.
  110434. * @returns a number indicating the current hardware scaling level
  110435. */
  110436. getHardwareScalingLevel(): number;
  110437. constructor(options?: NullEngineOptions);
  110438. /**
  110439. * Creates a vertex buffer
  110440. * @param vertices the data for the vertex buffer
  110441. * @returns the new WebGL static buffer
  110442. */
  110443. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110444. /**
  110445. * Creates a new index buffer
  110446. * @param indices defines the content of the index buffer
  110447. * @param updatable defines if the index buffer must be updatable
  110448. * @returns a new webGL buffer
  110449. */
  110450. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110451. /**
  110452. * Clear the current render buffer or the current render target (if any is set up)
  110453. * @param color defines the color to use
  110454. * @param backBuffer defines if the back buffer must be cleared
  110455. * @param depth defines if the depth buffer must be cleared
  110456. * @param stencil defines if the stencil buffer must be cleared
  110457. */
  110458. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110459. /**
  110460. * Gets the current render width
  110461. * @param useScreen defines if screen size must be used (or the current render target if any)
  110462. * @returns a number defining the current render width
  110463. */
  110464. getRenderWidth(useScreen?: boolean): number;
  110465. /**
  110466. * Gets the current render height
  110467. * @param useScreen defines if screen size must be used (or the current render target if any)
  110468. * @returns a number defining the current render height
  110469. */
  110470. getRenderHeight(useScreen?: boolean): number;
  110471. /**
  110472. * Set the WebGL's viewport
  110473. * @param viewport defines the viewport element to be used
  110474. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110475. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110476. */
  110477. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110478. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110479. /**
  110480. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110481. * @param pipelineContext defines the pipeline context to use
  110482. * @param uniformsNames defines the list of uniform names
  110483. * @returns an array of webGL uniform locations
  110484. */
  110485. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110486. /**
  110487. * Gets the lsit of active attributes for a given webGL program
  110488. * @param pipelineContext defines the pipeline context to use
  110489. * @param attributesNames defines the list of attribute names to get
  110490. * @returns an array of indices indicating the offset of each attribute
  110491. */
  110492. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110493. /**
  110494. * Binds an effect to the webGL context
  110495. * @param effect defines the effect to bind
  110496. */
  110497. bindSamplers(effect: Effect): void;
  110498. /**
  110499. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110500. * @param effect defines the effect to activate
  110501. */
  110502. enableEffect(effect: Effect): void;
  110503. /**
  110504. * Set various states to the webGL context
  110505. * @param culling defines backface culling state
  110506. * @param zOffset defines the value to apply to zOffset (0 by default)
  110507. * @param force defines if states must be applied even if cache is up to date
  110508. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110509. */
  110510. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110511. /**
  110512. * Set the value of an uniform to an array of int32
  110513. * @param uniform defines the webGL uniform location where to store the value
  110514. * @param array defines the array of int32 to store
  110515. */
  110516. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110517. /**
  110518. * Set the value of an uniform to an array of int32 (stored as vec2)
  110519. * @param uniform defines the webGL uniform location where to store the value
  110520. * @param array defines the array of int32 to store
  110521. */
  110522. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110523. /**
  110524. * Set the value of an uniform to an array of int32 (stored as vec3)
  110525. * @param uniform defines the webGL uniform location where to store the value
  110526. * @param array defines the array of int32 to store
  110527. */
  110528. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110529. /**
  110530. * Set the value of an uniform to an array of int32 (stored as vec4)
  110531. * @param uniform defines the webGL uniform location where to store the value
  110532. * @param array defines the array of int32 to store
  110533. */
  110534. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110535. /**
  110536. * Set the value of an uniform to an array of float32
  110537. * @param uniform defines the webGL uniform location where to store the value
  110538. * @param array defines the array of float32 to store
  110539. */
  110540. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110541. /**
  110542. * Set the value of an uniform to an array of float32 (stored as vec2)
  110543. * @param uniform defines the webGL uniform location where to store the value
  110544. * @param array defines the array of float32 to store
  110545. */
  110546. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110547. /**
  110548. * Set the value of an uniform to an array of float32 (stored as vec3)
  110549. * @param uniform defines the webGL uniform location where to store the value
  110550. * @param array defines the array of float32 to store
  110551. */
  110552. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110553. /**
  110554. * Set the value of an uniform to an array of float32 (stored as vec4)
  110555. * @param uniform defines the webGL uniform location where to store the value
  110556. * @param array defines the array of float32 to store
  110557. */
  110558. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110559. /**
  110560. * Set the value of an uniform to an array of number
  110561. * @param uniform defines the webGL uniform location where to store the value
  110562. * @param array defines the array of number to store
  110563. */
  110564. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110565. /**
  110566. * Set the value of an uniform to an array of number (stored as vec2)
  110567. * @param uniform defines the webGL uniform location where to store the value
  110568. * @param array defines the array of number to store
  110569. */
  110570. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110571. /**
  110572. * Set the value of an uniform to an array of number (stored as vec3)
  110573. * @param uniform defines the webGL uniform location where to store the value
  110574. * @param array defines the array of number to store
  110575. */
  110576. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110577. /**
  110578. * Set the value of an uniform to an array of number (stored as vec4)
  110579. * @param uniform defines the webGL uniform location where to store the value
  110580. * @param array defines the array of number to store
  110581. */
  110582. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110583. /**
  110584. * Set the value of an uniform to an array of float32 (stored as matrices)
  110585. * @param uniform defines the webGL uniform location where to store the value
  110586. * @param matrices defines the array of float32 to store
  110587. */
  110588. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110589. /**
  110590. * Set the value of an uniform to a matrix (3x3)
  110591. * @param uniform defines the webGL uniform location where to store the value
  110592. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110593. */
  110594. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110595. /**
  110596. * Set the value of an uniform to a matrix (2x2)
  110597. * @param uniform defines the webGL uniform location where to store the value
  110598. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110599. */
  110600. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110601. /**
  110602. * Set the value of an uniform to a number (float)
  110603. * @param uniform defines the webGL uniform location where to store the value
  110604. * @param value defines the float number to store
  110605. */
  110606. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110607. /**
  110608. * Set the value of an uniform to a vec2
  110609. * @param uniform defines the webGL uniform location where to store the value
  110610. * @param x defines the 1st component of the value
  110611. * @param y defines the 2nd component of the value
  110612. */
  110613. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110614. /**
  110615. * Set the value of an uniform to a vec3
  110616. * @param uniform defines the webGL uniform location where to store the value
  110617. * @param x defines the 1st component of the value
  110618. * @param y defines the 2nd component of the value
  110619. * @param z defines the 3rd component of the value
  110620. */
  110621. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110622. /**
  110623. * Set the value of an uniform to a boolean
  110624. * @param uniform defines the webGL uniform location where to store the value
  110625. * @param bool defines the boolean to store
  110626. */
  110627. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110628. /**
  110629. * Set the value of an uniform to a vec4
  110630. * @param uniform defines the webGL uniform location where to store the value
  110631. * @param x defines the 1st component of the value
  110632. * @param y defines the 2nd component of the value
  110633. * @param z defines the 3rd component of the value
  110634. * @param w defines the 4th component of the value
  110635. */
  110636. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110637. /**
  110638. * Sets the current alpha mode
  110639. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110640. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110641. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110642. */
  110643. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110644. /**
  110645. * Bind webGl buffers directly to the webGL context
  110646. * @param vertexBuffers defines the vertex buffer to bind
  110647. * @param indexBuffer defines the index buffer to bind
  110648. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110649. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110650. * @param effect defines the effect associated with the vertex buffer
  110651. */
  110652. bindBuffers(vertexBuffers: {
  110653. [key: string]: VertexBuffer;
  110654. }, indexBuffer: DataBuffer, effect: Effect): void;
  110655. /**
  110656. * Force the entire cache to be cleared
  110657. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110658. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110659. */
  110660. wipeCaches(bruteForce?: boolean): void;
  110661. /**
  110662. * Send a draw order
  110663. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110664. * @param indexStart defines the starting index
  110665. * @param indexCount defines the number of index to draw
  110666. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110667. */
  110668. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110669. /**
  110670. * Draw a list of indexed primitives
  110671. * @param fillMode defines the primitive to use
  110672. * @param indexStart defines the starting index
  110673. * @param indexCount defines the number of index to draw
  110674. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110675. */
  110676. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110677. /**
  110678. * Draw a list of unindexed primitives
  110679. * @param fillMode defines the primitive to use
  110680. * @param verticesStart defines the index of first vertex to draw
  110681. * @param verticesCount defines the count of vertices to draw
  110682. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110683. */
  110684. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110685. /** @hidden */
  110686. _createTexture(): WebGLTexture;
  110687. /** @hidden */
  110688. _releaseTexture(texture: InternalTexture): void;
  110689. /**
  110690. * Usually called from Texture.ts.
  110691. * Passed information to create a WebGLTexture
  110692. * @param urlArg defines a value which contains one of the following:
  110693. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110694. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110695. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110696. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110697. * @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)
  110698. * @param scene needed for loading to the correct scene
  110699. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110700. * @param onLoad optional callback to be called upon successful completion
  110701. * @param onError optional callback to be called upon failure
  110702. * @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
  110703. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110704. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110705. * @param forcedExtension defines the extension to use to pick the right loader
  110706. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110707. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110708. */
  110709. 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;
  110710. /**
  110711. * Creates a new render target texture
  110712. * @param size defines the size of the texture
  110713. * @param options defines the options used to create the texture
  110714. * @returns a new render target texture stored in an InternalTexture
  110715. */
  110716. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110717. /**
  110718. * Update the sampling mode of a given texture
  110719. * @param samplingMode defines the required sampling mode
  110720. * @param texture defines the texture to update
  110721. */
  110722. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110723. /**
  110724. * Binds the frame buffer to the specified texture.
  110725. * @param texture The texture to render to or null for the default canvas
  110726. * @param faceIndex The face of the texture to render to in case of cube texture
  110727. * @param requiredWidth The width of the target to render to
  110728. * @param requiredHeight The height of the target to render to
  110729. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110730. * @param depthStencilTexture The depth stencil texture to use to render
  110731. * @param lodLevel defines le lod level to bind to the frame buffer
  110732. */
  110733. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110734. /**
  110735. * Unbind the current render target texture from the webGL context
  110736. * @param texture defines the render target texture to unbind
  110737. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110738. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110739. */
  110740. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110741. /**
  110742. * Creates a dynamic vertex buffer
  110743. * @param vertices the data for the dynamic vertex buffer
  110744. * @returns the new WebGL dynamic buffer
  110745. */
  110746. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110747. /**
  110748. * Update the content of a dynamic texture
  110749. * @param texture defines the texture to update
  110750. * @param canvas defines the canvas containing the source
  110751. * @param invertY defines if data must be stored with Y axis inverted
  110752. * @param premulAlpha defines if alpha is stored as premultiplied
  110753. * @param format defines the format of the data
  110754. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110755. */
  110756. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110757. /**
  110758. * Gets a boolean indicating if all created effects are ready
  110759. * @returns true if all effects are ready
  110760. */
  110761. areAllEffectsReady(): boolean;
  110762. /**
  110763. * @hidden
  110764. * Get the current error code of the webGL context
  110765. * @returns the error code
  110766. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110767. */
  110768. getError(): number;
  110769. /** @hidden */
  110770. _getUnpackAlignement(): number;
  110771. /** @hidden */
  110772. _unpackFlipY(value: boolean): void;
  110773. /**
  110774. * Update a dynamic index buffer
  110775. * @param indexBuffer defines the target index buffer
  110776. * @param indices defines the data to update
  110777. * @param offset defines the offset in the target index buffer where update should start
  110778. */
  110779. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110780. /**
  110781. * Updates a dynamic vertex buffer.
  110782. * @param vertexBuffer the vertex buffer to update
  110783. * @param vertices the data used to update the vertex buffer
  110784. * @param byteOffset the byte offset of the data (optional)
  110785. * @param byteLength the byte length of the data (optional)
  110786. */
  110787. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110788. /** @hidden */
  110789. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110790. /** @hidden */
  110791. _bindTexture(channel: number, texture: InternalTexture): void;
  110792. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110793. /**
  110794. * 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
  110795. */
  110796. releaseEffects(): void;
  110797. displayLoadingUI(): void;
  110798. hideLoadingUI(): void;
  110799. /** @hidden */
  110800. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110801. /** @hidden */
  110802. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110803. /** @hidden */
  110804. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110805. /** @hidden */
  110806. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110807. }
  110808. }
  110809. declare module BABYLON {
  110810. /** @hidden */
  110811. export class _OcclusionDataStorage {
  110812. /** @hidden */
  110813. occlusionInternalRetryCounter: number;
  110814. /** @hidden */
  110815. isOcclusionQueryInProgress: boolean;
  110816. /** @hidden */
  110817. isOccluded: boolean;
  110818. /** @hidden */
  110819. occlusionRetryCount: number;
  110820. /** @hidden */
  110821. occlusionType: number;
  110822. /** @hidden */
  110823. occlusionQueryAlgorithmType: number;
  110824. }
  110825. interface Engine {
  110826. /**
  110827. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110828. * @return the new query
  110829. */
  110830. createQuery(): WebGLQuery;
  110831. /**
  110832. * Delete and release a webGL query
  110833. * @param query defines the query to delete
  110834. * @return the current engine
  110835. */
  110836. deleteQuery(query: WebGLQuery): Engine;
  110837. /**
  110838. * Check if a given query has resolved and got its value
  110839. * @param query defines the query to check
  110840. * @returns true if the query got its value
  110841. */
  110842. isQueryResultAvailable(query: WebGLQuery): boolean;
  110843. /**
  110844. * Gets the value of a given query
  110845. * @param query defines the query to check
  110846. * @returns the value of the query
  110847. */
  110848. getQueryResult(query: WebGLQuery): number;
  110849. /**
  110850. * Initiates an occlusion query
  110851. * @param algorithmType defines the algorithm to use
  110852. * @param query defines the query to use
  110853. * @returns the current engine
  110854. * @see http://doc.babylonjs.com/features/occlusionquery
  110855. */
  110856. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110857. /**
  110858. * Ends an occlusion query
  110859. * @see http://doc.babylonjs.com/features/occlusionquery
  110860. * @param algorithmType defines the algorithm to use
  110861. * @returns the current engine
  110862. */
  110863. endOcclusionQuery(algorithmType: number): Engine;
  110864. /**
  110865. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110866. * Please note that only one query can be issued at a time
  110867. * @returns a time token used to track the time span
  110868. */
  110869. startTimeQuery(): Nullable<_TimeToken>;
  110870. /**
  110871. * Ends a time query
  110872. * @param token defines the token used to measure the time span
  110873. * @returns the time spent (in ns)
  110874. */
  110875. endTimeQuery(token: _TimeToken): int;
  110876. /** @hidden */
  110877. _currentNonTimestampToken: Nullable<_TimeToken>;
  110878. /** @hidden */
  110879. _createTimeQuery(): WebGLQuery;
  110880. /** @hidden */
  110881. _deleteTimeQuery(query: WebGLQuery): void;
  110882. /** @hidden */
  110883. _getGlAlgorithmType(algorithmType: number): number;
  110884. /** @hidden */
  110885. _getTimeQueryResult(query: WebGLQuery): any;
  110886. /** @hidden */
  110887. _getTimeQueryAvailability(query: WebGLQuery): any;
  110888. }
  110889. interface AbstractMesh {
  110890. /**
  110891. * Backing filed
  110892. * @hidden
  110893. */
  110894. __occlusionDataStorage: _OcclusionDataStorage;
  110895. /**
  110896. * Access property
  110897. * @hidden
  110898. */
  110899. _occlusionDataStorage: _OcclusionDataStorage;
  110900. /**
  110901. * 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.
  110902. * The default value is -1 which means don't break the query and wait till the result
  110903. * @see http://doc.babylonjs.com/features/occlusionquery
  110904. */
  110905. occlusionRetryCount: number;
  110906. /**
  110907. * 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:
  110908. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110909. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110910. * * 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.
  110911. * @see http://doc.babylonjs.com/features/occlusionquery
  110912. */
  110913. occlusionType: number;
  110914. /**
  110915. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110916. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110917. * * 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.
  110918. * @see http://doc.babylonjs.com/features/occlusionquery
  110919. */
  110920. occlusionQueryAlgorithmType: number;
  110921. /**
  110922. * 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
  110923. * @see http://doc.babylonjs.com/features/occlusionquery
  110924. */
  110925. isOccluded: boolean;
  110926. /**
  110927. * Flag to check the progress status of the query
  110928. * @see http://doc.babylonjs.com/features/occlusionquery
  110929. */
  110930. isOcclusionQueryInProgress: boolean;
  110931. }
  110932. }
  110933. declare module BABYLON {
  110934. /** @hidden */
  110935. export var _forceTransformFeedbackToBundle: boolean;
  110936. interface Engine {
  110937. /**
  110938. * Creates a webGL transform feedback object
  110939. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110940. * @returns the webGL transform feedback object
  110941. */
  110942. createTransformFeedback(): WebGLTransformFeedback;
  110943. /**
  110944. * Delete a webGL transform feedback object
  110945. * @param value defines the webGL transform feedback object to delete
  110946. */
  110947. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110948. /**
  110949. * Bind a webGL transform feedback object to the webgl context
  110950. * @param value defines the webGL transform feedback object to bind
  110951. */
  110952. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110953. /**
  110954. * Begins a transform feedback operation
  110955. * @param usePoints defines if points or triangles must be used
  110956. */
  110957. beginTransformFeedback(usePoints: boolean): void;
  110958. /**
  110959. * Ends a transform feedback operation
  110960. */
  110961. endTransformFeedback(): void;
  110962. /**
  110963. * Specify the varyings to use with transform feedback
  110964. * @param program defines the associated webGL program
  110965. * @param value defines the list of strings representing the varying names
  110966. */
  110967. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110968. /**
  110969. * Bind a webGL buffer for a transform feedback operation
  110970. * @param value defines the webGL buffer to bind
  110971. */
  110972. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110973. }
  110974. }
  110975. declare module BABYLON {
  110976. /**
  110977. * Creation options of the multi render target texture.
  110978. */
  110979. export interface IMultiRenderTargetOptions {
  110980. /**
  110981. * Define if the texture needs to create mip maps after render.
  110982. */
  110983. generateMipMaps?: boolean;
  110984. /**
  110985. * Define the types of all the draw buffers we want to create
  110986. */
  110987. types?: number[];
  110988. /**
  110989. * Define the sampling modes of all the draw buffers we want to create
  110990. */
  110991. samplingModes?: number[];
  110992. /**
  110993. * Define if a depth buffer is required
  110994. */
  110995. generateDepthBuffer?: boolean;
  110996. /**
  110997. * Define if a stencil buffer is required
  110998. */
  110999. generateStencilBuffer?: boolean;
  111000. /**
  111001. * Define if a depth texture is required instead of a depth buffer
  111002. */
  111003. generateDepthTexture?: boolean;
  111004. /**
  111005. * Define the number of desired draw buffers
  111006. */
  111007. textureCount?: number;
  111008. /**
  111009. * Define if aspect ratio should be adapted to the texture or stay the scene one
  111010. */
  111011. doNotChangeAspectRatio?: boolean;
  111012. /**
  111013. * Define the default type of the buffers we are creating
  111014. */
  111015. defaultType?: number;
  111016. }
  111017. /**
  111018. * A multi render target, like a render target provides the ability to render to a texture.
  111019. * Unlike the render target, it can render to several draw buffers in one draw.
  111020. * This is specially interesting in deferred rendering or for any effects requiring more than
  111021. * just one color from a single pass.
  111022. */
  111023. export class MultiRenderTarget extends RenderTargetTexture {
  111024. private _internalTextures;
  111025. private _textures;
  111026. private _multiRenderTargetOptions;
  111027. /**
  111028. * Get if draw buffers are currently supported by the used hardware and browser.
  111029. */
  111030. readonly isSupported: boolean;
  111031. /**
  111032. * Get the list of textures generated by the multi render target.
  111033. */
  111034. readonly textures: Texture[];
  111035. /**
  111036. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111037. */
  111038. readonly depthTexture: Texture;
  111039. /**
  111040. * Set the wrapping mode on U of all the textures we are rendering to.
  111041. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111042. */
  111043. wrapU: number;
  111044. /**
  111045. * Set the wrapping mode on V of all the textures we are rendering to.
  111046. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111047. */
  111048. wrapV: number;
  111049. /**
  111050. * Instantiate a new multi render target texture.
  111051. * A multi render target, like a render target provides the ability to render to a texture.
  111052. * Unlike the render target, it can render to several draw buffers in one draw.
  111053. * This is specially interesting in deferred rendering or for any effects requiring more than
  111054. * just one color from a single pass.
  111055. * @param name Define the name of the texture
  111056. * @param size Define the size of the buffers to render to
  111057. * @param count Define the number of target we are rendering into
  111058. * @param scene Define the scene the texture belongs to
  111059. * @param options Define the options used to create the multi render target
  111060. */
  111061. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111062. /** @hidden */
  111063. _rebuild(): void;
  111064. private _createInternalTextures;
  111065. private _createTextures;
  111066. /**
  111067. * Define the number of samples used if MSAA is enabled.
  111068. */
  111069. samples: number;
  111070. /**
  111071. * Resize all the textures in the multi render target.
  111072. * Be carrefull as it will recreate all the data in the new texture.
  111073. * @param size Define the new size
  111074. */
  111075. resize(size: any): void;
  111076. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111077. /**
  111078. * Dispose the render targets and their associated resources
  111079. */
  111080. dispose(): void;
  111081. /**
  111082. * Release all the underlying texture used as draw buffers.
  111083. */
  111084. releaseInternalTextures(): void;
  111085. }
  111086. }
  111087. declare module BABYLON {
  111088. interface ThinEngine {
  111089. /**
  111090. * Unbind a list of render target textures from the webGL context
  111091. * This is used only when drawBuffer extension or webGL2 are active
  111092. * @param textures defines the render target textures to unbind
  111093. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111094. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111095. */
  111096. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111097. /**
  111098. * Create a multi render target texture
  111099. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111100. * @param size defines the size of the texture
  111101. * @param options defines the creation options
  111102. * @returns the cube texture as an InternalTexture
  111103. */
  111104. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111105. /**
  111106. * Update the sample count for a given multiple render target texture
  111107. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111108. * @param textures defines the textures to update
  111109. * @param samples defines the sample count to set
  111110. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111111. */
  111112. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111113. }
  111114. }
  111115. declare module BABYLON {
  111116. /**
  111117. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  111118. */
  111119. export interface CubeMapInfo {
  111120. /**
  111121. * The pixel array for the front face.
  111122. * This is stored in format, left to right, up to down format.
  111123. */
  111124. front: Nullable<ArrayBufferView>;
  111125. /**
  111126. * The pixel array for the back face.
  111127. * This is stored in format, left to right, up to down format.
  111128. */
  111129. back: Nullable<ArrayBufferView>;
  111130. /**
  111131. * The pixel array for the left face.
  111132. * This is stored in format, left to right, up to down format.
  111133. */
  111134. left: Nullable<ArrayBufferView>;
  111135. /**
  111136. * The pixel array for the right face.
  111137. * This is stored in format, left to right, up to down format.
  111138. */
  111139. right: Nullable<ArrayBufferView>;
  111140. /**
  111141. * The pixel array for the up face.
  111142. * This is stored in format, left to right, up to down format.
  111143. */
  111144. up: Nullable<ArrayBufferView>;
  111145. /**
  111146. * The pixel array for the down face.
  111147. * This is stored in format, left to right, up to down format.
  111148. */
  111149. down: Nullable<ArrayBufferView>;
  111150. /**
  111151. * The size of the cubemap stored.
  111152. *
  111153. * Each faces will be size * size pixels.
  111154. */
  111155. size: number;
  111156. /**
  111157. * The format of the texture.
  111158. *
  111159. * RGBA, RGB.
  111160. */
  111161. format: number;
  111162. /**
  111163. * The type of the texture data.
  111164. *
  111165. * UNSIGNED_INT, FLOAT.
  111166. */
  111167. type: number;
  111168. /**
  111169. * Specifies whether the texture is in gamma space.
  111170. */
  111171. gammaSpace: boolean;
  111172. }
  111173. /**
  111174. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  111175. */
  111176. export class PanoramaToCubeMapTools {
  111177. private static FACE_FRONT;
  111178. private static FACE_BACK;
  111179. private static FACE_RIGHT;
  111180. private static FACE_LEFT;
  111181. private static FACE_DOWN;
  111182. private static FACE_UP;
  111183. /**
  111184. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  111185. *
  111186. * @param float32Array The source data.
  111187. * @param inputWidth The width of the input panorama.
  111188. * @param inputHeight The height of the input panorama.
  111189. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  111190. * @return The cubemap data
  111191. */
  111192. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  111193. private static CreateCubemapTexture;
  111194. private static CalcProjectionSpherical;
  111195. }
  111196. }
  111197. declare module BABYLON {
  111198. /**
  111199. * Helper class dealing with the extraction of spherical polynomial dataArray
  111200. * from a cube map.
  111201. */
  111202. export class CubeMapToSphericalPolynomialTools {
  111203. private static FileFaces;
  111204. /**
  111205. * Converts a texture to the according Spherical Polynomial data.
  111206. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111207. *
  111208. * @param texture The texture to extract the information from.
  111209. * @return The Spherical Polynomial data.
  111210. */
  111211. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  111212. /**
  111213. * Converts a cubemap to the according Spherical Polynomial data.
  111214. * This extracts the first 3 orders only as they are the only one used in the lighting.
  111215. *
  111216. * @param cubeInfo The Cube map to extract the information from.
  111217. * @return The Spherical Polynomial data.
  111218. */
  111219. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  111220. }
  111221. }
  111222. declare module BABYLON {
  111223. interface BaseTexture {
  111224. /**
  111225. * Get the polynomial representation of the texture data.
  111226. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  111227. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  111228. */
  111229. sphericalPolynomial: Nullable<SphericalPolynomial>;
  111230. }
  111231. }
  111232. declare module BABYLON {
  111233. /** @hidden */
  111234. export var rgbdEncodePixelShader: {
  111235. name: string;
  111236. shader: string;
  111237. };
  111238. }
  111239. declare module BABYLON {
  111240. /** @hidden */
  111241. export var rgbdDecodePixelShader: {
  111242. name: string;
  111243. shader: string;
  111244. };
  111245. }
  111246. declare module BABYLON {
  111247. /**
  111248. * Raw texture data and descriptor sufficient for WebGL texture upload
  111249. */
  111250. export interface EnvironmentTextureInfo {
  111251. /**
  111252. * Version of the environment map
  111253. */
  111254. version: number;
  111255. /**
  111256. * Width of image
  111257. */
  111258. width: number;
  111259. /**
  111260. * Irradiance information stored in the file.
  111261. */
  111262. irradiance: any;
  111263. /**
  111264. * Specular information stored in the file.
  111265. */
  111266. specular: any;
  111267. }
  111268. /**
  111269. * Defines One Image in the file. It requires only the position in the file
  111270. * as well as the length.
  111271. */
  111272. interface BufferImageData {
  111273. /**
  111274. * Length of the image data.
  111275. */
  111276. length: number;
  111277. /**
  111278. * Position of the data from the null terminator delimiting the end of the JSON.
  111279. */
  111280. position: number;
  111281. }
  111282. /**
  111283. * Defines the specular data enclosed in the file.
  111284. * This corresponds to the version 1 of the data.
  111285. */
  111286. export interface EnvironmentTextureSpecularInfoV1 {
  111287. /**
  111288. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111289. */
  111290. specularDataPosition?: number;
  111291. /**
  111292. * This contains all the images data needed to reconstruct the cubemap.
  111293. */
  111294. mipmaps: Array<BufferImageData>;
  111295. /**
  111296. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111297. */
  111298. lodGenerationScale: number;
  111299. }
  111300. /**
  111301. * Sets of helpers addressing the serialization and deserialization of environment texture
  111302. * stored in a BabylonJS env file.
  111303. * Those files are usually stored as .env files.
  111304. */
  111305. export class EnvironmentTextureTools {
  111306. /**
  111307. * Magic number identifying the env file.
  111308. */
  111309. private static _MagicBytes;
  111310. /**
  111311. * Gets the environment info from an env file.
  111312. * @param data The array buffer containing the .env bytes.
  111313. * @returns the environment file info (the json header) if successfully parsed.
  111314. */
  111315. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111316. /**
  111317. * Creates an environment texture from a loaded cube texture.
  111318. * @param texture defines the cube texture to convert in env file
  111319. * @return a promise containing the environment data if succesfull.
  111320. */
  111321. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111322. /**
  111323. * Creates a JSON representation of the spherical data.
  111324. * @param texture defines the texture containing the polynomials
  111325. * @return the JSON representation of the spherical info
  111326. */
  111327. private static _CreateEnvTextureIrradiance;
  111328. /**
  111329. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111330. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111331. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111332. * @return the views described by info providing access to the underlying buffer
  111333. */
  111334. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111335. /**
  111336. * Uploads the texture info contained in the env file to the GPU.
  111337. * @param texture defines the internal texture to upload to
  111338. * @param arrayBuffer defines the buffer cotaining the data to load
  111339. * @param info defines the texture info retrieved through the GetEnvInfo method
  111340. * @returns a promise
  111341. */
  111342. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111343. /**
  111344. * Uploads the levels of image data to the GPU.
  111345. * @param texture defines the internal texture to upload to
  111346. * @param imageData defines the array buffer views of image data [mipmap][face]
  111347. * @returns a promise
  111348. */
  111349. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111350. /**
  111351. * Uploads spherical polynomials information to the texture.
  111352. * @param texture defines the texture we are trying to upload the information to
  111353. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111354. */
  111355. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111356. /** @hidden */
  111357. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111358. }
  111359. }
  111360. declare module BABYLON {
  111361. /**
  111362. * Contains position and normal vectors for a vertex
  111363. */
  111364. export class PositionNormalVertex {
  111365. /** the position of the vertex (defaut: 0,0,0) */
  111366. position: Vector3;
  111367. /** the normal of the vertex (defaut: 0,1,0) */
  111368. normal: Vector3;
  111369. /**
  111370. * Creates a PositionNormalVertex
  111371. * @param position the position of the vertex (defaut: 0,0,0)
  111372. * @param normal the normal of the vertex (defaut: 0,1,0)
  111373. */
  111374. constructor(
  111375. /** the position of the vertex (defaut: 0,0,0) */
  111376. position?: Vector3,
  111377. /** the normal of the vertex (defaut: 0,1,0) */
  111378. normal?: Vector3);
  111379. /**
  111380. * Clones the PositionNormalVertex
  111381. * @returns the cloned PositionNormalVertex
  111382. */
  111383. clone(): PositionNormalVertex;
  111384. }
  111385. /**
  111386. * Contains position, normal and uv vectors for a vertex
  111387. */
  111388. export class PositionNormalTextureVertex {
  111389. /** the position of the vertex (defaut: 0,0,0) */
  111390. position: Vector3;
  111391. /** the normal of the vertex (defaut: 0,1,0) */
  111392. normal: Vector3;
  111393. /** the uv of the vertex (default: 0,0) */
  111394. uv: Vector2;
  111395. /**
  111396. * Creates a PositionNormalTextureVertex
  111397. * @param position the position of the vertex (defaut: 0,0,0)
  111398. * @param normal the normal of the vertex (defaut: 0,1,0)
  111399. * @param uv the uv of the vertex (default: 0,0)
  111400. */
  111401. constructor(
  111402. /** the position of the vertex (defaut: 0,0,0) */
  111403. position?: Vector3,
  111404. /** the normal of the vertex (defaut: 0,1,0) */
  111405. normal?: Vector3,
  111406. /** the uv of the vertex (default: 0,0) */
  111407. uv?: Vector2);
  111408. /**
  111409. * Clones the PositionNormalTextureVertex
  111410. * @returns the cloned PositionNormalTextureVertex
  111411. */
  111412. clone(): PositionNormalTextureVertex;
  111413. }
  111414. }
  111415. declare module BABYLON {
  111416. /** @hidden */
  111417. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111418. private _genericAttributeLocation;
  111419. private _varyingLocationCount;
  111420. private _varyingLocationMap;
  111421. private _replacements;
  111422. private _textureCount;
  111423. private _uniforms;
  111424. lineProcessor(line: string): string;
  111425. attributeProcessor(attribute: string): string;
  111426. varyingProcessor(varying: string, isFragment: boolean): string;
  111427. uniformProcessor(uniform: string): string;
  111428. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111429. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111430. }
  111431. }
  111432. declare module BABYLON {
  111433. /**
  111434. * Container for accessors for natively-stored mesh data buffers.
  111435. */
  111436. class NativeDataBuffer extends DataBuffer {
  111437. /**
  111438. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111439. */
  111440. nativeIndexBuffer?: any;
  111441. /**
  111442. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111443. */
  111444. nativeVertexBuffer?: any;
  111445. }
  111446. /** @hidden */
  111447. export class NativeEngine extends Engine {
  111448. private readonly _native;
  111449. getHardwareScalingLevel(): number;
  111450. constructor();
  111451. /**
  111452. * Can be used to override the current requestAnimationFrame requester.
  111453. * @hidden
  111454. */
  111455. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111456. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111457. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111458. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111459. recordVertexArrayObject(vertexBuffers: {
  111460. [key: string]: VertexBuffer;
  111461. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111462. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111463. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111464. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111465. /**
  111466. * Draw a list of indexed primitives
  111467. * @param fillMode defines the primitive to use
  111468. * @param indexStart defines the starting index
  111469. * @param indexCount defines the number of index to draw
  111470. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111471. */
  111472. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111473. /**
  111474. * Draw a list of unindexed primitives
  111475. * @param fillMode defines the primitive to use
  111476. * @param verticesStart defines the index of first vertex to draw
  111477. * @param verticesCount defines the count of vertices to draw
  111478. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111479. */
  111480. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111481. createPipelineContext(): IPipelineContext;
  111482. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111483. /** @hidden */
  111484. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111485. /** @hidden */
  111486. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111487. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111488. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111489. protected _setProgram(program: WebGLProgram): void;
  111490. _releaseEffect(effect: Effect): void;
  111491. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111492. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111493. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111494. bindSamplers(effect: Effect): void;
  111495. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111496. getRenderWidth(useScreen?: boolean): number;
  111497. getRenderHeight(useScreen?: boolean): number;
  111498. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111499. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111500. /**
  111501. * Set the z offset to apply to current rendering
  111502. * @param value defines the offset to apply
  111503. */
  111504. setZOffset(value: number): void;
  111505. /**
  111506. * Gets the current value of the zOffset
  111507. * @returns the current zOffset state
  111508. */
  111509. getZOffset(): number;
  111510. /**
  111511. * Enable or disable depth buffering
  111512. * @param enable defines the state to set
  111513. */
  111514. setDepthBuffer(enable: boolean): void;
  111515. /**
  111516. * Gets a boolean indicating if depth writing is enabled
  111517. * @returns the current depth writing state
  111518. */
  111519. getDepthWrite(): boolean;
  111520. /**
  111521. * Enable or disable depth writing
  111522. * @param enable defines the state to set
  111523. */
  111524. setDepthWrite(enable: boolean): void;
  111525. /**
  111526. * Enable or disable color writing
  111527. * @param enable defines the state to set
  111528. */
  111529. setColorWrite(enable: boolean): void;
  111530. /**
  111531. * Gets a boolean indicating if color writing is enabled
  111532. * @returns the current color writing state
  111533. */
  111534. getColorWrite(): boolean;
  111535. /**
  111536. * Sets alpha constants used by some alpha blending modes
  111537. * @param r defines the red component
  111538. * @param g defines the green component
  111539. * @param b defines the blue component
  111540. * @param a defines the alpha component
  111541. */
  111542. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111543. /**
  111544. * Sets the current alpha mode
  111545. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111546. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111547. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111548. */
  111549. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111550. /**
  111551. * Gets the current alpha mode
  111552. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111553. * @returns the current alpha mode
  111554. */
  111555. getAlphaMode(): number;
  111556. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111557. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111558. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111559. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111560. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111561. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111562. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111563. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111564. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111565. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111566. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111567. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111568. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111569. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111570. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111571. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111572. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111573. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111574. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111575. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111576. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111577. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111578. wipeCaches(bruteForce?: boolean): void;
  111579. _createTexture(): WebGLTexture;
  111580. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111581. /**
  111582. * Usually called from BABYLON.Texture.ts.
  111583. * Passed information to create a WebGLTexture
  111584. * @param urlArg defines a value which contains one of the following:
  111585. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111586. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111587. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111588. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111589. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111590. * @param scene needed for loading to the correct scene
  111591. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111592. * @param onLoad optional callback to be called upon successful completion
  111593. * @param onError optional callback to be called upon failure
  111594. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111595. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111596. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111597. * @param forcedExtension defines the extension to use to pick the right loader
  111598. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111599. */
  111600. 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;
  111601. /**
  111602. * Creates a cube texture
  111603. * @param rootUrl defines the url where the files to load is located
  111604. * @param scene defines the current scene
  111605. * @param files defines the list of files to load (1 per face)
  111606. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111607. * @param onLoad defines an optional callback raised when the texture is loaded
  111608. * @param onError defines an optional callback raised if there is an issue to load the texture
  111609. * @param format defines the format of the data
  111610. * @param forcedExtension defines the extension to use to pick the right loader
  111611. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111612. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111613. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111614. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111615. * @returns the cube texture as an InternalTexture
  111616. */
  111617. 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;
  111618. private _getSamplingFilter;
  111619. private static _GetNativeTextureFormat;
  111620. createRenderTargetTexture(size: number | {
  111621. width: number;
  111622. height: number;
  111623. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111624. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111625. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111626. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111627. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111628. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111629. /**
  111630. * Updates a dynamic vertex buffer.
  111631. * @param vertexBuffer the vertex buffer to update
  111632. * @param data the data used to update the vertex buffer
  111633. * @param byteOffset the byte offset of the data (optional)
  111634. * @param byteLength the byte length of the data (optional)
  111635. */
  111636. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111637. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111638. private _updateAnisotropicLevel;
  111639. private _getAddressMode;
  111640. /** @hidden */
  111641. _bindTexture(channel: number, texture: InternalTexture): void;
  111642. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111643. releaseEffects(): void;
  111644. /** @hidden */
  111645. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111646. /** @hidden */
  111647. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111648. /** @hidden */
  111649. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111650. /** @hidden */
  111651. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111652. }
  111653. }
  111654. declare module BABYLON {
  111655. /**
  111656. * Gather the list of clipboard event types as constants.
  111657. */
  111658. export class ClipboardEventTypes {
  111659. /**
  111660. * The clipboard event is fired when a copy command is active (pressed).
  111661. */
  111662. static readonly COPY: number;
  111663. /**
  111664. * The clipboard event is fired when a cut command is active (pressed).
  111665. */
  111666. static readonly CUT: number;
  111667. /**
  111668. * The clipboard event is fired when a paste command is active (pressed).
  111669. */
  111670. static readonly PASTE: number;
  111671. }
  111672. /**
  111673. * This class is used to store clipboard related info for the onClipboardObservable event.
  111674. */
  111675. export class ClipboardInfo {
  111676. /**
  111677. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111678. */
  111679. type: number;
  111680. /**
  111681. * Defines the related dom event
  111682. */
  111683. event: ClipboardEvent;
  111684. /**
  111685. *Creates an instance of ClipboardInfo.
  111686. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111687. * @param event Defines the related dom event
  111688. */
  111689. constructor(
  111690. /**
  111691. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111692. */
  111693. type: number,
  111694. /**
  111695. * Defines the related dom event
  111696. */
  111697. event: ClipboardEvent);
  111698. /**
  111699. * Get the clipboard event's type from the keycode.
  111700. * @param keyCode Defines the keyCode for the current keyboard event.
  111701. * @return {number}
  111702. */
  111703. static GetTypeFromCharacter(keyCode: number): number;
  111704. }
  111705. }
  111706. declare module BABYLON {
  111707. /**
  111708. * Google Daydream controller
  111709. */
  111710. export class DaydreamController extends WebVRController {
  111711. /**
  111712. * Base Url for the controller model.
  111713. */
  111714. static MODEL_BASE_URL: string;
  111715. /**
  111716. * File name for the controller model.
  111717. */
  111718. static MODEL_FILENAME: string;
  111719. /**
  111720. * Gamepad Id prefix used to identify Daydream Controller.
  111721. */
  111722. static readonly GAMEPAD_ID_PREFIX: string;
  111723. /**
  111724. * Creates a new DaydreamController from a gamepad
  111725. * @param vrGamepad the gamepad that the controller should be created from
  111726. */
  111727. constructor(vrGamepad: any);
  111728. /**
  111729. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111730. * @param scene scene in which to add meshes
  111731. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111732. */
  111733. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111734. /**
  111735. * Called once for each button that changed state since the last frame
  111736. * @param buttonIdx Which button index changed
  111737. * @param state New state of the button
  111738. * @param changes Which properties on the state changed since last frame
  111739. */
  111740. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111741. }
  111742. }
  111743. declare module BABYLON {
  111744. /**
  111745. * Gear VR Controller
  111746. */
  111747. export class GearVRController extends WebVRController {
  111748. /**
  111749. * Base Url for the controller model.
  111750. */
  111751. static MODEL_BASE_URL: string;
  111752. /**
  111753. * File name for the controller model.
  111754. */
  111755. static MODEL_FILENAME: string;
  111756. /**
  111757. * Gamepad Id prefix used to identify this controller.
  111758. */
  111759. static readonly GAMEPAD_ID_PREFIX: string;
  111760. private readonly _buttonIndexToObservableNameMap;
  111761. /**
  111762. * Creates a new GearVRController from a gamepad
  111763. * @param vrGamepad the gamepad that the controller should be created from
  111764. */
  111765. constructor(vrGamepad: any);
  111766. /**
  111767. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111768. * @param scene scene in which to add meshes
  111769. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111770. */
  111771. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111772. /**
  111773. * Called once for each button that changed state since the last frame
  111774. * @param buttonIdx Which button index changed
  111775. * @param state New state of the button
  111776. * @param changes Which properties on the state changed since last frame
  111777. */
  111778. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111779. }
  111780. }
  111781. declare module BABYLON {
  111782. /**
  111783. * Class containing static functions to help procedurally build meshes
  111784. */
  111785. export class PolyhedronBuilder {
  111786. /**
  111787. * Creates a polyhedron mesh
  111788. * * 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
  111789. * * The parameter `size` (positive float, default 1) sets the polygon size
  111790. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111791. * * 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`
  111792. * * 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
  111793. * * 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)`)
  111794. * * 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
  111795. * * 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
  111796. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111797. * * 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
  111798. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111799. * @param name defines the name of the mesh
  111800. * @param options defines the options used to create the mesh
  111801. * @param scene defines the hosting scene
  111802. * @returns the polyhedron mesh
  111803. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111804. */
  111805. static CreatePolyhedron(name: string, options: {
  111806. type?: number;
  111807. size?: number;
  111808. sizeX?: number;
  111809. sizeY?: number;
  111810. sizeZ?: number;
  111811. custom?: any;
  111812. faceUV?: Vector4[];
  111813. faceColors?: Color4[];
  111814. flat?: boolean;
  111815. updatable?: boolean;
  111816. sideOrientation?: number;
  111817. frontUVs?: Vector4;
  111818. backUVs?: Vector4;
  111819. }, scene?: Nullable<Scene>): Mesh;
  111820. }
  111821. }
  111822. declare module BABYLON {
  111823. /**
  111824. * Gizmo that enables scaling a mesh along 3 axis
  111825. */
  111826. export class ScaleGizmo extends Gizmo {
  111827. /**
  111828. * Internal gizmo used for interactions on the x axis
  111829. */
  111830. xGizmo: AxisScaleGizmo;
  111831. /**
  111832. * Internal gizmo used for interactions on the y axis
  111833. */
  111834. yGizmo: AxisScaleGizmo;
  111835. /**
  111836. * Internal gizmo used for interactions on the z axis
  111837. */
  111838. zGizmo: AxisScaleGizmo;
  111839. /**
  111840. * Internal gizmo used to scale all axis equally
  111841. */
  111842. uniformScaleGizmo: AxisScaleGizmo;
  111843. private _meshAttached;
  111844. private _updateGizmoRotationToMatchAttachedMesh;
  111845. private _snapDistance;
  111846. private _scaleRatio;
  111847. private _uniformScalingMesh;
  111848. private _octahedron;
  111849. /** Fires an event when any of it's sub gizmos are dragged */
  111850. onDragStartObservable: Observable<unknown>;
  111851. /** Fires an event when any of it's sub gizmos are released from dragging */
  111852. onDragEndObservable: Observable<unknown>;
  111853. attachedMesh: Nullable<AbstractMesh>;
  111854. /**
  111855. * Creates a ScaleGizmo
  111856. * @param gizmoLayer The utility layer the gizmo will be added to
  111857. */
  111858. constructor(gizmoLayer?: UtilityLayerRenderer);
  111859. updateGizmoRotationToMatchAttachedMesh: boolean;
  111860. /**
  111861. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111862. */
  111863. snapDistance: number;
  111864. /**
  111865. * Ratio for the scale of the gizmo (Default: 1)
  111866. */
  111867. scaleRatio: number;
  111868. /**
  111869. * Disposes of the gizmo
  111870. */
  111871. dispose(): void;
  111872. }
  111873. }
  111874. declare module BABYLON {
  111875. /**
  111876. * Single axis scale gizmo
  111877. */
  111878. export class AxisScaleGizmo extends Gizmo {
  111879. /**
  111880. * Drag behavior responsible for the gizmos dragging interactions
  111881. */
  111882. dragBehavior: PointerDragBehavior;
  111883. private _pointerObserver;
  111884. /**
  111885. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111886. */
  111887. snapDistance: number;
  111888. /**
  111889. * Event that fires each time the gizmo snaps to a new location.
  111890. * * snapDistance is the the change in distance
  111891. */
  111892. onSnapObservable: Observable<{
  111893. snapDistance: number;
  111894. }>;
  111895. /**
  111896. * If the scaling operation should be done on all axis (default: false)
  111897. */
  111898. uniformScaling: boolean;
  111899. private _isEnabled;
  111900. private _parent;
  111901. private _arrow;
  111902. private _coloredMaterial;
  111903. private _hoverMaterial;
  111904. /**
  111905. * Creates an AxisScaleGizmo
  111906. * @param gizmoLayer The utility layer the gizmo will be added to
  111907. * @param dragAxis The axis which the gizmo will be able to scale on
  111908. * @param color The color of the gizmo
  111909. */
  111910. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111911. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111912. /**
  111913. * If the gizmo is enabled
  111914. */
  111915. isEnabled: boolean;
  111916. /**
  111917. * Disposes of the gizmo
  111918. */
  111919. dispose(): void;
  111920. /**
  111921. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111922. * @param mesh The mesh to replace the default mesh of the gizmo
  111923. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111924. */
  111925. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111926. }
  111927. }
  111928. declare module BABYLON {
  111929. /**
  111930. * Bounding box gizmo
  111931. */
  111932. export class BoundingBoxGizmo extends Gizmo {
  111933. private _lineBoundingBox;
  111934. private _rotateSpheresParent;
  111935. private _scaleBoxesParent;
  111936. private _boundingDimensions;
  111937. private _renderObserver;
  111938. private _pointerObserver;
  111939. private _scaleDragSpeed;
  111940. private _tmpQuaternion;
  111941. private _tmpVector;
  111942. private _tmpRotationMatrix;
  111943. /**
  111944. * 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)
  111945. */
  111946. ignoreChildren: boolean;
  111947. /**
  111948. * 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)
  111949. */
  111950. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111951. /**
  111952. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111953. */
  111954. rotationSphereSize: number;
  111955. /**
  111956. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111957. */
  111958. scaleBoxSize: number;
  111959. /**
  111960. * 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)
  111961. */
  111962. fixedDragMeshScreenSize: boolean;
  111963. /**
  111964. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111965. */
  111966. fixedDragMeshScreenSizeDistanceFactor: number;
  111967. /**
  111968. * Fired when a rotation sphere or scale box is dragged
  111969. */
  111970. onDragStartObservable: Observable<{}>;
  111971. /**
  111972. * Fired when a scale box is dragged
  111973. */
  111974. onScaleBoxDragObservable: Observable<{}>;
  111975. /**
  111976. * Fired when a scale box drag is ended
  111977. */
  111978. onScaleBoxDragEndObservable: Observable<{}>;
  111979. /**
  111980. * Fired when a rotation sphere is dragged
  111981. */
  111982. onRotationSphereDragObservable: Observable<{}>;
  111983. /**
  111984. * Fired when a rotation sphere drag is ended
  111985. */
  111986. onRotationSphereDragEndObservable: Observable<{}>;
  111987. /**
  111988. * 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)
  111989. */
  111990. scalePivot: Nullable<Vector3>;
  111991. /**
  111992. * Mesh used as a pivot to rotate the attached mesh
  111993. */
  111994. private _anchorMesh;
  111995. private _existingMeshScale;
  111996. private _dragMesh;
  111997. private pointerDragBehavior;
  111998. private coloredMaterial;
  111999. private hoverColoredMaterial;
  112000. /**
  112001. * Sets the color of the bounding box gizmo
  112002. * @param color the color to set
  112003. */
  112004. setColor(color: Color3): void;
  112005. /**
  112006. * Creates an BoundingBoxGizmo
  112007. * @param gizmoLayer The utility layer the gizmo will be added to
  112008. * @param color The color of the gizmo
  112009. */
  112010. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  112011. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112012. private _selectNode;
  112013. /**
  112014. * Updates the bounding box information for the Gizmo
  112015. */
  112016. updateBoundingBox(): void;
  112017. private _updateRotationSpheres;
  112018. private _updateScaleBoxes;
  112019. /**
  112020. * Enables rotation on the specified axis and disables rotation on the others
  112021. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  112022. */
  112023. setEnabledRotationAxis(axis: string): void;
  112024. /**
  112025. * Enables/disables scaling
  112026. * @param enable if scaling should be enabled
  112027. */
  112028. setEnabledScaling(enable: boolean): void;
  112029. private _updateDummy;
  112030. /**
  112031. * Enables a pointer drag behavior on the bounding box of the gizmo
  112032. */
  112033. enableDragBehavior(): void;
  112034. /**
  112035. * Disposes of the gizmo
  112036. */
  112037. dispose(): void;
  112038. /**
  112039. * 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)
  112040. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  112041. * @returns the bounding box mesh with the passed in mesh as a child
  112042. */
  112043. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  112044. /**
  112045. * CustomMeshes are not supported by this gizmo
  112046. * @param mesh The mesh to replace the default mesh of the gizmo
  112047. */
  112048. setCustomMesh(mesh: Mesh): void;
  112049. }
  112050. }
  112051. declare module BABYLON {
  112052. /**
  112053. * Single plane rotation gizmo
  112054. */
  112055. export class PlaneRotationGizmo extends Gizmo {
  112056. /**
  112057. * Drag behavior responsible for the gizmos dragging interactions
  112058. */
  112059. dragBehavior: PointerDragBehavior;
  112060. private _pointerObserver;
  112061. /**
  112062. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  112063. */
  112064. snapDistance: number;
  112065. /**
  112066. * Event that fires each time the gizmo snaps to a new location.
  112067. * * snapDistance is the the change in distance
  112068. */
  112069. onSnapObservable: Observable<{
  112070. snapDistance: number;
  112071. }>;
  112072. private _isEnabled;
  112073. private _parent;
  112074. /**
  112075. * Creates a PlaneRotationGizmo
  112076. * @param gizmoLayer The utility layer the gizmo will be added to
  112077. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  112078. * @param color The color of the gizmo
  112079. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112080. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112081. */
  112082. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  112083. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  112084. /**
  112085. * If the gizmo is enabled
  112086. */
  112087. isEnabled: boolean;
  112088. /**
  112089. * Disposes of the gizmo
  112090. */
  112091. dispose(): void;
  112092. }
  112093. }
  112094. declare module BABYLON {
  112095. /**
  112096. * Gizmo that enables rotating a mesh along 3 axis
  112097. */
  112098. export class RotationGizmo extends Gizmo {
  112099. /**
  112100. * Internal gizmo used for interactions on the x axis
  112101. */
  112102. xGizmo: PlaneRotationGizmo;
  112103. /**
  112104. * Internal gizmo used for interactions on the y axis
  112105. */
  112106. yGizmo: PlaneRotationGizmo;
  112107. /**
  112108. * Internal gizmo used for interactions on the z axis
  112109. */
  112110. zGizmo: PlaneRotationGizmo;
  112111. /** Fires an event when any of it's sub gizmos are dragged */
  112112. onDragStartObservable: Observable<unknown>;
  112113. /** Fires an event when any of it's sub gizmos are released from dragging */
  112114. onDragEndObservable: Observable<unknown>;
  112115. private _meshAttached;
  112116. attachedMesh: Nullable<AbstractMesh>;
  112117. /**
  112118. * Creates a RotationGizmo
  112119. * @param gizmoLayer The utility layer the gizmo will be added to
  112120. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112121. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112122. */
  112123. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112124. updateGizmoRotationToMatchAttachedMesh: boolean;
  112125. /**
  112126. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112127. */
  112128. snapDistance: number;
  112129. /**
  112130. * Ratio for the scale of the gizmo (Default: 1)
  112131. */
  112132. scaleRatio: number;
  112133. /**
  112134. * Disposes of the gizmo
  112135. */
  112136. dispose(): void;
  112137. /**
  112138. * CustomMeshes are not supported by this gizmo
  112139. * @param mesh The mesh to replace the default mesh of the gizmo
  112140. */
  112141. setCustomMesh(mesh: Mesh): void;
  112142. }
  112143. }
  112144. declare module BABYLON {
  112145. /**
  112146. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112147. */
  112148. export class GizmoManager implements IDisposable {
  112149. private scene;
  112150. /**
  112151. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112152. */
  112153. gizmos: {
  112154. positionGizmo: Nullable<PositionGizmo>;
  112155. rotationGizmo: Nullable<RotationGizmo>;
  112156. scaleGizmo: Nullable<ScaleGizmo>;
  112157. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112158. };
  112159. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112160. clearGizmoOnEmptyPointerEvent: boolean;
  112161. /** Fires an event when the manager is attached to a mesh */
  112162. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112163. private _gizmosEnabled;
  112164. private _pointerObserver;
  112165. private _attachedMesh;
  112166. private _boundingBoxColor;
  112167. private _defaultUtilityLayer;
  112168. private _defaultKeepDepthUtilityLayer;
  112169. /**
  112170. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112171. */
  112172. boundingBoxDragBehavior: SixDofDragBehavior;
  112173. /**
  112174. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112175. */
  112176. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112177. /**
  112178. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112179. */
  112180. usePointerToAttachGizmos: boolean;
  112181. /**
  112182. * Utility layer that the bounding box gizmo belongs to
  112183. */
  112184. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112185. /**
  112186. * Utility layer that all gizmos besides bounding box belong to
  112187. */
  112188. readonly utilityLayer: UtilityLayerRenderer;
  112189. /**
  112190. * Instatiates a gizmo manager
  112191. * @param scene the scene to overlay the gizmos on top of
  112192. */
  112193. constructor(scene: Scene);
  112194. /**
  112195. * Attaches a set of gizmos to the specified mesh
  112196. * @param mesh The mesh the gizmo's should be attached to
  112197. */
  112198. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112199. /**
  112200. * If the position gizmo is enabled
  112201. */
  112202. positionGizmoEnabled: boolean;
  112203. /**
  112204. * If the rotation gizmo is enabled
  112205. */
  112206. rotationGizmoEnabled: boolean;
  112207. /**
  112208. * If the scale gizmo is enabled
  112209. */
  112210. scaleGizmoEnabled: boolean;
  112211. /**
  112212. * If the boundingBox gizmo is enabled
  112213. */
  112214. boundingBoxGizmoEnabled: boolean;
  112215. /**
  112216. * Disposes of the gizmo manager
  112217. */
  112218. dispose(): void;
  112219. }
  112220. }
  112221. declare module BABYLON {
  112222. /**
  112223. * A directional light is defined by a direction (what a surprise!).
  112224. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112225. * 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.
  112226. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112227. */
  112228. export class DirectionalLight extends ShadowLight {
  112229. private _shadowFrustumSize;
  112230. /**
  112231. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112232. */
  112233. /**
  112234. * Specifies a fix frustum size for the shadow generation.
  112235. */
  112236. shadowFrustumSize: number;
  112237. private _shadowOrthoScale;
  112238. /**
  112239. * Gets the shadow projection scale against the optimal computed one.
  112240. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112241. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112242. */
  112243. /**
  112244. * Sets the shadow projection scale against the optimal computed one.
  112245. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112246. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112247. */
  112248. shadowOrthoScale: number;
  112249. /**
  112250. * Automatically compute the projection matrix to best fit (including all the casters)
  112251. * on each frame.
  112252. */
  112253. autoUpdateExtends: boolean;
  112254. private _orthoLeft;
  112255. private _orthoRight;
  112256. private _orthoTop;
  112257. private _orthoBottom;
  112258. /**
  112259. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112260. * The directional light is emitted from everywhere in the given direction.
  112261. * It can cast shadows.
  112262. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112263. * @param name The friendly name of the light
  112264. * @param direction The direction of the light
  112265. * @param scene The scene the light belongs to
  112266. */
  112267. constructor(name: string, direction: Vector3, scene: Scene);
  112268. /**
  112269. * Returns the string "DirectionalLight".
  112270. * @return The class name
  112271. */
  112272. getClassName(): string;
  112273. /**
  112274. * Returns the integer 1.
  112275. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112276. */
  112277. getTypeID(): number;
  112278. /**
  112279. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112280. * Returns the DirectionalLight Shadow projection matrix.
  112281. */
  112282. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112283. /**
  112284. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112285. * Returns the DirectionalLight Shadow projection matrix.
  112286. */
  112287. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112288. /**
  112289. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112290. * Returns the DirectionalLight Shadow projection matrix.
  112291. */
  112292. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112293. protected _buildUniformLayout(): void;
  112294. /**
  112295. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112296. * @param effect The effect to update
  112297. * @param lightIndex The index of the light in the effect to update
  112298. * @returns The directional light
  112299. */
  112300. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112301. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112302. /**
  112303. * Gets the minZ used for shadow according to both the scene and the light.
  112304. *
  112305. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112306. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112307. * @param activeCamera The camera we are returning the min for
  112308. * @returns the depth min z
  112309. */
  112310. getDepthMinZ(activeCamera: Camera): number;
  112311. /**
  112312. * Gets the maxZ used for shadow according to both the scene and the light.
  112313. *
  112314. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112315. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112316. * @param activeCamera The camera we are returning the max for
  112317. * @returns the depth max z
  112318. */
  112319. getDepthMaxZ(activeCamera: Camera): number;
  112320. /**
  112321. * Prepares the list of defines specific to the light type.
  112322. * @param defines the list of defines
  112323. * @param lightIndex defines the index of the light for the effect
  112324. */
  112325. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112326. }
  112327. }
  112328. declare module BABYLON {
  112329. /**
  112330. * Class containing static functions to help procedurally build meshes
  112331. */
  112332. export class HemisphereBuilder {
  112333. /**
  112334. * Creates a hemisphere mesh
  112335. * @param name defines the name of the mesh
  112336. * @param options defines the options used to create the mesh
  112337. * @param scene defines the hosting scene
  112338. * @returns the hemisphere mesh
  112339. */
  112340. static CreateHemisphere(name: string, options: {
  112341. segments?: number;
  112342. diameter?: number;
  112343. sideOrientation?: number;
  112344. }, scene: any): Mesh;
  112345. }
  112346. }
  112347. declare module BABYLON {
  112348. /**
  112349. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112350. * These values define a cone of light starting from the position, emitting toward the direction.
  112351. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112352. * and the exponent defines the speed of the decay of the light with distance (reach).
  112353. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112354. */
  112355. export class SpotLight extends ShadowLight {
  112356. private _angle;
  112357. private _innerAngle;
  112358. private _cosHalfAngle;
  112359. private _lightAngleScale;
  112360. private _lightAngleOffset;
  112361. /**
  112362. * Gets the cone angle of the spot light in Radians.
  112363. */
  112364. /**
  112365. * Sets the cone angle of the spot light in Radians.
  112366. */
  112367. angle: number;
  112368. /**
  112369. * Only used in gltf falloff mode, this defines the angle where
  112370. * the directional falloff will start before cutting at angle which could be seen
  112371. * as outer angle.
  112372. */
  112373. /**
  112374. * Only used in gltf falloff mode, this defines the angle where
  112375. * the directional falloff will start before cutting at angle which could be seen
  112376. * as outer angle.
  112377. */
  112378. innerAngle: number;
  112379. private _shadowAngleScale;
  112380. /**
  112381. * Allows scaling the angle of the light for shadow generation only.
  112382. */
  112383. /**
  112384. * Allows scaling the angle of the light for shadow generation only.
  112385. */
  112386. shadowAngleScale: number;
  112387. /**
  112388. * The light decay speed with the distance from the emission spot.
  112389. */
  112390. exponent: number;
  112391. private _projectionTextureMatrix;
  112392. /**
  112393. * Allows reading the projecton texture
  112394. */
  112395. readonly projectionTextureMatrix: Matrix;
  112396. protected _projectionTextureLightNear: number;
  112397. /**
  112398. * Gets the near clip of the Spotlight for texture projection.
  112399. */
  112400. /**
  112401. * Sets the near clip of the Spotlight for texture projection.
  112402. */
  112403. projectionTextureLightNear: number;
  112404. protected _projectionTextureLightFar: number;
  112405. /**
  112406. * Gets the far clip of the Spotlight for texture projection.
  112407. */
  112408. /**
  112409. * Sets the far clip of the Spotlight for texture projection.
  112410. */
  112411. projectionTextureLightFar: number;
  112412. protected _projectionTextureUpDirection: Vector3;
  112413. /**
  112414. * Gets the Up vector of the Spotlight for texture projection.
  112415. */
  112416. /**
  112417. * Sets the Up vector of the Spotlight for texture projection.
  112418. */
  112419. projectionTextureUpDirection: Vector3;
  112420. private _projectionTexture;
  112421. /**
  112422. * Gets the projection texture of the light.
  112423. */
  112424. /**
  112425. * Sets the projection texture of the light.
  112426. */
  112427. projectionTexture: Nullable<BaseTexture>;
  112428. private _projectionTextureViewLightDirty;
  112429. private _projectionTextureProjectionLightDirty;
  112430. private _projectionTextureDirty;
  112431. private _projectionTextureViewTargetVector;
  112432. private _projectionTextureViewLightMatrix;
  112433. private _projectionTextureProjectionLightMatrix;
  112434. private _projectionTextureScalingMatrix;
  112435. /**
  112436. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112437. * It can cast shadows.
  112438. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112439. * @param name The light friendly name
  112440. * @param position The position of the spot light in the scene
  112441. * @param direction The direction of the light in the scene
  112442. * @param angle The cone angle of the light in Radians
  112443. * @param exponent The light decay speed with the distance from the emission spot
  112444. * @param scene The scene the lights belongs to
  112445. */
  112446. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112447. /**
  112448. * Returns the string "SpotLight".
  112449. * @returns the class name
  112450. */
  112451. getClassName(): string;
  112452. /**
  112453. * Returns the integer 2.
  112454. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112455. */
  112456. getTypeID(): number;
  112457. /**
  112458. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112459. */
  112460. protected _setDirection(value: Vector3): void;
  112461. /**
  112462. * Overrides the position setter to recompute the projection texture view light Matrix.
  112463. */
  112464. protected _setPosition(value: Vector3): void;
  112465. /**
  112466. * 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.
  112467. * Returns the SpotLight.
  112468. */
  112469. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112470. protected _computeProjectionTextureViewLightMatrix(): void;
  112471. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112472. /**
  112473. * Main function for light texture projection matrix computing.
  112474. */
  112475. protected _computeProjectionTextureMatrix(): void;
  112476. protected _buildUniformLayout(): void;
  112477. private _computeAngleValues;
  112478. /**
  112479. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112480. * @param effect The effect to update
  112481. * @param lightIndex The index of the light in the effect to update
  112482. * @returns The spot light
  112483. */
  112484. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112485. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112486. /**
  112487. * Disposes the light and the associated resources.
  112488. */
  112489. dispose(): void;
  112490. /**
  112491. * Prepares the list of defines specific to the light type.
  112492. * @param defines the list of defines
  112493. * @param lightIndex defines the index of the light for the effect
  112494. */
  112495. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112496. }
  112497. }
  112498. declare module BABYLON {
  112499. /**
  112500. * Gizmo that enables viewing a light
  112501. */
  112502. export class LightGizmo extends Gizmo {
  112503. private _lightMesh;
  112504. private _material;
  112505. private cachedPosition;
  112506. private cachedForward;
  112507. /**
  112508. * Creates a LightGizmo
  112509. * @param gizmoLayer The utility layer the gizmo will be added to
  112510. */
  112511. constructor(gizmoLayer?: UtilityLayerRenderer);
  112512. private _light;
  112513. /**
  112514. * The light that the gizmo is attached to
  112515. */
  112516. light: Nullable<Light>;
  112517. /**
  112518. * Gets the material used to render the light gizmo
  112519. */
  112520. readonly material: StandardMaterial;
  112521. /**
  112522. * @hidden
  112523. * Updates the gizmo to match the attached mesh's position/rotation
  112524. */
  112525. protected _update(): void;
  112526. private static _Scale;
  112527. /**
  112528. * Creates the lines for a light mesh
  112529. */
  112530. private static _createLightLines;
  112531. /**
  112532. * Disposes of the light gizmo
  112533. */
  112534. dispose(): void;
  112535. private static _CreateHemisphericLightMesh;
  112536. private static _CreatePointLightMesh;
  112537. private static _CreateSpotLightMesh;
  112538. private static _CreateDirectionalLightMesh;
  112539. }
  112540. }
  112541. declare module BABYLON {
  112542. /** @hidden */
  112543. export var backgroundFragmentDeclaration: {
  112544. name: string;
  112545. shader: string;
  112546. };
  112547. }
  112548. declare module BABYLON {
  112549. /** @hidden */
  112550. export var backgroundUboDeclaration: {
  112551. name: string;
  112552. shader: string;
  112553. };
  112554. }
  112555. declare module BABYLON {
  112556. /** @hidden */
  112557. export var backgroundPixelShader: {
  112558. name: string;
  112559. shader: string;
  112560. };
  112561. }
  112562. declare module BABYLON {
  112563. /** @hidden */
  112564. export var backgroundVertexDeclaration: {
  112565. name: string;
  112566. shader: string;
  112567. };
  112568. }
  112569. declare module BABYLON {
  112570. /** @hidden */
  112571. export var backgroundVertexShader: {
  112572. name: string;
  112573. shader: string;
  112574. };
  112575. }
  112576. declare module BABYLON {
  112577. /**
  112578. * Background material used to create an efficient environement around your scene.
  112579. */
  112580. export class BackgroundMaterial extends PushMaterial {
  112581. /**
  112582. * Standard reflectance value at parallel view angle.
  112583. */
  112584. static StandardReflectance0: number;
  112585. /**
  112586. * Standard reflectance value at grazing angle.
  112587. */
  112588. static StandardReflectance90: number;
  112589. protected _primaryColor: Color3;
  112590. /**
  112591. * Key light Color (multiply against the environement texture)
  112592. */
  112593. primaryColor: Color3;
  112594. protected __perceptualColor: Nullable<Color3>;
  112595. /**
  112596. * Experimental Internal Use Only.
  112597. *
  112598. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112599. * This acts as a helper to set the primary color to a more "human friendly" value.
  112600. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112601. * output color as close as possible from the chosen value.
  112602. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112603. * part of lighting setup.)
  112604. */
  112605. _perceptualColor: Nullable<Color3>;
  112606. protected _primaryColorShadowLevel: float;
  112607. /**
  112608. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112609. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112610. */
  112611. primaryColorShadowLevel: float;
  112612. protected _primaryColorHighlightLevel: float;
  112613. /**
  112614. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112615. * The primary color is used at the level chosen to define what the white area would look.
  112616. */
  112617. primaryColorHighlightLevel: float;
  112618. protected _reflectionTexture: Nullable<BaseTexture>;
  112619. /**
  112620. * Reflection Texture used in the material.
  112621. * Should be author in a specific way for the best result (refer to the documentation).
  112622. */
  112623. reflectionTexture: Nullable<BaseTexture>;
  112624. protected _reflectionBlur: float;
  112625. /**
  112626. * Reflection Texture level of blur.
  112627. *
  112628. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112629. * texture twice.
  112630. */
  112631. reflectionBlur: float;
  112632. protected _diffuseTexture: Nullable<BaseTexture>;
  112633. /**
  112634. * Diffuse Texture used in the material.
  112635. * Should be author in a specific way for the best result (refer to the documentation).
  112636. */
  112637. diffuseTexture: Nullable<BaseTexture>;
  112638. protected _shadowLights: Nullable<IShadowLight[]>;
  112639. /**
  112640. * Specify the list of lights casting shadow on the material.
  112641. * All scene shadow lights will be included if null.
  112642. */
  112643. shadowLights: Nullable<IShadowLight[]>;
  112644. protected _shadowLevel: float;
  112645. /**
  112646. * Helps adjusting the shadow to a softer level if required.
  112647. * 0 means black shadows and 1 means no shadows.
  112648. */
  112649. shadowLevel: float;
  112650. protected _sceneCenter: Vector3;
  112651. /**
  112652. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112653. * It is usually zero but might be interesting to modify according to your setup.
  112654. */
  112655. sceneCenter: Vector3;
  112656. protected _opacityFresnel: boolean;
  112657. /**
  112658. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112659. * This helps ensuring a nice transition when the camera goes under the ground.
  112660. */
  112661. opacityFresnel: boolean;
  112662. protected _reflectionFresnel: boolean;
  112663. /**
  112664. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112665. * This helps adding a mirror texture on the ground.
  112666. */
  112667. reflectionFresnel: boolean;
  112668. protected _reflectionFalloffDistance: number;
  112669. /**
  112670. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112671. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112672. */
  112673. reflectionFalloffDistance: number;
  112674. protected _reflectionAmount: number;
  112675. /**
  112676. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112677. */
  112678. reflectionAmount: number;
  112679. protected _reflectionReflectance0: number;
  112680. /**
  112681. * This specifies the weight of the reflection at grazing angle.
  112682. */
  112683. reflectionReflectance0: number;
  112684. protected _reflectionReflectance90: number;
  112685. /**
  112686. * This specifies the weight of the reflection at a perpendicular point of view.
  112687. */
  112688. reflectionReflectance90: number;
  112689. /**
  112690. * Sets the reflection reflectance fresnel values according to the default standard
  112691. * empirically know to work well :-)
  112692. */
  112693. reflectionStandardFresnelWeight: number;
  112694. protected _useRGBColor: boolean;
  112695. /**
  112696. * Helps to directly use the maps channels instead of their level.
  112697. */
  112698. useRGBColor: boolean;
  112699. protected _enableNoise: boolean;
  112700. /**
  112701. * This helps reducing the banding effect that could occur on the background.
  112702. */
  112703. enableNoise: boolean;
  112704. /**
  112705. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112706. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112707. * Recommended to be keep at 1.0 except for special cases.
  112708. */
  112709. fovMultiplier: number;
  112710. private _fovMultiplier;
  112711. /**
  112712. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112713. */
  112714. useEquirectangularFOV: boolean;
  112715. private _maxSimultaneousLights;
  112716. /**
  112717. * Number of Simultaneous lights allowed on the material.
  112718. */
  112719. maxSimultaneousLights: int;
  112720. /**
  112721. * Default configuration related to image processing available in the Background Material.
  112722. */
  112723. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112724. /**
  112725. * Keep track of the image processing observer to allow dispose and replace.
  112726. */
  112727. private _imageProcessingObserver;
  112728. /**
  112729. * Attaches a new image processing configuration to the PBR Material.
  112730. * @param configuration (if null the scene configuration will be use)
  112731. */
  112732. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112733. /**
  112734. * Gets the image processing configuration used either in this material.
  112735. */
  112736. /**
  112737. * Sets the Default image processing configuration used either in the this material.
  112738. *
  112739. * If sets to null, the scene one is in use.
  112740. */
  112741. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112742. /**
  112743. * Gets wether the color curves effect is enabled.
  112744. */
  112745. /**
  112746. * Sets wether the color curves effect is enabled.
  112747. */
  112748. cameraColorCurvesEnabled: boolean;
  112749. /**
  112750. * Gets wether the color grading effect is enabled.
  112751. */
  112752. /**
  112753. * Gets wether the color grading effect is enabled.
  112754. */
  112755. cameraColorGradingEnabled: boolean;
  112756. /**
  112757. * Gets wether tonemapping is enabled or not.
  112758. */
  112759. /**
  112760. * Sets wether tonemapping is enabled or not
  112761. */
  112762. cameraToneMappingEnabled: boolean;
  112763. /**
  112764. * The camera exposure used on this material.
  112765. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112766. * This corresponds to a photographic exposure.
  112767. */
  112768. /**
  112769. * The camera exposure used on this material.
  112770. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112771. * This corresponds to a photographic exposure.
  112772. */
  112773. cameraExposure: float;
  112774. /**
  112775. * Gets The camera contrast used on this material.
  112776. */
  112777. /**
  112778. * Sets The camera contrast used on this material.
  112779. */
  112780. cameraContrast: float;
  112781. /**
  112782. * Gets the Color Grading 2D Lookup Texture.
  112783. */
  112784. /**
  112785. * Sets the Color Grading 2D Lookup Texture.
  112786. */
  112787. cameraColorGradingTexture: Nullable<BaseTexture>;
  112788. /**
  112789. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112790. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112791. * 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;
  112792. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112793. */
  112794. /**
  112795. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112796. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112797. * 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;
  112798. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112799. */
  112800. cameraColorCurves: Nullable<ColorCurves>;
  112801. /**
  112802. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112803. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112804. */
  112805. switchToBGR: boolean;
  112806. private _renderTargets;
  112807. private _reflectionControls;
  112808. private _white;
  112809. private _primaryShadowColor;
  112810. private _primaryHighlightColor;
  112811. /**
  112812. * Instantiates a Background Material in the given scene
  112813. * @param name The friendly name of the material
  112814. * @param scene The scene to add the material to
  112815. */
  112816. constructor(name: string, scene: Scene);
  112817. /**
  112818. * Gets a boolean indicating that current material needs to register RTT
  112819. */
  112820. readonly hasRenderTargetTextures: boolean;
  112821. /**
  112822. * The entire material has been created in order to prevent overdraw.
  112823. * @returns false
  112824. */
  112825. needAlphaTesting(): boolean;
  112826. /**
  112827. * The entire material has been created in order to prevent overdraw.
  112828. * @returns true if blending is enable
  112829. */
  112830. needAlphaBlending(): boolean;
  112831. /**
  112832. * Checks wether the material is ready to be rendered for a given mesh.
  112833. * @param mesh The mesh to render
  112834. * @param subMesh The submesh to check against
  112835. * @param useInstances Specify wether or not the material is used with instances
  112836. * @returns true if all the dependencies are ready (Textures, Effects...)
  112837. */
  112838. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112839. /**
  112840. * Compute the primary color according to the chosen perceptual color.
  112841. */
  112842. private _computePrimaryColorFromPerceptualColor;
  112843. /**
  112844. * Compute the highlights and shadow colors according to their chosen levels.
  112845. */
  112846. private _computePrimaryColors;
  112847. /**
  112848. * Build the uniform buffer used in the material.
  112849. */
  112850. buildUniformLayout(): void;
  112851. /**
  112852. * Unbind the material.
  112853. */
  112854. unbind(): void;
  112855. /**
  112856. * Bind only the world matrix to the material.
  112857. * @param world The world matrix to bind.
  112858. */
  112859. bindOnlyWorldMatrix(world: Matrix): void;
  112860. /**
  112861. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112862. * @param world The world matrix to bind.
  112863. * @param subMesh The submesh to bind for.
  112864. */
  112865. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112866. /**
  112867. * Checks to see if a texture is used in the material.
  112868. * @param texture - Base texture to use.
  112869. * @returns - Boolean specifying if a texture is used in the material.
  112870. */
  112871. hasTexture(texture: BaseTexture): boolean;
  112872. /**
  112873. * Dispose the material.
  112874. * @param forceDisposeEffect Force disposal of the associated effect.
  112875. * @param forceDisposeTextures Force disposal of the associated textures.
  112876. */
  112877. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112878. /**
  112879. * Clones the material.
  112880. * @param name The cloned name.
  112881. * @returns The cloned material.
  112882. */
  112883. clone(name: string): BackgroundMaterial;
  112884. /**
  112885. * Serializes the current material to its JSON representation.
  112886. * @returns The JSON representation.
  112887. */
  112888. serialize(): any;
  112889. /**
  112890. * Gets the class name of the material
  112891. * @returns "BackgroundMaterial"
  112892. */
  112893. getClassName(): string;
  112894. /**
  112895. * Parse a JSON input to create back a background material.
  112896. * @param source The JSON data to parse
  112897. * @param scene The scene to create the parsed material in
  112898. * @param rootUrl The root url of the assets the material depends upon
  112899. * @returns the instantiated BackgroundMaterial.
  112900. */
  112901. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112902. }
  112903. }
  112904. declare module BABYLON {
  112905. /**
  112906. * Represents the different options available during the creation of
  112907. * a Environment helper.
  112908. *
  112909. * This can control the default ground, skybox and image processing setup of your scene.
  112910. */
  112911. export interface IEnvironmentHelperOptions {
  112912. /**
  112913. * Specifies wether or not to create a ground.
  112914. * True by default.
  112915. */
  112916. createGround: boolean;
  112917. /**
  112918. * Specifies the ground size.
  112919. * 15 by default.
  112920. */
  112921. groundSize: number;
  112922. /**
  112923. * The texture used on the ground for the main color.
  112924. * Comes from the BabylonJS CDN by default.
  112925. *
  112926. * Remarks: Can be either a texture or a url.
  112927. */
  112928. groundTexture: string | BaseTexture;
  112929. /**
  112930. * The color mixed in the ground texture by default.
  112931. * BabylonJS clearColor by default.
  112932. */
  112933. groundColor: Color3;
  112934. /**
  112935. * Specifies the ground opacity.
  112936. * 1 by default.
  112937. */
  112938. groundOpacity: number;
  112939. /**
  112940. * Enables the ground to receive shadows.
  112941. * True by default.
  112942. */
  112943. enableGroundShadow: boolean;
  112944. /**
  112945. * Helps preventing the shadow to be fully black on the ground.
  112946. * 0.5 by default.
  112947. */
  112948. groundShadowLevel: number;
  112949. /**
  112950. * Creates a mirror texture attach to the ground.
  112951. * false by default.
  112952. */
  112953. enableGroundMirror: boolean;
  112954. /**
  112955. * Specifies the ground mirror size ratio.
  112956. * 0.3 by default as the default kernel is 64.
  112957. */
  112958. groundMirrorSizeRatio: number;
  112959. /**
  112960. * Specifies the ground mirror blur kernel size.
  112961. * 64 by default.
  112962. */
  112963. groundMirrorBlurKernel: number;
  112964. /**
  112965. * Specifies the ground mirror visibility amount.
  112966. * 1 by default
  112967. */
  112968. groundMirrorAmount: number;
  112969. /**
  112970. * Specifies the ground mirror reflectance weight.
  112971. * This uses the standard weight of the background material to setup the fresnel effect
  112972. * of the mirror.
  112973. * 1 by default.
  112974. */
  112975. groundMirrorFresnelWeight: number;
  112976. /**
  112977. * Specifies the ground mirror Falloff distance.
  112978. * This can helps reducing the size of the reflection.
  112979. * 0 by Default.
  112980. */
  112981. groundMirrorFallOffDistance: number;
  112982. /**
  112983. * Specifies the ground mirror texture type.
  112984. * Unsigned Int by Default.
  112985. */
  112986. groundMirrorTextureType: number;
  112987. /**
  112988. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112989. * the shown objects.
  112990. */
  112991. groundYBias: number;
  112992. /**
  112993. * Specifies wether or not to create a skybox.
  112994. * True by default.
  112995. */
  112996. createSkybox: boolean;
  112997. /**
  112998. * Specifies the skybox size.
  112999. * 20 by default.
  113000. */
  113001. skyboxSize: number;
  113002. /**
  113003. * The texture used on the skybox for the main color.
  113004. * Comes from the BabylonJS CDN by default.
  113005. *
  113006. * Remarks: Can be either a texture or a url.
  113007. */
  113008. skyboxTexture: string | BaseTexture;
  113009. /**
  113010. * The color mixed in the skybox texture by default.
  113011. * BabylonJS clearColor by default.
  113012. */
  113013. skyboxColor: Color3;
  113014. /**
  113015. * The background rotation around the Y axis of the scene.
  113016. * This helps aligning the key lights of your scene with the background.
  113017. * 0 by default.
  113018. */
  113019. backgroundYRotation: number;
  113020. /**
  113021. * Compute automatically the size of the elements to best fit with the scene.
  113022. */
  113023. sizeAuto: boolean;
  113024. /**
  113025. * Default position of the rootMesh if autoSize is not true.
  113026. */
  113027. rootPosition: Vector3;
  113028. /**
  113029. * Sets up the image processing in the scene.
  113030. * true by default.
  113031. */
  113032. setupImageProcessing: boolean;
  113033. /**
  113034. * The texture used as your environment texture in the scene.
  113035. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  113036. *
  113037. * Remarks: Can be either a texture or a url.
  113038. */
  113039. environmentTexture: string | BaseTexture;
  113040. /**
  113041. * The value of the exposure to apply to the scene.
  113042. * 0.6 by default if setupImageProcessing is true.
  113043. */
  113044. cameraExposure: number;
  113045. /**
  113046. * The value of the contrast to apply to the scene.
  113047. * 1.6 by default if setupImageProcessing is true.
  113048. */
  113049. cameraContrast: number;
  113050. /**
  113051. * Specifies wether or not tonemapping should be enabled in the scene.
  113052. * true by default if setupImageProcessing is true.
  113053. */
  113054. toneMappingEnabled: boolean;
  113055. }
  113056. /**
  113057. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  113058. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  113059. * It also helps with the default setup of your imageProcessing configuration.
  113060. */
  113061. export class EnvironmentHelper {
  113062. /**
  113063. * Default ground texture URL.
  113064. */
  113065. private static _groundTextureCDNUrl;
  113066. /**
  113067. * Default skybox texture URL.
  113068. */
  113069. private static _skyboxTextureCDNUrl;
  113070. /**
  113071. * Default environment texture URL.
  113072. */
  113073. private static _environmentTextureCDNUrl;
  113074. /**
  113075. * Creates the default options for the helper.
  113076. */
  113077. private static _getDefaultOptions;
  113078. private _rootMesh;
  113079. /**
  113080. * Gets the root mesh created by the helper.
  113081. */
  113082. readonly rootMesh: Mesh;
  113083. private _skybox;
  113084. /**
  113085. * Gets the skybox created by the helper.
  113086. */
  113087. readonly skybox: Nullable<Mesh>;
  113088. private _skyboxTexture;
  113089. /**
  113090. * Gets the skybox texture created by the helper.
  113091. */
  113092. readonly skyboxTexture: Nullable<BaseTexture>;
  113093. private _skyboxMaterial;
  113094. /**
  113095. * Gets the skybox material created by the helper.
  113096. */
  113097. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113098. private _ground;
  113099. /**
  113100. * Gets the ground mesh created by the helper.
  113101. */
  113102. readonly ground: Nullable<Mesh>;
  113103. private _groundTexture;
  113104. /**
  113105. * Gets the ground texture created by the helper.
  113106. */
  113107. readonly groundTexture: Nullable<BaseTexture>;
  113108. private _groundMirror;
  113109. /**
  113110. * Gets the ground mirror created by the helper.
  113111. */
  113112. readonly groundMirror: Nullable<MirrorTexture>;
  113113. /**
  113114. * Gets the ground mirror render list to helps pushing the meshes
  113115. * you wish in the ground reflection.
  113116. */
  113117. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113118. private _groundMaterial;
  113119. /**
  113120. * Gets the ground material created by the helper.
  113121. */
  113122. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113123. /**
  113124. * Stores the creation options.
  113125. */
  113126. private readonly _scene;
  113127. private _options;
  113128. /**
  113129. * This observable will be notified with any error during the creation of the environment,
  113130. * mainly texture creation errors.
  113131. */
  113132. onErrorObservable: Observable<{
  113133. message?: string;
  113134. exception?: any;
  113135. }>;
  113136. /**
  113137. * constructor
  113138. * @param options Defines the options we want to customize the helper
  113139. * @param scene The scene to add the material to
  113140. */
  113141. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113142. /**
  113143. * Updates the background according to the new options
  113144. * @param options
  113145. */
  113146. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113147. /**
  113148. * Sets the primary color of all the available elements.
  113149. * @param color the main color to affect to the ground and the background
  113150. */
  113151. setMainColor(color: Color3): void;
  113152. /**
  113153. * Setup the image processing according to the specified options.
  113154. */
  113155. private _setupImageProcessing;
  113156. /**
  113157. * Setup the environment texture according to the specified options.
  113158. */
  113159. private _setupEnvironmentTexture;
  113160. /**
  113161. * Setup the background according to the specified options.
  113162. */
  113163. private _setupBackground;
  113164. /**
  113165. * Get the scene sizes according to the setup.
  113166. */
  113167. private _getSceneSize;
  113168. /**
  113169. * Setup the ground according to the specified options.
  113170. */
  113171. private _setupGround;
  113172. /**
  113173. * Setup the ground material according to the specified options.
  113174. */
  113175. private _setupGroundMaterial;
  113176. /**
  113177. * Setup the ground diffuse texture according to the specified options.
  113178. */
  113179. private _setupGroundDiffuseTexture;
  113180. /**
  113181. * Setup the ground mirror texture according to the specified options.
  113182. */
  113183. private _setupGroundMirrorTexture;
  113184. /**
  113185. * Setup the ground to receive the mirror texture.
  113186. */
  113187. private _setupMirrorInGroundMaterial;
  113188. /**
  113189. * Setup the skybox according to the specified options.
  113190. */
  113191. private _setupSkybox;
  113192. /**
  113193. * Setup the skybox material according to the specified options.
  113194. */
  113195. private _setupSkyboxMaterial;
  113196. /**
  113197. * Setup the skybox reflection texture according to the specified options.
  113198. */
  113199. private _setupSkyboxReflectionTexture;
  113200. private _errorHandler;
  113201. /**
  113202. * Dispose all the elements created by the Helper.
  113203. */
  113204. dispose(): void;
  113205. }
  113206. }
  113207. declare module BABYLON {
  113208. /**
  113209. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113210. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113211. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113212. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113213. */
  113214. export class PhotoDome extends TransformNode {
  113215. /**
  113216. * Define the image as a Monoscopic panoramic 360 image.
  113217. */
  113218. static readonly MODE_MONOSCOPIC: number;
  113219. /**
  113220. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113221. */
  113222. static readonly MODE_TOPBOTTOM: number;
  113223. /**
  113224. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113225. */
  113226. static readonly MODE_SIDEBYSIDE: number;
  113227. private _useDirectMapping;
  113228. /**
  113229. * The texture being displayed on the sphere
  113230. */
  113231. protected _photoTexture: Texture;
  113232. /**
  113233. * Gets or sets the texture being displayed on the sphere
  113234. */
  113235. photoTexture: Texture;
  113236. /**
  113237. * Observable raised when an error occured while loading the 360 image
  113238. */
  113239. onLoadErrorObservable: Observable<string>;
  113240. /**
  113241. * The skybox material
  113242. */
  113243. protected _material: BackgroundMaterial;
  113244. /**
  113245. * The surface used for the skybox
  113246. */
  113247. protected _mesh: Mesh;
  113248. /**
  113249. * Gets the mesh used for the skybox.
  113250. */
  113251. readonly mesh: Mesh;
  113252. /**
  113253. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113254. * Also see the options.resolution property.
  113255. */
  113256. fovMultiplier: number;
  113257. private _imageMode;
  113258. /**
  113259. * Gets or set the current video mode for the video. It can be:
  113260. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113261. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113262. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113263. */
  113264. imageMode: number;
  113265. /**
  113266. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113267. * @param name Element's name, child elements will append suffixes for their own names.
  113268. * @param urlsOfPhoto defines the url of the photo to display
  113269. * @param options defines an object containing optional or exposed sub element properties
  113270. * @param onError defines a callback called when an error occured while loading the texture
  113271. */
  113272. constructor(name: string, urlOfPhoto: string, options: {
  113273. resolution?: number;
  113274. size?: number;
  113275. useDirectMapping?: boolean;
  113276. faceForward?: boolean;
  113277. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113278. private _onBeforeCameraRenderObserver;
  113279. private _changeImageMode;
  113280. /**
  113281. * Releases resources associated with this node.
  113282. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113283. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113284. */
  113285. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113286. }
  113287. }
  113288. declare module BABYLON {
  113289. /**
  113290. * Class used to host RGBD texture specific utilities
  113291. */
  113292. export class RGBDTextureTools {
  113293. /**
  113294. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113295. * @param texture the texture to expand.
  113296. */
  113297. static ExpandRGBDTexture(texture: Texture): void;
  113298. }
  113299. }
  113300. declare module BABYLON {
  113301. /**
  113302. * Class used to host texture specific utilities
  113303. */
  113304. export class BRDFTextureTools {
  113305. /**
  113306. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113307. * @param scene defines the hosting scene
  113308. * @returns the environment BRDF texture
  113309. */
  113310. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113311. private static _environmentBRDFBase64Texture;
  113312. }
  113313. }
  113314. declare module BABYLON {
  113315. /**
  113316. * @hidden
  113317. */
  113318. export interface IMaterialClearCoatDefines {
  113319. CLEARCOAT: boolean;
  113320. CLEARCOAT_DEFAULTIOR: boolean;
  113321. CLEARCOAT_TEXTURE: boolean;
  113322. CLEARCOAT_TEXTUREDIRECTUV: number;
  113323. CLEARCOAT_BUMP: boolean;
  113324. CLEARCOAT_BUMPDIRECTUV: number;
  113325. CLEARCOAT_TINT: boolean;
  113326. CLEARCOAT_TINT_TEXTURE: boolean;
  113327. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113328. /** @hidden */
  113329. _areTexturesDirty: boolean;
  113330. }
  113331. /**
  113332. * Define the code related to the clear coat parameters of the pbr material.
  113333. */
  113334. export class PBRClearCoatConfiguration {
  113335. /**
  113336. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113337. * The default fits with a polyurethane material.
  113338. */
  113339. private static readonly _DefaultIndexOfRefraction;
  113340. private _isEnabled;
  113341. /**
  113342. * Defines if the clear coat is enabled in the material.
  113343. */
  113344. isEnabled: boolean;
  113345. /**
  113346. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113347. */
  113348. intensity: number;
  113349. /**
  113350. * Defines the clear coat layer roughness.
  113351. */
  113352. roughness: number;
  113353. private _indexOfRefraction;
  113354. /**
  113355. * Defines the index of refraction of the clear coat.
  113356. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113357. * The default fits with a polyurethane material.
  113358. * Changing the default value is more performance intensive.
  113359. */
  113360. indexOfRefraction: number;
  113361. private _texture;
  113362. /**
  113363. * Stores the clear coat values in a texture.
  113364. */
  113365. texture: Nullable<BaseTexture>;
  113366. private _bumpTexture;
  113367. /**
  113368. * Define the clear coat specific bump texture.
  113369. */
  113370. bumpTexture: Nullable<BaseTexture>;
  113371. private _isTintEnabled;
  113372. /**
  113373. * Defines if the clear coat tint is enabled in the material.
  113374. */
  113375. isTintEnabled: boolean;
  113376. /**
  113377. * Defines the clear coat tint of the material.
  113378. * This is only use if tint is enabled
  113379. */
  113380. tintColor: Color3;
  113381. /**
  113382. * Defines the distance at which the tint color should be found in the
  113383. * clear coat media.
  113384. * This is only use if tint is enabled
  113385. */
  113386. tintColorAtDistance: number;
  113387. /**
  113388. * Defines the clear coat layer thickness.
  113389. * This is only use if tint is enabled
  113390. */
  113391. tintThickness: number;
  113392. private _tintTexture;
  113393. /**
  113394. * Stores the clear tint values in a texture.
  113395. * rgb is tint
  113396. * a is a thickness factor
  113397. */
  113398. tintTexture: Nullable<BaseTexture>;
  113399. /** @hidden */
  113400. private _internalMarkAllSubMeshesAsTexturesDirty;
  113401. /** @hidden */
  113402. _markAllSubMeshesAsTexturesDirty(): void;
  113403. /**
  113404. * Instantiate a new istance of clear coat configuration.
  113405. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113406. */
  113407. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113408. /**
  113409. * Gets wehter the submesh is ready to be used or not.
  113410. * @param defines the list of "defines" to update.
  113411. * @param scene defines the scene the material belongs to.
  113412. * @param engine defines the engine the material belongs to.
  113413. * @param disableBumpMap defines wether the material disables bump or not.
  113414. * @returns - boolean indicating that the submesh is ready or not.
  113415. */
  113416. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113417. /**
  113418. * Checks to see if a texture is used in the material.
  113419. * @param defines the list of "defines" to update.
  113420. * @param scene defines the scene to the material belongs to.
  113421. */
  113422. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113423. /**
  113424. * Binds the material data.
  113425. * @param uniformBuffer defines the Uniform buffer to fill in.
  113426. * @param scene defines the scene the material belongs to.
  113427. * @param engine defines the engine the material belongs to.
  113428. * @param disableBumpMap defines wether the material disables bump or not.
  113429. * @param isFrozen defines wether the material is frozen or not.
  113430. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113431. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113432. */
  113433. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113434. /**
  113435. * Checks to see if a texture is used in the material.
  113436. * @param texture - Base texture to use.
  113437. * @returns - Boolean specifying if a texture is used in the material.
  113438. */
  113439. hasTexture(texture: BaseTexture): boolean;
  113440. /**
  113441. * Returns an array of the actively used textures.
  113442. * @param activeTextures Array of BaseTextures
  113443. */
  113444. getActiveTextures(activeTextures: BaseTexture[]): void;
  113445. /**
  113446. * Returns the animatable textures.
  113447. * @param animatables Array of animatable textures.
  113448. */
  113449. getAnimatables(animatables: IAnimatable[]): void;
  113450. /**
  113451. * Disposes the resources of the material.
  113452. * @param forceDisposeTextures - Forces the disposal of all textures.
  113453. */
  113454. dispose(forceDisposeTextures?: boolean): void;
  113455. /**
  113456. * Get the current class name of the texture useful for serialization or dynamic coding.
  113457. * @returns "PBRClearCoatConfiguration"
  113458. */
  113459. getClassName(): string;
  113460. /**
  113461. * Add fallbacks to the effect fallbacks list.
  113462. * @param defines defines the Base texture to use.
  113463. * @param fallbacks defines the current fallback list.
  113464. * @param currentRank defines the current fallback rank.
  113465. * @returns the new fallback rank.
  113466. */
  113467. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113468. /**
  113469. * Add the required uniforms to the current list.
  113470. * @param uniforms defines the current uniform list.
  113471. */
  113472. static AddUniforms(uniforms: string[]): void;
  113473. /**
  113474. * Add the required samplers to the current list.
  113475. * @param samplers defines the current sampler list.
  113476. */
  113477. static AddSamplers(samplers: string[]): void;
  113478. /**
  113479. * Add the required uniforms to the current buffer.
  113480. * @param uniformBuffer defines the current uniform buffer.
  113481. */
  113482. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113483. /**
  113484. * Makes a duplicate of the current configuration into another one.
  113485. * @param clearCoatConfiguration define the config where to copy the info
  113486. */
  113487. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113488. /**
  113489. * Serializes this clear coat configuration.
  113490. * @returns - An object with the serialized config.
  113491. */
  113492. serialize(): any;
  113493. /**
  113494. * Parses a anisotropy Configuration from a serialized object.
  113495. * @param source - Serialized object.
  113496. * @param scene Defines the scene we are parsing for
  113497. * @param rootUrl Defines the rootUrl to load from
  113498. */
  113499. parse(source: any, scene: Scene, rootUrl: string): void;
  113500. }
  113501. }
  113502. declare module BABYLON {
  113503. /**
  113504. * @hidden
  113505. */
  113506. export interface IMaterialAnisotropicDefines {
  113507. ANISOTROPIC: boolean;
  113508. ANISOTROPIC_TEXTURE: boolean;
  113509. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113510. MAINUV1: boolean;
  113511. _areTexturesDirty: boolean;
  113512. _needUVs: boolean;
  113513. }
  113514. /**
  113515. * Define the code related to the anisotropic parameters of the pbr material.
  113516. */
  113517. export class PBRAnisotropicConfiguration {
  113518. private _isEnabled;
  113519. /**
  113520. * Defines if the anisotropy is enabled in the material.
  113521. */
  113522. isEnabled: boolean;
  113523. /**
  113524. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113525. */
  113526. intensity: number;
  113527. /**
  113528. * Defines if the effect is along the tangents, bitangents or in between.
  113529. * By default, the effect is "strectching" the highlights along the tangents.
  113530. */
  113531. direction: Vector2;
  113532. private _texture;
  113533. /**
  113534. * Stores the anisotropy values in a texture.
  113535. * rg is direction (like normal from -1 to 1)
  113536. * b is a intensity
  113537. */
  113538. texture: Nullable<BaseTexture>;
  113539. /** @hidden */
  113540. private _internalMarkAllSubMeshesAsTexturesDirty;
  113541. /** @hidden */
  113542. _markAllSubMeshesAsTexturesDirty(): void;
  113543. /**
  113544. * Instantiate a new istance of anisotropy configuration.
  113545. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113546. */
  113547. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113548. /**
  113549. * Specifies that the submesh is ready to be used.
  113550. * @param defines the list of "defines" to update.
  113551. * @param scene defines the scene the material belongs to.
  113552. * @returns - boolean indicating that the submesh is ready or not.
  113553. */
  113554. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113555. /**
  113556. * Checks to see if a texture is used in the material.
  113557. * @param defines the list of "defines" to update.
  113558. * @param mesh the mesh we are preparing the defines for.
  113559. * @param scene defines the scene the material belongs to.
  113560. */
  113561. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113562. /**
  113563. * Binds the material data.
  113564. * @param uniformBuffer defines the Uniform buffer to fill in.
  113565. * @param scene defines the scene the material belongs to.
  113566. * @param isFrozen defines wether the material is frozen or not.
  113567. */
  113568. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113569. /**
  113570. * Checks to see if a texture is used in the material.
  113571. * @param texture - Base texture to use.
  113572. * @returns - Boolean specifying if a texture is used in the material.
  113573. */
  113574. hasTexture(texture: BaseTexture): boolean;
  113575. /**
  113576. * Returns an array of the actively used textures.
  113577. * @param activeTextures Array of BaseTextures
  113578. */
  113579. getActiveTextures(activeTextures: BaseTexture[]): void;
  113580. /**
  113581. * Returns the animatable textures.
  113582. * @param animatables Array of animatable textures.
  113583. */
  113584. getAnimatables(animatables: IAnimatable[]): void;
  113585. /**
  113586. * Disposes the resources of the material.
  113587. * @param forceDisposeTextures - Forces the disposal of all textures.
  113588. */
  113589. dispose(forceDisposeTextures?: boolean): void;
  113590. /**
  113591. * Get the current class name of the texture useful for serialization or dynamic coding.
  113592. * @returns "PBRAnisotropicConfiguration"
  113593. */
  113594. getClassName(): string;
  113595. /**
  113596. * Add fallbacks to the effect fallbacks list.
  113597. * @param defines defines the Base texture to use.
  113598. * @param fallbacks defines the current fallback list.
  113599. * @param currentRank defines the current fallback rank.
  113600. * @returns the new fallback rank.
  113601. */
  113602. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113603. /**
  113604. * Add the required uniforms to the current list.
  113605. * @param uniforms defines the current uniform list.
  113606. */
  113607. static AddUniforms(uniforms: string[]): void;
  113608. /**
  113609. * Add the required uniforms to the current buffer.
  113610. * @param uniformBuffer defines the current uniform buffer.
  113611. */
  113612. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113613. /**
  113614. * Add the required samplers to the current list.
  113615. * @param samplers defines the current sampler list.
  113616. */
  113617. static AddSamplers(samplers: string[]): void;
  113618. /**
  113619. * Makes a duplicate of the current configuration into another one.
  113620. * @param anisotropicConfiguration define the config where to copy the info
  113621. */
  113622. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113623. /**
  113624. * Serializes this anisotropy configuration.
  113625. * @returns - An object with the serialized config.
  113626. */
  113627. serialize(): any;
  113628. /**
  113629. * Parses a anisotropy Configuration from a serialized object.
  113630. * @param source - Serialized object.
  113631. * @param scene Defines the scene we are parsing for
  113632. * @param rootUrl Defines the rootUrl to load from
  113633. */
  113634. parse(source: any, scene: Scene, rootUrl: string): void;
  113635. }
  113636. }
  113637. declare module BABYLON {
  113638. /**
  113639. * @hidden
  113640. */
  113641. export interface IMaterialBRDFDefines {
  113642. BRDF_V_HEIGHT_CORRELATED: boolean;
  113643. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113644. SPHERICAL_HARMONICS: boolean;
  113645. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113646. /** @hidden */
  113647. _areMiscDirty: boolean;
  113648. }
  113649. /**
  113650. * Define the code related to the BRDF parameters of the pbr material.
  113651. */
  113652. export class PBRBRDFConfiguration {
  113653. /**
  113654. * Default value used for the energy conservation.
  113655. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113656. */
  113657. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113658. /**
  113659. * Default value used for the Smith Visibility Height Correlated mode.
  113660. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113661. */
  113662. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113663. /**
  113664. * Default value used for the IBL diffuse part.
  113665. * This can help switching back to the polynomials mode globally which is a tiny bit
  113666. * less GPU intensive at the drawback of a lower quality.
  113667. */
  113668. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113669. /**
  113670. * Default value used for activating energy conservation for the specular workflow.
  113671. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113672. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113673. */
  113674. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113675. private _useEnergyConservation;
  113676. /**
  113677. * Defines if the material uses energy conservation.
  113678. */
  113679. useEnergyConservation: boolean;
  113680. private _useSmithVisibilityHeightCorrelated;
  113681. /**
  113682. * LEGACY Mode set to false
  113683. * Defines if the material uses height smith correlated visibility term.
  113684. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113685. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113686. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113687. * Not relying on height correlated will also disable energy conservation.
  113688. */
  113689. useSmithVisibilityHeightCorrelated: boolean;
  113690. private _useSphericalHarmonics;
  113691. /**
  113692. * LEGACY Mode set to false
  113693. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113694. * diffuse part of the IBL.
  113695. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113696. * to the ground truth.
  113697. */
  113698. useSphericalHarmonics: boolean;
  113699. private _useSpecularGlossinessInputEnergyConservation;
  113700. /**
  113701. * Defines if the material uses energy conservation, when the specular workflow is active.
  113702. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113703. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113704. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113705. */
  113706. useSpecularGlossinessInputEnergyConservation: boolean;
  113707. /** @hidden */
  113708. private _internalMarkAllSubMeshesAsMiscDirty;
  113709. /** @hidden */
  113710. _markAllSubMeshesAsMiscDirty(): void;
  113711. /**
  113712. * Instantiate a new istance of clear coat configuration.
  113713. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113714. */
  113715. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113716. /**
  113717. * Checks to see if a texture is used in the material.
  113718. * @param defines the list of "defines" to update.
  113719. */
  113720. prepareDefines(defines: IMaterialBRDFDefines): void;
  113721. /**
  113722. * Get the current class name of the texture useful for serialization or dynamic coding.
  113723. * @returns "PBRClearCoatConfiguration"
  113724. */
  113725. getClassName(): string;
  113726. /**
  113727. * Makes a duplicate of the current configuration into another one.
  113728. * @param brdfConfiguration define the config where to copy the info
  113729. */
  113730. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113731. /**
  113732. * Serializes this BRDF configuration.
  113733. * @returns - An object with the serialized config.
  113734. */
  113735. serialize(): any;
  113736. /**
  113737. * Parses a anisotropy Configuration from a serialized object.
  113738. * @param source - Serialized object.
  113739. * @param scene Defines the scene we are parsing for
  113740. * @param rootUrl Defines the rootUrl to load from
  113741. */
  113742. parse(source: any, scene: Scene, rootUrl: string): void;
  113743. }
  113744. }
  113745. declare module BABYLON {
  113746. /**
  113747. * @hidden
  113748. */
  113749. export interface IMaterialSheenDefines {
  113750. SHEEN: boolean;
  113751. SHEEN_TEXTURE: boolean;
  113752. SHEEN_TEXTUREDIRECTUV: number;
  113753. SHEEN_LINKWITHALBEDO: boolean;
  113754. /** @hidden */
  113755. _areTexturesDirty: boolean;
  113756. }
  113757. /**
  113758. * Define the code related to the Sheen parameters of the pbr material.
  113759. */
  113760. export class PBRSheenConfiguration {
  113761. private _isEnabled;
  113762. /**
  113763. * Defines if the material uses sheen.
  113764. */
  113765. isEnabled: boolean;
  113766. private _linkSheenWithAlbedo;
  113767. /**
  113768. * Defines if the sheen is linked to the sheen color.
  113769. */
  113770. linkSheenWithAlbedo: boolean;
  113771. /**
  113772. * Defines the sheen intensity.
  113773. */
  113774. intensity: number;
  113775. /**
  113776. * Defines the sheen color.
  113777. */
  113778. color: Color3;
  113779. private _texture;
  113780. /**
  113781. * Stores the sheen tint values in a texture.
  113782. * rgb is tint
  113783. * a is a intensity
  113784. */
  113785. texture: Nullable<BaseTexture>;
  113786. /** @hidden */
  113787. private _internalMarkAllSubMeshesAsTexturesDirty;
  113788. /** @hidden */
  113789. _markAllSubMeshesAsTexturesDirty(): void;
  113790. /**
  113791. * Instantiate a new istance of clear coat configuration.
  113792. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113793. */
  113794. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113795. /**
  113796. * Specifies that the submesh is ready to be used.
  113797. * @param defines the list of "defines" to update.
  113798. * @param scene defines the scene the material belongs to.
  113799. * @returns - boolean indicating that the submesh is ready or not.
  113800. */
  113801. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113802. /**
  113803. * Checks to see if a texture is used in the material.
  113804. * @param defines the list of "defines" to update.
  113805. * @param scene defines the scene the material belongs to.
  113806. */
  113807. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113808. /**
  113809. * Binds the material data.
  113810. * @param uniformBuffer defines the Uniform buffer to fill in.
  113811. * @param scene defines the scene the material belongs to.
  113812. * @param isFrozen defines wether the material is frozen or not.
  113813. */
  113814. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113815. /**
  113816. * Checks to see if a texture is used in the material.
  113817. * @param texture - Base texture to use.
  113818. * @returns - Boolean specifying if a texture is used in the material.
  113819. */
  113820. hasTexture(texture: BaseTexture): boolean;
  113821. /**
  113822. * Returns an array of the actively used textures.
  113823. * @param activeTextures Array of BaseTextures
  113824. */
  113825. getActiveTextures(activeTextures: BaseTexture[]): void;
  113826. /**
  113827. * Returns the animatable textures.
  113828. * @param animatables Array of animatable textures.
  113829. */
  113830. getAnimatables(animatables: IAnimatable[]): void;
  113831. /**
  113832. * Disposes the resources of the material.
  113833. * @param forceDisposeTextures - Forces the disposal of all textures.
  113834. */
  113835. dispose(forceDisposeTextures?: boolean): void;
  113836. /**
  113837. * Get the current class name of the texture useful for serialization or dynamic coding.
  113838. * @returns "PBRSheenConfiguration"
  113839. */
  113840. getClassName(): string;
  113841. /**
  113842. * Add fallbacks to the effect fallbacks list.
  113843. * @param defines defines the Base texture to use.
  113844. * @param fallbacks defines the current fallback list.
  113845. * @param currentRank defines the current fallback rank.
  113846. * @returns the new fallback rank.
  113847. */
  113848. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113849. /**
  113850. * Add the required uniforms to the current list.
  113851. * @param uniforms defines the current uniform list.
  113852. */
  113853. static AddUniforms(uniforms: string[]): void;
  113854. /**
  113855. * Add the required uniforms to the current buffer.
  113856. * @param uniformBuffer defines the current uniform buffer.
  113857. */
  113858. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113859. /**
  113860. * Add the required samplers to the current list.
  113861. * @param samplers defines the current sampler list.
  113862. */
  113863. static AddSamplers(samplers: string[]): void;
  113864. /**
  113865. * Makes a duplicate of the current configuration into another one.
  113866. * @param sheenConfiguration define the config where to copy the info
  113867. */
  113868. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113869. /**
  113870. * Serializes this BRDF configuration.
  113871. * @returns - An object with the serialized config.
  113872. */
  113873. serialize(): any;
  113874. /**
  113875. * Parses a anisotropy Configuration from a serialized object.
  113876. * @param source - Serialized object.
  113877. * @param scene Defines the scene we are parsing for
  113878. * @param rootUrl Defines the rootUrl to load from
  113879. */
  113880. parse(source: any, scene: Scene, rootUrl: string): void;
  113881. }
  113882. }
  113883. declare module BABYLON {
  113884. /**
  113885. * @hidden
  113886. */
  113887. export interface IMaterialSubSurfaceDefines {
  113888. SUBSURFACE: boolean;
  113889. SS_REFRACTION: boolean;
  113890. SS_TRANSLUCENCY: boolean;
  113891. SS_SCATERRING: boolean;
  113892. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113893. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113894. SS_REFRACTIONMAP_3D: boolean;
  113895. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113896. SS_LODINREFRACTIONALPHA: boolean;
  113897. SS_GAMMAREFRACTION: boolean;
  113898. SS_RGBDREFRACTION: boolean;
  113899. SS_LINEARSPECULARREFRACTION: boolean;
  113900. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113901. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113902. /** @hidden */
  113903. _areTexturesDirty: boolean;
  113904. }
  113905. /**
  113906. * Define the code related to the sub surface parameters of the pbr material.
  113907. */
  113908. export class PBRSubSurfaceConfiguration {
  113909. private _isRefractionEnabled;
  113910. /**
  113911. * Defines if the refraction is enabled in the material.
  113912. */
  113913. isRefractionEnabled: boolean;
  113914. private _isTranslucencyEnabled;
  113915. /**
  113916. * Defines if the translucency is enabled in the material.
  113917. */
  113918. isTranslucencyEnabled: boolean;
  113919. private _isScatteringEnabled;
  113920. /**
  113921. * Defines the refraction intensity of the material.
  113922. * The refraction when enabled replaces the Diffuse part of the material.
  113923. * The intensity helps transitionning between diffuse and refraction.
  113924. */
  113925. refractionIntensity: number;
  113926. /**
  113927. * Defines the translucency intensity of the material.
  113928. * When translucency has been enabled, this defines how much of the "translucency"
  113929. * is addded to the diffuse part of the material.
  113930. */
  113931. translucencyIntensity: number;
  113932. /**
  113933. * Defines the scattering intensity of the material.
  113934. * When scattering has been enabled, this defines how much of the "scattered light"
  113935. * is addded to the diffuse part of the material.
  113936. */
  113937. scatteringIntensity: number;
  113938. private _thicknessTexture;
  113939. /**
  113940. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113941. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113942. * 0 would mean minimumThickness
  113943. * 1 would mean maximumThickness
  113944. * The other channels might be use as a mask to vary the different effects intensity.
  113945. */
  113946. thicknessTexture: Nullable<BaseTexture>;
  113947. private _refractionTexture;
  113948. /**
  113949. * Defines the texture to use for refraction.
  113950. */
  113951. refractionTexture: Nullable<BaseTexture>;
  113952. private _indexOfRefraction;
  113953. /**
  113954. * Defines the index of refraction used in the material.
  113955. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113956. */
  113957. indexOfRefraction: number;
  113958. private _invertRefractionY;
  113959. /**
  113960. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113961. */
  113962. invertRefractionY: boolean;
  113963. private _linkRefractionWithTransparency;
  113964. /**
  113965. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113966. * Materials half opaque for instance using refraction could benefit from this control.
  113967. */
  113968. linkRefractionWithTransparency: boolean;
  113969. /**
  113970. * Defines the minimum thickness stored in the thickness map.
  113971. * If no thickness map is defined, this value will be used to simulate thickness.
  113972. */
  113973. minimumThickness: number;
  113974. /**
  113975. * Defines the maximum thickness stored in the thickness map.
  113976. */
  113977. maximumThickness: number;
  113978. /**
  113979. * Defines the volume tint of the material.
  113980. * This is used for both translucency and scattering.
  113981. */
  113982. tintColor: Color3;
  113983. /**
  113984. * Defines the distance at which the tint color should be found in the media.
  113985. * This is used for refraction only.
  113986. */
  113987. tintColorAtDistance: number;
  113988. /**
  113989. * Defines how far each channel transmit through the media.
  113990. * It is defined as a color to simplify it selection.
  113991. */
  113992. diffusionDistance: Color3;
  113993. private _useMaskFromThicknessTexture;
  113994. /**
  113995. * Stores the intensity of the different subsurface effects in the thickness texture.
  113996. * * the green channel is the translucency intensity.
  113997. * * the blue channel is the scattering intensity.
  113998. * * the alpha channel is the refraction intensity.
  113999. */
  114000. useMaskFromThicknessTexture: boolean;
  114001. /** @hidden */
  114002. private _internalMarkAllSubMeshesAsTexturesDirty;
  114003. /** @hidden */
  114004. _markAllSubMeshesAsTexturesDirty(): void;
  114005. /**
  114006. * Instantiate a new istance of sub surface configuration.
  114007. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  114008. */
  114009. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  114010. /**
  114011. * Gets wehter the submesh is ready to be used or not.
  114012. * @param defines the list of "defines" to update.
  114013. * @param scene defines the scene the material belongs to.
  114014. * @returns - boolean indicating that the submesh is ready or not.
  114015. */
  114016. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  114017. /**
  114018. * Checks to see if a texture is used in the material.
  114019. * @param defines the list of "defines" to update.
  114020. * @param scene defines the scene to the material belongs to.
  114021. */
  114022. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  114023. /**
  114024. * Binds the material data.
  114025. * @param uniformBuffer defines the Uniform buffer to fill in.
  114026. * @param scene defines the scene the material belongs to.
  114027. * @param engine defines the engine the material belongs to.
  114028. * @param isFrozen defines wether the material is frozen or not.
  114029. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  114030. */
  114031. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  114032. /**
  114033. * Unbinds the material from the mesh.
  114034. * @param activeEffect defines the effect that should be unbound from.
  114035. * @returns true if unbound, otherwise false
  114036. */
  114037. unbind(activeEffect: Effect): boolean;
  114038. /**
  114039. * Returns the texture used for refraction or null if none is used.
  114040. * @param scene defines the scene the material belongs to.
  114041. * @returns - Refraction texture if present. If no refraction texture and refraction
  114042. * is linked with transparency, returns environment texture. Otherwise, returns null.
  114043. */
  114044. private _getRefractionTexture;
  114045. /**
  114046. * Returns true if alpha blending should be disabled.
  114047. */
  114048. readonly disableAlphaBlending: boolean;
  114049. /**
  114050. * Fills the list of render target textures.
  114051. * @param renderTargets the list of render targets to update
  114052. */
  114053. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  114054. /**
  114055. * Checks to see if a texture is used in the material.
  114056. * @param texture - Base texture to use.
  114057. * @returns - Boolean specifying if a texture is used in the material.
  114058. */
  114059. hasTexture(texture: BaseTexture): boolean;
  114060. /**
  114061. * Gets a boolean indicating that current material needs to register RTT
  114062. * @returns true if this uses a render target otherwise false.
  114063. */
  114064. hasRenderTargetTextures(): boolean;
  114065. /**
  114066. * Returns an array of the actively used textures.
  114067. * @param activeTextures Array of BaseTextures
  114068. */
  114069. getActiveTextures(activeTextures: BaseTexture[]): void;
  114070. /**
  114071. * Returns the animatable textures.
  114072. * @param animatables Array of animatable textures.
  114073. */
  114074. getAnimatables(animatables: IAnimatable[]): void;
  114075. /**
  114076. * Disposes the resources of the material.
  114077. * @param forceDisposeTextures - Forces the disposal of all textures.
  114078. */
  114079. dispose(forceDisposeTextures?: boolean): void;
  114080. /**
  114081. * Get the current class name of the texture useful for serialization or dynamic coding.
  114082. * @returns "PBRSubSurfaceConfiguration"
  114083. */
  114084. getClassName(): string;
  114085. /**
  114086. * Add fallbacks to the effect fallbacks list.
  114087. * @param defines defines the Base texture to use.
  114088. * @param fallbacks defines the current fallback list.
  114089. * @param currentRank defines the current fallback rank.
  114090. * @returns the new fallback rank.
  114091. */
  114092. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  114093. /**
  114094. * Add the required uniforms to the current list.
  114095. * @param uniforms defines the current uniform list.
  114096. */
  114097. static AddUniforms(uniforms: string[]): void;
  114098. /**
  114099. * Add the required samplers to the current list.
  114100. * @param samplers defines the current sampler list.
  114101. */
  114102. static AddSamplers(samplers: string[]): void;
  114103. /**
  114104. * Add the required uniforms to the current buffer.
  114105. * @param uniformBuffer defines the current uniform buffer.
  114106. */
  114107. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114108. /**
  114109. * Makes a duplicate of the current configuration into another one.
  114110. * @param configuration define the config where to copy the info
  114111. */
  114112. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114113. /**
  114114. * Serializes this Sub Surface configuration.
  114115. * @returns - An object with the serialized config.
  114116. */
  114117. serialize(): any;
  114118. /**
  114119. * Parses a anisotropy Configuration from a serialized object.
  114120. * @param source - Serialized object.
  114121. * @param scene Defines the scene we are parsing for
  114122. * @param rootUrl Defines the rootUrl to load from
  114123. */
  114124. parse(source: any, scene: Scene, rootUrl: string): void;
  114125. }
  114126. }
  114127. declare module BABYLON {
  114128. /** @hidden */
  114129. export var pbrFragmentDeclaration: {
  114130. name: string;
  114131. shader: string;
  114132. };
  114133. }
  114134. declare module BABYLON {
  114135. /** @hidden */
  114136. export var pbrUboDeclaration: {
  114137. name: string;
  114138. shader: string;
  114139. };
  114140. }
  114141. declare module BABYLON {
  114142. /** @hidden */
  114143. export var pbrFragmentExtraDeclaration: {
  114144. name: string;
  114145. shader: string;
  114146. };
  114147. }
  114148. declare module BABYLON {
  114149. /** @hidden */
  114150. export var pbrFragmentSamplersDeclaration: {
  114151. name: string;
  114152. shader: string;
  114153. };
  114154. }
  114155. declare module BABYLON {
  114156. /** @hidden */
  114157. export var pbrHelperFunctions: {
  114158. name: string;
  114159. shader: string;
  114160. };
  114161. }
  114162. declare module BABYLON {
  114163. /** @hidden */
  114164. export var harmonicsFunctions: {
  114165. name: string;
  114166. shader: string;
  114167. };
  114168. }
  114169. declare module BABYLON {
  114170. /** @hidden */
  114171. export var pbrDirectLightingSetupFunctions: {
  114172. name: string;
  114173. shader: string;
  114174. };
  114175. }
  114176. declare module BABYLON {
  114177. /** @hidden */
  114178. export var pbrDirectLightingFalloffFunctions: {
  114179. name: string;
  114180. shader: string;
  114181. };
  114182. }
  114183. declare module BABYLON {
  114184. /** @hidden */
  114185. export var pbrBRDFFunctions: {
  114186. name: string;
  114187. shader: string;
  114188. };
  114189. }
  114190. declare module BABYLON {
  114191. /** @hidden */
  114192. export var pbrDirectLightingFunctions: {
  114193. name: string;
  114194. shader: string;
  114195. };
  114196. }
  114197. declare module BABYLON {
  114198. /** @hidden */
  114199. export var pbrIBLFunctions: {
  114200. name: string;
  114201. shader: string;
  114202. };
  114203. }
  114204. declare module BABYLON {
  114205. /** @hidden */
  114206. export var pbrDebug: {
  114207. name: string;
  114208. shader: string;
  114209. };
  114210. }
  114211. declare module BABYLON {
  114212. /** @hidden */
  114213. export var pbrPixelShader: {
  114214. name: string;
  114215. shader: string;
  114216. };
  114217. }
  114218. declare module BABYLON {
  114219. /** @hidden */
  114220. export var pbrVertexDeclaration: {
  114221. name: string;
  114222. shader: string;
  114223. };
  114224. }
  114225. declare module BABYLON {
  114226. /** @hidden */
  114227. export var pbrVertexShader: {
  114228. name: string;
  114229. shader: string;
  114230. };
  114231. }
  114232. declare module BABYLON {
  114233. /**
  114234. * Manages the defines for the PBR Material.
  114235. * @hidden
  114236. */
  114237. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114238. PBR: boolean;
  114239. MAINUV1: boolean;
  114240. MAINUV2: boolean;
  114241. UV1: boolean;
  114242. UV2: boolean;
  114243. ALBEDO: boolean;
  114244. ALBEDODIRECTUV: number;
  114245. VERTEXCOLOR: boolean;
  114246. AMBIENT: boolean;
  114247. AMBIENTDIRECTUV: number;
  114248. AMBIENTINGRAYSCALE: boolean;
  114249. OPACITY: boolean;
  114250. VERTEXALPHA: boolean;
  114251. OPACITYDIRECTUV: number;
  114252. OPACITYRGB: boolean;
  114253. ALPHATEST: boolean;
  114254. DEPTHPREPASS: boolean;
  114255. ALPHABLEND: boolean;
  114256. ALPHAFROMALBEDO: boolean;
  114257. ALPHATESTVALUE: string;
  114258. SPECULAROVERALPHA: boolean;
  114259. RADIANCEOVERALPHA: boolean;
  114260. ALPHAFRESNEL: boolean;
  114261. LINEARALPHAFRESNEL: boolean;
  114262. PREMULTIPLYALPHA: boolean;
  114263. EMISSIVE: boolean;
  114264. EMISSIVEDIRECTUV: number;
  114265. REFLECTIVITY: boolean;
  114266. REFLECTIVITYDIRECTUV: number;
  114267. SPECULARTERM: boolean;
  114268. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114269. MICROSURFACEAUTOMATIC: boolean;
  114270. LODBASEDMICROSFURACE: boolean;
  114271. MICROSURFACEMAP: boolean;
  114272. MICROSURFACEMAPDIRECTUV: number;
  114273. METALLICWORKFLOW: boolean;
  114274. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114275. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114276. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114277. AOSTOREINMETALMAPRED: boolean;
  114278. ENVIRONMENTBRDF: boolean;
  114279. ENVIRONMENTBRDF_RGBD: boolean;
  114280. NORMAL: boolean;
  114281. TANGENT: boolean;
  114282. BUMP: boolean;
  114283. BUMPDIRECTUV: number;
  114284. OBJECTSPACE_NORMALMAP: boolean;
  114285. PARALLAX: boolean;
  114286. PARALLAXOCCLUSION: boolean;
  114287. NORMALXYSCALE: boolean;
  114288. LIGHTMAP: boolean;
  114289. LIGHTMAPDIRECTUV: number;
  114290. USELIGHTMAPASSHADOWMAP: boolean;
  114291. GAMMALIGHTMAP: boolean;
  114292. RGBDLIGHTMAP: boolean;
  114293. REFLECTION: boolean;
  114294. REFLECTIONMAP_3D: boolean;
  114295. REFLECTIONMAP_SPHERICAL: boolean;
  114296. REFLECTIONMAP_PLANAR: boolean;
  114297. REFLECTIONMAP_CUBIC: boolean;
  114298. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114299. REFLECTIONMAP_PROJECTION: boolean;
  114300. REFLECTIONMAP_SKYBOX: boolean;
  114301. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114302. REFLECTIONMAP_EXPLICIT: boolean;
  114303. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114304. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114305. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114306. INVERTCUBICMAP: boolean;
  114307. USESPHERICALFROMREFLECTIONMAP: boolean;
  114308. USEIRRADIANCEMAP: boolean;
  114309. SPHERICAL_HARMONICS: boolean;
  114310. USESPHERICALINVERTEX: boolean;
  114311. REFLECTIONMAP_OPPOSITEZ: boolean;
  114312. LODINREFLECTIONALPHA: boolean;
  114313. GAMMAREFLECTION: boolean;
  114314. RGBDREFLECTION: boolean;
  114315. LINEARSPECULARREFLECTION: boolean;
  114316. RADIANCEOCCLUSION: boolean;
  114317. HORIZONOCCLUSION: boolean;
  114318. INSTANCES: boolean;
  114319. NUM_BONE_INFLUENCERS: number;
  114320. BonesPerMesh: number;
  114321. BONETEXTURE: boolean;
  114322. NONUNIFORMSCALING: boolean;
  114323. MORPHTARGETS: boolean;
  114324. MORPHTARGETS_NORMAL: boolean;
  114325. MORPHTARGETS_TANGENT: boolean;
  114326. MORPHTARGETS_UV: boolean;
  114327. NUM_MORPH_INFLUENCERS: number;
  114328. IMAGEPROCESSING: boolean;
  114329. VIGNETTE: boolean;
  114330. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114331. VIGNETTEBLENDMODEOPAQUE: boolean;
  114332. TONEMAPPING: boolean;
  114333. TONEMAPPING_ACES: boolean;
  114334. CONTRAST: boolean;
  114335. COLORCURVES: boolean;
  114336. COLORGRADING: boolean;
  114337. COLORGRADING3D: boolean;
  114338. SAMPLER3DGREENDEPTH: boolean;
  114339. SAMPLER3DBGRMAP: boolean;
  114340. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114341. EXPOSURE: boolean;
  114342. MULTIVIEW: boolean;
  114343. USEPHYSICALLIGHTFALLOFF: boolean;
  114344. USEGLTFLIGHTFALLOFF: boolean;
  114345. TWOSIDEDLIGHTING: boolean;
  114346. SHADOWFLOAT: boolean;
  114347. CLIPPLANE: boolean;
  114348. CLIPPLANE2: boolean;
  114349. CLIPPLANE3: boolean;
  114350. CLIPPLANE4: boolean;
  114351. POINTSIZE: boolean;
  114352. FOG: boolean;
  114353. LOGARITHMICDEPTH: boolean;
  114354. FORCENORMALFORWARD: boolean;
  114355. SPECULARAA: boolean;
  114356. CLEARCOAT: boolean;
  114357. CLEARCOAT_DEFAULTIOR: boolean;
  114358. CLEARCOAT_TEXTURE: boolean;
  114359. CLEARCOAT_TEXTUREDIRECTUV: number;
  114360. CLEARCOAT_BUMP: boolean;
  114361. CLEARCOAT_BUMPDIRECTUV: number;
  114362. CLEARCOAT_TINT: boolean;
  114363. CLEARCOAT_TINT_TEXTURE: boolean;
  114364. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114365. ANISOTROPIC: boolean;
  114366. ANISOTROPIC_TEXTURE: boolean;
  114367. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114368. BRDF_V_HEIGHT_CORRELATED: boolean;
  114369. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114370. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114371. SHEEN: boolean;
  114372. SHEEN_TEXTURE: boolean;
  114373. SHEEN_TEXTUREDIRECTUV: number;
  114374. SHEEN_LINKWITHALBEDO: boolean;
  114375. SUBSURFACE: boolean;
  114376. SS_REFRACTION: boolean;
  114377. SS_TRANSLUCENCY: boolean;
  114378. SS_SCATERRING: boolean;
  114379. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114380. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114381. SS_REFRACTIONMAP_3D: boolean;
  114382. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114383. SS_LODINREFRACTIONALPHA: boolean;
  114384. SS_GAMMAREFRACTION: boolean;
  114385. SS_RGBDREFRACTION: boolean;
  114386. SS_LINEARSPECULARREFRACTION: boolean;
  114387. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114388. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114389. UNLIT: boolean;
  114390. DEBUGMODE: number;
  114391. /**
  114392. * Initializes the PBR Material defines.
  114393. */
  114394. constructor();
  114395. /**
  114396. * Resets the PBR Material defines.
  114397. */
  114398. reset(): void;
  114399. }
  114400. /**
  114401. * The Physically based material base class of BJS.
  114402. *
  114403. * This offers the main features of a standard PBR material.
  114404. * For more information, please refer to the documentation :
  114405. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114406. */
  114407. export abstract class PBRBaseMaterial extends PushMaterial {
  114408. /**
  114409. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114410. */
  114411. static readonly PBRMATERIAL_OPAQUE: number;
  114412. /**
  114413. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114414. */
  114415. static readonly PBRMATERIAL_ALPHATEST: number;
  114416. /**
  114417. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114418. */
  114419. static readonly PBRMATERIAL_ALPHABLEND: number;
  114420. /**
  114421. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114422. * They are also discarded below the alpha cutoff threshold to improve performances.
  114423. */
  114424. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114425. /**
  114426. * Defines the default value of how much AO map is occluding the analytical lights
  114427. * (point spot...).
  114428. */
  114429. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114430. /**
  114431. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114432. */
  114433. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114434. /**
  114435. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114436. * to enhance interoperability with other engines.
  114437. */
  114438. static readonly LIGHTFALLOFF_GLTF: number;
  114439. /**
  114440. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114441. * to enhance interoperability with other materials.
  114442. */
  114443. static readonly LIGHTFALLOFF_STANDARD: number;
  114444. /**
  114445. * Intensity of the direct lights e.g. the four lights available in your scene.
  114446. * This impacts both the direct diffuse and specular highlights.
  114447. */
  114448. protected _directIntensity: number;
  114449. /**
  114450. * Intensity of the emissive part of the material.
  114451. * This helps controlling the emissive effect without modifying the emissive color.
  114452. */
  114453. protected _emissiveIntensity: number;
  114454. /**
  114455. * Intensity of the environment e.g. how much the environment will light the object
  114456. * either through harmonics for rough material or through the refelction for shiny ones.
  114457. */
  114458. protected _environmentIntensity: number;
  114459. /**
  114460. * This is a special control allowing the reduction of the specular highlights coming from the
  114461. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114462. */
  114463. protected _specularIntensity: number;
  114464. /**
  114465. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114466. */
  114467. private _lightingInfos;
  114468. /**
  114469. * Debug Control allowing disabling the bump map on this material.
  114470. */
  114471. protected _disableBumpMap: boolean;
  114472. /**
  114473. * AKA Diffuse Texture in standard nomenclature.
  114474. */
  114475. protected _albedoTexture: Nullable<BaseTexture>;
  114476. /**
  114477. * AKA Occlusion Texture in other nomenclature.
  114478. */
  114479. protected _ambientTexture: Nullable<BaseTexture>;
  114480. /**
  114481. * AKA Occlusion Texture Intensity in other nomenclature.
  114482. */
  114483. protected _ambientTextureStrength: number;
  114484. /**
  114485. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114486. * 1 means it completely occludes it
  114487. * 0 mean it has no impact
  114488. */
  114489. protected _ambientTextureImpactOnAnalyticalLights: number;
  114490. /**
  114491. * Stores the alpha values in a texture.
  114492. */
  114493. protected _opacityTexture: Nullable<BaseTexture>;
  114494. /**
  114495. * Stores the reflection values in a texture.
  114496. */
  114497. protected _reflectionTexture: Nullable<BaseTexture>;
  114498. /**
  114499. * Stores the emissive values in a texture.
  114500. */
  114501. protected _emissiveTexture: Nullable<BaseTexture>;
  114502. /**
  114503. * AKA Specular texture in other nomenclature.
  114504. */
  114505. protected _reflectivityTexture: Nullable<BaseTexture>;
  114506. /**
  114507. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114508. */
  114509. protected _metallicTexture: Nullable<BaseTexture>;
  114510. /**
  114511. * Specifies the metallic scalar of the metallic/roughness workflow.
  114512. * Can also be used to scale the metalness values of the metallic texture.
  114513. */
  114514. protected _metallic: Nullable<number>;
  114515. /**
  114516. * Specifies the roughness scalar of the metallic/roughness workflow.
  114517. * Can also be used to scale the roughness values of the metallic texture.
  114518. */
  114519. protected _roughness: Nullable<number>;
  114520. /**
  114521. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114522. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114523. */
  114524. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114525. /**
  114526. * Stores surface normal data used to displace a mesh in a texture.
  114527. */
  114528. protected _bumpTexture: Nullable<BaseTexture>;
  114529. /**
  114530. * Stores the pre-calculated light information of a mesh in a texture.
  114531. */
  114532. protected _lightmapTexture: Nullable<BaseTexture>;
  114533. /**
  114534. * The color of a material in ambient lighting.
  114535. */
  114536. protected _ambientColor: Color3;
  114537. /**
  114538. * AKA Diffuse Color in other nomenclature.
  114539. */
  114540. protected _albedoColor: Color3;
  114541. /**
  114542. * AKA Specular Color in other nomenclature.
  114543. */
  114544. protected _reflectivityColor: Color3;
  114545. /**
  114546. * The color applied when light is reflected from a material.
  114547. */
  114548. protected _reflectionColor: Color3;
  114549. /**
  114550. * The color applied when light is emitted from a material.
  114551. */
  114552. protected _emissiveColor: Color3;
  114553. /**
  114554. * AKA Glossiness in other nomenclature.
  114555. */
  114556. protected _microSurface: number;
  114557. /**
  114558. * Specifies that the material will use the light map as a show map.
  114559. */
  114560. protected _useLightmapAsShadowmap: boolean;
  114561. /**
  114562. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114563. * makes the reflect vector face the model (under horizon).
  114564. */
  114565. protected _useHorizonOcclusion: boolean;
  114566. /**
  114567. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114568. * too much the area relying on ambient texture to define their ambient occlusion.
  114569. */
  114570. protected _useRadianceOcclusion: boolean;
  114571. /**
  114572. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114573. */
  114574. protected _useAlphaFromAlbedoTexture: boolean;
  114575. /**
  114576. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114577. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114578. */
  114579. protected _useSpecularOverAlpha: boolean;
  114580. /**
  114581. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114582. */
  114583. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114584. /**
  114585. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114586. */
  114587. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114588. /**
  114589. * Specifies if the metallic texture contains the roughness information in its green channel.
  114590. */
  114591. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114592. /**
  114593. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114594. */
  114595. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114596. /**
  114597. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114598. */
  114599. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114600. /**
  114601. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114602. */
  114603. protected _useAmbientInGrayScale: boolean;
  114604. /**
  114605. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114606. * The material will try to infer what glossiness each pixel should be.
  114607. */
  114608. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114609. /**
  114610. * Defines the falloff type used in this material.
  114611. * It by default is Physical.
  114612. */
  114613. protected _lightFalloff: number;
  114614. /**
  114615. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114616. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114617. */
  114618. protected _useRadianceOverAlpha: boolean;
  114619. /**
  114620. * Allows using an object space normal map (instead of tangent space).
  114621. */
  114622. protected _useObjectSpaceNormalMap: boolean;
  114623. /**
  114624. * Allows using the bump map in parallax mode.
  114625. */
  114626. protected _useParallax: boolean;
  114627. /**
  114628. * Allows using the bump map in parallax occlusion mode.
  114629. */
  114630. protected _useParallaxOcclusion: boolean;
  114631. /**
  114632. * Controls the scale bias of the parallax mode.
  114633. */
  114634. protected _parallaxScaleBias: number;
  114635. /**
  114636. * If sets to true, disables all the lights affecting the material.
  114637. */
  114638. protected _disableLighting: boolean;
  114639. /**
  114640. * Number of Simultaneous lights allowed on the material.
  114641. */
  114642. protected _maxSimultaneousLights: number;
  114643. /**
  114644. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114645. */
  114646. protected _invertNormalMapX: boolean;
  114647. /**
  114648. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114649. */
  114650. protected _invertNormalMapY: boolean;
  114651. /**
  114652. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114653. */
  114654. protected _twoSidedLighting: boolean;
  114655. /**
  114656. * Defines the alpha limits in alpha test mode.
  114657. */
  114658. protected _alphaCutOff: number;
  114659. /**
  114660. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114661. */
  114662. protected _forceAlphaTest: boolean;
  114663. /**
  114664. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114665. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114666. */
  114667. protected _useAlphaFresnel: boolean;
  114668. /**
  114669. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114670. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114671. */
  114672. protected _useLinearAlphaFresnel: boolean;
  114673. /**
  114674. * The transparency mode of the material.
  114675. */
  114676. protected _transparencyMode: Nullable<number>;
  114677. /**
  114678. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114679. * from cos thetav and roughness:
  114680. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114681. */
  114682. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114683. /**
  114684. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114685. */
  114686. protected _forceIrradianceInFragment: boolean;
  114687. /**
  114688. * Force normal to face away from face.
  114689. */
  114690. protected _forceNormalForward: boolean;
  114691. /**
  114692. * Enables specular anti aliasing in the PBR shader.
  114693. * It will both interacts on the Geometry for analytical and IBL lighting.
  114694. * It also prefilter the roughness map based on the bump values.
  114695. */
  114696. protected _enableSpecularAntiAliasing: boolean;
  114697. /**
  114698. * Default configuration related to image processing available in the PBR Material.
  114699. */
  114700. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114701. /**
  114702. * Keep track of the image processing observer to allow dispose and replace.
  114703. */
  114704. private _imageProcessingObserver;
  114705. /**
  114706. * Attaches a new image processing configuration to the PBR Material.
  114707. * @param configuration
  114708. */
  114709. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114710. /**
  114711. * Stores the available render targets.
  114712. */
  114713. private _renderTargets;
  114714. /**
  114715. * Sets the global ambient color for the material used in lighting calculations.
  114716. */
  114717. private _globalAmbientColor;
  114718. /**
  114719. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114720. */
  114721. private _useLogarithmicDepth;
  114722. /**
  114723. * If set to true, no lighting calculations will be applied.
  114724. */
  114725. private _unlit;
  114726. private _debugMode;
  114727. /**
  114728. * @hidden
  114729. * This is reserved for the inspector.
  114730. * Defines the material debug mode.
  114731. * It helps seeing only some components of the material while troubleshooting.
  114732. */
  114733. debugMode: number;
  114734. /**
  114735. * @hidden
  114736. * This is reserved for the inspector.
  114737. * Specify from where on screen the debug mode should start.
  114738. * The value goes from -1 (full screen) to 1 (not visible)
  114739. * It helps with side by side comparison against the final render
  114740. * This defaults to -1
  114741. */
  114742. private debugLimit;
  114743. /**
  114744. * @hidden
  114745. * This is reserved for the inspector.
  114746. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114747. * You can use the factor to better multiply the final value.
  114748. */
  114749. private debugFactor;
  114750. /**
  114751. * Defines the clear coat layer parameters for the material.
  114752. */
  114753. readonly clearCoat: PBRClearCoatConfiguration;
  114754. /**
  114755. * Defines the anisotropic parameters for the material.
  114756. */
  114757. readonly anisotropy: PBRAnisotropicConfiguration;
  114758. /**
  114759. * Defines the BRDF parameters for the material.
  114760. */
  114761. readonly brdf: PBRBRDFConfiguration;
  114762. /**
  114763. * Defines the Sheen parameters for the material.
  114764. */
  114765. readonly sheen: PBRSheenConfiguration;
  114766. /**
  114767. * Defines the SubSurface parameters for the material.
  114768. */
  114769. readonly subSurface: PBRSubSurfaceConfiguration;
  114770. /**
  114771. * Custom callback helping to override the default shader used in the material.
  114772. */
  114773. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114774. protected _rebuildInParallel: boolean;
  114775. /**
  114776. * Instantiates a new PBRMaterial instance.
  114777. *
  114778. * @param name The material name
  114779. * @param scene The scene the material will be use in.
  114780. */
  114781. constructor(name: string, scene: Scene);
  114782. /**
  114783. * Gets a boolean indicating that current material needs to register RTT
  114784. */
  114785. readonly hasRenderTargetTextures: boolean;
  114786. /**
  114787. * Gets the name of the material class.
  114788. */
  114789. getClassName(): string;
  114790. /**
  114791. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114792. */
  114793. /**
  114794. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114795. */
  114796. useLogarithmicDepth: boolean;
  114797. /**
  114798. * Gets the current transparency mode.
  114799. */
  114800. /**
  114801. * Sets the transparency mode of the material.
  114802. *
  114803. * | Value | Type | Description |
  114804. * | ----- | ----------------------------------- | ----------- |
  114805. * | 0 | OPAQUE | |
  114806. * | 1 | ALPHATEST | |
  114807. * | 2 | ALPHABLEND | |
  114808. * | 3 | ALPHATESTANDBLEND | |
  114809. *
  114810. */
  114811. transparencyMode: Nullable<number>;
  114812. /**
  114813. * Returns true if alpha blending should be disabled.
  114814. */
  114815. private readonly _disableAlphaBlending;
  114816. /**
  114817. * Specifies whether or not this material should be rendered in alpha blend mode.
  114818. */
  114819. needAlphaBlending(): boolean;
  114820. /**
  114821. * Specifies if the mesh will require alpha blending.
  114822. * @param mesh - BJS mesh.
  114823. */
  114824. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114825. /**
  114826. * Specifies whether or not this material should be rendered in alpha test mode.
  114827. */
  114828. needAlphaTesting(): boolean;
  114829. /**
  114830. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114831. */
  114832. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114833. /**
  114834. * Gets the texture used for the alpha test.
  114835. */
  114836. getAlphaTestTexture(): Nullable<BaseTexture>;
  114837. /**
  114838. * Specifies that the submesh is ready to be used.
  114839. * @param mesh - BJS mesh.
  114840. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114841. * @param useInstances - Specifies that instances should be used.
  114842. * @returns - boolean indicating that the submesh is ready or not.
  114843. */
  114844. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114845. /**
  114846. * Specifies if the material uses metallic roughness workflow.
  114847. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114848. */
  114849. isMetallicWorkflow(): boolean;
  114850. private _prepareEffect;
  114851. private _prepareDefines;
  114852. /**
  114853. * Force shader compilation
  114854. */
  114855. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114856. clipPlane: boolean;
  114857. }>): void;
  114858. /**
  114859. * Initializes the uniform buffer layout for the shader.
  114860. */
  114861. buildUniformLayout(): void;
  114862. /**
  114863. * Unbinds the material from the mesh
  114864. */
  114865. unbind(): void;
  114866. /**
  114867. * Binds the submesh data.
  114868. * @param world - The world matrix.
  114869. * @param mesh - The BJS mesh.
  114870. * @param subMesh - A submesh of the BJS mesh.
  114871. */
  114872. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114873. /**
  114874. * Returns the animatable textures.
  114875. * @returns - Array of animatable textures.
  114876. */
  114877. getAnimatables(): IAnimatable[];
  114878. /**
  114879. * Returns the texture used for reflections.
  114880. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114881. */
  114882. private _getReflectionTexture;
  114883. /**
  114884. * Returns an array of the actively used textures.
  114885. * @returns - Array of BaseTextures
  114886. */
  114887. getActiveTextures(): BaseTexture[];
  114888. /**
  114889. * Checks to see if a texture is used in the material.
  114890. * @param texture - Base texture to use.
  114891. * @returns - Boolean specifying if a texture is used in the material.
  114892. */
  114893. hasTexture(texture: BaseTexture): boolean;
  114894. /**
  114895. * Disposes the resources of the material.
  114896. * @param forceDisposeEffect - Forces the disposal of effects.
  114897. * @param forceDisposeTextures - Forces the disposal of all textures.
  114898. */
  114899. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114900. }
  114901. }
  114902. declare module BABYLON {
  114903. /**
  114904. * The Physically based material of BJS.
  114905. *
  114906. * This offers the main features of a standard PBR material.
  114907. * For more information, please refer to the documentation :
  114908. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114909. */
  114910. export class PBRMaterial extends PBRBaseMaterial {
  114911. /**
  114912. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114913. */
  114914. static readonly PBRMATERIAL_OPAQUE: number;
  114915. /**
  114916. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114917. */
  114918. static readonly PBRMATERIAL_ALPHATEST: number;
  114919. /**
  114920. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114921. */
  114922. static readonly PBRMATERIAL_ALPHABLEND: number;
  114923. /**
  114924. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114925. * They are also discarded below the alpha cutoff threshold to improve performances.
  114926. */
  114927. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114928. /**
  114929. * Defines the default value of how much AO map is occluding the analytical lights
  114930. * (point spot...).
  114931. */
  114932. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114933. /**
  114934. * Intensity of the direct lights e.g. the four lights available in your scene.
  114935. * This impacts both the direct diffuse and specular highlights.
  114936. */
  114937. directIntensity: number;
  114938. /**
  114939. * Intensity of the emissive part of the material.
  114940. * This helps controlling the emissive effect without modifying the emissive color.
  114941. */
  114942. emissiveIntensity: number;
  114943. /**
  114944. * Intensity of the environment e.g. how much the environment will light the object
  114945. * either through harmonics for rough material or through the refelction for shiny ones.
  114946. */
  114947. environmentIntensity: number;
  114948. /**
  114949. * This is a special control allowing the reduction of the specular highlights coming from the
  114950. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114951. */
  114952. specularIntensity: number;
  114953. /**
  114954. * Debug Control allowing disabling the bump map on this material.
  114955. */
  114956. disableBumpMap: boolean;
  114957. /**
  114958. * AKA Diffuse Texture in standard nomenclature.
  114959. */
  114960. albedoTexture: BaseTexture;
  114961. /**
  114962. * AKA Occlusion Texture in other nomenclature.
  114963. */
  114964. ambientTexture: BaseTexture;
  114965. /**
  114966. * AKA Occlusion Texture Intensity in other nomenclature.
  114967. */
  114968. ambientTextureStrength: number;
  114969. /**
  114970. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114971. * 1 means it completely occludes it
  114972. * 0 mean it has no impact
  114973. */
  114974. ambientTextureImpactOnAnalyticalLights: number;
  114975. /**
  114976. * Stores the alpha values in a texture.
  114977. */
  114978. opacityTexture: BaseTexture;
  114979. /**
  114980. * Stores the reflection values in a texture.
  114981. */
  114982. reflectionTexture: Nullable<BaseTexture>;
  114983. /**
  114984. * Stores the emissive values in a texture.
  114985. */
  114986. emissiveTexture: BaseTexture;
  114987. /**
  114988. * AKA Specular texture in other nomenclature.
  114989. */
  114990. reflectivityTexture: BaseTexture;
  114991. /**
  114992. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114993. */
  114994. metallicTexture: BaseTexture;
  114995. /**
  114996. * Specifies the metallic scalar of the metallic/roughness workflow.
  114997. * Can also be used to scale the metalness values of the metallic texture.
  114998. */
  114999. metallic: Nullable<number>;
  115000. /**
  115001. * Specifies the roughness scalar of the metallic/roughness workflow.
  115002. * Can also be used to scale the roughness values of the metallic texture.
  115003. */
  115004. roughness: Nullable<number>;
  115005. /**
  115006. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  115007. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  115008. */
  115009. microSurfaceTexture: BaseTexture;
  115010. /**
  115011. * Stores surface normal data used to displace a mesh in a texture.
  115012. */
  115013. bumpTexture: BaseTexture;
  115014. /**
  115015. * Stores the pre-calculated light information of a mesh in a texture.
  115016. */
  115017. lightmapTexture: BaseTexture;
  115018. /**
  115019. * Stores the refracted light information in a texture.
  115020. */
  115021. refractionTexture: Nullable<BaseTexture>;
  115022. /**
  115023. * The color of a material in ambient lighting.
  115024. */
  115025. ambientColor: Color3;
  115026. /**
  115027. * AKA Diffuse Color in other nomenclature.
  115028. */
  115029. albedoColor: Color3;
  115030. /**
  115031. * AKA Specular Color in other nomenclature.
  115032. */
  115033. reflectivityColor: Color3;
  115034. /**
  115035. * The color reflected from the material.
  115036. */
  115037. reflectionColor: Color3;
  115038. /**
  115039. * The color emitted from the material.
  115040. */
  115041. emissiveColor: Color3;
  115042. /**
  115043. * AKA Glossiness in other nomenclature.
  115044. */
  115045. microSurface: number;
  115046. /**
  115047. * source material index of refraction (IOR)' / 'destination material IOR.
  115048. */
  115049. indexOfRefraction: number;
  115050. /**
  115051. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  115052. */
  115053. invertRefractionY: boolean;
  115054. /**
  115055. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  115056. * Materials half opaque for instance using refraction could benefit from this control.
  115057. */
  115058. linkRefractionWithTransparency: boolean;
  115059. /**
  115060. * If true, the light map contains occlusion information instead of lighting info.
  115061. */
  115062. useLightmapAsShadowmap: boolean;
  115063. /**
  115064. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  115065. */
  115066. useAlphaFromAlbedoTexture: boolean;
  115067. /**
  115068. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  115069. */
  115070. forceAlphaTest: boolean;
  115071. /**
  115072. * Defines the alpha limits in alpha test mode.
  115073. */
  115074. alphaCutOff: number;
  115075. /**
  115076. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  115077. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  115078. */
  115079. useSpecularOverAlpha: boolean;
  115080. /**
  115081. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  115082. */
  115083. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  115084. /**
  115085. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  115086. */
  115087. useRoughnessFromMetallicTextureAlpha: boolean;
  115088. /**
  115089. * Specifies if the metallic texture contains the roughness information in its green channel.
  115090. */
  115091. useRoughnessFromMetallicTextureGreen: boolean;
  115092. /**
  115093. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115094. */
  115095. useMetallnessFromMetallicTextureBlue: boolean;
  115096. /**
  115097. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115098. */
  115099. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115100. /**
  115101. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115102. */
  115103. useAmbientInGrayScale: boolean;
  115104. /**
  115105. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115106. * The material will try to infer what glossiness each pixel should be.
  115107. */
  115108. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115109. /**
  115110. * BJS is using an harcoded light falloff based on a manually sets up range.
  115111. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115112. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115113. */
  115114. /**
  115115. * BJS is using an harcoded light falloff based on a manually sets up range.
  115116. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115117. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115118. */
  115119. usePhysicalLightFalloff: boolean;
  115120. /**
  115121. * In order to support the falloff compatibility with gltf, a special mode has been added
  115122. * to reproduce the gltf light falloff.
  115123. */
  115124. /**
  115125. * In order to support the falloff compatibility with gltf, a special mode has been added
  115126. * to reproduce the gltf light falloff.
  115127. */
  115128. useGLTFLightFalloff: boolean;
  115129. /**
  115130. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115131. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115132. */
  115133. useRadianceOverAlpha: boolean;
  115134. /**
  115135. * Allows using an object space normal map (instead of tangent space).
  115136. */
  115137. useObjectSpaceNormalMap: boolean;
  115138. /**
  115139. * Allows using the bump map in parallax mode.
  115140. */
  115141. useParallax: boolean;
  115142. /**
  115143. * Allows using the bump map in parallax occlusion mode.
  115144. */
  115145. useParallaxOcclusion: boolean;
  115146. /**
  115147. * Controls the scale bias of the parallax mode.
  115148. */
  115149. parallaxScaleBias: number;
  115150. /**
  115151. * If sets to true, disables all the lights affecting the material.
  115152. */
  115153. disableLighting: boolean;
  115154. /**
  115155. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115156. */
  115157. forceIrradianceInFragment: boolean;
  115158. /**
  115159. * Number of Simultaneous lights allowed on the material.
  115160. */
  115161. maxSimultaneousLights: number;
  115162. /**
  115163. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115164. */
  115165. invertNormalMapX: boolean;
  115166. /**
  115167. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115168. */
  115169. invertNormalMapY: boolean;
  115170. /**
  115171. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115172. */
  115173. twoSidedLighting: boolean;
  115174. /**
  115175. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115176. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115177. */
  115178. useAlphaFresnel: boolean;
  115179. /**
  115180. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115181. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115182. */
  115183. useLinearAlphaFresnel: boolean;
  115184. /**
  115185. * Let user defines the brdf lookup texture used for IBL.
  115186. * A default 8bit version is embedded but you could point at :
  115187. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115188. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115189. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115190. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115191. */
  115192. environmentBRDFTexture: Nullable<BaseTexture>;
  115193. /**
  115194. * Force normal to face away from face.
  115195. */
  115196. forceNormalForward: boolean;
  115197. /**
  115198. * Enables specular anti aliasing in the PBR shader.
  115199. * It will both interacts on the Geometry for analytical and IBL lighting.
  115200. * It also prefilter the roughness map based on the bump values.
  115201. */
  115202. enableSpecularAntiAliasing: boolean;
  115203. /**
  115204. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115205. * makes the reflect vector face the model (under horizon).
  115206. */
  115207. useHorizonOcclusion: boolean;
  115208. /**
  115209. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115210. * too much the area relying on ambient texture to define their ambient occlusion.
  115211. */
  115212. useRadianceOcclusion: boolean;
  115213. /**
  115214. * If set to true, no lighting calculations will be applied.
  115215. */
  115216. unlit: boolean;
  115217. /**
  115218. * Gets the image processing configuration used either in this material.
  115219. */
  115220. /**
  115221. * Sets the Default image processing configuration used either in the this material.
  115222. *
  115223. * If sets to null, the scene one is in use.
  115224. */
  115225. imageProcessingConfiguration: ImageProcessingConfiguration;
  115226. /**
  115227. * Gets wether the color curves effect is enabled.
  115228. */
  115229. /**
  115230. * Sets wether the color curves effect is enabled.
  115231. */
  115232. cameraColorCurvesEnabled: boolean;
  115233. /**
  115234. * Gets wether the color grading effect is enabled.
  115235. */
  115236. /**
  115237. * Gets wether the color grading effect is enabled.
  115238. */
  115239. cameraColorGradingEnabled: boolean;
  115240. /**
  115241. * Gets wether tonemapping is enabled or not.
  115242. */
  115243. /**
  115244. * Sets wether tonemapping is enabled or not
  115245. */
  115246. cameraToneMappingEnabled: boolean;
  115247. /**
  115248. * The camera exposure used on this material.
  115249. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115250. * This corresponds to a photographic exposure.
  115251. */
  115252. /**
  115253. * The camera exposure used on this material.
  115254. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115255. * This corresponds to a photographic exposure.
  115256. */
  115257. cameraExposure: number;
  115258. /**
  115259. * Gets The camera contrast used on this material.
  115260. */
  115261. /**
  115262. * Sets The camera contrast used on this material.
  115263. */
  115264. cameraContrast: number;
  115265. /**
  115266. * Gets the Color Grading 2D Lookup Texture.
  115267. */
  115268. /**
  115269. * Sets the Color Grading 2D Lookup Texture.
  115270. */
  115271. cameraColorGradingTexture: Nullable<BaseTexture>;
  115272. /**
  115273. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115274. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115275. * 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;
  115276. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115277. */
  115278. /**
  115279. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115280. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115281. * 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;
  115282. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115283. */
  115284. cameraColorCurves: Nullable<ColorCurves>;
  115285. /**
  115286. * Instantiates a new PBRMaterial instance.
  115287. *
  115288. * @param name The material name
  115289. * @param scene The scene the material will be use in.
  115290. */
  115291. constructor(name: string, scene: Scene);
  115292. /**
  115293. * Returns the name of this material class.
  115294. */
  115295. getClassName(): string;
  115296. /**
  115297. * Makes a duplicate of the current material.
  115298. * @param name - name to use for the new material.
  115299. */
  115300. clone(name: string): PBRMaterial;
  115301. /**
  115302. * Serializes this PBR Material.
  115303. * @returns - An object with the serialized material.
  115304. */
  115305. serialize(): any;
  115306. /**
  115307. * Parses a PBR Material from a serialized object.
  115308. * @param source - Serialized object.
  115309. * @param scene - BJS scene instance.
  115310. * @param rootUrl - url for the scene object
  115311. * @returns - PBRMaterial
  115312. */
  115313. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115314. }
  115315. }
  115316. declare module BABYLON {
  115317. /**
  115318. * Direct draw surface info
  115319. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115320. */
  115321. export interface DDSInfo {
  115322. /**
  115323. * Width of the texture
  115324. */
  115325. width: number;
  115326. /**
  115327. * Width of the texture
  115328. */
  115329. height: number;
  115330. /**
  115331. * Number of Mipmaps for the texture
  115332. * @see https://en.wikipedia.org/wiki/Mipmap
  115333. */
  115334. mipmapCount: number;
  115335. /**
  115336. * If the textures format is a known fourCC format
  115337. * @see https://www.fourcc.org/
  115338. */
  115339. isFourCC: boolean;
  115340. /**
  115341. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115342. */
  115343. isRGB: boolean;
  115344. /**
  115345. * If the texture is a lumincance format
  115346. */
  115347. isLuminance: boolean;
  115348. /**
  115349. * If this is a cube texture
  115350. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115351. */
  115352. isCube: boolean;
  115353. /**
  115354. * If the texture is a compressed format eg. FOURCC_DXT1
  115355. */
  115356. isCompressed: boolean;
  115357. /**
  115358. * The dxgiFormat of the texture
  115359. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115360. */
  115361. dxgiFormat: number;
  115362. /**
  115363. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115364. */
  115365. textureType: number;
  115366. /**
  115367. * Sphericle polynomial created for the dds texture
  115368. */
  115369. sphericalPolynomial?: SphericalPolynomial;
  115370. }
  115371. /**
  115372. * Class used to provide DDS decompression tools
  115373. */
  115374. export class DDSTools {
  115375. /**
  115376. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115377. */
  115378. static StoreLODInAlphaChannel: boolean;
  115379. /**
  115380. * Gets DDS information from an array buffer
  115381. * @param arrayBuffer defines the array buffer to read data from
  115382. * @returns the DDS information
  115383. */
  115384. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115385. private static _FloatView;
  115386. private static _Int32View;
  115387. private static _ToHalfFloat;
  115388. private static _FromHalfFloat;
  115389. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115390. private static _GetHalfFloatRGBAArrayBuffer;
  115391. private static _GetFloatRGBAArrayBuffer;
  115392. private static _GetFloatAsUIntRGBAArrayBuffer;
  115393. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115394. private static _GetRGBAArrayBuffer;
  115395. private static _ExtractLongWordOrder;
  115396. private static _GetRGBArrayBuffer;
  115397. private static _GetLuminanceArrayBuffer;
  115398. /**
  115399. * Uploads DDS Levels to a Babylon Texture
  115400. * @hidden
  115401. */
  115402. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115403. }
  115404. interface ThinEngine {
  115405. /**
  115406. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115407. * @param rootUrl defines the url where the file to load is located
  115408. * @param scene defines the current scene
  115409. * @param lodScale defines scale to apply to the mip map selection
  115410. * @param lodOffset defines offset to apply to the mip map selection
  115411. * @param onLoad defines an optional callback raised when the texture is loaded
  115412. * @param onError defines an optional callback raised if there is an issue to load the texture
  115413. * @param format defines the format of the data
  115414. * @param forcedExtension defines the extension to use to pick the right loader
  115415. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115416. * @returns the cube texture as an InternalTexture
  115417. */
  115418. 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;
  115419. }
  115420. }
  115421. declare module BABYLON {
  115422. /**
  115423. * Implementation of the DDS Texture Loader.
  115424. * @hidden
  115425. */
  115426. export class _DDSTextureLoader implements IInternalTextureLoader {
  115427. /**
  115428. * Defines wether the loader supports cascade loading the different faces.
  115429. */
  115430. readonly supportCascades: boolean;
  115431. /**
  115432. * This returns if the loader support the current file information.
  115433. * @param extension defines the file extension of the file being loaded
  115434. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115435. * @param fallback defines the fallback internal texture if any
  115436. * @param isBase64 defines whether the texture is encoded as a base64
  115437. * @param isBuffer defines whether the texture data are stored as a buffer
  115438. * @returns true if the loader can load the specified file
  115439. */
  115440. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115441. /**
  115442. * Transform the url before loading if required.
  115443. * @param rootUrl the url of the texture
  115444. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115445. * @returns the transformed texture
  115446. */
  115447. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115448. /**
  115449. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115450. * @param rootUrl the url of the texture
  115451. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115452. * @returns the fallback texture
  115453. */
  115454. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115455. /**
  115456. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115457. * @param data contains the texture data
  115458. * @param texture defines the BabylonJS internal texture
  115459. * @param createPolynomials will be true if polynomials have been requested
  115460. * @param onLoad defines the callback to trigger once the texture is ready
  115461. * @param onError defines the callback to trigger in case of error
  115462. */
  115463. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115464. /**
  115465. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115466. * @param data contains the texture data
  115467. * @param texture defines the BabylonJS internal texture
  115468. * @param callback defines the method to call once ready to upload
  115469. */
  115470. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115471. }
  115472. }
  115473. declare module BABYLON {
  115474. /**
  115475. * Implementation of the ENV Texture Loader.
  115476. * @hidden
  115477. */
  115478. export class _ENVTextureLoader implements IInternalTextureLoader {
  115479. /**
  115480. * Defines wether the loader supports cascade loading the different faces.
  115481. */
  115482. readonly supportCascades: boolean;
  115483. /**
  115484. * This returns if the loader support the current file information.
  115485. * @param extension defines the file extension of the file being loaded
  115486. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115487. * @param fallback defines the fallback internal texture if any
  115488. * @param isBase64 defines whether the texture is encoded as a base64
  115489. * @param isBuffer defines whether the texture data are stored as a buffer
  115490. * @returns true if the loader can load the specified file
  115491. */
  115492. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115493. /**
  115494. * Transform the url before loading if required.
  115495. * @param rootUrl the url of the texture
  115496. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115497. * @returns the transformed texture
  115498. */
  115499. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115500. /**
  115501. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115502. * @param rootUrl the url of the texture
  115503. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115504. * @returns the fallback texture
  115505. */
  115506. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115507. /**
  115508. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115509. * @param data contains the texture data
  115510. * @param texture defines the BabylonJS internal texture
  115511. * @param createPolynomials will be true if polynomials have been requested
  115512. * @param onLoad defines the callback to trigger once the texture is ready
  115513. * @param onError defines the callback to trigger in case of error
  115514. */
  115515. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115516. /**
  115517. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115518. * @param data contains the texture data
  115519. * @param texture defines the BabylonJS internal texture
  115520. * @param callback defines the method to call once ready to upload
  115521. */
  115522. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115523. }
  115524. }
  115525. declare module BABYLON {
  115526. /**
  115527. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115528. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115529. */
  115530. export class KhronosTextureContainer {
  115531. /** contents of the KTX container file */
  115532. arrayBuffer: any;
  115533. private static HEADER_LEN;
  115534. private static COMPRESSED_2D;
  115535. private static COMPRESSED_3D;
  115536. private static TEX_2D;
  115537. private static TEX_3D;
  115538. /**
  115539. * Gets the openGL type
  115540. */
  115541. glType: number;
  115542. /**
  115543. * Gets the openGL type size
  115544. */
  115545. glTypeSize: number;
  115546. /**
  115547. * Gets the openGL format
  115548. */
  115549. glFormat: number;
  115550. /**
  115551. * Gets the openGL internal format
  115552. */
  115553. glInternalFormat: number;
  115554. /**
  115555. * Gets the base internal format
  115556. */
  115557. glBaseInternalFormat: number;
  115558. /**
  115559. * Gets image width in pixel
  115560. */
  115561. pixelWidth: number;
  115562. /**
  115563. * Gets image height in pixel
  115564. */
  115565. pixelHeight: number;
  115566. /**
  115567. * Gets image depth in pixels
  115568. */
  115569. pixelDepth: number;
  115570. /**
  115571. * Gets the number of array elements
  115572. */
  115573. numberOfArrayElements: number;
  115574. /**
  115575. * Gets the number of faces
  115576. */
  115577. numberOfFaces: number;
  115578. /**
  115579. * Gets the number of mipmap levels
  115580. */
  115581. numberOfMipmapLevels: number;
  115582. /**
  115583. * Gets the bytes of key value data
  115584. */
  115585. bytesOfKeyValueData: number;
  115586. /**
  115587. * Gets the load type
  115588. */
  115589. loadType: number;
  115590. /**
  115591. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115592. */
  115593. isInvalid: boolean;
  115594. /**
  115595. * Creates a new KhronosTextureContainer
  115596. * @param arrayBuffer contents of the KTX container file
  115597. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115598. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115599. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115600. */
  115601. constructor(
  115602. /** contents of the KTX container file */
  115603. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115604. /**
  115605. * Uploads KTX content to a Babylon Texture.
  115606. * It is assumed that the texture has already been created & is currently bound
  115607. * @hidden
  115608. */
  115609. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115610. private _upload2DCompressedLevels;
  115611. }
  115612. }
  115613. declare module BABYLON {
  115614. /**
  115615. * Implementation of the KTX Texture Loader.
  115616. * @hidden
  115617. */
  115618. export class _KTXTextureLoader implements IInternalTextureLoader {
  115619. /**
  115620. * Defines wether the loader supports cascade loading the different faces.
  115621. */
  115622. readonly supportCascades: boolean;
  115623. /**
  115624. * This returns if the loader support the current file information.
  115625. * @param extension defines the file extension of the file being loaded
  115626. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115627. * @param fallback defines the fallback internal texture if any
  115628. * @param isBase64 defines whether the texture is encoded as a base64
  115629. * @param isBuffer defines whether the texture data are stored as a buffer
  115630. * @returns true if the loader can load the specified file
  115631. */
  115632. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115633. /**
  115634. * Transform the url before loading if required.
  115635. * @param rootUrl the url of the texture
  115636. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115637. * @returns the transformed texture
  115638. */
  115639. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115640. /**
  115641. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115642. * @param rootUrl the url of the texture
  115643. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115644. * @returns the fallback texture
  115645. */
  115646. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115647. /**
  115648. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115649. * @param data contains the texture data
  115650. * @param texture defines the BabylonJS internal texture
  115651. * @param createPolynomials will be true if polynomials have been requested
  115652. * @param onLoad defines the callback to trigger once the texture is ready
  115653. * @param onError defines the callback to trigger in case of error
  115654. */
  115655. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115656. /**
  115657. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115658. * @param data contains the texture data
  115659. * @param texture defines the BabylonJS internal texture
  115660. * @param callback defines the method to call once ready to upload
  115661. */
  115662. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115663. }
  115664. }
  115665. declare module BABYLON {
  115666. /**
  115667. * Options for the default xr helper
  115668. */
  115669. export class WebXRDefaultExperienceOptions {
  115670. /**
  115671. * Floor meshes that should be used for teleporting
  115672. */
  115673. floorMeshes: Array<AbstractMesh>;
  115674. }
  115675. /**
  115676. * Default experience which provides a similar setup to the previous webVRExperience
  115677. */
  115678. export class WebXRDefaultExperience {
  115679. /**
  115680. * Base experience
  115681. */
  115682. baseExperience: WebXRExperienceHelper;
  115683. /**
  115684. * Input experience extension
  115685. */
  115686. input: WebXRInput;
  115687. /**
  115688. * Loads the controller models
  115689. */
  115690. controllerModelLoader: WebXRControllerModelLoader;
  115691. /**
  115692. * Enables laser pointer and selection
  115693. */
  115694. pointerSelection: WebXRControllerPointerSelection;
  115695. /**
  115696. * Enables teleportation
  115697. */
  115698. teleportation: WebXRControllerTeleportation;
  115699. /**
  115700. * Enables ui for enetering/exiting xr
  115701. */
  115702. enterExitUI: WebXREnterExitUI;
  115703. /**
  115704. * Default output canvas xr should render to
  115705. */
  115706. outputCanvas: WebXRManagedOutputCanvas;
  115707. /**
  115708. * Creates the default xr experience
  115709. * @param scene scene
  115710. * @param options options for basic configuration
  115711. * @returns resulting WebXRDefaultExperience
  115712. */
  115713. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115714. private constructor();
  115715. /**
  115716. * DIsposes of the experience helper
  115717. */
  115718. dispose(): void;
  115719. }
  115720. }
  115721. declare module BABYLON {
  115722. /** @hidden */
  115723. export var _forceSceneHelpersToBundle: boolean;
  115724. interface Scene {
  115725. /**
  115726. * Creates a default light for the scene.
  115727. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115728. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115729. */
  115730. createDefaultLight(replace?: boolean): void;
  115731. /**
  115732. * Creates a default camera for the scene.
  115733. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115734. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115735. * @param replace has default false, when true replaces the active camera in the scene
  115736. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115737. */
  115738. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115739. /**
  115740. * Creates a default camera and a default light.
  115741. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115742. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115743. * @param replace has the default false, when true replaces the active camera/light in the scene
  115744. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115745. */
  115746. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115747. /**
  115748. * Creates a new sky box
  115749. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115750. * @param environmentTexture defines the texture to use as environment texture
  115751. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115752. * @param scale defines the overall scale of the skybox
  115753. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115754. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115755. * @returns a new mesh holding the sky box
  115756. */
  115757. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115758. /**
  115759. * Creates a new environment
  115760. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115761. * @param options defines the options you can use to configure the environment
  115762. * @returns the new EnvironmentHelper
  115763. */
  115764. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115765. /**
  115766. * Creates a new VREXperienceHelper
  115767. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115768. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115769. * @returns a new VREXperienceHelper
  115770. */
  115771. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115772. /**
  115773. * Creates a new WebXRDefaultExperience
  115774. * @see http://doc.babylonjs.com/how_to/webxr
  115775. * @param options experience options
  115776. * @returns a promise for a new WebXRDefaultExperience
  115777. */
  115778. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115779. }
  115780. }
  115781. declare module BABYLON {
  115782. /**
  115783. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115784. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115785. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115786. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115787. */
  115788. export class VideoDome extends TransformNode {
  115789. /**
  115790. * Define the video source as a Monoscopic panoramic 360 video.
  115791. */
  115792. static readonly MODE_MONOSCOPIC: number;
  115793. /**
  115794. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115795. */
  115796. static readonly MODE_TOPBOTTOM: number;
  115797. /**
  115798. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115799. */
  115800. static readonly MODE_SIDEBYSIDE: number;
  115801. private _halfDome;
  115802. private _useDirectMapping;
  115803. /**
  115804. * The video texture being displayed on the sphere
  115805. */
  115806. protected _videoTexture: VideoTexture;
  115807. /**
  115808. * Gets the video texture being displayed on the sphere
  115809. */
  115810. readonly videoTexture: VideoTexture;
  115811. /**
  115812. * The skybox material
  115813. */
  115814. protected _material: BackgroundMaterial;
  115815. /**
  115816. * The surface used for the skybox
  115817. */
  115818. protected _mesh: Mesh;
  115819. /**
  115820. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115821. */
  115822. private _halfDomeMask;
  115823. /**
  115824. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115825. * Also see the options.resolution property.
  115826. */
  115827. fovMultiplier: number;
  115828. private _videoMode;
  115829. /**
  115830. * Gets or set the current video mode for the video. It can be:
  115831. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115832. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115833. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115834. */
  115835. videoMode: number;
  115836. /**
  115837. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115838. *
  115839. */
  115840. /**
  115841. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115842. */
  115843. halfDome: boolean;
  115844. /**
  115845. * Oberserver used in Stereoscopic VR Mode.
  115846. */
  115847. private _onBeforeCameraRenderObserver;
  115848. /**
  115849. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115850. * @param name Element's name, child elements will append suffixes for their own names.
  115851. * @param urlsOrVideo defines the url(s) or the video element to use
  115852. * @param options An object containing optional or exposed sub element properties
  115853. */
  115854. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115855. resolution?: number;
  115856. clickToPlay?: boolean;
  115857. autoPlay?: boolean;
  115858. loop?: boolean;
  115859. size?: number;
  115860. poster?: string;
  115861. faceForward?: boolean;
  115862. useDirectMapping?: boolean;
  115863. halfDomeMode?: boolean;
  115864. }, scene: Scene);
  115865. private _changeVideoMode;
  115866. /**
  115867. * Releases resources associated with this node.
  115868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115870. */
  115871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115872. }
  115873. }
  115874. declare module BABYLON {
  115875. /**
  115876. * This class can be used to get instrumentation data from a Babylon engine
  115877. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115878. */
  115879. export class EngineInstrumentation implements IDisposable {
  115880. /**
  115881. * Define the instrumented engine.
  115882. */
  115883. engine: Engine;
  115884. private _captureGPUFrameTime;
  115885. private _gpuFrameTimeToken;
  115886. private _gpuFrameTime;
  115887. private _captureShaderCompilationTime;
  115888. private _shaderCompilationTime;
  115889. private _onBeginFrameObserver;
  115890. private _onEndFrameObserver;
  115891. private _onBeforeShaderCompilationObserver;
  115892. private _onAfterShaderCompilationObserver;
  115893. /**
  115894. * Gets the perf counter used for GPU frame time
  115895. */
  115896. readonly gpuFrameTimeCounter: PerfCounter;
  115897. /**
  115898. * Gets the GPU frame time capture status
  115899. */
  115900. /**
  115901. * Enable or disable the GPU frame time capture
  115902. */
  115903. captureGPUFrameTime: boolean;
  115904. /**
  115905. * Gets the perf counter used for shader compilation time
  115906. */
  115907. readonly shaderCompilationTimeCounter: PerfCounter;
  115908. /**
  115909. * Gets the shader compilation time capture status
  115910. */
  115911. /**
  115912. * Enable or disable the shader compilation time capture
  115913. */
  115914. captureShaderCompilationTime: boolean;
  115915. /**
  115916. * Instantiates a new engine instrumentation.
  115917. * This class can be used to get instrumentation data from a Babylon engine
  115918. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115919. * @param engine Defines the engine to instrument
  115920. */
  115921. constructor(
  115922. /**
  115923. * Define the instrumented engine.
  115924. */
  115925. engine: Engine);
  115926. /**
  115927. * Dispose and release associated resources.
  115928. */
  115929. dispose(): void;
  115930. }
  115931. }
  115932. declare module BABYLON {
  115933. /**
  115934. * This class can be used to get instrumentation data from a Babylon engine
  115935. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115936. */
  115937. export class SceneInstrumentation implements IDisposable {
  115938. /**
  115939. * Defines the scene to instrument
  115940. */
  115941. scene: Scene;
  115942. private _captureActiveMeshesEvaluationTime;
  115943. private _activeMeshesEvaluationTime;
  115944. private _captureRenderTargetsRenderTime;
  115945. private _renderTargetsRenderTime;
  115946. private _captureFrameTime;
  115947. private _frameTime;
  115948. private _captureRenderTime;
  115949. private _renderTime;
  115950. private _captureInterFrameTime;
  115951. private _interFrameTime;
  115952. private _captureParticlesRenderTime;
  115953. private _particlesRenderTime;
  115954. private _captureSpritesRenderTime;
  115955. private _spritesRenderTime;
  115956. private _capturePhysicsTime;
  115957. private _physicsTime;
  115958. private _captureAnimationsTime;
  115959. private _animationsTime;
  115960. private _captureCameraRenderTime;
  115961. private _cameraRenderTime;
  115962. private _onBeforeActiveMeshesEvaluationObserver;
  115963. private _onAfterActiveMeshesEvaluationObserver;
  115964. private _onBeforeRenderTargetsRenderObserver;
  115965. private _onAfterRenderTargetsRenderObserver;
  115966. private _onAfterRenderObserver;
  115967. private _onBeforeDrawPhaseObserver;
  115968. private _onAfterDrawPhaseObserver;
  115969. private _onBeforeAnimationsObserver;
  115970. private _onBeforeParticlesRenderingObserver;
  115971. private _onAfterParticlesRenderingObserver;
  115972. private _onBeforeSpritesRenderingObserver;
  115973. private _onAfterSpritesRenderingObserver;
  115974. private _onBeforePhysicsObserver;
  115975. private _onAfterPhysicsObserver;
  115976. private _onAfterAnimationsObserver;
  115977. private _onBeforeCameraRenderObserver;
  115978. private _onAfterCameraRenderObserver;
  115979. /**
  115980. * Gets the perf counter used for active meshes evaluation time
  115981. */
  115982. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115983. /**
  115984. * Gets the active meshes evaluation time capture status
  115985. */
  115986. /**
  115987. * Enable or disable the active meshes evaluation time capture
  115988. */
  115989. captureActiveMeshesEvaluationTime: boolean;
  115990. /**
  115991. * Gets the perf counter used for render targets render time
  115992. */
  115993. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115994. /**
  115995. * Gets the render targets render time capture status
  115996. */
  115997. /**
  115998. * Enable or disable the render targets render time capture
  115999. */
  116000. captureRenderTargetsRenderTime: boolean;
  116001. /**
  116002. * Gets the perf counter used for particles render time
  116003. */
  116004. readonly particlesRenderTimeCounter: PerfCounter;
  116005. /**
  116006. * Gets the particles render time capture status
  116007. */
  116008. /**
  116009. * Enable or disable the particles render time capture
  116010. */
  116011. captureParticlesRenderTime: boolean;
  116012. /**
  116013. * Gets the perf counter used for sprites render time
  116014. */
  116015. readonly spritesRenderTimeCounter: PerfCounter;
  116016. /**
  116017. * Gets the sprites render time capture status
  116018. */
  116019. /**
  116020. * Enable or disable the sprites render time capture
  116021. */
  116022. captureSpritesRenderTime: boolean;
  116023. /**
  116024. * Gets the perf counter used for physics time
  116025. */
  116026. readonly physicsTimeCounter: PerfCounter;
  116027. /**
  116028. * Gets the physics time capture status
  116029. */
  116030. /**
  116031. * Enable or disable the physics time capture
  116032. */
  116033. capturePhysicsTime: boolean;
  116034. /**
  116035. * Gets the perf counter used for animations time
  116036. */
  116037. readonly animationsTimeCounter: PerfCounter;
  116038. /**
  116039. * Gets the animations time capture status
  116040. */
  116041. /**
  116042. * Enable or disable the animations time capture
  116043. */
  116044. captureAnimationsTime: boolean;
  116045. /**
  116046. * Gets the perf counter used for frame time capture
  116047. */
  116048. readonly frameTimeCounter: PerfCounter;
  116049. /**
  116050. * Gets the frame time capture status
  116051. */
  116052. /**
  116053. * Enable or disable the frame time capture
  116054. */
  116055. captureFrameTime: boolean;
  116056. /**
  116057. * Gets the perf counter used for inter-frames time capture
  116058. */
  116059. readonly interFrameTimeCounter: PerfCounter;
  116060. /**
  116061. * Gets the inter-frames time capture status
  116062. */
  116063. /**
  116064. * Enable or disable the inter-frames time capture
  116065. */
  116066. captureInterFrameTime: boolean;
  116067. /**
  116068. * Gets the perf counter used for render time capture
  116069. */
  116070. readonly renderTimeCounter: PerfCounter;
  116071. /**
  116072. * Gets the render time capture status
  116073. */
  116074. /**
  116075. * Enable or disable the render time capture
  116076. */
  116077. captureRenderTime: boolean;
  116078. /**
  116079. * Gets the perf counter used for camera render time capture
  116080. */
  116081. readonly cameraRenderTimeCounter: PerfCounter;
  116082. /**
  116083. * Gets the camera render time capture status
  116084. */
  116085. /**
  116086. * Enable or disable the camera render time capture
  116087. */
  116088. captureCameraRenderTime: boolean;
  116089. /**
  116090. * Gets the perf counter used for draw calls
  116091. */
  116092. readonly drawCallsCounter: PerfCounter;
  116093. /**
  116094. * Instantiates a new scene instrumentation.
  116095. * This class can be used to get instrumentation data from a Babylon engine
  116096. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116097. * @param scene Defines the scene to instrument
  116098. */
  116099. constructor(
  116100. /**
  116101. * Defines the scene to instrument
  116102. */
  116103. scene: Scene);
  116104. /**
  116105. * Dispose and release associated resources.
  116106. */
  116107. dispose(): void;
  116108. }
  116109. }
  116110. declare module BABYLON {
  116111. /** @hidden */
  116112. export var glowMapGenerationPixelShader: {
  116113. name: string;
  116114. shader: string;
  116115. };
  116116. }
  116117. declare module BABYLON {
  116118. /** @hidden */
  116119. export var glowMapGenerationVertexShader: {
  116120. name: string;
  116121. shader: string;
  116122. };
  116123. }
  116124. declare module BABYLON {
  116125. /**
  116126. * Effect layer options. This helps customizing the behaviour
  116127. * of the effect layer.
  116128. */
  116129. export interface IEffectLayerOptions {
  116130. /**
  116131. * Multiplication factor apply to the canvas size to compute the render target size
  116132. * used to generated the objects (the smaller the faster).
  116133. */
  116134. mainTextureRatio: number;
  116135. /**
  116136. * Enforces a fixed size texture to ensure effect stability across devices.
  116137. */
  116138. mainTextureFixedSize?: number;
  116139. /**
  116140. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116141. */
  116142. alphaBlendingMode: number;
  116143. /**
  116144. * The camera attached to the layer.
  116145. */
  116146. camera: Nullable<Camera>;
  116147. /**
  116148. * The rendering group to draw the layer in.
  116149. */
  116150. renderingGroupId: number;
  116151. }
  116152. /**
  116153. * The effect layer Helps adding post process effect blended with the main pass.
  116154. *
  116155. * This can be for instance use to generate glow or higlight effects on the scene.
  116156. *
  116157. * The effect layer class can not be used directly and is intented to inherited from to be
  116158. * customized per effects.
  116159. */
  116160. export abstract class EffectLayer {
  116161. private _vertexBuffers;
  116162. private _indexBuffer;
  116163. private _cachedDefines;
  116164. private _effectLayerMapGenerationEffect;
  116165. private _effectLayerOptions;
  116166. private _mergeEffect;
  116167. protected _scene: Scene;
  116168. protected _engine: Engine;
  116169. protected _maxSize: number;
  116170. protected _mainTextureDesiredSize: ISize;
  116171. protected _mainTexture: RenderTargetTexture;
  116172. protected _shouldRender: boolean;
  116173. protected _postProcesses: PostProcess[];
  116174. protected _textures: BaseTexture[];
  116175. protected _emissiveTextureAndColor: {
  116176. texture: Nullable<BaseTexture>;
  116177. color: Color4;
  116178. };
  116179. /**
  116180. * The name of the layer
  116181. */
  116182. name: string;
  116183. /**
  116184. * The clear color of the texture used to generate the glow map.
  116185. */
  116186. neutralColor: Color4;
  116187. /**
  116188. * Specifies wether the highlight layer is enabled or not.
  116189. */
  116190. isEnabled: boolean;
  116191. /**
  116192. * Gets the camera attached to the layer.
  116193. */
  116194. readonly camera: Nullable<Camera>;
  116195. /**
  116196. * Gets the rendering group id the layer should render in.
  116197. */
  116198. renderingGroupId: number;
  116199. /**
  116200. * An event triggered when the effect layer has been disposed.
  116201. */
  116202. onDisposeObservable: Observable<EffectLayer>;
  116203. /**
  116204. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116205. */
  116206. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116207. /**
  116208. * An event triggered when the generated texture is being merged in the scene.
  116209. */
  116210. onBeforeComposeObservable: Observable<EffectLayer>;
  116211. /**
  116212. * An event triggered when the generated texture has been merged in the scene.
  116213. */
  116214. onAfterComposeObservable: Observable<EffectLayer>;
  116215. /**
  116216. * An event triggered when the efffect layer changes its size.
  116217. */
  116218. onSizeChangedObservable: Observable<EffectLayer>;
  116219. /** @hidden */
  116220. static _SceneComponentInitialization: (scene: Scene) => void;
  116221. /**
  116222. * Instantiates a new effect Layer and references it in the scene.
  116223. * @param name The name of the layer
  116224. * @param scene The scene to use the layer in
  116225. */
  116226. constructor(
  116227. /** The Friendly of the effect in the scene */
  116228. name: string, scene: Scene);
  116229. /**
  116230. * Get the effect name of the layer.
  116231. * @return The effect name
  116232. */
  116233. abstract getEffectName(): string;
  116234. /**
  116235. * Checks for the readiness of the element composing the layer.
  116236. * @param subMesh the mesh to check for
  116237. * @param useInstances specify wether or not to use instances to render the mesh
  116238. * @return true if ready otherwise, false
  116239. */
  116240. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116241. /**
  116242. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116243. * @returns true if the effect requires stencil during the main canvas render pass.
  116244. */
  116245. abstract needStencil(): boolean;
  116246. /**
  116247. * Create the merge effect. This is the shader use to blit the information back
  116248. * to the main canvas at the end of the scene rendering.
  116249. * @returns The effect containing the shader used to merge the effect on the main canvas
  116250. */
  116251. protected abstract _createMergeEffect(): Effect;
  116252. /**
  116253. * Creates the render target textures and post processes used in the effect layer.
  116254. */
  116255. protected abstract _createTextureAndPostProcesses(): void;
  116256. /**
  116257. * Implementation specific of rendering the generating effect on the main canvas.
  116258. * @param effect The effect used to render through
  116259. */
  116260. protected abstract _internalRender(effect: Effect): void;
  116261. /**
  116262. * Sets the required values for both the emissive texture and and the main color.
  116263. */
  116264. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116265. /**
  116266. * Free any resources and references associated to a mesh.
  116267. * Internal use
  116268. * @param mesh The mesh to free.
  116269. */
  116270. abstract _disposeMesh(mesh: Mesh): void;
  116271. /**
  116272. * Serializes this layer (Glow or Highlight for example)
  116273. * @returns a serialized layer object
  116274. */
  116275. abstract serialize?(): any;
  116276. /**
  116277. * Initializes the effect layer with the required options.
  116278. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116279. */
  116280. protected _init(options: Partial<IEffectLayerOptions>): void;
  116281. /**
  116282. * Generates the index buffer of the full screen quad blending to the main canvas.
  116283. */
  116284. private _generateIndexBuffer;
  116285. /**
  116286. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116287. */
  116288. private _generateVertexBuffer;
  116289. /**
  116290. * Sets the main texture desired size which is the closest power of two
  116291. * of the engine canvas size.
  116292. */
  116293. private _setMainTextureSize;
  116294. /**
  116295. * Creates the main texture for the effect layer.
  116296. */
  116297. protected _createMainTexture(): void;
  116298. /**
  116299. * Adds specific effects defines.
  116300. * @param defines The defines to add specifics to.
  116301. */
  116302. protected _addCustomEffectDefines(defines: string[]): void;
  116303. /**
  116304. * Checks for the readiness of the element composing the layer.
  116305. * @param subMesh the mesh to check for
  116306. * @param useInstances specify wether or not to use instances to render the mesh
  116307. * @param emissiveTexture the associated emissive texture used to generate the glow
  116308. * @return true if ready otherwise, false
  116309. */
  116310. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116311. /**
  116312. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116313. */
  116314. render(): void;
  116315. /**
  116316. * Determine if a given mesh will be used in the current effect.
  116317. * @param mesh mesh to test
  116318. * @returns true if the mesh will be used
  116319. */
  116320. hasMesh(mesh: AbstractMesh): boolean;
  116321. /**
  116322. * Returns true if the layer contains information to display, otherwise false.
  116323. * @returns true if the glow layer should be rendered
  116324. */
  116325. shouldRender(): boolean;
  116326. /**
  116327. * Returns true if the mesh should render, otherwise false.
  116328. * @param mesh The mesh to render
  116329. * @returns true if it should render otherwise false
  116330. */
  116331. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116332. /**
  116333. * Returns true if the mesh can be rendered, otherwise false.
  116334. * @param mesh The mesh to render
  116335. * @param material The material used on the mesh
  116336. * @returns true if it can be rendered otherwise false
  116337. */
  116338. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116339. /**
  116340. * Returns true if the mesh should render, otherwise false.
  116341. * @param mesh The mesh to render
  116342. * @returns true if it should render otherwise false
  116343. */
  116344. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116345. /**
  116346. * Renders the submesh passed in parameter to the generation map.
  116347. */
  116348. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116349. /**
  116350. * Rebuild the required buffers.
  116351. * @hidden Internal use only.
  116352. */
  116353. _rebuild(): void;
  116354. /**
  116355. * Dispose only the render target textures and post process.
  116356. */
  116357. private _disposeTextureAndPostProcesses;
  116358. /**
  116359. * Dispose the highlight layer and free resources.
  116360. */
  116361. dispose(): void;
  116362. /**
  116363. * Gets the class name of the effect layer
  116364. * @returns the string with the class name of the effect layer
  116365. */
  116366. getClassName(): string;
  116367. /**
  116368. * Creates an effect layer from parsed effect layer data
  116369. * @param parsedEffectLayer defines effect layer data
  116370. * @param scene defines the current scene
  116371. * @param rootUrl defines the root URL containing the effect layer information
  116372. * @returns a parsed effect Layer
  116373. */
  116374. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116375. }
  116376. }
  116377. declare module BABYLON {
  116378. interface AbstractScene {
  116379. /**
  116380. * The list of effect layers (highlights/glow) added to the scene
  116381. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116382. * @see http://doc.babylonjs.com/how_to/glow_layer
  116383. */
  116384. effectLayers: Array<EffectLayer>;
  116385. /**
  116386. * Removes the given effect layer from this scene.
  116387. * @param toRemove defines the effect layer to remove
  116388. * @returns the index of the removed effect layer
  116389. */
  116390. removeEffectLayer(toRemove: EffectLayer): number;
  116391. /**
  116392. * Adds the given effect layer to this scene
  116393. * @param newEffectLayer defines the effect layer to add
  116394. */
  116395. addEffectLayer(newEffectLayer: EffectLayer): void;
  116396. }
  116397. /**
  116398. * Defines the layer scene component responsible to manage any effect layers
  116399. * in a given scene.
  116400. */
  116401. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116402. /**
  116403. * The component name helpfull to identify the component in the list of scene components.
  116404. */
  116405. readonly name: string;
  116406. /**
  116407. * The scene the component belongs to.
  116408. */
  116409. scene: Scene;
  116410. private _engine;
  116411. private _renderEffects;
  116412. private _needStencil;
  116413. private _previousStencilState;
  116414. /**
  116415. * Creates a new instance of the component for the given scene
  116416. * @param scene Defines the scene to register the component in
  116417. */
  116418. constructor(scene: Scene);
  116419. /**
  116420. * Registers the component in a given scene
  116421. */
  116422. register(): void;
  116423. /**
  116424. * Rebuilds the elements related to this component in case of
  116425. * context lost for instance.
  116426. */
  116427. rebuild(): void;
  116428. /**
  116429. * Serializes the component data to the specified json object
  116430. * @param serializationObject The object to serialize to
  116431. */
  116432. serialize(serializationObject: any): void;
  116433. /**
  116434. * Adds all the elements from the container to the scene
  116435. * @param container the container holding the elements
  116436. */
  116437. addFromContainer(container: AbstractScene): void;
  116438. /**
  116439. * Removes all the elements in the container from the scene
  116440. * @param container contains the elements to remove
  116441. * @param dispose if the removed element should be disposed (default: false)
  116442. */
  116443. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116444. /**
  116445. * Disposes the component and the associated ressources.
  116446. */
  116447. dispose(): void;
  116448. private _isReadyForMesh;
  116449. private _renderMainTexture;
  116450. private _setStencil;
  116451. private _setStencilBack;
  116452. private _draw;
  116453. private _drawCamera;
  116454. private _drawRenderingGroup;
  116455. }
  116456. }
  116457. declare module BABYLON {
  116458. /** @hidden */
  116459. export var glowMapMergePixelShader: {
  116460. name: string;
  116461. shader: string;
  116462. };
  116463. }
  116464. declare module BABYLON {
  116465. /** @hidden */
  116466. export var glowMapMergeVertexShader: {
  116467. name: string;
  116468. shader: string;
  116469. };
  116470. }
  116471. declare module BABYLON {
  116472. interface AbstractScene {
  116473. /**
  116474. * Return a the first highlight layer of the scene with a given name.
  116475. * @param name The name of the highlight layer to look for.
  116476. * @return The highlight layer if found otherwise null.
  116477. */
  116478. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116479. }
  116480. /**
  116481. * Glow layer options. This helps customizing the behaviour
  116482. * of the glow layer.
  116483. */
  116484. export interface IGlowLayerOptions {
  116485. /**
  116486. * Multiplication factor apply to the canvas size to compute the render target size
  116487. * used to generated the glowing objects (the smaller the faster).
  116488. */
  116489. mainTextureRatio: number;
  116490. /**
  116491. * Enforces a fixed size texture to ensure resize independant blur.
  116492. */
  116493. mainTextureFixedSize?: number;
  116494. /**
  116495. * How big is the kernel of the blur texture.
  116496. */
  116497. blurKernelSize: number;
  116498. /**
  116499. * The camera attached to the layer.
  116500. */
  116501. camera: Nullable<Camera>;
  116502. /**
  116503. * Enable MSAA by chosing the number of samples.
  116504. */
  116505. mainTextureSamples?: number;
  116506. /**
  116507. * The rendering group to draw the layer in.
  116508. */
  116509. renderingGroupId: number;
  116510. }
  116511. /**
  116512. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116513. *
  116514. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116515. * glowy meshes to your scene.
  116516. *
  116517. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116518. */
  116519. export class GlowLayer extends EffectLayer {
  116520. /**
  116521. * Effect Name of the layer.
  116522. */
  116523. static readonly EffectName: string;
  116524. /**
  116525. * The default blur kernel size used for the glow.
  116526. */
  116527. static DefaultBlurKernelSize: number;
  116528. /**
  116529. * The default texture size ratio used for the glow.
  116530. */
  116531. static DefaultTextureRatio: number;
  116532. /**
  116533. * Sets the kernel size of the blur.
  116534. */
  116535. /**
  116536. * Gets the kernel size of the blur.
  116537. */
  116538. blurKernelSize: number;
  116539. /**
  116540. * Sets the glow intensity.
  116541. */
  116542. /**
  116543. * Gets the glow intensity.
  116544. */
  116545. intensity: number;
  116546. private _options;
  116547. private _intensity;
  116548. private _horizontalBlurPostprocess1;
  116549. private _verticalBlurPostprocess1;
  116550. private _horizontalBlurPostprocess2;
  116551. private _verticalBlurPostprocess2;
  116552. private _blurTexture1;
  116553. private _blurTexture2;
  116554. private _postProcesses1;
  116555. private _postProcesses2;
  116556. private _includedOnlyMeshes;
  116557. private _excludedMeshes;
  116558. /**
  116559. * Callback used to let the user override the color selection on a per mesh basis
  116560. */
  116561. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116562. /**
  116563. * Callback used to let the user override the texture selection on a per mesh basis
  116564. */
  116565. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116566. /**
  116567. * Instantiates a new glow Layer and references it to the scene.
  116568. * @param name The name of the layer
  116569. * @param scene The scene to use the layer in
  116570. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116571. */
  116572. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116573. /**
  116574. * Get the effect name of the layer.
  116575. * @return The effect name
  116576. */
  116577. getEffectName(): string;
  116578. /**
  116579. * Create the merge effect. This is the shader use to blit the information back
  116580. * to the main canvas at the end of the scene rendering.
  116581. */
  116582. protected _createMergeEffect(): Effect;
  116583. /**
  116584. * Creates the render target textures and post processes used in the glow layer.
  116585. */
  116586. protected _createTextureAndPostProcesses(): void;
  116587. /**
  116588. * Checks for the readiness of the element composing the layer.
  116589. * @param subMesh the mesh to check for
  116590. * @param useInstances specify wether or not to use instances to render the mesh
  116591. * @param emissiveTexture the associated emissive texture used to generate the glow
  116592. * @return true if ready otherwise, false
  116593. */
  116594. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116595. /**
  116596. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116597. */
  116598. needStencil(): boolean;
  116599. /**
  116600. * Returns true if the mesh can be rendered, otherwise false.
  116601. * @param mesh The mesh to render
  116602. * @param material The material used on the mesh
  116603. * @returns true if it can be rendered otherwise false
  116604. */
  116605. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116606. /**
  116607. * Implementation specific of rendering the generating effect on the main canvas.
  116608. * @param effect The effect used to render through
  116609. */
  116610. protected _internalRender(effect: Effect): void;
  116611. /**
  116612. * Sets the required values for both the emissive texture and and the main color.
  116613. */
  116614. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116615. /**
  116616. * Returns true if the mesh should render, otherwise false.
  116617. * @param mesh The mesh to render
  116618. * @returns true if it should render otherwise false
  116619. */
  116620. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116621. /**
  116622. * Adds specific effects defines.
  116623. * @param defines The defines to add specifics to.
  116624. */
  116625. protected _addCustomEffectDefines(defines: string[]): void;
  116626. /**
  116627. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116628. * @param mesh The mesh to exclude from the glow layer
  116629. */
  116630. addExcludedMesh(mesh: Mesh): void;
  116631. /**
  116632. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116633. * @param mesh The mesh to remove
  116634. */
  116635. removeExcludedMesh(mesh: Mesh): void;
  116636. /**
  116637. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116638. * @param mesh The mesh to include in the glow layer
  116639. */
  116640. addIncludedOnlyMesh(mesh: Mesh): void;
  116641. /**
  116642. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116643. * @param mesh The mesh to remove
  116644. */
  116645. removeIncludedOnlyMesh(mesh: Mesh): void;
  116646. /**
  116647. * Determine if a given mesh will be used in the glow layer
  116648. * @param mesh The mesh to test
  116649. * @returns true if the mesh will be highlighted by the current glow layer
  116650. */
  116651. hasMesh(mesh: AbstractMesh): boolean;
  116652. /**
  116653. * Free any resources and references associated to a mesh.
  116654. * Internal use
  116655. * @param mesh The mesh to free.
  116656. * @hidden
  116657. */
  116658. _disposeMesh(mesh: Mesh): void;
  116659. /**
  116660. * Gets the class name of the effect layer
  116661. * @returns the string with the class name of the effect layer
  116662. */
  116663. getClassName(): string;
  116664. /**
  116665. * Serializes this glow layer
  116666. * @returns a serialized glow layer object
  116667. */
  116668. serialize(): any;
  116669. /**
  116670. * Creates a Glow Layer from parsed glow layer data
  116671. * @param parsedGlowLayer defines glow layer data
  116672. * @param scene defines the current scene
  116673. * @param rootUrl defines the root URL containing the glow layer information
  116674. * @returns a parsed Glow Layer
  116675. */
  116676. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116677. }
  116678. }
  116679. declare module BABYLON {
  116680. /** @hidden */
  116681. export var glowBlurPostProcessPixelShader: {
  116682. name: string;
  116683. shader: string;
  116684. };
  116685. }
  116686. declare module BABYLON {
  116687. interface AbstractScene {
  116688. /**
  116689. * Return a the first highlight layer of the scene with a given name.
  116690. * @param name The name of the highlight layer to look for.
  116691. * @return The highlight layer if found otherwise null.
  116692. */
  116693. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116694. }
  116695. /**
  116696. * Highlight layer options. This helps customizing the behaviour
  116697. * of the highlight layer.
  116698. */
  116699. export interface IHighlightLayerOptions {
  116700. /**
  116701. * Multiplication factor apply to the canvas size to compute the render target size
  116702. * used to generated the glowing objects (the smaller the faster).
  116703. */
  116704. mainTextureRatio: number;
  116705. /**
  116706. * Enforces a fixed size texture to ensure resize independant blur.
  116707. */
  116708. mainTextureFixedSize?: number;
  116709. /**
  116710. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116711. * of the picture to blur (the smaller the faster).
  116712. */
  116713. blurTextureSizeRatio: number;
  116714. /**
  116715. * How big in texel of the blur texture is the vertical blur.
  116716. */
  116717. blurVerticalSize: number;
  116718. /**
  116719. * How big in texel of the blur texture is the horizontal blur.
  116720. */
  116721. blurHorizontalSize: number;
  116722. /**
  116723. * Alpha blending mode used to apply the blur. Default is combine.
  116724. */
  116725. alphaBlendingMode: number;
  116726. /**
  116727. * The camera attached to the layer.
  116728. */
  116729. camera: Nullable<Camera>;
  116730. /**
  116731. * Should we display highlight as a solid stroke?
  116732. */
  116733. isStroke?: boolean;
  116734. /**
  116735. * The rendering group to draw the layer in.
  116736. */
  116737. renderingGroupId: number;
  116738. }
  116739. /**
  116740. * The highlight layer Helps adding a glow effect around a mesh.
  116741. *
  116742. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116743. * glowy meshes to your scene.
  116744. *
  116745. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116746. */
  116747. export class HighlightLayer extends EffectLayer {
  116748. name: string;
  116749. /**
  116750. * Effect Name of the highlight layer.
  116751. */
  116752. static readonly EffectName: string;
  116753. /**
  116754. * The neutral color used during the preparation of the glow effect.
  116755. * This is black by default as the blend operation is a blend operation.
  116756. */
  116757. static NeutralColor: Color4;
  116758. /**
  116759. * Stencil value used for glowing meshes.
  116760. */
  116761. static GlowingMeshStencilReference: number;
  116762. /**
  116763. * Stencil value used for the other meshes in the scene.
  116764. */
  116765. static NormalMeshStencilReference: number;
  116766. /**
  116767. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116768. */
  116769. innerGlow: boolean;
  116770. /**
  116771. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116772. */
  116773. outerGlow: boolean;
  116774. /**
  116775. * Specifies the horizontal size of the blur.
  116776. */
  116777. /**
  116778. * Gets the horizontal size of the blur.
  116779. */
  116780. blurHorizontalSize: number;
  116781. /**
  116782. * Specifies the vertical size of the blur.
  116783. */
  116784. /**
  116785. * Gets the vertical size of the blur.
  116786. */
  116787. blurVerticalSize: number;
  116788. /**
  116789. * An event triggered when the highlight layer is being blurred.
  116790. */
  116791. onBeforeBlurObservable: Observable<HighlightLayer>;
  116792. /**
  116793. * An event triggered when the highlight layer has been blurred.
  116794. */
  116795. onAfterBlurObservable: Observable<HighlightLayer>;
  116796. private _instanceGlowingMeshStencilReference;
  116797. private _options;
  116798. private _downSamplePostprocess;
  116799. private _horizontalBlurPostprocess;
  116800. private _verticalBlurPostprocess;
  116801. private _blurTexture;
  116802. private _meshes;
  116803. private _excludedMeshes;
  116804. /**
  116805. * Instantiates a new highlight Layer and references it to the scene..
  116806. * @param name The name of the layer
  116807. * @param scene The scene to use the layer in
  116808. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116809. */
  116810. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116811. /**
  116812. * Get the effect name of the layer.
  116813. * @return The effect name
  116814. */
  116815. getEffectName(): string;
  116816. /**
  116817. * Create the merge effect. This is the shader use to blit the information back
  116818. * to the main canvas at the end of the scene rendering.
  116819. */
  116820. protected _createMergeEffect(): Effect;
  116821. /**
  116822. * Creates the render target textures and post processes used in the highlight layer.
  116823. */
  116824. protected _createTextureAndPostProcesses(): void;
  116825. /**
  116826. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116827. */
  116828. needStencil(): boolean;
  116829. /**
  116830. * Checks for the readiness of the element composing the layer.
  116831. * @param subMesh the mesh to check for
  116832. * @param useInstances specify wether or not to use instances to render the mesh
  116833. * @param emissiveTexture the associated emissive texture used to generate the glow
  116834. * @return true if ready otherwise, false
  116835. */
  116836. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116837. /**
  116838. * Implementation specific of rendering the generating effect on the main canvas.
  116839. * @param effect The effect used to render through
  116840. */
  116841. protected _internalRender(effect: Effect): void;
  116842. /**
  116843. * Returns true if the layer contains information to display, otherwise false.
  116844. */
  116845. shouldRender(): boolean;
  116846. /**
  116847. * Returns true if the mesh should render, otherwise false.
  116848. * @param mesh The mesh to render
  116849. * @returns true if it should render otherwise false
  116850. */
  116851. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116852. /**
  116853. * Sets the required values for both the emissive texture and and the main color.
  116854. */
  116855. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116856. /**
  116857. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116858. * @param mesh The mesh to exclude from the highlight layer
  116859. */
  116860. addExcludedMesh(mesh: Mesh): void;
  116861. /**
  116862. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116863. * @param mesh The mesh to highlight
  116864. */
  116865. removeExcludedMesh(mesh: Mesh): void;
  116866. /**
  116867. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116868. * @param mesh mesh to test
  116869. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116870. */
  116871. hasMesh(mesh: AbstractMesh): boolean;
  116872. /**
  116873. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116874. * @param mesh The mesh to highlight
  116875. * @param color The color of the highlight
  116876. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116877. */
  116878. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116879. /**
  116880. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116881. * @param mesh The mesh to highlight
  116882. */
  116883. removeMesh(mesh: Mesh): void;
  116884. /**
  116885. * Force the stencil to the normal expected value for none glowing parts
  116886. */
  116887. private _defaultStencilReference;
  116888. /**
  116889. * Free any resources and references associated to a mesh.
  116890. * Internal use
  116891. * @param mesh The mesh to free.
  116892. * @hidden
  116893. */
  116894. _disposeMesh(mesh: Mesh): void;
  116895. /**
  116896. * Dispose the highlight layer and free resources.
  116897. */
  116898. dispose(): void;
  116899. /**
  116900. * Gets the class name of the effect layer
  116901. * @returns the string with the class name of the effect layer
  116902. */
  116903. getClassName(): string;
  116904. /**
  116905. * Serializes this Highlight layer
  116906. * @returns a serialized Highlight layer object
  116907. */
  116908. serialize(): any;
  116909. /**
  116910. * Creates a Highlight layer from parsed Highlight layer data
  116911. * @param parsedHightlightLayer defines the Highlight layer data
  116912. * @param scene defines the current scene
  116913. * @param rootUrl defines the root URL containing the Highlight layer information
  116914. * @returns a parsed Highlight layer
  116915. */
  116916. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116917. }
  116918. }
  116919. declare module BABYLON {
  116920. interface AbstractScene {
  116921. /**
  116922. * The list of layers (background and foreground) of the scene
  116923. */
  116924. layers: Array<Layer>;
  116925. }
  116926. /**
  116927. * Defines the layer scene component responsible to manage any layers
  116928. * in a given scene.
  116929. */
  116930. export class LayerSceneComponent implements ISceneComponent {
  116931. /**
  116932. * The component name helpfull to identify the component in the list of scene components.
  116933. */
  116934. readonly name: string;
  116935. /**
  116936. * The scene the component belongs to.
  116937. */
  116938. scene: Scene;
  116939. private _engine;
  116940. /**
  116941. * Creates a new instance of the component for the given scene
  116942. * @param scene Defines the scene to register the component in
  116943. */
  116944. constructor(scene: Scene);
  116945. /**
  116946. * Registers the component in a given scene
  116947. */
  116948. register(): void;
  116949. /**
  116950. * Rebuilds the elements related to this component in case of
  116951. * context lost for instance.
  116952. */
  116953. rebuild(): void;
  116954. /**
  116955. * Disposes the component and the associated ressources.
  116956. */
  116957. dispose(): void;
  116958. private _draw;
  116959. private _drawCameraPredicate;
  116960. private _drawCameraBackground;
  116961. private _drawCameraForeground;
  116962. private _drawRenderTargetPredicate;
  116963. private _drawRenderTargetBackground;
  116964. private _drawRenderTargetForeground;
  116965. /**
  116966. * Adds all the elements from the container to the scene
  116967. * @param container the container holding the elements
  116968. */
  116969. addFromContainer(container: AbstractScene): void;
  116970. /**
  116971. * Removes all the elements in the container from the scene
  116972. * @param container contains the elements to remove
  116973. * @param dispose if the removed element should be disposed (default: false)
  116974. */
  116975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116976. }
  116977. }
  116978. declare module BABYLON {
  116979. /** @hidden */
  116980. export var layerPixelShader: {
  116981. name: string;
  116982. shader: string;
  116983. };
  116984. }
  116985. declare module BABYLON {
  116986. /** @hidden */
  116987. export var layerVertexShader: {
  116988. name: string;
  116989. shader: string;
  116990. };
  116991. }
  116992. declare module BABYLON {
  116993. /**
  116994. * This represents a full screen 2d layer.
  116995. * This can be useful to display a picture in the background of your scene for instance.
  116996. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116997. */
  116998. export class Layer {
  116999. /**
  117000. * Define the name of the layer.
  117001. */
  117002. name: string;
  117003. /**
  117004. * Define the texture the layer should display.
  117005. */
  117006. texture: Nullable<Texture>;
  117007. /**
  117008. * Is the layer in background or foreground.
  117009. */
  117010. isBackground: boolean;
  117011. /**
  117012. * Define the color of the layer (instead of texture).
  117013. */
  117014. color: Color4;
  117015. /**
  117016. * Define the scale of the layer in order to zoom in out of the texture.
  117017. */
  117018. scale: Vector2;
  117019. /**
  117020. * Define an offset for the layer in order to shift the texture.
  117021. */
  117022. offset: Vector2;
  117023. /**
  117024. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  117025. */
  117026. alphaBlendingMode: number;
  117027. /**
  117028. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  117029. * Alpha test will not mix with the background color in case of transparency.
  117030. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  117031. */
  117032. alphaTest: boolean;
  117033. /**
  117034. * Define a mask to restrict the layer to only some of the scene cameras.
  117035. */
  117036. layerMask: number;
  117037. /**
  117038. * Define the list of render target the layer is visible into.
  117039. */
  117040. renderTargetTextures: RenderTargetTexture[];
  117041. /**
  117042. * Define if the layer is only used in renderTarget or if it also
  117043. * renders in the main frame buffer of the canvas.
  117044. */
  117045. renderOnlyInRenderTargetTextures: boolean;
  117046. private _scene;
  117047. private _vertexBuffers;
  117048. private _indexBuffer;
  117049. private _effect;
  117050. private _alphaTestEffect;
  117051. /**
  117052. * An event triggered when the layer is disposed.
  117053. */
  117054. onDisposeObservable: Observable<Layer>;
  117055. private _onDisposeObserver;
  117056. /**
  117057. * Back compatibility with callback before the onDisposeObservable existed.
  117058. * The set callback will be triggered when the layer has been disposed.
  117059. */
  117060. onDispose: () => void;
  117061. /**
  117062. * An event triggered before rendering the scene
  117063. */
  117064. onBeforeRenderObservable: Observable<Layer>;
  117065. private _onBeforeRenderObserver;
  117066. /**
  117067. * Back compatibility with callback before the onBeforeRenderObservable existed.
  117068. * The set callback will be triggered just before rendering the layer.
  117069. */
  117070. onBeforeRender: () => void;
  117071. /**
  117072. * An event triggered after rendering the scene
  117073. */
  117074. onAfterRenderObservable: Observable<Layer>;
  117075. private _onAfterRenderObserver;
  117076. /**
  117077. * Back compatibility with callback before the onAfterRenderObservable existed.
  117078. * The set callback will be triggered just after rendering the layer.
  117079. */
  117080. onAfterRender: () => void;
  117081. /**
  117082. * Instantiates a new layer.
  117083. * This represents a full screen 2d layer.
  117084. * This can be useful to display a picture in the background of your scene for instance.
  117085. * @see https://www.babylonjs-playground.com/#08A2BS#1
  117086. * @param name Define the name of the layer in the scene
  117087. * @param imgUrl Define the url of the texture to display in the layer
  117088. * @param scene Define the scene the layer belongs to
  117089. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  117090. * @param color Defines a color for the layer
  117091. */
  117092. constructor(
  117093. /**
  117094. * Define the name of the layer.
  117095. */
  117096. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117097. private _createIndexBuffer;
  117098. /** @hidden */
  117099. _rebuild(): void;
  117100. /**
  117101. * Renders the layer in the scene.
  117102. */
  117103. render(): void;
  117104. /**
  117105. * Disposes and releases the associated ressources.
  117106. */
  117107. dispose(): void;
  117108. }
  117109. }
  117110. declare module BABYLON {
  117111. /** @hidden */
  117112. export var lensFlarePixelShader: {
  117113. name: string;
  117114. shader: string;
  117115. };
  117116. }
  117117. declare module BABYLON {
  117118. /** @hidden */
  117119. export var lensFlareVertexShader: {
  117120. name: string;
  117121. shader: string;
  117122. };
  117123. }
  117124. declare module BABYLON {
  117125. /**
  117126. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117127. * It is usually composed of several `lensFlare`.
  117128. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117129. */
  117130. export class LensFlareSystem {
  117131. /**
  117132. * Define the name of the lens flare system
  117133. */
  117134. name: string;
  117135. /**
  117136. * List of lens flares used in this system.
  117137. */
  117138. lensFlares: LensFlare[];
  117139. /**
  117140. * Define a limit from the border the lens flare can be visible.
  117141. */
  117142. borderLimit: number;
  117143. /**
  117144. * Define a viewport border we do not want to see the lens flare in.
  117145. */
  117146. viewportBorder: number;
  117147. /**
  117148. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117149. */
  117150. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117151. /**
  117152. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117153. */
  117154. layerMask: number;
  117155. /**
  117156. * Define the id of the lens flare system in the scene.
  117157. * (equal to name by default)
  117158. */
  117159. id: string;
  117160. private _scene;
  117161. private _emitter;
  117162. private _vertexBuffers;
  117163. private _indexBuffer;
  117164. private _effect;
  117165. private _positionX;
  117166. private _positionY;
  117167. private _isEnabled;
  117168. /** @hidden */
  117169. static _SceneComponentInitialization: (scene: Scene) => void;
  117170. /**
  117171. * Instantiates a lens flare system.
  117172. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117173. * It is usually composed of several `lensFlare`.
  117174. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117175. * @param name Define the name of the lens flare system in the scene
  117176. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117177. * @param scene Define the scene the lens flare system belongs to
  117178. */
  117179. constructor(
  117180. /**
  117181. * Define the name of the lens flare system
  117182. */
  117183. name: string, emitter: any, scene: Scene);
  117184. /**
  117185. * Define if the lens flare system is enabled.
  117186. */
  117187. isEnabled: boolean;
  117188. /**
  117189. * Get the scene the effects belongs to.
  117190. * @returns the scene holding the lens flare system
  117191. */
  117192. getScene(): Scene;
  117193. /**
  117194. * Get the emitter of the lens flare system.
  117195. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117196. * @returns the emitter of the lens flare system
  117197. */
  117198. getEmitter(): any;
  117199. /**
  117200. * Set the emitter of the lens flare system.
  117201. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117202. * @param newEmitter Define the new emitter of the system
  117203. */
  117204. setEmitter(newEmitter: any): void;
  117205. /**
  117206. * Get the lens flare system emitter position.
  117207. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117208. * @returns the position
  117209. */
  117210. getEmitterPosition(): Vector3;
  117211. /**
  117212. * @hidden
  117213. */
  117214. computeEffectivePosition(globalViewport: Viewport): boolean;
  117215. /** @hidden */
  117216. _isVisible(): boolean;
  117217. /**
  117218. * @hidden
  117219. */
  117220. render(): boolean;
  117221. /**
  117222. * Dispose and release the lens flare with its associated resources.
  117223. */
  117224. dispose(): void;
  117225. /**
  117226. * Parse a lens flare system from a JSON repressentation
  117227. * @param parsedLensFlareSystem Define the JSON to parse
  117228. * @param scene Define the scene the parsed system should be instantiated in
  117229. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117230. * @returns the parsed system
  117231. */
  117232. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117233. /**
  117234. * Serialize the current Lens Flare System into a JSON representation.
  117235. * @returns the serialized JSON
  117236. */
  117237. serialize(): any;
  117238. }
  117239. }
  117240. declare module BABYLON {
  117241. /**
  117242. * This represents one of the lens effect in a `lensFlareSystem`.
  117243. * It controls one of the indiviual texture used in the effect.
  117244. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117245. */
  117246. export class LensFlare {
  117247. /**
  117248. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117249. */
  117250. size: number;
  117251. /**
  117252. * 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.
  117253. */
  117254. position: number;
  117255. /**
  117256. * Define the lens color.
  117257. */
  117258. color: Color3;
  117259. /**
  117260. * Define the lens texture.
  117261. */
  117262. texture: Nullable<Texture>;
  117263. /**
  117264. * Define the alpha mode to render this particular lens.
  117265. */
  117266. alphaMode: number;
  117267. private _system;
  117268. /**
  117269. * Creates a new Lens Flare.
  117270. * This represents one of the lens effect in a `lensFlareSystem`.
  117271. * It controls one of the indiviual texture used in the effect.
  117272. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117273. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117274. * @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.
  117275. * @param color Define the lens color
  117276. * @param imgUrl Define the lens texture url
  117277. * @param system Define the `lensFlareSystem` this flare is part of
  117278. * @returns The newly created Lens Flare
  117279. */
  117280. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117281. /**
  117282. * Instantiates a new Lens Flare.
  117283. * This represents one of the lens effect in a `lensFlareSystem`.
  117284. * It controls one of the indiviual texture used in the effect.
  117285. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117286. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117287. * @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.
  117288. * @param color Define the lens color
  117289. * @param imgUrl Define the lens texture url
  117290. * @param system Define the `lensFlareSystem` this flare is part of
  117291. */
  117292. constructor(
  117293. /**
  117294. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117295. */
  117296. size: number,
  117297. /**
  117298. * 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.
  117299. */
  117300. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117301. /**
  117302. * Dispose and release the lens flare with its associated resources.
  117303. */
  117304. dispose(): void;
  117305. }
  117306. }
  117307. declare module BABYLON {
  117308. interface AbstractScene {
  117309. /**
  117310. * The list of lens flare system added to the scene
  117311. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117312. */
  117313. lensFlareSystems: Array<LensFlareSystem>;
  117314. /**
  117315. * Removes the given lens flare system from this scene.
  117316. * @param toRemove The lens flare system to remove
  117317. * @returns The index of the removed lens flare system
  117318. */
  117319. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117320. /**
  117321. * Adds the given lens flare system to this scene
  117322. * @param newLensFlareSystem The lens flare system to add
  117323. */
  117324. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117325. /**
  117326. * Gets a lens flare system using its name
  117327. * @param name defines the name to look for
  117328. * @returns the lens flare system or null if not found
  117329. */
  117330. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117331. /**
  117332. * Gets a lens flare system using its id
  117333. * @param id defines the id to look for
  117334. * @returns the lens flare system or null if not found
  117335. */
  117336. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117337. }
  117338. /**
  117339. * Defines the lens flare scene component responsible to manage any lens flares
  117340. * in a given scene.
  117341. */
  117342. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117343. /**
  117344. * The component name helpfull to identify the component in the list of scene components.
  117345. */
  117346. readonly name: string;
  117347. /**
  117348. * The scene the component belongs to.
  117349. */
  117350. scene: Scene;
  117351. /**
  117352. * Creates a new instance of the component for the given scene
  117353. * @param scene Defines the scene to register the component in
  117354. */
  117355. constructor(scene: Scene);
  117356. /**
  117357. * Registers the component in a given scene
  117358. */
  117359. register(): void;
  117360. /**
  117361. * Rebuilds the elements related to this component in case of
  117362. * context lost for instance.
  117363. */
  117364. rebuild(): void;
  117365. /**
  117366. * Adds all the elements from the container to the scene
  117367. * @param container the container holding the elements
  117368. */
  117369. addFromContainer(container: AbstractScene): void;
  117370. /**
  117371. * Removes all the elements in the container from the scene
  117372. * @param container contains the elements to remove
  117373. * @param dispose if the removed element should be disposed (default: false)
  117374. */
  117375. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117376. /**
  117377. * Serializes the component data to the specified json object
  117378. * @param serializationObject The object to serialize to
  117379. */
  117380. serialize(serializationObject: any): void;
  117381. /**
  117382. * Disposes the component and the associated ressources.
  117383. */
  117384. dispose(): void;
  117385. private _draw;
  117386. }
  117387. }
  117388. declare module BABYLON {
  117389. /**
  117390. * Defines the shadow generator component responsible to manage any shadow generators
  117391. * in a given scene.
  117392. */
  117393. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117394. /**
  117395. * The component name helpfull to identify the component in the list of scene components.
  117396. */
  117397. readonly name: string;
  117398. /**
  117399. * The scene the component belongs to.
  117400. */
  117401. scene: Scene;
  117402. /**
  117403. * Creates a new instance of the component for the given scene
  117404. * @param scene Defines the scene to register the component in
  117405. */
  117406. constructor(scene: Scene);
  117407. /**
  117408. * Registers the component in a given scene
  117409. */
  117410. register(): void;
  117411. /**
  117412. * Rebuilds the elements related to this component in case of
  117413. * context lost for instance.
  117414. */
  117415. rebuild(): void;
  117416. /**
  117417. * Serializes the component data to the specified json object
  117418. * @param serializationObject The object to serialize to
  117419. */
  117420. serialize(serializationObject: any): void;
  117421. /**
  117422. * Adds all the elements from the container to the scene
  117423. * @param container the container holding the elements
  117424. */
  117425. addFromContainer(container: AbstractScene): void;
  117426. /**
  117427. * Removes all the elements in the container from the scene
  117428. * @param container contains the elements to remove
  117429. * @param dispose if the removed element should be disposed (default: false)
  117430. */
  117431. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117432. /**
  117433. * Rebuilds the elements related to this component in case of
  117434. * context lost for instance.
  117435. */
  117436. dispose(): void;
  117437. private _gatherRenderTargets;
  117438. }
  117439. }
  117440. declare module BABYLON {
  117441. /**
  117442. * A point light is a light defined by an unique point in world space.
  117443. * The light is emitted in every direction from this point.
  117444. * A good example of a point light is a standard light bulb.
  117445. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117446. */
  117447. export class PointLight extends ShadowLight {
  117448. private _shadowAngle;
  117449. /**
  117450. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117451. * This specifies what angle the shadow will use to be created.
  117452. *
  117453. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117454. */
  117455. /**
  117456. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117457. * This specifies what angle the shadow will use to be created.
  117458. *
  117459. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117460. */
  117461. shadowAngle: number;
  117462. /**
  117463. * Gets the direction if it has been set.
  117464. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117465. */
  117466. /**
  117467. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117468. */
  117469. direction: Vector3;
  117470. /**
  117471. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117472. * A PointLight emits the light in every direction.
  117473. * It can cast shadows.
  117474. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117475. * ```javascript
  117476. * var pointLight = new PointLight("pl", camera.position, scene);
  117477. * ```
  117478. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117479. * @param name The light friendly name
  117480. * @param position The position of the point light in the scene
  117481. * @param scene The scene the lights belongs to
  117482. */
  117483. constructor(name: string, position: Vector3, scene: Scene);
  117484. /**
  117485. * Returns the string "PointLight"
  117486. * @returns the class name
  117487. */
  117488. getClassName(): string;
  117489. /**
  117490. * Returns the integer 0.
  117491. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117492. */
  117493. getTypeID(): number;
  117494. /**
  117495. * Specifies wether or not the shadowmap should be a cube texture.
  117496. * @returns true if the shadowmap needs to be a cube texture.
  117497. */
  117498. needCube(): boolean;
  117499. /**
  117500. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117501. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117502. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117503. */
  117504. getShadowDirection(faceIndex?: number): Vector3;
  117505. /**
  117506. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117507. * - fov = PI / 2
  117508. * - aspect ratio : 1.0
  117509. * - z-near and far equal to the active camera minZ and maxZ.
  117510. * Returns the PointLight.
  117511. */
  117512. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117513. protected _buildUniformLayout(): void;
  117514. /**
  117515. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117516. * @param effect The effect to update
  117517. * @param lightIndex The index of the light in the effect to update
  117518. * @returns The point light
  117519. */
  117520. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117521. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117522. /**
  117523. * Prepares the list of defines specific to the light type.
  117524. * @param defines the list of defines
  117525. * @param lightIndex defines the index of the light for the effect
  117526. */
  117527. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117528. }
  117529. }
  117530. declare module BABYLON {
  117531. /**
  117532. * Header information of HDR texture files.
  117533. */
  117534. export interface HDRInfo {
  117535. /**
  117536. * The height of the texture in pixels.
  117537. */
  117538. height: number;
  117539. /**
  117540. * The width of the texture in pixels.
  117541. */
  117542. width: number;
  117543. /**
  117544. * The index of the beginning of the data in the binary file.
  117545. */
  117546. dataPosition: number;
  117547. }
  117548. /**
  117549. * This groups tools to convert HDR texture to native colors array.
  117550. */
  117551. export class HDRTools {
  117552. private static Ldexp;
  117553. private static Rgbe2float;
  117554. private static readStringLine;
  117555. /**
  117556. * Reads header information from an RGBE texture stored in a native array.
  117557. * More information on this format are available here:
  117558. * https://en.wikipedia.org/wiki/RGBE_image_format
  117559. *
  117560. * @param uint8array The binary file stored in native array.
  117561. * @return The header information.
  117562. */
  117563. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117564. /**
  117565. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117566. * This RGBE texture needs to store the information as a panorama.
  117567. *
  117568. * More information on this format are available here:
  117569. * https://en.wikipedia.org/wiki/RGBE_image_format
  117570. *
  117571. * @param buffer The binary file stored in an array buffer.
  117572. * @param size The expected size of the extracted cubemap.
  117573. * @return The Cube Map information.
  117574. */
  117575. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117576. /**
  117577. * Returns the pixels data extracted from an RGBE texture.
  117578. * This pixels will be stored left to right up to down in the R G B order in one array.
  117579. *
  117580. * More information on this format are available here:
  117581. * https://en.wikipedia.org/wiki/RGBE_image_format
  117582. *
  117583. * @param uint8array The binary file stored in an array buffer.
  117584. * @param hdrInfo The header information of the file.
  117585. * @return The pixels data in RGB right to left up to down order.
  117586. */
  117587. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117588. private static RGBE_ReadPixels_RLE;
  117589. }
  117590. }
  117591. declare module BABYLON {
  117592. /**
  117593. * This represents a texture coming from an HDR input.
  117594. *
  117595. * The only supported format is currently panorama picture stored in RGBE format.
  117596. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117597. */
  117598. export class HDRCubeTexture extends BaseTexture {
  117599. private static _facesMapping;
  117600. private _generateHarmonics;
  117601. private _noMipmap;
  117602. private _textureMatrix;
  117603. private _size;
  117604. private _onLoad;
  117605. private _onError;
  117606. /**
  117607. * The texture URL.
  117608. */
  117609. url: string;
  117610. /**
  117611. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117612. */
  117613. coordinatesMode: number;
  117614. protected _isBlocking: boolean;
  117615. /**
  117616. * Sets wether or not the texture is blocking during loading.
  117617. */
  117618. /**
  117619. * Gets wether or not the texture is blocking during loading.
  117620. */
  117621. isBlocking: boolean;
  117622. protected _rotationY: number;
  117623. /**
  117624. * Sets texture matrix rotation angle around Y axis in radians.
  117625. */
  117626. /**
  117627. * Gets texture matrix rotation angle around Y axis radians.
  117628. */
  117629. rotationY: number;
  117630. /**
  117631. * Gets or sets the center of the bounding box associated with the cube texture
  117632. * It must define where the camera used to render the texture was set
  117633. */
  117634. boundingBoxPosition: Vector3;
  117635. private _boundingBoxSize;
  117636. /**
  117637. * Gets or sets the size of the bounding box associated with the cube texture
  117638. * When defined, the cubemap will switch to local mode
  117639. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117640. * @example https://www.babylonjs-playground.com/#RNASML
  117641. */
  117642. boundingBoxSize: Vector3;
  117643. /**
  117644. * Instantiates an HDRTexture from the following parameters.
  117645. *
  117646. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117647. * @param scene The scene the texture will be used in
  117648. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117649. * @param noMipmap Forces to not generate the mipmap if true
  117650. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117651. * @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)
  117652. * @param reserved Reserved flag for internal use.
  117653. */
  117654. 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>);
  117655. /**
  117656. * Get the current class name of the texture useful for serialization or dynamic coding.
  117657. * @returns "HDRCubeTexture"
  117658. */
  117659. getClassName(): string;
  117660. /**
  117661. * Occurs when the file is raw .hdr file.
  117662. */
  117663. private loadTexture;
  117664. clone(): HDRCubeTexture;
  117665. delayLoad(): void;
  117666. /**
  117667. * Get the texture reflection matrix used to rotate/transform the reflection.
  117668. * @returns the reflection matrix
  117669. */
  117670. getReflectionTextureMatrix(): Matrix;
  117671. /**
  117672. * Set the texture reflection matrix used to rotate/transform the reflection.
  117673. * @param value Define the reflection matrix to set
  117674. */
  117675. setReflectionTextureMatrix(value: Matrix): void;
  117676. /**
  117677. * Parses a JSON representation of an HDR Texture in order to create the texture
  117678. * @param parsedTexture Define the JSON representation
  117679. * @param scene Define the scene the texture should be created in
  117680. * @param rootUrl Define the root url in case we need to load relative dependencies
  117681. * @returns the newly created texture after parsing
  117682. */
  117683. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117684. serialize(): any;
  117685. }
  117686. }
  117687. declare module BABYLON {
  117688. /**
  117689. * Class used to control physics engine
  117690. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117691. */
  117692. export class PhysicsEngine implements IPhysicsEngine {
  117693. private _physicsPlugin;
  117694. /**
  117695. * Global value used to control the smallest number supported by the simulation
  117696. */
  117697. static Epsilon: number;
  117698. private _impostors;
  117699. private _joints;
  117700. /**
  117701. * Gets the gravity vector used by the simulation
  117702. */
  117703. gravity: Vector3;
  117704. /**
  117705. * Factory used to create the default physics plugin.
  117706. * @returns The default physics plugin
  117707. */
  117708. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117709. /**
  117710. * Creates a new Physics Engine
  117711. * @param gravity defines the gravity vector used by the simulation
  117712. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117713. */
  117714. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117715. /**
  117716. * Sets the gravity vector used by the simulation
  117717. * @param gravity defines the gravity vector to use
  117718. */
  117719. setGravity(gravity: Vector3): void;
  117720. /**
  117721. * Set the time step of the physics engine.
  117722. * Default is 1/60.
  117723. * To slow it down, enter 1/600 for example.
  117724. * To speed it up, 1/30
  117725. * @param newTimeStep defines the new timestep to apply to this world.
  117726. */
  117727. setTimeStep(newTimeStep?: number): void;
  117728. /**
  117729. * Get the time step of the physics engine.
  117730. * @returns the current time step
  117731. */
  117732. getTimeStep(): number;
  117733. /**
  117734. * Release all resources
  117735. */
  117736. dispose(): void;
  117737. /**
  117738. * Gets the name of the current physics plugin
  117739. * @returns the name of the plugin
  117740. */
  117741. getPhysicsPluginName(): string;
  117742. /**
  117743. * Adding a new impostor for the impostor tracking.
  117744. * This will be done by the impostor itself.
  117745. * @param impostor the impostor to add
  117746. */
  117747. addImpostor(impostor: PhysicsImpostor): void;
  117748. /**
  117749. * Remove an impostor from the engine.
  117750. * This impostor and its mesh will not longer be updated by the physics engine.
  117751. * @param impostor the impostor to remove
  117752. */
  117753. removeImpostor(impostor: PhysicsImpostor): void;
  117754. /**
  117755. * Add a joint to the physics engine
  117756. * @param mainImpostor defines the main impostor to which the joint is added.
  117757. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117758. * @param joint defines the joint that will connect both impostors.
  117759. */
  117760. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117761. /**
  117762. * Removes a joint from the simulation
  117763. * @param mainImpostor defines the impostor used with the joint
  117764. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117765. * @param joint defines the joint to remove
  117766. */
  117767. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117768. /**
  117769. * Called by the scene. No need to call it.
  117770. * @param delta defines the timespam between frames
  117771. */
  117772. _step(delta: number): void;
  117773. /**
  117774. * Gets the current plugin used to run the simulation
  117775. * @returns current plugin
  117776. */
  117777. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117778. /**
  117779. * Gets the list of physic impostors
  117780. * @returns an array of PhysicsImpostor
  117781. */
  117782. getImpostors(): Array<PhysicsImpostor>;
  117783. /**
  117784. * Gets the impostor for a physics enabled object
  117785. * @param object defines the object impersonated by the impostor
  117786. * @returns the PhysicsImpostor or null if not found
  117787. */
  117788. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117789. /**
  117790. * Gets the impostor for a physics body object
  117791. * @param body defines physics body used by the impostor
  117792. * @returns the PhysicsImpostor or null if not found
  117793. */
  117794. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117795. /**
  117796. * Does a raycast in the physics world
  117797. * @param from when should the ray start?
  117798. * @param to when should the ray end?
  117799. * @returns PhysicsRaycastResult
  117800. */
  117801. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117802. }
  117803. }
  117804. declare module BABYLON {
  117805. /** @hidden */
  117806. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117807. private _useDeltaForWorldStep;
  117808. world: any;
  117809. name: string;
  117810. private _physicsMaterials;
  117811. private _fixedTimeStep;
  117812. private _cannonRaycastResult;
  117813. private _raycastResult;
  117814. private _physicsBodysToRemoveAfterStep;
  117815. BJSCANNON: any;
  117816. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117817. setGravity(gravity: Vector3): void;
  117818. setTimeStep(timeStep: number): void;
  117819. getTimeStep(): number;
  117820. executeStep(delta: number): void;
  117821. private _removeMarkedPhysicsBodiesFromWorld;
  117822. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117823. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117824. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117825. private _processChildMeshes;
  117826. removePhysicsBody(impostor: PhysicsImpostor): void;
  117827. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117828. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117829. private _addMaterial;
  117830. private _checkWithEpsilon;
  117831. private _createShape;
  117832. private _createHeightmap;
  117833. private _minus90X;
  117834. private _plus90X;
  117835. private _tmpPosition;
  117836. private _tmpDeltaPosition;
  117837. private _tmpUnityRotation;
  117838. private _updatePhysicsBodyTransformation;
  117839. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117840. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117841. isSupported(): boolean;
  117842. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117843. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117844. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117845. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117846. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117847. getBodyMass(impostor: PhysicsImpostor): number;
  117848. getBodyFriction(impostor: PhysicsImpostor): number;
  117849. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117850. getBodyRestitution(impostor: PhysicsImpostor): number;
  117851. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117852. sleepBody(impostor: PhysicsImpostor): void;
  117853. wakeUpBody(impostor: PhysicsImpostor): void;
  117854. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117855. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117856. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117857. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117858. getRadius(impostor: PhysicsImpostor): number;
  117859. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117860. dispose(): void;
  117861. private _extendNamespace;
  117862. /**
  117863. * Does a raycast in the physics world
  117864. * @param from when should the ray start?
  117865. * @param to when should the ray end?
  117866. * @returns PhysicsRaycastResult
  117867. */
  117868. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117869. }
  117870. }
  117871. declare module BABYLON {
  117872. /** @hidden */
  117873. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117874. world: any;
  117875. name: string;
  117876. BJSOIMO: any;
  117877. private _raycastResult;
  117878. constructor(iterations?: number, oimoInjection?: any);
  117879. setGravity(gravity: Vector3): void;
  117880. setTimeStep(timeStep: number): void;
  117881. getTimeStep(): number;
  117882. private _tmpImpostorsArray;
  117883. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117884. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117885. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117886. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117887. private _tmpPositionVector;
  117888. removePhysicsBody(impostor: PhysicsImpostor): void;
  117889. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117890. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117891. isSupported(): boolean;
  117892. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117893. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117894. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117895. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117896. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117897. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117898. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117899. getBodyMass(impostor: PhysicsImpostor): number;
  117900. getBodyFriction(impostor: PhysicsImpostor): number;
  117901. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117902. getBodyRestitution(impostor: PhysicsImpostor): number;
  117903. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117904. sleepBody(impostor: PhysicsImpostor): void;
  117905. wakeUpBody(impostor: PhysicsImpostor): void;
  117906. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117907. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117908. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117909. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117910. getRadius(impostor: PhysicsImpostor): number;
  117911. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117912. dispose(): void;
  117913. /**
  117914. * Does a raycast in the physics world
  117915. * @param from when should the ray start?
  117916. * @param to when should the ray end?
  117917. * @returns PhysicsRaycastResult
  117918. */
  117919. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117920. }
  117921. }
  117922. declare module BABYLON {
  117923. /**
  117924. * Class containing static functions to help procedurally build meshes
  117925. */
  117926. export class RibbonBuilder {
  117927. /**
  117928. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117929. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117930. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117931. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117932. * * 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
  117933. * * 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
  117934. * * 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
  117935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117936. * * 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
  117937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117938. * * 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
  117939. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117940. * * 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
  117941. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117943. * @param name defines the name of the mesh
  117944. * @param options defines the options used to create the mesh
  117945. * @param scene defines the hosting scene
  117946. * @returns the ribbon mesh
  117947. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117948. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117949. */
  117950. static CreateRibbon(name: string, options: {
  117951. pathArray: Vector3[][];
  117952. closeArray?: boolean;
  117953. closePath?: boolean;
  117954. offset?: number;
  117955. updatable?: boolean;
  117956. sideOrientation?: number;
  117957. frontUVs?: Vector4;
  117958. backUVs?: Vector4;
  117959. instance?: Mesh;
  117960. invertUV?: boolean;
  117961. uvs?: Vector2[];
  117962. colors?: Color4[];
  117963. }, scene?: Nullable<Scene>): Mesh;
  117964. }
  117965. }
  117966. declare module BABYLON {
  117967. /**
  117968. * Class containing static functions to help procedurally build meshes
  117969. */
  117970. export class ShapeBuilder {
  117971. /**
  117972. * 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.
  117973. * * 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.
  117974. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117975. * * 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.
  117976. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117977. * * 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
  117978. * * 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
  117979. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117980. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117981. * * 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
  117982. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117983. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117984. * @param name defines the name of the mesh
  117985. * @param options defines the options used to create the mesh
  117986. * @param scene defines the hosting scene
  117987. * @returns the extruded shape mesh
  117988. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117989. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117990. */
  117991. static ExtrudeShape(name: string, options: {
  117992. shape: Vector3[];
  117993. path: Vector3[];
  117994. scale?: number;
  117995. rotation?: number;
  117996. cap?: number;
  117997. updatable?: boolean;
  117998. sideOrientation?: number;
  117999. frontUVs?: Vector4;
  118000. backUVs?: Vector4;
  118001. instance?: Mesh;
  118002. invertUV?: boolean;
  118003. }, scene?: Nullable<Scene>): Mesh;
  118004. /**
  118005. * Creates an custom extruded shape mesh.
  118006. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  118007. * * 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.
  118008. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  118009. * * 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
  118010. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  118011. * * 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
  118012. * * It must returns a float value that will be the scale value applied to the shape on each path point
  118013. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  118014. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  118015. * * 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
  118016. * * 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
  118017. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  118018. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118019. * * 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
  118020. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  118021. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118022. * @param name defines the name of the mesh
  118023. * @param options defines the options used to create the mesh
  118024. * @param scene defines the hosting scene
  118025. * @returns the custom extruded shape mesh
  118026. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  118027. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  118028. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  118029. */
  118030. static ExtrudeShapeCustom(name: string, options: {
  118031. shape: Vector3[];
  118032. path: Vector3[];
  118033. scaleFunction?: any;
  118034. rotationFunction?: any;
  118035. ribbonCloseArray?: boolean;
  118036. ribbonClosePath?: boolean;
  118037. cap?: number;
  118038. updatable?: boolean;
  118039. sideOrientation?: number;
  118040. frontUVs?: Vector4;
  118041. backUVs?: Vector4;
  118042. instance?: Mesh;
  118043. invertUV?: boolean;
  118044. }, scene?: Nullable<Scene>): Mesh;
  118045. private static _ExtrudeShapeGeneric;
  118046. }
  118047. }
  118048. declare module BABYLON {
  118049. /**
  118050. * AmmoJS Physics plugin
  118051. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  118052. * @see https://github.com/kripken/ammo.js/
  118053. */
  118054. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  118055. private _useDeltaForWorldStep;
  118056. /**
  118057. * Reference to the Ammo library
  118058. */
  118059. bjsAMMO: any;
  118060. /**
  118061. * Created ammoJS world which physics bodies are added to
  118062. */
  118063. world: any;
  118064. /**
  118065. * Name of the plugin
  118066. */
  118067. name: string;
  118068. private _timeStep;
  118069. private _fixedTimeStep;
  118070. private _maxSteps;
  118071. private _tmpQuaternion;
  118072. private _tmpAmmoTransform;
  118073. private _tmpAmmoQuaternion;
  118074. private _tmpAmmoConcreteContactResultCallback;
  118075. private _collisionConfiguration;
  118076. private _dispatcher;
  118077. private _overlappingPairCache;
  118078. private _solver;
  118079. private _softBodySolver;
  118080. private _tmpAmmoVectorA;
  118081. private _tmpAmmoVectorB;
  118082. private _tmpAmmoVectorC;
  118083. private _tmpAmmoVectorD;
  118084. private _tmpContactCallbackResult;
  118085. private _tmpAmmoVectorRCA;
  118086. private _tmpAmmoVectorRCB;
  118087. private _raycastResult;
  118088. private static readonly DISABLE_COLLISION_FLAG;
  118089. private static readonly KINEMATIC_FLAG;
  118090. private static readonly DISABLE_DEACTIVATION_FLAG;
  118091. /**
  118092. * Initializes the ammoJS plugin
  118093. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118094. * @param ammoInjection can be used to inject your own ammo reference
  118095. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118096. */
  118097. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118098. /**
  118099. * Sets the gravity of the physics world (m/(s^2))
  118100. * @param gravity Gravity to set
  118101. */
  118102. setGravity(gravity: Vector3): void;
  118103. /**
  118104. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118105. * @param timeStep timestep to use in seconds
  118106. */
  118107. setTimeStep(timeStep: number): void;
  118108. /**
  118109. * 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)
  118110. * @param fixedTimeStep fixedTimeStep to use in seconds
  118111. */
  118112. setFixedTimeStep(fixedTimeStep: number): void;
  118113. /**
  118114. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118115. * @param maxSteps the maximum number of steps by the physics engine per frame
  118116. */
  118117. setMaxSteps(maxSteps: number): void;
  118118. /**
  118119. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118120. * @returns the current timestep in seconds
  118121. */
  118122. getTimeStep(): number;
  118123. private _isImpostorInContact;
  118124. private _isImpostorPairInContact;
  118125. private _stepSimulation;
  118126. /**
  118127. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118128. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118129. * After the step the babylon meshes are set to the position of the physics imposters
  118130. * @param delta amount of time to step forward
  118131. * @param impostors array of imposters to update before/after the step
  118132. */
  118133. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118134. /**
  118135. * Update babylon mesh to match physics world object
  118136. * @param impostor imposter to match
  118137. */
  118138. private _afterSoftStep;
  118139. /**
  118140. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118141. * @param impostor imposter to match
  118142. */
  118143. private _ropeStep;
  118144. /**
  118145. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118146. * @param impostor imposter to match
  118147. */
  118148. private _softbodyOrClothStep;
  118149. private _tmpVector;
  118150. private _tmpMatrix;
  118151. /**
  118152. * Applies an impulse on the imposter
  118153. * @param impostor imposter to apply impulse to
  118154. * @param force amount of force to be applied to the imposter
  118155. * @param contactPoint the location to apply the impulse on the imposter
  118156. */
  118157. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118158. /**
  118159. * Applies a force on the imposter
  118160. * @param impostor imposter to apply force
  118161. * @param force amount of force to be applied to the imposter
  118162. * @param contactPoint the location to apply the force on the imposter
  118163. */
  118164. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118165. /**
  118166. * Creates a physics body using the plugin
  118167. * @param impostor the imposter to create the physics body on
  118168. */
  118169. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118170. /**
  118171. * Removes the physics body from the imposter and disposes of the body's memory
  118172. * @param impostor imposter to remove the physics body from
  118173. */
  118174. removePhysicsBody(impostor: PhysicsImpostor): void;
  118175. /**
  118176. * Generates a joint
  118177. * @param impostorJoint the imposter joint to create the joint with
  118178. */
  118179. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118180. /**
  118181. * Removes a joint
  118182. * @param impostorJoint the imposter joint to remove the joint from
  118183. */
  118184. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118185. private _addMeshVerts;
  118186. /**
  118187. * Initialise the soft body vertices to match its object's (mesh) vertices
  118188. * Softbody vertices (nodes) are in world space and to match this
  118189. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118190. * @param impostor to create the softbody for
  118191. */
  118192. private _softVertexData;
  118193. /**
  118194. * Create an impostor's soft body
  118195. * @param impostor to create the softbody for
  118196. */
  118197. private _createSoftbody;
  118198. /**
  118199. * Create cloth for an impostor
  118200. * @param impostor to create the softbody for
  118201. */
  118202. private _createCloth;
  118203. /**
  118204. * Create rope for an impostor
  118205. * @param impostor to create the softbody for
  118206. */
  118207. private _createRope;
  118208. private _addHullVerts;
  118209. private _createShape;
  118210. /**
  118211. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118212. * @param impostor imposter containing the physics body and babylon object
  118213. */
  118214. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118215. /**
  118216. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118217. * @param impostor imposter containing the physics body and babylon object
  118218. * @param newPosition new position
  118219. * @param newRotation new rotation
  118220. */
  118221. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118222. /**
  118223. * If this plugin is supported
  118224. * @returns true if its supported
  118225. */
  118226. isSupported(): boolean;
  118227. /**
  118228. * Sets the linear velocity of the physics body
  118229. * @param impostor imposter to set the velocity on
  118230. * @param velocity velocity to set
  118231. */
  118232. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118233. /**
  118234. * Sets the angular velocity of the physics body
  118235. * @param impostor imposter to set the velocity on
  118236. * @param velocity velocity to set
  118237. */
  118238. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118239. /**
  118240. * gets the linear velocity
  118241. * @param impostor imposter to get linear velocity from
  118242. * @returns linear velocity
  118243. */
  118244. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118245. /**
  118246. * gets the angular velocity
  118247. * @param impostor imposter to get angular velocity from
  118248. * @returns angular velocity
  118249. */
  118250. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118251. /**
  118252. * Sets the mass of physics body
  118253. * @param impostor imposter to set the mass on
  118254. * @param mass mass to set
  118255. */
  118256. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118257. /**
  118258. * Gets the mass of the physics body
  118259. * @param impostor imposter to get the mass from
  118260. * @returns mass
  118261. */
  118262. getBodyMass(impostor: PhysicsImpostor): number;
  118263. /**
  118264. * Gets friction of the impostor
  118265. * @param impostor impostor to get friction from
  118266. * @returns friction value
  118267. */
  118268. getBodyFriction(impostor: PhysicsImpostor): number;
  118269. /**
  118270. * Sets friction of the impostor
  118271. * @param impostor impostor to set friction on
  118272. * @param friction friction value
  118273. */
  118274. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118275. /**
  118276. * Gets restitution of the impostor
  118277. * @param impostor impostor to get restitution from
  118278. * @returns restitution value
  118279. */
  118280. getBodyRestitution(impostor: PhysicsImpostor): number;
  118281. /**
  118282. * Sets resitution of the impostor
  118283. * @param impostor impostor to set resitution on
  118284. * @param restitution resitution value
  118285. */
  118286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118287. /**
  118288. * Gets pressure inside the impostor
  118289. * @param impostor impostor to get pressure from
  118290. * @returns pressure value
  118291. */
  118292. getBodyPressure(impostor: PhysicsImpostor): number;
  118293. /**
  118294. * Sets pressure inside a soft body impostor
  118295. * Cloth and rope must remain 0 pressure
  118296. * @param impostor impostor to set pressure on
  118297. * @param pressure pressure value
  118298. */
  118299. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118300. /**
  118301. * Gets stiffness of the impostor
  118302. * @param impostor impostor to get stiffness from
  118303. * @returns pressure value
  118304. */
  118305. getBodyStiffness(impostor: PhysicsImpostor): number;
  118306. /**
  118307. * Sets stiffness of the impostor
  118308. * @param impostor impostor to set stiffness on
  118309. * @param stiffness stiffness value from 0 to 1
  118310. */
  118311. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118312. /**
  118313. * Gets velocityIterations of the impostor
  118314. * @param impostor impostor to get velocity iterations from
  118315. * @returns velocityIterations value
  118316. */
  118317. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118318. /**
  118319. * Sets velocityIterations of the impostor
  118320. * @param impostor impostor to set velocity iterations on
  118321. * @param velocityIterations velocityIterations value
  118322. */
  118323. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118324. /**
  118325. * Gets positionIterations of the impostor
  118326. * @param impostor impostor to get position iterations from
  118327. * @returns positionIterations value
  118328. */
  118329. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118330. /**
  118331. * Sets positionIterations of the impostor
  118332. * @param impostor impostor to set position on
  118333. * @param positionIterations positionIterations value
  118334. */
  118335. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118336. /**
  118337. * Append an anchor to a cloth object
  118338. * @param impostor is the cloth impostor to add anchor to
  118339. * @param otherImpostor is the rigid impostor to anchor to
  118340. * @param width ratio across width from 0 to 1
  118341. * @param height ratio up height from 0 to 1
  118342. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118343. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118344. */
  118345. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118346. /**
  118347. * Append an hook to a rope object
  118348. * @param impostor is the rope impostor to add hook to
  118349. * @param otherImpostor is the rigid impostor to hook to
  118350. * @param length ratio along the rope from 0 to 1
  118351. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118352. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118353. */
  118354. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118355. /**
  118356. * Sleeps the physics body and stops it from being active
  118357. * @param impostor impostor to sleep
  118358. */
  118359. sleepBody(impostor: PhysicsImpostor): void;
  118360. /**
  118361. * Activates the physics body
  118362. * @param impostor impostor to activate
  118363. */
  118364. wakeUpBody(impostor: PhysicsImpostor): void;
  118365. /**
  118366. * Updates the distance parameters of the joint
  118367. * @param joint joint to update
  118368. * @param maxDistance maximum distance of the joint
  118369. * @param minDistance minimum distance of the joint
  118370. */
  118371. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118372. /**
  118373. * Sets a motor on the joint
  118374. * @param joint joint to set motor on
  118375. * @param speed speed of the motor
  118376. * @param maxForce maximum force of the motor
  118377. * @param motorIndex index of the motor
  118378. */
  118379. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118380. /**
  118381. * Sets the motors limit
  118382. * @param joint joint to set limit on
  118383. * @param upperLimit upper limit
  118384. * @param lowerLimit lower limit
  118385. */
  118386. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118387. /**
  118388. * Syncs the position and rotation of a mesh with the impostor
  118389. * @param mesh mesh to sync
  118390. * @param impostor impostor to update the mesh with
  118391. */
  118392. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118393. /**
  118394. * Gets the radius of the impostor
  118395. * @param impostor impostor to get radius from
  118396. * @returns the radius
  118397. */
  118398. getRadius(impostor: PhysicsImpostor): number;
  118399. /**
  118400. * Gets the box size of the impostor
  118401. * @param impostor impostor to get box size from
  118402. * @param result the resulting box size
  118403. */
  118404. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118405. /**
  118406. * Disposes of the impostor
  118407. */
  118408. dispose(): void;
  118409. /**
  118410. * Does a raycast in the physics world
  118411. * @param from when should the ray start?
  118412. * @param to when should the ray end?
  118413. * @returns PhysicsRaycastResult
  118414. */
  118415. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118416. }
  118417. }
  118418. declare module BABYLON {
  118419. interface AbstractScene {
  118420. /**
  118421. * The list of reflection probes added to the scene
  118422. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118423. */
  118424. reflectionProbes: Array<ReflectionProbe>;
  118425. /**
  118426. * Removes the given reflection probe from this scene.
  118427. * @param toRemove The reflection probe to remove
  118428. * @returns The index of the removed reflection probe
  118429. */
  118430. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118431. /**
  118432. * Adds the given reflection probe to this scene.
  118433. * @param newReflectionProbe The reflection probe to add
  118434. */
  118435. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118436. }
  118437. /**
  118438. * Class used to generate realtime reflection / refraction cube textures
  118439. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118440. */
  118441. export class ReflectionProbe {
  118442. /** defines the name of the probe */
  118443. name: string;
  118444. private _scene;
  118445. private _renderTargetTexture;
  118446. private _projectionMatrix;
  118447. private _viewMatrix;
  118448. private _target;
  118449. private _add;
  118450. private _attachedMesh;
  118451. private _invertYAxis;
  118452. /** Gets or sets probe position (center of the cube map) */
  118453. position: Vector3;
  118454. /**
  118455. * Creates a new reflection probe
  118456. * @param name defines the name of the probe
  118457. * @param size defines the texture resolution (for each face)
  118458. * @param scene defines the hosting scene
  118459. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118460. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118461. */
  118462. constructor(
  118463. /** defines the name of the probe */
  118464. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118465. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118466. samples: number;
  118467. /** Gets or sets the refresh rate to use (on every frame by default) */
  118468. refreshRate: number;
  118469. /**
  118470. * Gets the hosting scene
  118471. * @returns a Scene
  118472. */
  118473. getScene(): Scene;
  118474. /** Gets the internal CubeTexture used to render to */
  118475. readonly cubeTexture: RenderTargetTexture;
  118476. /** Gets the list of meshes to render */
  118477. readonly renderList: Nullable<AbstractMesh[]>;
  118478. /**
  118479. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118480. * @param mesh defines the mesh to attach to
  118481. */
  118482. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118483. /**
  118484. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118485. * @param renderingGroupId The rendering group id corresponding to its index
  118486. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118487. */
  118488. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118489. /**
  118490. * Clean all associated resources
  118491. */
  118492. dispose(): void;
  118493. /**
  118494. * Converts the reflection probe information to a readable string for debug purpose.
  118495. * @param fullDetails Supports for multiple levels of logging within scene loading
  118496. * @returns the human readable reflection probe info
  118497. */
  118498. toString(fullDetails?: boolean): string;
  118499. /**
  118500. * Get the class name of the relfection probe.
  118501. * @returns "ReflectionProbe"
  118502. */
  118503. getClassName(): string;
  118504. /**
  118505. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118506. * @returns The JSON representation of the texture
  118507. */
  118508. serialize(): any;
  118509. /**
  118510. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118511. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118512. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118513. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118514. * @returns The parsed reflection probe if successful
  118515. */
  118516. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118517. }
  118518. }
  118519. declare module BABYLON {
  118520. /** @hidden */
  118521. export var _BabylonLoaderRegistered: boolean;
  118522. }
  118523. declare module BABYLON {
  118524. /**
  118525. * The Physically based simple base material of BJS.
  118526. *
  118527. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118528. * It is used as the base class for both the specGloss and metalRough conventions.
  118529. */
  118530. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118531. /**
  118532. * Number of Simultaneous lights allowed on the material.
  118533. */
  118534. maxSimultaneousLights: number;
  118535. /**
  118536. * If sets to true, disables all the lights affecting the material.
  118537. */
  118538. disableLighting: boolean;
  118539. /**
  118540. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118541. */
  118542. environmentTexture: BaseTexture;
  118543. /**
  118544. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118545. */
  118546. invertNormalMapX: boolean;
  118547. /**
  118548. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118549. */
  118550. invertNormalMapY: boolean;
  118551. /**
  118552. * Normal map used in the model.
  118553. */
  118554. normalTexture: BaseTexture;
  118555. /**
  118556. * Emissivie color used to self-illuminate the model.
  118557. */
  118558. emissiveColor: Color3;
  118559. /**
  118560. * Emissivie texture used to self-illuminate the model.
  118561. */
  118562. emissiveTexture: BaseTexture;
  118563. /**
  118564. * Occlusion Channel Strenght.
  118565. */
  118566. occlusionStrength: number;
  118567. /**
  118568. * Occlusion Texture of the material (adding extra occlusion effects).
  118569. */
  118570. occlusionTexture: BaseTexture;
  118571. /**
  118572. * Defines the alpha limits in alpha test mode.
  118573. */
  118574. alphaCutOff: number;
  118575. /**
  118576. * Gets the current double sided mode.
  118577. */
  118578. /**
  118579. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118580. */
  118581. doubleSided: boolean;
  118582. /**
  118583. * Stores the pre-calculated light information of a mesh in a texture.
  118584. */
  118585. lightmapTexture: BaseTexture;
  118586. /**
  118587. * If true, the light map contains occlusion information instead of lighting info.
  118588. */
  118589. useLightmapAsShadowmap: boolean;
  118590. /**
  118591. * Instantiates a new PBRMaterial instance.
  118592. *
  118593. * @param name The material name
  118594. * @param scene The scene the material will be use in.
  118595. */
  118596. constructor(name: string, scene: Scene);
  118597. getClassName(): string;
  118598. }
  118599. }
  118600. declare module BABYLON {
  118601. /**
  118602. * The PBR material of BJS following the metal roughness convention.
  118603. *
  118604. * This fits to the PBR convention in the GLTF definition:
  118605. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118606. */
  118607. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118608. /**
  118609. * The base color has two different interpretations depending on the value of metalness.
  118610. * When the material is a metal, the base color is the specific measured reflectance value
  118611. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118612. * of the material.
  118613. */
  118614. baseColor: Color3;
  118615. /**
  118616. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118617. * well as opacity information in the alpha channel.
  118618. */
  118619. baseTexture: BaseTexture;
  118620. /**
  118621. * Specifies the metallic scalar value of the material.
  118622. * Can also be used to scale the metalness values of the metallic texture.
  118623. */
  118624. metallic: number;
  118625. /**
  118626. * Specifies the roughness scalar value of the material.
  118627. * Can also be used to scale the roughness values of the metallic texture.
  118628. */
  118629. roughness: number;
  118630. /**
  118631. * Texture containing both the metallic value in the B channel and the
  118632. * roughness value in the G channel to keep better precision.
  118633. */
  118634. metallicRoughnessTexture: BaseTexture;
  118635. /**
  118636. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118637. *
  118638. * @param name The material name
  118639. * @param scene The scene the material will be use in.
  118640. */
  118641. constructor(name: string, scene: Scene);
  118642. /**
  118643. * Return the currrent class name of the material.
  118644. */
  118645. getClassName(): string;
  118646. /**
  118647. * Makes a duplicate of the current material.
  118648. * @param name - name to use for the new material.
  118649. */
  118650. clone(name: string): PBRMetallicRoughnessMaterial;
  118651. /**
  118652. * Serialize the material to a parsable JSON object.
  118653. */
  118654. serialize(): any;
  118655. /**
  118656. * Parses a JSON object correponding to the serialize function.
  118657. */
  118658. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118659. }
  118660. }
  118661. declare module BABYLON {
  118662. /**
  118663. * The PBR material of BJS following the specular glossiness convention.
  118664. *
  118665. * This fits to the PBR convention in the GLTF definition:
  118666. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118667. */
  118668. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118669. /**
  118670. * Specifies the diffuse color of the material.
  118671. */
  118672. diffuseColor: Color3;
  118673. /**
  118674. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118675. * channel.
  118676. */
  118677. diffuseTexture: BaseTexture;
  118678. /**
  118679. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118680. */
  118681. specularColor: Color3;
  118682. /**
  118683. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118684. */
  118685. glossiness: number;
  118686. /**
  118687. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118688. */
  118689. specularGlossinessTexture: BaseTexture;
  118690. /**
  118691. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118692. *
  118693. * @param name The material name
  118694. * @param scene The scene the material will be use in.
  118695. */
  118696. constructor(name: string, scene: Scene);
  118697. /**
  118698. * Return the currrent class name of the material.
  118699. */
  118700. getClassName(): string;
  118701. /**
  118702. * Makes a duplicate of the current material.
  118703. * @param name - name to use for the new material.
  118704. */
  118705. clone(name: string): PBRSpecularGlossinessMaterial;
  118706. /**
  118707. * Serialize the material to a parsable JSON object.
  118708. */
  118709. serialize(): any;
  118710. /**
  118711. * Parses a JSON object correponding to the serialize function.
  118712. */
  118713. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118714. }
  118715. }
  118716. declare module BABYLON {
  118717. /**
  118718. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118719. * It can help converting any input color in a desired output one. This can then be used to create effects
  118720. * from sepia, black and white to sixties or futuristic rendering...
  118721. *
  118722. * The only supported format is currently 3dl.
  118723. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118724. */
  118725. export class ColorGradingTexture extends BaseTexture {
  118726. /**
  118727. * The current texture matrix. (will always be identity in color grading texture)
  118728. */
  118729. private _textureMatrix;
  118730. /**
  118731. * The texture URL.
  118732. */
  118733. url: string;
  118734. /**
  118735. * Empty line regex stored for GC.
  118736. */
  118737. private static _noneEmptyLineRegex;
  118738. private _engine;
  118739. /**
  118740. * Instantiates a ColorGradingTexture from the following parameters.
  118741. *
  118742. * @param url The location of the color gradind data (currently only supporting 3dl)
  118743. * @param scene The scene the texture will be used in
  118744. */
  118745. constructor(url: string, scene: Scene);
  118746. /**
  118747. * Returns the texture matrix used in most of the material.
  118748. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118749. */
  118750. getTextureMatrix(): Matrix;
  118751. /**
  118752. * Occurs when the file being loaded is a .3dl LUT file.
  118753. */
  118754. private load3dlTexture;
  118755. /**
  118756. * Starts the loading process of the texture.
  118757. */
  118758. private loadTexture;
  118759. /**
  118760. * Clones the color gradind texture.
  118761. */
  118762. clone(): ColorGradingTexture;
  118763. /**
  118764. * Called during delayed load for textures.
  118765. */
  118766. delayLoad(): void;
  118767. /**
  118768. * Parses a color grading texture serialized by Babylon.
  118769. * @param parsedTexture The texture information being parsedTexture
  118770. * @param scene The scene to load the texture in
  118771. * @param rootUrl The root url of the data assets to load
  118772. * @return A color gradind texture
  118773. */
  118774. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118775. /**
  118776. * Serializes the LUT texture to json format.
  118777. */
  118778. serialize(): any;
  118779. }
  118780. }
  118781. declare module BABYLON {
  118782. /**
  118783. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118784. */
  118785. export class EquiRectangularCubeTexture extends BaseTexture {
  118786. /** The six faces of the cube. */
  118787. private static _FacesMapping;
  118788. private _noMipmap;
  118789. private _onLoad;
  118790. private _onError;
  118791. /** The size of the cubemap. */
  118792. private _size;
  118793. /** The buffer of the image. */
  118794. private _buffer;
  118795. /** The width of the input image. */
  118796. private _width;
  118797. /** The height of the input image. */
  118798. private _height;
  118799. /** The URL to the image. */
  118800. url: string;
  118801. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118802. coordinatesMode: number;
  118803. /**
  118804. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118805. * @param url The location of the image
  118806. * @param scene The scene the texture will be used in
  118807. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118808. * @param noMipmap Forces to not generate the mipmap if true
  118809. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118810. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118811. * @param onLoad — defines a callback called when texture is loaded
  118812. * @param onError — defines a callback called if there is an error
  118813. */
  118814. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118815. /**
  118816. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118817. */
  118818. private loadImage;
  118819. /**
  118820. * Convert the image buffer into a cubemap and create a CubeTexture.
  118821. */
  118822. private loadTexture;
  118823. /**
  118824. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118825. * @param buffer The ArrayBuffer that should be converted.
  118826. * @returns The buffer as Float32Array.
  118827. */
  118828. private getFloat32ArrayFromArrayBuffer;
  118829. /**
  118830. * Get the current class name of the texture useful for serialization or dynamic coding.
  118831. * @returns "EquiRectangularCubeTexture"
  118832. */
  118833. getClassName(): string;
  118834. /**
  118835. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118836. * @returns A clone of the current EquiRectangularCubeTexture.
  118837. */
  118838. clone(): EquiRectangularCubeTexture;
  118839. }
  118840. }
  118841. declare module BABYLON {
  118842. /**
  118843. * Based on jsTGALoader - Javascript loader for TGA file
  118844. * By Vincent Thibault
  118845. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118846. */
  118847. export class TGATools {
  118848. private static _TYPE_INDEXED;
  118849. private static _TYPE_RGB;
  118850. private static _TYPE_GREY;
  118851. private static _TYPE_RLE_INDEXED;
  118852. private static _TYPE_RLE_RGB;
  118853. private static _TYPE_RLE_GREY;
  118854. private static _ORIGIN_MASK;
  118855. private static _ORIGIN_SHIFT;
  118856. private static _ORIGIN_BL;
  118857. private static _ORIGIN_BR;
  118858. private static _ORIGIN_UL;
  118859. private static _ORIGIN_UR;
  118860. /**
  118861. * Gets the header of a TGA file
  118862. * @param data defines the TGA data
  118863. * @returns the header
  118864. */
  118865. static GetTGAHeader(data: Uint8Array): any;
  118866. /**
  118867. * Uploads TGA content to a Babylon Texture
  118868. * @hidden
  118869. */
  118870. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118871. /** @hidden */
  118872. 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;
  118873. /** @hidden */
  118874. 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;
  118875. /** @hidden */
  118876. 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;
  118877. /** @hidden */
  118878. 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;
  118879. /** @hidden */
  118880. 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;
  118881. /** @hidden */
  118882. 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;
  118883. }
  118884. }
  118885. declare module BABYLON {
  118886. /**
  118887. * Implementation of the TGA Texture Loader.
  118888. * @hidden
  118889. */
  118890. export class _TGATextureLoader implements IInternalTextureLoader {
  118891. /**
  118892. * Defines wether the loader supports cascade loading the different faces.
  118893. */
  118894. readonly supportCascades: boolean;
  118895. /**
  118896. * This returns if the loader support the current file information.
  118897. * @param extension defines the file extension of the file being loaded
  118898. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118899. * @param fallback defines the fallback internal texture if any
  118900. * @param isBase64 defines whether the texture is encoded as a base64
  118901. * @param isBuffer defines whether the texture data are stored as a buffer
  118902. * @returns true if the loader can load the specified file
  118903. */
  118904. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118905. /**
  118906. * Transform the url before loading if required.
  118907. * @param rootUrl the url of the texture
  118908. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118909. * @returns the transformed texture
  118910. */
  118911. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118912. /**
  118913. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118914. * @param rootUrl the url of the texture
  118915. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118916. * @returns the fallback texture
  118917. */
  118918. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118919. /**
  118920. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118921. * @param data contains the texture data
  118922. * @param texture defines the BabylonJS internal texture
  118923. * @param createPolynomials will be true if polynomials have been requested
  118924. * @param onLoad defines the callback to trigger once the texture is ready
  118925. * @param onError defines the callback to trigger in case of error
  118926. */
  118927. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118928. /**
  118929. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118930. * @param data contains the texture data
  118931. * @param texture defines the BabylonJS internal texture
  118932. * @param callback defines the method to call once ready to upload
  118933. */
  118934. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118935. }
  118936. }
  118937. declare module BABYLON {
  118938. /**
  118939. * Info about the .basis files
  118940. */
  118941. class BasisFileInfo {
  118942. /**
  118943. * If the file has alpha
  118944. */
  118945. hasAlpha: boolean;
  118946. /**
  118947. * Info about each image of the basis file
  118948. */
  118949. images: Array<{
  118950. levels: Array<{
  118951. width: number;
  118952. height: number;
  118953. transcodedPixels: ArrayBufferView;
  118954. }>;
  118955. }>;
  118956. }
  118957. /**
  118958. * Result of transcoding a basis file
  118959. */
  118960. class TranscodeResult {
  118961. /**
  118962. * Info about the .basis file
  118963. */
  118964. fileInfo: BasisFileInfo;
  118965. /**
  118966. * Format to use when loading the file
  118967. */
  118968. format: number;
  118969. }
  118970. /**
  118971. * Configuration options for the Basis transcoder
  118972. */
  118973. export class BasisTranscodeConfiguration {
  118974. /**
  118975. * Supported compression formats used to determine the supported output format of the transcoder
  118976. */
  118977. supportedCompressionFormats?: {
  118978. /**
  118979. * etc1 compression format
  118980. */
  118981. etc1?: boolean;
  118982. /**
  118983. * s3tc compression format
  118984. */
  118985. s3tc?: boolean;
  118986. /**
  118987. * pvrtc compression format
  118988. */
  118989. pvrtc?: boolean;
  118990. /**
  118991. * etc2 compression format
  118992. */
  118993. etc2?: boolean;
  118994. };
  118995. /**
  118996. * If mipmap levels should be loaded for transcoded images (Default: true)
  118997. */
  118998. loadMipmapLevels?: boolean;
  118999. /**
  119000. * Index of a single image to load (Default: all images)
  119001. */
  119002. loadSingleImage?: number;
  119003. }
  119004. /**
  119005. * Used to load .Basis files
  119006. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  119007. */
  119008. export class BasisTools {
  119009. private static _IgnoreSupportedFormats;
  119010. /**
  119011. * URL to use when loading the basis transcoder
  119012. */
  119013. static JSModuleURL: string;
  119014. /**
  119015. * URL to use when loading the wasm module for the transcoder
  119016. */
  119017. static WasmModuleURL: string;
  119018. /**
  119019. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  119020. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  119021. * @returns internal format corresponding to the Basis format
  119022. */
  119023. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  119024. private static _WorkerPromise;
  119025. private static _Worker;
  119026. private static _actionId;
  119027. private static _CreateWorkerAsync;
  119028. /**
  119029. * Transcodes a loaded image file to compressed pixel data
  119030. * @param imageData image data to transcode
  119031. * @param config configuration options for the transcoding
  119032. * @returns a promise resulting in the transcoded image
  119033. */
  119034. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  119035. /**
  119036. * Loads a texture from the transcode result
  119037. * @param texture texture load to
  119038. * @param transcodeResult the result of transcoding the basis file to load from
  119039. */
  119040. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  119041. }
  119042. }
  119043. declare module BABYLON {
  119044. /**
  119045. * Loader for .basis file format
  119046. */
  119047. export class _BasisTextureLoader implements IInternalTextureLoader {
  119048. /**
  119049. * Defines whether the loader supports cascade loading the different faces.
  119050. */
  119051. readonly supportCascades: boolean;
  119052. /**
  119053. * This returns if the loader support the current file information.
  119054. * @param extension defines the file extension of the file being loaded
  119055. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119056. * @param fallback defines the fallback internal texture if any
  119057. * @param isBase64 defines whether the texture is encoded as a base64
  119058. * @param isBuffer defines whether the texture data are stored as a buffer
  119059. * @returns true if the loader can load the specified file
  119060. */
  119061. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  119062. /**
  119063. * Transform the url before loading if required.
  119064. * @param rootUrl the url of the texture
  119065. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119066. * @returns the transformed texture
  119067. */
  119068. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  119069. /**
  119070. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  119071. * @param rootUrl the url of the texture
  119072. * @param textureFormatInUse defines the current compressed format in use iun the engine
  119073. * @returns the fallback texture
  119074. */
  119075. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  119076. /**
  119077. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  119078. * @param data contains the texture data
  119079. * @param texture defines the BabylonJS internal texture
  119080. * @param createPolynomials will be true if polynomials have been requested
  119081. * @param onLoad defines the callback to trigger once the texture is ready
  119082. * @param onError defines the callback to trigger in case of error
  119083. */
  119084. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  119085. /**
  119086. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  119087. * @param data contains the texture data
  119088. * @param texture defines the BabylonJS internal texture
  119089. * @param callback defines the method to call once ready to upload
  119090. */
  119091. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  119092. }
  119093. }
  119094. declare module BABYLON {
  119095. /**
  119096. * 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.
  119097. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119098. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119099. */
  119100. export class CustomProceduralTexture extends ProceduralTexture {
  119101. private _animate;
  119102. private _time;
  119103. private _config;
  119104. private _texturePath;
  119105. /**
  119106. * Instantiates a new Custom Procedural Texture.
  119107. * 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.
  119108. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119109. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119110. * @param name Define the name of the texture
  119111. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119112. * @param size Define the size of the texture to create
  119113. * @param scene Define the scene the texture belongs to
  119114. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119115. * @param generateMipMaps Define if the texture should creates mip maps or not
  119116. */
  119117. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119118. private _loadJson;
  119119. /**
  119120. * Is the texture ready to be used ? (rendered at least once)
  119121. * @returns true if ready, otherwise, false.
  119122. */
  119123. isReady(): boolean;
  119124. /**
  119125. * Render the texture to its associated render target.
  119126. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119127. */
  119128. render(useCameraPostProcess?: boolean): void;
  119129. /**
  119130. * Update the list of dependant textures samplers in the shader.
  119131. */
  119132. updateTextures(): void;
  119133. /**
  119134. * Update the uniform values of the procedural texture in the shader.
  119135. */
  119136. updateShaderUniforms(): void;
  119137. /**
  119138. * Define if the texture animates or not.
  119139. */
  119140. animate: boolean;
  119141. }
  119142. }
  119143. declare module BABYLON {
  119144. /** @hidden */
  119145. export var noisePixelShader: {
  119146. name: string;
  119147. shader: string;
  119148. };
  119149. }
  119150. declare module BABYLON {
  119151. /**
  119152. * Class used to generate noise procedural textures
  119153. */
  119154. export class NoiseProceduralTexture extends ProceduralTexture {
  119155. private _time;
  119156. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119157. brightness: number;
  119158. /** Defines the number of octaves to process */
  119159. octaves: number;
  119160. /** Defines the level of persistence (0.8 by default) */
  119161. persistence: number;
  119162. /** Gets or sets animation speed factor (default is 1) */
  119163. animationSpeedFactor: number;
  119164. /**
  119165. * Creates a new NoiseProceduralTexture
  119166. * @param name defines the name fo the texture
  119167. * @param size defines the size of the texture (default is 256)
  119168. * @param scene defines the hosting scene
  119169. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119170. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119171. */
  119172. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119173. private _updateShaderUniforms;
  119174. protected _getDefines(): string;
  119175. /** Generate the current state of the procedural texture */
  119176. render(useCameraPostProcess?: boolean): void;
  119177. /**
  119178. * Serializes this noise procedural texture
  119179. * @returns a serialized noise procedural texture object
  119180. */
  119181. serialize(): any;
  119182. /**
  119183. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119184. * @param parsedTexture defines parsed texture data
  119185. * @param scene defines the current scene
  119186. * @param rootUrl defines the root URL containing noise procedural texture information
  119187. * @returns a parsed NoiseProceduralTexture
  119188. */
  119189. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119190. }
  119191. }
  119192. declare module BABYLON {
  119193. /**
  119194. * Raw cube texture where the raw buffers are passed in
  119195. */
  119196. export class RawCubeTexture extends CubeTexture {
  119197. /**
  119198. * Creates a cube texture where the raw buffers are passed in.
  119199. * @param scene defines the scene the texture is attached to
  119200. * @param data defines the array of data to use to create each face
  119201. * @param size defines the size of the textures
  119202. * @param format defines the format of the data
  119203. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119204. * @param generateMipMaps defines if the engine should generate the mip levels
  119205. * @param invertY defines if data must be stored with Y axis inverted
  119206. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119207. * @param compression defines the compression used (null by default)
  119208. */
  119209. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119210. /**
  119211. * Updates the raw cube texture.
  119212. * @param data defines the data to store
  119213. * @param format defines the data format
  119214. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119215. * @param invertY defines if data must be stored with Y axis inverted
  119216. * @param compression defines the compression used (null by default)
  119217. * @param level defines which level of the texture to update
  119218. */
  119219. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119220. /**
  119221. * Updates a raw cube texture with RGBD encoded data.
  119222. * @param data defines the array of data [mipmap][face] to use to create each face
  119223. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119224. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119225. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119226. * @returns a promsie that resolves when the operation is complete
  119227. */
  119228. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119229. /**
  119230. * Clones the raw cube texture.
  119231. * @return a new cube texture
  119232. */
  119233. clone(): CubeTexture;
  119234. /** @hidden */
  119235. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119236. }
  119237. }
  119238. declare module BABYLON {
  119239. /**
  119240. * Class used to store 3D textures containing user data
  119241. */
  119242. export class RawTexture3D extends Texture {
  119243. /** Gets or sets the texture format to use */
  119244. format: number;
  119245. private _engine;
  119246. /**
  119247. * Create a new RawTexture3D
  119248. * @param data defines the data of the texture
  119249. * @param width defines the width of the texture
  119250. * @param height defines the height of the texture
  119251. * @param depth defines the depth of the texture
  119252. * @param format defines the texture format to use
  119253. * @param scene defines the hosting scene
  119254. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119255. * @param invertY defines if texture must be stored with Y axis inverted
  119256. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119257. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119258. */
  119259. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119260. /** Gets or sets the texture format to use */
  119261. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119262. /**
  119263. * Update the texture with new data
  119264. * @param data defines the data to store in the texture
  119265. */
  119266. update(data: ArrayBufferView): void;
  119267. }
  119268. }
  119269. declare module BABYLON {
  119270. /**
  119271. * Creates a refraction texture used by refraction channel of the standard material.
  119272. * It is like a mirror but to see through a material.
  119273. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119274. */
  119275. export class RefractionTexture extends RenderTargetTexture {
  119276. /**
  119277. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119278. * 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.
  119279. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119280. */
  119281. refractionPlane: Plane;
  119282. /**
  119283. * Define how deep under the surface we should see.
  119284. */
  119285. depth: number;
  119286. /**
  119287. * Creates a refraction texture used by refraction channel of the standard material.
  119288. * It is like a mirror but to see through a material.
  119289. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119290. * @param name Define the texture name
  119291. * @param size Define the size of the underlying texture
  119292. * @param scene Define the scene the refraction belongs to
  119293. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119294. */
  119295. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119296. /**
  119297. * Clone the refraction texture.
  119298. * @returns the cloned texture
  119299. */
  119300. clone(): RefractionTexture;
  119301. /**
  119302. * Serialize the texture to a JSON representation you could use in Parse later on
  119303. * @returns the serialized JSON representation
  119304. */
  119305. serialize(): any;
  119306. }
  119307. }
  119308. declare module BABYLON {
  119309. /**
  119310. * Defines the options related to the creation of an HtmlElementTexture
  119311. */
  119312. export interface IHtmlElementTextureOptions {
  119313. /**
  119314. * Defines wether mip maps should be created or not.
  119315. */
  119316. generateMipMaps?: boolean;
  119317. /**
  119318. * Defines the sampling mode of the texture.
  119319. */
  119320. samplingMode?: number;
  119321. /**
  119322. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119323. */
  119324. engine: Nullable<ThinEngine>;
  119325. /**
  119326. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119327. */
  119328. scene: Nullable<Scene>;
  119329. }
  119330. /**
  119331. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119332. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119333. * is automatically managed.
  119334. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119335. * in your application.
  119336. *
  119337. * As the update is not automatic, you need to call them manually.
  119338. */
  119339. export class HtmlElementTexture extends BaseTexture {
  119340. /**
  119341. * The texture URL.
  119342. */
  119343. element: HTMLVideoElement | HTMLCanvasElement;
  119344. private static readonly DefaultOptions;
  119345. private _textureMatrix;
  119346. private _engine;
  119347. private _isVideo;
  119348. private _generateMipMaps;
  119349. private _samplingMode;
  119350. /**
  119351. * Instantiates a HtmlElementTexture from the following parameters.
  119352. *
  119353. * @param name Defines the name of the texture
  119354. * @param element Defines the video or canvas the texture is filled with
  119355. * @param options Defines the other none mandatory texture creation options
  119356. */
  119357. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119358. private _createInternalTexture;
  119359. /**
  119360. * Returns the texture matrix used in most of the material.
  119361. */
  119362. getTextureMatrix(): Matrix;
  119363. /**
  119364. * Updates the content of the texture.
  119365. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119366. */
  119367. update(invertY?: Nullable<boolean>): void;
  119368. }
  119369. }
  119370. declare module BABYLON {
  119371. /**
  119372. * Enum used to define the target of a block
  119373. */
  119374. export enum NodeMaterialBlockTargets {
  119375. /** Vertex shader */
  119376. Vertex = 1,
  119377. /** Fragment shader */
  119378. Fragment = 2,
  119379. /** Neutral */
  119380. Neutral = 4,
  119381. /** Vertex and Fragment */
  119382. VertexAndFragment = 3
  119383. }
  119384. }
  119385. declare module BABYLON {
  119386. /**
  119387. * Defines the kind of connection point for node based material
  119388. */
  119389. export enum NodeMaterialBlockConnectionPointTypes {
  119390. /** Float */
  119391. Float = 1,
  119392. /** Int */
  119393. Int = 2,
  119394. /** Vector2 */
  119395. Vector2 = 4,
  119396. /** Vector3 */
  119397. Vector3 = 8,
  119398. /** Vector4 */
  119399. Vector4 = 16,
  119400. /** Color3 */
  119401. Color3 = 32,
  119402. /** Color4 */
  119403. Color4 = 64,
  119404. /** Matrix */
  119405. Matrix = 128,
  119406. /** Detect type based on connection */
  119407. AutoDetect = 1024,
  119408. /** Output type that will be defined by input type */
  119409. BasedOnInput = 2048
  119410. }
  119411. }
  119412. declare module BABYLON {
  119413. /**
  119414. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119415. */
  119416. export enum NodeMaterialBlockConnectionPointMode {
  119417. /** Value is an uniform */
  119418. Uniform = 0,
  119419. /** Value is a mesh attribute */
  119420. Attribute = 1,
  119421. /** Value is a varying between vertex and fragment shaders */
  119422. Varying = 2,
  119423. /** Mode is undefined */
  119424. Undefined = 3
  119425. }
  119426. }
  119427. declare module BABYLON {
  119428. /**
  119429. * Enum used to define system values e.g. values automatically provided by the system
  119430. */
  119431. export enum NodeMaterialSystemValues {
  119432. /** World */
  119433. World = 1,
  119434. /** View */
  119435. View = 2,
  119436. /** Projection */
  119437. Projection = 3,
  119438. /** ViewProjection */
  119439. ViewProjection = 4,
  119440. /** WorldView */
  119441. WorldView = 5,
  119442. /** WorldViewProjection */
  119443. WorldViewProjection = 6,
  119444. /** CameraPosition */
  119445. CameraPosition = 7,
  119446. /** Fog Color */
  119447. FogColor = 8,
  119448. /** Delta time */
  119449. DeltaTime = 9
  119450. }
  119451. }
  119452. declare module BABYLON {
  119453. /**
  119454. * Root class for all node material optimizers
  119455. */
  119456. export class NodeMaterialOptimizer {
  119457. /**
  119458. * Function used to optimize a NodeMaterial graph
  119459. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119460. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119461. */
  119462. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119463. }
  119464. }
  119465. declare module BABYLON {
  119466. /**
  119467. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119468. */
  119469. export class TransformBlock extends NodeMaterialBlock {
  119470. /**
  119471. * Defines the value to use to complement W value to transform it to a Vector4
  119472. */
  119473. complementW: number;
  119474. /**
  119475. * Defines the value to use to complement z value to transform it to a Vector4
  119476. */
  119477. complementZ: number;
  119478. /**
  119479. * Creates a new TransformBlock
  119480. * @param name defines the block name
  119481. */
  119482. constructor(name: string);
  119483. /**
  119484. * Gets the current class name
  119485. * @returns the class name
  119486. */
  119487. getClassName(): string;
  119488. /**
  119489. * Gets the vector input
  119490. */
  119491. readonly vector: NodeMaterialConnectionPoint;
  119492. /**
  119493. * Gets the output component
  119494. */
  119495. readonly output: NodeMaterialConnectionPoint;
  119496. /**
  119497. * Gets the matrix transform input
  119498. */
  119499. readonly transform: NodeMaterialConnectionPoint;
  119500. protected _buildBlock(state: NodeMaterialBuildState): this;
  119501. serialize(): any;
  119502. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119503. protected _dumpPropertiesCode(): string;
  119504. }
  119505. }
  119506. declare module BABYLON {
  119507. /**
  119508. * Block used to output the vertex position
  119509. */
  119510. export class VertexOutputBlock extends NodeMaterialBlock {
  119511. /**
  119512. * Creates a new VertexOutputBlock
  119513. * @param name defines the block name
  119514. */
  119515. constructor(name: string);
  119516. /**
  119517. * Gets the current class name
  119518. * @returns the class name
  119519. */
  119520. getClassName(): string;
  119521. /**
  119522. * Gets the vector input component
  119523. */
  119524. readonly vector: NodeMaterialConnectionPoint;
  119525. protected _buildBlock(state: NodeMaterialBuildState): this;
  119526. }
  119527. }
  119528. declare module BABYLON {
  119529. /**
  119530. * Block used to output the final color
  119531. */
  119532. export class FragmentOutputBlock extends NodeMaterialBlock {
  119533. /**
  119534. * Create a new FragmentOutputBlock
  119535. * @param name defines the block name
  119536. */
  119537. constructor(name: string);
  119538. /**
  119539. * Gets the current class name
  119540. * @returns the class name
  119541. */
  119542. getClassName(): string;
  119543. /**
  119544. * Gets the rgba input component
  119545. */
  119546. readonly rgba: NodeMaterialConnectionPoint;
  119547. /**
  119548. * Gets the rgb input component
  119549. */
  119550. readonly rgb: NodeMaterialConnectionPoint;
  119551. /**
  119552. * Gets the a input component
  119553. */
  119554. readonly a: NodeMaterialConnectionPoint;
  119555. protected _buildBlock(state: NodeMaterialBuildState): this;
  119556. }
  119557. }
  119558. declare module BABYLON {
  119559. /**
  119560. * Block used to read a reflection texture from a sampler
  119561. */
  119562. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119563. private _define3DName;
  119564. private _defineCubicName;
  119565. private _defineExplicitName;
  119566. private _defineProjectionName;
  119567. private _defineLocalCubicName;
  119568. private _defineSphericalName;
  119569. private _definePlanarName;
  119570. private _defineEquirectangularName;
  119571. private _defineMirroredEquirectangularFixedName;
  119572. private _defineEquirectangularFixedName;
  119573. private _defineSkyboxName;
  119574. private _cubeSamplerName;
  119575. private _2DSamplerName;
  119576. private _positionUVWName;
  119577. private _directionWName;
  119578. private _reflectionCoordsName;
  119579. private _reflection2DCoordsName;
  119580. private _reflectionColorName;
  119581. private _reflectionMatrixName;
  119582. /**
  119583. * Gets or sets the texture associated with the node
  119584. */
  119585. texture: Nullable<BaseTexture>;
  119586. /**
  119587. * Create a new TextureBlock
  119588. * @param name defines the block name
  119589. */
  119590. constructor(name: string);
  119591. /**
  119592. * Gets the current class name
  119593. * @returns the class name
  119594. */
  119595. getClassName(): string;
  119596. /**
  119597. * Gets the world position input component
  119598. */
  119599. readonly position: NodeMaterialConnectionPoint;
  119600. /**
  119601. * Gets the world position input component
  119602. */
  119603. readonly worldPosition: NodeMaterialConnectionPoint;
  119604. /**
  119605. * Gets the world normal input component
  119606. */
  119607. readonly worldNormal: NodeMaterialConnectionPoint;
  119608. /**
  119609. * Gets the world input component
  119610. */
  119611. readonly world: NodeMaterialConnectionPoint;
  119612. /**
  119613. * Gets the camera (or eye) position component
  119614. */
  119615. readonly cameraPosition: NodeMaterialConnectionPoint;
  119616. /**
  119617. * Gets the view input component
  119618. */
  119619. readonly view: NodeMaterialConnectionPoint;
  119620. /**
  119621. * Gets the rgb output component
  119622. */
  119623. readonly rgb: NodeMaterialConnectionPoint;
  119624. /**
  119625. * Gets the r output component
  119626. */
  119627. readonly r: NodeMaterialConnectionPoint;
  119628. /**
  119629. * Gets the g output component
  119630. */
  119631. readonly g: NodeMaterialConnectionPoint;
  119632. /**
  119633. * Gets the b output component
  119634. */
  119635. readonly b: NodeMaterialConnectionPoint;
  119636. autoConfigure(material: NodeMaterial): void;
  119637. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119638. isReady(): boolean;
  119639. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119640. private _injectVertexCode;
  119641. private _writeOutput;
  119642. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119643. serialize(): any;
  119644. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119645. }
  119646. }
  119647. declare module BABYLON {
  119648. /**
  119649. * Interface used to configure the node material editor
  119650. */
  119651. export interface INodeMaterialEditorOptions {
  119652. /** Define the URl to load node editor script */
  119653. editorURL?: string;
  119654. }
  119655. /** @hidden */
  119656. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119657. /** BONES */
  119658. NUM_BONE_INFLUENCERS: number;
  119659. BonesPerMesh: number;
  119660. BONETEXTURE: boolean;
  119661. /** MORPH TARGETS */
  119662. MORPHTARGETS: boolean;
  119663. MORPHTARGETS_NORMAL: boolean;
  119664. MORPHTARGETS_TANGENT: boolean;
  119665. MORPHTARGETS_UV: boolean;
  119666. NUM_MORPH_INFLUENCERS: number;
  119667. /** IMAGE PROCESSING */
  119668. IMAGEPROCESSING: boolean;
  119669. VIGNETTE: boolean;
  119670. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119671. VIGNETTEBLENDMODEOPAQUE: boolean;
  119672. TONEMAPPING: boolean;
  119673. TONEMAPPING_ACES: boolean;
  119674. CONTRAST: boolean;
  119675. EXPOSURE: boolean;
  119676. COLORCURVES: boolean;
  119677. COLORGRADING: boolean;
  119678. COLORGRADING3D: boolean;
  119679. SAMPLER3DGREENDEPTH: boolean;
  119680. SAMPLER3DBGRMAP: boolean;
  119681. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119682. /** MISC. */
  119683. BUMPDIRECTUV: number;
  119684. constructor();
  119685. setValue(name: string, value: boolean): void;
  119686. }
  119687. /**
  119688. * Class used to configure NodeMaterial
  119689. */
  119690. export interface INodeMaterialOptions {
  119691. /**
  119692. * Defines if blocks should emit comments
  119693. */
  119694. emitComments: boolean;
  119695. }
  119696. /**
  119697. * Class used to create a node based material built by assembling shader blocks
  119698. */
  119699. export class NodeMaterial extends PushMaterial {
  119700. private static _BuildIdGenerator;
  119701. private _options;
  119702. private _vertexCompilationState;
  119703. private _fragmentCompilationState;
  119704. private _sharedData;
  119705. private _buildId;
  119706. private _buildWasSuccessful;
  119707. private _cachedWorldViewMatrix;
  119708. private _cachedWorldViewProjectionMatrix;
  119709. private _optimizers;
  119710. private _animationFrame;
  119711. /** Define the URl to load node editor script */
  119712. static EditorURL: string;
  119713. private BJSNODEMATERIALEDITOR;
  119714. /** Get the inspector from bundle or global */
  119715. private _getGlobalNodeMaterialEditor;
  119716. /**
  119717. * 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)
  119718. */
  119719. ignoreAlpha: boolean;
  119720. /**
  119721. * Defines the maximum number of lights that can be used in the material
  119722. */
  119723. maxSimultaneousLights: number;
  119724. /**
  119725. * Observable raised when the material is built
  119726. */
  119727. onBuildObservable: Observable<NodeMaterial>;
  119728. /**
  119729. * Gets or sets the root nodes of the material vertex shader
  119730. */
  119731. _vertexOutputNodes: NodeMaterialBlock[];
  119732. /**
  119733. * Gets or sets the root nodes of the material fragment (pixel) shader
  119734. */
  119735. _fragmentOutputNodes: NodeMaterialBlock[];
  119736. /** Gets or sets options to control the node material overall behavior */
  119737. options: INodeMaterialOptions;
  119738. /**
  119739. * Default configuration related to image processing available in the standard Material.
  119740. */
  119741. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119742. /**
  119743. * Gets the image processing configuration used either in this material.
  119744. */
  119745. /**
  119746. * Sets the Default image processing configuration used either in the this material.
  119747. *
  119748. * If sets to null, the scene one is in use.
  119749. */
  119750. imageProcessingConfiguration: ImageProcessingConfiguration;
  119751. /**
  119752. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119753. */
  119754. attachedBlocks: NodeMaterialBlock[];
  119755. /**
  119756. * Create a new node based material
  119757. * @param name defines the material name
  119758. * @param scene defines the hosting scene
  119759. * @param options defines creation option
  119760. */
  119761. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119762. /**
  119763. * Gets the current class name of the material e.g. "NodeMaterial"
  119764. * @returns the class name
  119765. */
  119766. getClassName(): string;
  119767. /**
  119768. * Keep track of the image processing observer to allow dispose and replace.
  119769. */
  119770. private _imageProcessingObserver;
  119771. /**
  119772. * Attaches a new image processing configuration to the Standard Material.
  119773. * @param configuration
  119774. */
  119775. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119776. /**
  119777. * Get a block by its name
  119778. * @param name defines the name of the block to retrieve
  119779. * @returns the required block or null if not found
  119780. */
  119781. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119782. /**
  119783. * Get a block by its name
  119784. * @param predicate defines the predicate used to find the good candidate
  119785. * @returns the required block or null if not found
  119786. */
  119787. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119788. /**
  119789. * Get an input block by its name
  119790. * @param predicate defines the predicate used to find the good candidate
  119791. * @returns the required input block or null if not found
  119792. */
  119793. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119794. /**
  119795. * Gets the list of input blocks attached to this material
  119796. * @returns an array of InputBlocks
  119797. */
  119798. getInputBlocks(): InputBlock[];
  119799. /**
  119800. * Adds a new optimizer to the list of optimizers
  119801. * @param optimizer defines the optimizers to add
  119802. * @returns the current material
  119803. */
  119804. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119805. /**
  119806. * Remove an optimizer from the list of optimizers
  119807. * @param optimizer defines the optimizers to remove
  119808. * @returns the current material
  119809. */
  119810. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119811. /**
  119812. * Add a new block to the list of output nodes
  119813. * @param node defines the node to add
  119814. * @returns the current material
  119815. */
  119816. addOutputNode(node: NodeMaterialBlock): this;
  119817. /**
  119818. * Remove a block from the list of root nodes
  119819. * @param node defines the node to remove
  119820. * @returns the current material
  119821. */
  119822. removeOutputNode(node: NodeMaterialBlock): this;
  119823. private _addVertexOutputNode;
  119824. private _removeVertexOutputNode;
  119825. private _addFragmentOutputNode;
  119826. private _removeFragmentOutputNode;
  119827. /**
  119828. * Specifies if the material will require alpha blending
  119829. * @returns a boolean specifying if alpha blending is needed
  119830. */
  119831. needAlphaBlending(): boolean;
  119832. /**
  119833. * Specifies if this material should be rendered in alpha test mode
  119834. * @returns a boolean specifying if an alpha test is needed.
  119835. */
  119836. needAlphaTesting(): boolean;
  119837. private _initializeBlock;
  119838. private _resetDualBlocks;
  119839. /**
  119840. * Build the material and generates the inner effect
  119841. * @param verbose defines if the build should log activity
  119842. */
  119843. build(verbose?: boolean): void;
  119844. /**
  119845. * Runs an otpimization phase to try to improve the shader code
  119846. */
  119847. optimize(): void;
  119848. private _prepareDefinesForAttributes;
  119849. /**
  119850. * Get if the submesh is ready to be used and all its information available.
  119851. * Child classes can use it to update shaders
  119852. * @param mesh defines the mesh to check
  119853. * @param subMesh defines which submesh to check
  119854. * @param useInstances specifies that instances should be used
  119855. * @returns a boolean indicating that the submesh is ready or not
  119856. */
  119857. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119858. /**
  119859. * Get a string representing the shaders built by the current node graph
  119860. */
  119861. readonly compiledShaders: string;
  119862. /**
  119863. * Binds the world matrix to the material
  119864. * @param world defines the world transformation matrix
  119865. */
  119866. bindOnlyWorldMatrix(world: Matrix): void;
  119867. /**
  119868. * Binds the submesh to this material by preparing the effect and shader to draw
  119869. * @param world defines the world transformation matrix
  119870. * @param mesh defines the mesh containing the submesh
  119871. * @param subMesh defines the submesh to bind the material to
  119872. */
  119873. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119874. /**
  119875. * Gets the active textures from the material
  119876. * @returns an array of textures
  119877. */
  119878. getActiveTextures(): BaseTexture[];
  119879. /**
  119880. * Gets the list of texture blocks
  119881. * @returns an array of texture blocks
  119882. */
  119883. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119884. /**
  119885. * Specifies if the material uses a texture
  119886. * @param texture defines the texture to check against the material
  119887. * @returns a boolean specifying if the material uses the texture
  119888. */
  119889. hasTexture(texture: BaseTexture): boolean;
  119890. /**
  119891. * Disposes the material
  119892. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119893. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119894. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119895. */
  119896. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119897. /** Creates the node editor window. */
  119898. private _createNodeEditor;
  119899. /**
  119900. * Launch the node material editor
  119901. * @param config Define the configuration of the editor
  119902. * @return a promise fulfilled when the node editor is visible
  119903. */
  119904. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119905. /**
  119906. * Clear the current material
  119907. */
  119908. clear(): void;
  119909. /**
  119910. * Clear the current material and set it to a default state
  119911. */
  119912. setToDefault(): void;
  119913. /**
  119914. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119915. * @param url defines the url to load from
  119916. * @returns a promise that will fullfil when the material is fully loaded
  119917. */
  119918. loadAsync(url: string): Promise<unknown>;
  119919. private _gatherBlocks;
  119920. /**
  119921. * Generate a string containing the code declaration required to create an equivalent of this material
  119922. * @returns a string
  119923. */
  119924. generateCode(): string;
  119925. /**
  119926. * Serializes this material in a JSON representation
  119927. * @returns the serialized material object
  119928. */
  119929. serialize(): any;
  119930. private _restoreConnections;
  119931. /**
  119932. * Clear the current graph and load a new one from a serialization object
  119933. * @param source defines the JSON representation of the material
  119934. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119935. */
  119936. loadFromSerialization(source: any, rootUrl?: string): void;
  119937. /**
  119938. * Creates a node material from parsed material data
  119939. * @param source defines the JSON representation of the material
  119940. * @param scene defines the hosting scene
  119941. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119942. * @returns a new node material
  119943. */
  119944. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119945. /**
  119946. * Creates a new node material set to default basic configuration
  119947. * @param name defines the name of the material
  119948. * @param scene defines the hosting scene
  119949. * @returns a new NodeMaterial
  119950. */
  119951. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119952. }
  119953. }
  119954. declare module BABYLON {
  119955. /**
  119956. * Block used to read a texture from a sampler
  119957. */
  119958. export class TextureBlock extends NodeMaterialBlock {
  119959. private _defineName;
  119960. private _linearDefineName;
  119961. private _samplerName;
  119962. private _transformedUVName;
  119963. private _textureTransformName;
  119964. private _textureInfoName;
  119965. private _mainUVName;
  119966. private _mainUVDefineName;
  119967. /**
  119968. * Gets or sets the texture associated with the node
  119969. */
  119970. texture: Nullable<Texture>;
  119971. /**
  119972. * Create a new TextureBlock
  119973. * @param name defines the block name
  119974. */
  119975. constructor(name: string);
  119976. /**
  119977. * Gets the current class name
  119978. * @returns the class name
  119979. */
  119980. getClassName(): string;
  119981. /**
  119982. * Gets the uv input component
  119983. */
  119984. readonly uv: NodeMaterialConnectionPoint;
  119985. /**
  119986. * Gets the rgba output component
  119987. */
  119988. readonly rgba: NodeMaterialConnectionPoint;
  119989. /**
  119990. * Gets the rgb output component
  119991. */
  119992. readonly rgb: NodeMaterialConnectionPoint;
  119993. /**
  119994. * Gets the r output component
  119995. */
  119996. readonly r: NodeMaterialConnectionPoint;
  119997. /**
  119998. * Gets the g output component
  119999. */
  120000. readonly g: NodeMaterialConnectionPoint;
  120001. /**
  120002. * Gets the b output component
  120003. */
  120004. readonly b: NodeMaterialConnectionPoint;
  120005. /**
  120006. * Gets the a output component
  120007. */
  120008. readonly a: NodeMaterialConnectionPoint;
  120009. readonly target: NodeMaterialBlockTargets;
  120010. autoConfigure(material: NodeMaterial): void;
  120011. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120012. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120013. isReady(): boolean;
  120014. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120015. private readonly _isMixed;
  120016. private _injectVertexCode;
  120017. private _writeOutput;
  120018. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  120019. protected _dumpPropertiesCode(): string;
  120020. serialize(): any;
  120021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120022. }
  120023. }
  120024. declare module BABYLON {
  120025. /**
  120026. * Class used to store shared data between 2 NodeMaterialBuildState
  120027. */
  120028. export class NodeMaterialBuildStateSharedData {
  120029. /**
  120030. * Gets the list of emitted varyings
  120031. */
  120032. temps: string[];
  120033. /**
  120034. * Gets the list of emitted varyings
  120035. */
  120036. varyings: string[];
  120037. /**
  120038. * Gets the varying declaration string
  120039. */
  120040. varyingDeclaration: string;
  120041. /**
  120042. * Input blocks
  120043. */
  120044. inputBlocks: InputBlock[];
  120045. /**
  120046. * Input blocks
  120047. */
  120048. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  120049. /**
  120050. * Bindable blocks (Blocks that need to set data to the effect)
  120051. */
  120052. bindableBlocks: NodeMaterialBlock[];
  120053. /**
  120054. * List of blocks that can provide a compilation fallback
  120055. */
  120056. blocksWithFallbacks: NodeMaterialBlock[];
  120057. /**
  120058. * List of blocks that can provide a define update
  120059. */
  120060. blocksWithDefines: NodeMaterialBlock[];
  120061. /**
  120062. * List of blocks that can provide a repeatable content
  120063. */
  120064. repeatableContentBlocks: NodeMaterialBlock[];
  120065. /**
  120066. * List of blocks that can provide a dynamic list of uniforms
  120067. */
  120068. dynamicUniformBlocks: NodeMaterialBlock[];
  120069. /**
  120070. * List of blocks that can block the isReady function for the material
  120071. */
  120072. blockingBlocks: NodeMaterialBlock[];
  120073. /**
  120074. * Gets the list of animated inputs
  120075. */
  120076. animatedInputs: InputBlock[];
  120077. /**
  120078. * Build Id used to avoid multiple recompilations
  120079. */
  120080. buildId: number;
  120081. /** List of emitted variables */
  120082. variableNames: {
  120083. [key: string]: number;
  120084. };
  120085. /** List of emitted defines */
  120086. defineNames: {
  120087. [key: string]: number;
  120088. };
  120089. /** Should emit comments? */
  120090. emitComments: boolean;
  120091. /** Emit build activity */
  120092. verbose: boolean;
  120093. /** Gets or sets the hosting scene */
  120094. scene: Scene;
  120095. /**
  120096. * Gets the compilation hints emitted at compilation time
  120097. */
  120098. hints: {
  120099. needWorldViewMatrix: boolean;
  120100. needWorldViewProjectionMatrix: boolean;
  120101. needAlphaBlending: boolean;
  120102. needAlphaTesting: boolean;
  120103. };
  120104. /**
  120105. * List of compilation checks
  120106. */
  120107. checks: {
  120108. emitVertex: boolean;
  120109. emitFragment: boolean;
  120110. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120111. };
  120112. /** Creates a new shared data */
  120113. constructor();
  120114. /**
  120115. * Emits console errors and exceptions if there is a failing check
  120116. */
  120117. emitErrors(): void;
  120118. }
  120119. }
  120120. declare module BABYLON {
  120121. /**
  120122. * Class used to store node based material build state
  120123. */
  120124. export class NodeMaterialBuildState {
  120125. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120126. supportUniformBuffers: boolean;
  120127. /**
  120128. * Gets the list of emitted attributes
  120129. */
  120130. attributes: string[];
  120131. /**
  120132. * Gets the list of emitted uniforms
  120133. */
  120134. uniforms: string[];
  120135. /**
  120136. * Gets the list of emitted constants
  120137. */
  120138. constants: string[];
  120139. /**
  120140. * Gets the list of emitted uniform buffers
  120141. */
  120142. uniformBuffers: string[];
  120143. /**
  120144. * Gets the list of emitted samplers
  120145. */
  120146. samplers: string[];
  120147. /**
  120148. * Gets the list of emitted functions
  120149. */
  120150. functions: {
  120151. [key: string]: string;
  120152. };
  120153. /**
  120154. * Gets the list of emitted extensions
  120155. */
  120156. extensions: {
  120157. [key: string]: string;
  120158. };
  120159. /**
  120160. * Gets the target of the compilation state
  120161. */
  120162. target: NodeMaterialBlockTargets;
  120163. /**
  120164. * Gets the list of emitted counters
  120165. */
  120166. counters: {
  120167. [key: string]: number;
  120168. };
  120169. /**
  120170. * Shared data between multiple NodeMaterialBuildState instances
  120171. */
  120172. sharedData: NodeMaterialBuildStateSharedData;
  120173. /** @hidden */
  120174. _vertexState: NodeMaterialBuildState;
  120175. /** @hidden */
  120176. _attributeDeclaration: string;
  120177. /** @hidden */
  120178. _uniformDeclaration: string;
  120179. /** @hidden */
  120180. _constantDeclaration: string;
  120181. /** @hidden */
  120182. _samplerDeclaration: string;
  120183. /** @hidden */
  120184. _varyingTransfer: string;
  120185. private _repeatableContentAnchorIndex;
  120186. /** @hidden */
  120187. _builtCompilationString: string;
  120188. /**
  120189. * Gets the emitted compilation strings
  120190. */
  120191. compilationString: string;
  120192. /**
  120193. * Finalize the compilation strings
  120194. * @param state defines the current compilation state
  120195. */
  120196. finalize(state: NodeMaterialBuildState): void;
  120197. /** @hidden */
  120198. readonly _repeatableContentAnchor: string;
  120199. /** @hidden */
  120200. _getFreeVariableName(prefix: string): string;
  120201. /** @hidden */
  120202. _getFreeDefineName(prefix: string): string;
  120203. /** @hidden */
  120204. _excludeVariableName(name: string): void;
  120205. /** @hidden */
  120206. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120207. /** @hidden */
  120208. _emitExtension(name: string, extension: string): void;
  120209. /** @hidden */
  120210. _emitFunction(name: string, code: string, comments: string): void;
  120211. /** @hidden */
  120212. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120213. replaceStrings?: {
  120214. search: RegExp;
  120215. replace: string;
  120216. }[];
  120217. repeatKey?: string;
  120218. }): string;
  120219. /** @hidden */
  120220. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120221. repeatKey?: string;
  120222. removeAttributes?: boolean;
  120223. removeUniforms?: boolean;
  120224. removeVaryings?: boolean;
  120225. removeIfDef?: boolean;
  120226. replaceStrings?: {
  120227. search: RegExp;
  120228. replace: string;
  120229. }[];
  120230. }, storeKey?: string): void;
  120231. /** @hidden */
  120232. _registerTempVariable(name: string): boolean;
  120233. /** @hidden */
  120234. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120235. /** @hidden */
  120236. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120237. /** @hidden */
  120238. _emitFloat(value: number): string;
  120239. }
  120240. }
  120241. declare module BABYLON {
  120242. /**
  120243. * Defines a block that can be used inside a node based material
  120244. */
  120245. export class NodeMaterialBlock {
  120246. private _buildId;
  120247. private _buildTarget;
  120248. private _target;
  120249. private _isFinalMerger;
  120250. private _isInput;
  120251. /** @hidden */
  120252. _codeVariableName: string;
  120253. /** @hidden */
  120254. _inputs: NodeMaterialConnectionPoint[];
  120255. /** @hidden */
  120256. _outputs: NodeMaterialConnectionPoint[];
  120257. /** @hidden */
  120258. _preparationId: number;
  120259. /**
  120260. * Gets or sets the name of the block
  120261. */
  120262. name: string;
  120263. /**
  120264. * Gets or sets the unique id of the node
  120265. */
  120266. uniqueId: number;
  120267. /**
  120268. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120269. */
  120270. readonly isFinalMerger: boolean;
  120271. /**
  120272. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120273. */
  120274. readonly isInput: boolean;
  120275. /**
  120276. * Gets or sets the build Id
  120277. */
  120278. buildId: number;
  120279. /**
  120280. * Gets or sets the target of the block
  120281. */
  120282. target: NodeMaterialBlockTargets;
  120283. /**
  120284. * Gets the list of input points
  120285. */
  120286. readonly inputs: NodeMaterialConnectionPoint[];
  120287. /** Gets the list of output points */
  120288. readonly outputs: NodeMaterialConnectionPoint[];
  120289. /**
  120290. * Find an input by its name
  120291. * @param name defines the name of the input to look for
  120292. * @returns the input or null if not found
  120293. */
  120294. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120295. /**
  120296. * Find an output by its name
  120297. * @param name defines the name of the outputto look for
  120298. * @returns the output or null if not found
  120299. */
  120300. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120301. /**
  120302. * Creates a new NodeMaterialBlock
  120303. * @param name defines the block name
  120304. * @param target defines the target of that block (Vertex by default)
  120305. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120306. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120307. */
  120308. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120309. /**
  120310. * Initialize the block and prepare the context for build
  120311. * @param state defines the state that will be used for the build
  120312. */
  120313. initialize(state: NodeMaterialBuildState): void;
  120314. /**
  120315. * Bind data to effect. Will only be called for blocks with isBindable === true
  120316. * @param effect defines the effect to bind data to
  120317. * @param nodeMaterial defines the hosting NodeMaterial
  120318. * @param mesh defines the mesh that will be rendered
  120319. */
  120320. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120321. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120322. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120323. protected _writeFloat(value: number): string;
  120324. /**
  120325. * Gets the current class name e.g. "NodeMaterialBlock"
  120326. * @returns the class name
  120327. */
  120328. getClassName(): string;
  120329. /**
  120330. * Register a new input. Must be called inside a block constructor
  120331. * @param name defines the connection point name
  120332. * @param type defines the connection point type
  120333. * @param isOptional defines a boolean indicating that this input can be omitted
  120334. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120335. * @returns the current block
  120336. */
  120337. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120338. /**
  120339. * Register a new output. Must be called inside a block constructor
  120340. * @param name defines the connection point name
  120341. * @param type defines the connection point type
  120342. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120343. * @returns the current block
  120344. */
  120345. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120346. /**
  120347. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120348. * @param forOutput defines an optional connection point to check compatibility with
  120349. * @returns the first available input or null
  120350. */
  120351. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120352. /**
  120353. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120354. * @param forBlock defines an optional block to check compatibility with
  120355. * @returns the first available input or null
  120356. */
  120357. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120358. /**
  120359. * Gets the sibling of the given output
  120360. * @param current defines the current output
  120361. * @returns the next output in the list or null
  120362. */
  120363. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120364. /**
  120365. * Connect current block with another block
  120366. * @param other defines the block to connect with
  120367. * @param options define the various options to help pick the right connections
  120368. * @returns the current block
  120369. */
  120370. connectTo(other: NodeMaterialBlock, options?: {
  120371. input?: string;
  120372. output?: string;
  120373. outputSwizzle?: string;
  120374. }): this | undefined;
  120375. protected _buildBlock(state: NodeMaterialBuildState): void;
  120376. /**
  120377. * Add uniforms, samplers and uniform buffers at compilation time
  120378. * @param state defines the state to update
  120379. * @param nodeMaterial defines the node material requesting the update
  120380. * @param defines defines the material defines to update
  120381. */
  120382. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120383. /**
  120384. * Add potential fallbacks if shader compilation fails
  120385. * @param mesh defines the mesh to be rendered
  120386. * @param fallbacks defines the current prioritized list of fallbacks
  120387. */
  120388. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120389. /**
  120390. * Initialize defines for shader compilation
  120391. * @param mesh defines the mesh to be rendered
  120392. * @param nodeMaterial defines the node material requesting the update
  120393. * @param defines defines the material defines to update
  120394. * @param useInstances specifies that instances should be used
  120395. */
  120396. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120397. /**
  120398. * Update defines for shader compilation
  120399. * @param mesh defines the mesh to be rendered
  120400. * @param nodeMaterial defines the node material requesting the update
  120401. * @param defines defines the material defines to update
  120402. * @param useInstances specifies that instances should be used
  120403. */
  120404. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120405. /**
  120406. * Lets the block try to connect some inputs automatically
  120407. * @param material defines the hosting NodeMaterial
  120408. */
  120409. autoConfigure(material: NodeMaterial): void;
  120410. /**
  120411. * Function called when a block is declared as repeatable content generator
  120412. * @param vertexShaderState defines the current compilation state for the vertex shader
  120413. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120414. * @param mesh defines the mesh to be rendered
  120415. * @param defines defines the material defines to update
  120416. */
  120417. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120418. /**
  120419. * Checks if the block is ready
  120420. * @param mesh defines the mesh to be rendered
  120421. * @param nodeMaterial defines the node material requesting the update
  120422. * @param defines defines the material defines to update
  120423. * @param useInstances specifies that instances should be used
  120424. * @returns true if the block is ready
  120425. */
  120426. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120427. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120428. private _processBuild;
  120429. /**
  120430. * Compile the current node and generate the shader code
  120431. * @param state defines the current compilation state (uniforms, samplers, current string)
  120432. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120433. * @returns true if already built
  120434. */
  120435. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120436. protected _inputRename(name: string): string;
  120437. protected _outputRename(name: string): string;
  120438. protected _dumpPropertiesCode(): string;
  120439. /** @hidden */
  120440. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120441. /**
  120442. * Clone the current block to a new identical block
  120443. * @param scene defines the hosting scene
  120444. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120445. * @returns a copy of the current block
  120446. */
  120447. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120448. /**
  120449. * Serializes this block in a JSON representation
  120450. * @returns the serialized block object
  120451. */
  120452. serialize(): any;
  120453. /** @hidden */
  120454. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120455. }
  120456. }
  120457. declare module BABYLON {
  120458. /**
  120459. * Enum defining the type of animations supported by InputBlock
  120460. */
  120461. export enum AnimatedInputBlockTypes {
  120462. /** No animation */
  120463. None = 0,
  120464. /** Time based animation. Will only work for floats */
  120465. Time = 1
  120466. }
  120467. }
  120468. declare module BABYLON {
  120469. /**
  120470. * Block used to expose an input value
  120471. */
  120472. export class InputBlock extends NodeMaterialBlock {
  120473. private _mode;
  120474. private _associatedVariableName;
  120475. private _storedValue;
  120476. private _valueCallback;
  120477. private _type;
  120478. private _animationType;
  120479. /** Gets or set a value used to limit the range of float values */
  120480. min: number;
  120481. /** Gets or set a value used to limit the range of float values */
  120482. max: number;
  120483. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120484. matrixMode: number;
  120485. /** @hidden */
  120486. _systemValue: Nullable<NodeMaterialSystemValues>;
  120487. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120488. visibleInInspector: boolean;
  120489. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120490. isConstant: boolean;
  120491. /**
  120492. * Gets or sets the connection point type (default is float)
  120493. */
  120494. readonly type: NodeMaterialBlockConnectionPointTypes;
  120495. /**
  120496. * Creates a new InputBlock
  120497. * @param name defines the block name
  120498. * @param target defines the target of that block (Vertex by default)
  120499. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120500. */
  120501. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120502. /**
  120503. * Gets the output component
  120504. */
  120505. readonly output: NodeMaterialConnectionPoint;
  120506. /**
  120507. * Set the source of this connection point to a vertex attribute
  120508. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120509. * @returns the current connection point
  120510. */
  120511. setAsAttribute(attributeName?: string): InputBlock;
  120512. /**
  120513. * Set the source of this connection point to a system value
  120514. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120515. * @returns the current connection point
  120516. */
  120517. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120518. /**
  120519. * Gets or sets the value of that point.
  120520. * Please note that this value will be ignored if valueCallback is defined
  120521. */
  120522. value: any;
  120523. /**
  120524. * Gets or sets a callback used to get the value of that point.
  120525. * Please note that setting this value will force the connection point to ignore the value property
  120526. */
  120527. valueCallback: () => any;
  120528. /**
  120529. * Gets or sets the associated variable name in the shader
  120530. */
  120531. associatedVariableName: string;
  120532. /** Gets or sets the type of animation applied to the input */
  120533. animationType: AnimatedInputBlockTypes;
  120534. /**
  120535. * Gets a boolean indicating that this connection point not defined yet
  120536. */
  120537. readonly isUndefined: boolean;
  120538. /**
  120539. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120540. * In this case the connection point name must be the name of the uniform to use.
  120541. * Can only be set on inputs
  120542. */
  120543. isUniform: boolean;
  120544. /**
  120545. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120546. * In this case the connection point name must be the name of the attribute to use
  120547. * Can only be set on inputs
  120548. */
  120549. isAttribute: boolean;
  120550. /**
  120551. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120552. * Can only be set on exit points
  120553. */
  120554. isVarying: boolean;
  120555. /**
  120556. * Gets a boolean indicating that the current connection point is a system value
  120557. */
  120558. readonly isSystemValue: boolean;
  120559. /**
  120560. * Gets or sets the current well known value or null if not defined as a system value
  120561. */
  120562. systemValue: Nullable<NodeMaterialSystemValues>;
  120563. /**
  120564. * Gets the current class name
  120565. * @returns the class name
  120566. */
  120567. getClassName(): string;
  120568. /**
  120569. * Animate the input if animationType !== None
  120570. * @param scene defines the rendering scene
  120571. */
  120572. animate(scene: Scene): void;
  120573. private _emitDefine;
  120574. initialize(state: NodeMaterialBuildState): void;
  120575. /**
  120576. * Set the input block to its default value (based on its type)
  120577. */
  120578. setDefaultValue(): void;
  120579. private _emitConstant;
  120580. private _emit;
  120581. /** @hidden */
  120582. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120583. /** @hidden */
  120584. _transmit(effect: Effect, scene: Scene): void;
  120585. protected _buildBlock(state: NodeMaterialBuildState): void;
  120586. protected _dumpPropertiesCode(): string;
  120587. serialize(): any;
  120588. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120589. }
  120590. }
  120591. declare module BABYLON {
  120592. /**
  120593. * Defines a connection point for a block
  120594. */
  120595. export class NodeMaterialConnectionPoint {
  120596. /** @hidden */
  120597. _ownerBlock: NodeMaterialBlock;
  120598. /** @hidden */
  120599. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120600. private _endpoints;
  120601. private _associatedVariableName;
  120602. /** @hidden */
  120603. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120604. /** @hidden */
  120605. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120606. private _type;
  120607. /** @hidden */
  120608. _enforceAssociatedVariableName: boolean;
  120609. /**
  120610. * Gets or sets the additional types supported by this connection point
  120611. */
  120612. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120613. /**
  120614. * Gets or sets the additional types excluded by this connection point
  120615. */
  120616. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120617. /**
  120618. * Gets or sets the associated variable name in the shader
  120619. */
  120620. associatedVariableName: string;
  120621. /**
  120622. * Gets or sets the connection point type (default is float)
  120623. */
  120624. type: NodeMaterialBlockConnectionPointTypes;
  120625. /**
  120626. * Gets or sets the connection point name
  120627. */
  120628. name: string;
  120629. /**
  120630. * Gets or sets a boolean indicating that this connection point can be omitted
  120631. */
  120632. isOptional: boolean;
  120633. /**
  120634. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120635. */
  120636. define: string;
  120637. /** Gets or sets the target of that connection point */
  120638. target: NodeMaterialBlockTargets;
  120639. /**
  120640. * Gets a boolean indicating that the current point is connected
  120641. */
  120642. readonly isConnected: boolean;
  120643. /**
  120644. * Gets a boolean indicating that the current point is connected to an input block
  120645. */
  120646. readonly isConnectedToInputBlock: boolean;
  120647. /**
  120648. * Gets a the connected input block (if any)
  120649. */
  120650. readonly connectInputBlock: Nullable<InputBlock>;
  120651. /** Get the other side of the connection (if any) */
  120652. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120653. /** Get the block that owns this connection point */
  120654. readonly ownerBlock: NodeMaterialBlock;
  120655. /** Get the block connected on the other side of this connection (if any) */
  120656. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120657. /** Get the block connected on the endpoints of this connection (if any) */
  120658. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120659. /** Gets the list of connected endpoints */
  120660. readonly endpoints: NodeMaterialConnectionPoint[];
  120661. /** Gets a boolean indicating if that output point is connected to at least one input */
  120662. readonly hasEndpoints: boolean;
  120663. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  120664. readonly isConnectedInVertexShader: boolean;
  120665. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  120666. readonly isConnectedInFragmentShader: boolean;
  120667. /**
  120668. * Creates a new connection point
  120669. * @param name defines the connection point name
  120670. * @param ownerBlock defines the block hosting this connection point
  120671. */
  120672. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120673. /**
  120674. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120675. * @returns the class name
  120676. */
  120677. getClassName(): string;
  120678. /**
  120679. * Gets an boolean indicating if the current point can be connected to another point
  120680. * @param connectionPoint defines the other connection point
  120681. * @returns true if the connection is possible
  120682. */
  120683. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120684. /**
  120685. * Connect this point to another connection point
  120686. * @param connectionPoint defines the other connection point
  120687. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120688. * @returns the current connection point
  120689. */
  120690. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120691. /**
  120692. * Disconnect this point from one of his endpoint
  120693. * @param endpoint defines the other connection point
  120694. * @returns the current connection point
  120695. */
  120696. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120697. /**
  120698. * Serializes this point in a JSON representation
  120699. * @returns the serialized point object
  120700. */
  120701. serialize(): any;
  120702. }
  120703. }
  120704. declare module BABYLON {
  120705. /**
  120706. * Block used to add support for vertex skinning (bones)
  120707. */
  120708. export class BonesBlock extends NodeMaterialBlock {
  120709. /**
  120710. * Creates a new BonesBlock
  120711. * @param name defines the block name
  120712. */
  120713. constructor(name: string);
  120714. /**
  120715. * Initialize the block and prepare the context for build
  120716. * @param state defines the state that will be used for the build
  120717. */
  120718. initialize(state: NodeMaterialBuildState): void;
  120719. /**
  120720. * Gets the current class name
  120721. * @returns the class name
  120722. */
  120723. getClassName(): string;
  120724. /**
  120725. * Gets the matrix indices input component
  120726. */
  120727. readonly matricesIndices: NodeMaterialConnectionPoint;
  120728. /**
  120729. * Gets the matrix weights input component
  120730. */
  120731. readonly matricesWeights: NodeMaterialConnectionPoint;
  120732. /**
  120733. * Gets the extra matrix indices input component
  120734. */
  120735. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120736. /**
  120737. * Gets the extra matrix weights input component
  120738. */
  120739. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120740. /**
  120741. * Gets the world input component
  120742. */
  120743. readonly world: NodeMaterialConnectionPoint;
  120744. /**
  120745. * Gets the output component
  120746. */
  120747. readonly output: NodeMaterialConnectionPoint;
  120748. autoConfigure(material: NodeMaterial): void;
  120749. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120750. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120751. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120752. protected _buildBlock(state: NodeMaterialBuildState): this;
  120753. }
  120754. }
  120755. declare module BABYLON {
  120756. /**
  120757. * Block used to add support for instances
  120758. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120759. */
  120760. export class InstancesBlock extends NodeMaterialBlock {
  120761. /**
  120762. * Creates a new InstancesBlock
  120763. * @param name defines the block name
  120764. */
  120765. constructor(name: string);
  120766. /**
  120767. * Gets the current class name
  120768. * @returns the class name
  120769. */
  120770. getClassName(): string;
  120771. /**
  120772. * Gets the first world row input component
  120773. */
  120774. readonly world0: NodeMaterialConnectionPoint;
  120775. /**
  120776. * Gets the second world row input component
  120777. */
  120778. readonly world1: NodeMaterialConnectionPoint;
  120779. /**
  120780. * Gets the third world row input component
  120781. */
  120782. readonly world2: NodeMaterialConnectionPoint;
  120783. /**
  120784. * Gets the forth world row input component
  120785. */
  120786. readonly world3: NodeMaterialConnectionPoint;
  120787. /**
  120788. * Gets the world input component
  120789. */
  120790. readonly world: NodeMaterialConnectionPoint;
  120791. /**
  120792. * Gets the output component
  120793. */
  120794. readonly output: NodeMaterialConnectionPoint;
  120795. autoConfigure(material: NodeMaterial): void;
  120796. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120797. protected _buildBlock(state: NodeMaterialBuildState): this;
  120798. }
  120799. }
  120800. declare module BABYLON {
  120801. /**
  120802. * Block used to add morph targets support to vertex shader
  120803. */
  120804. export class MorphTargetsBlock extends NodeMaterialBlock {
  120805. private _repeatableContentAnchor;
  120806. private _repeatebleContentGenerated;
  120807. /**
  120808. * Create a new MorphTargetsBlock
  120809. * @param name defines the block name
  120810. */
  120811. constructor(name: string);
  120812. /**
  120813. * Gets the current class name
  120814. * @returns the class name
  120815. */
  120816. getClassName(): string;
  120817. /**
  120818. * Gets the position input component
  120819. */
  120820. readonly position: NodeMaterialConnectionPoint;
  120821. /**
  120822. * Gets the normal input component
  120823. */
  120824. readonly normal: NodeMaterialConnectionPoint;
  120825. /**
  120826. * Gets the tangent input component
  120827. */
  120828. readonly tangent: NodeMaterialConnectionPoint;
  120829. /**
  120830. * Gets the tangent input component
  120831. */
  120832. readonly uv: NodeMaterialConnectionPoint;
  120833. /**
  120834. * Gets the position output component
  120835. */
  120836. readonly positionOutput: NodeMaterialConnectionPoint;
  120837. /**
  120838. * Gets the normal output component
  120839. */
  120840. readonly normalOutput: NodeMaterialConnectionPoint;
  120841. /**
  120842. * Gets the tangent output component
  120843. */
  120844. readonly tangentOutput: NodeMaterialConnectionPoint;
  120845. /**
  120846. * Gets the tangent output component
  120847. */
  120848. readonly uvOutput: NodeMaterialConnectionPoint;
  120849. initialize(state: NodeMaterialBuildState): void;
  120850. autoConfigure(material: NodeMaterial): void;
  120851. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120852. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120853. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120854. protected _buildBlock(state: NodeMaterialBuildState): this;
  120855. }
  120856. }
  120857. declare module BABYLON {
  120858. /**
  120859. * Block used to get data information from a light
  120860. */
  120861. export class LightInformationBlock extends NodeMaterialBlock {
  120862. private _lightDataUniformName;
  120863. private _lightColorUniformName;
  120864. private _lightTypeDefineName;
  120865. /**
  120866. * Gets or sets the light associated with this block
  120867. */
  120868. light: Nullable<Light>;
  120869. /**
  120870. * Creates a new LightInformationBlock
  120871. * @param name defines the block name
  120872. */
  120873. constructor(name: string);
  120874. /**
  120875. * Gets the current class name
  120876. * @returns the class name
  120877. */
  120878. getClassName(): string;
  120879. /**
  120880. * Gets the world position input component
  120881. */
  120882. readonly worldPosition: NodeMaterialConnectionPoint;
  120883. /**
  120884. * Gets the direction output component
  120885. */
  120886. readonly direction: NodeMaterialConnectionPoint;
  120887. /**
  120888. * Gets the direction output component
  120889. */
  120890. readonly color: NodeMaterialConnectionPoint;
  120891. /**
  120892. * Gets the direction output component
  120893. */
  120894. readonly intensity: NodeMaterialConnectionPoint;
  120895. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120896. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120897. protected _buildBlock(state: NodeMaterialBuildState): this;
  120898. serialize(): any;
  120899. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120900. }
  120901. }
  120902. declare module BABYLON {
  120903. /**
  120904. * Block used to add image processing support to fragment shader
  120905. */
  120906. export class ImageProcessingBlock extends NodeMaterialBlock {
  120907. /**
  120908. * Create a new ImageProcessingBlock
  120909. * @param name defines the block name
  120910. */
  120911. constructor(name: string);
  120912. /**
  120913. * Gets the current class name
  120914. * @returns the class name
  120915. */
  120916. getClassName(): string;
  120917. /**
  120918. * Gets the color input component
  120919. */
  120920. readonly color: NodeMaterialConnectionPoint;
  120921. /**
  120922. * Gets the output component
  120923. */
  120924. readonly output: NodeMaterialConnectionPoint;
  120925. /**
  120926. * Initialize the block and prepare the context for build
  120927. * @param state defines the state that will be used for the build
  120928. */
  120929. initialize(state: NodeMaterialBuildState): void;
  120930. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120931. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120932. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120933. protected _buildBlock(state: NodeMaterialBuildState): this;
  120934. }
  120935. }
  120936. declare module BABYLON {
  120937. /**
  120938. * Block used to pertub normals based on a normal map
  120939. */
  120940. export class PerturbNormalBlock extends NodeMaterialBlock {
  120941. private _tangentSpaceParameterName;
  120942. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120943. invertX: boolean;
  120944. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120945. invertY: boolean;
  120946. /**
  120947. * Create a new PerturbNormalBlock
  120948. * @param name defines the block name
  120949. */
  120950. constructor(name: string);
  120951. /**
  120952. * Gets the current class name
  120953. * @returns the class name
  120954. */
  120955. getClassName(): string;
  120956. /**
  120957. * Gets the world position input component
  120958. */
  120959. readonly worldPosition: NodeMaterialConnectionPoint;
  120960. /**
  120961. * Gets the world normal input component
  120962. */
  120963. readonly worldNormal: NodeMaterialConnectionPoint;
  120964. /**
  120965. * Gets the uv input component
  120966. */
  120967. readonly uv: NodeMaterialConnectionPoint;
  120968. /**
  120969. * Gets the normal map color input component
  120970. */
  120971. readonly normalMapColor: NodeMaterialConnectionPoint;
  120972. /**
  120973. * Gets the strength input component
  120974. */
  120975. readonly strength: NodeMaterialConnectionPoint;
  120976. /**
  120977. * Gets the output component
  120978. */
  120979. readonly output: NodeMaterialConnectionPoint;
  120980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120981. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120982. autoConfigure(material: NodeMaterial): void;
  120983. protected _buildBlock(state: NodeMaterialBuildState): this;
  120984. protected _dumpPropertiesCode(): string;
  120985. serialize(): any;
  120986. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120987. }
  120988. }
  120989. declare module BABYLON {
  120990. /**
  120991. * Block used to discard a pixel if a value is smaller than a cutoff
  120992. */
  120993. export class DiscardBlock extends NodeMaterialBlock {
  120994. /**
  120995. * Create a new DiscardBlock
  120996. * @param name defines the block name
  120997. */
  120998. constructor(name: string);
  120999. /**
  121000. * Gets the current class name
  121001. * @returns the class name
  121002. */
  121003. getClassName(): string;
  121004. /**
  121005. * Gets the color input component
  121006. */
  121007. readonly value: NodeMaterialConnectionPoint;
  121008. /**
  121009. * Gets the cutoff input component
  121010. */
  121011. readonly cutoff: NodeMaterialConnectionPoint;
  121012. protected _buildBlock(state: NodeMaterialBuildState): this;
  121013. }
  121014. }
  121015. declare module BABYLON {
  121016. /**
  121017. * Block used to add support for scene fog
  121018. */
  121019. export class FogBlock extends NodeMaterialBlock {
  121020. private _fogDistanceName;
  121021. private _fogParameters;
  121022. /**
  121023. * Create a new FogBlock
  121024. * @param name defines the block name
  121025. */
  121026. constructor(name: string);
  121027. /**
  121028. * Gets the current class name
  121029. * @returns the class name
  121030. */
  121031. getClassName(): string;
  121032. /**
  121033. * Gets the world position input component
  121034. */
  121035. readonly worldPosition: NodeMaterialConnectionPoint;
  121036. /**
  121037. * Gets the view input component
  121038. */
  121039. readonly view: NodeMaterialConnectionPoint;
  121040. /**
  121041. * Gets the color input component
  121042. */
  121043. readonly input: NodeMaterialConnectionPoint;
  121044. /**
  121045. * Gets the fog color input component
  121046. */
  121047. readonly fogColor: NodeMaterialConnectionPoint;
  121048. /**
  121049. * Gets the output component
  121050. */
  121051. readonly output: NodeMaterialConnectionPoint;
  121052. autoConfigure(material: NodeMaterial): void;
  121053. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121054. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121055. protected _buildBlock(state: NodeMaterialBuildState): this;
  121056. }
  121057. }
  121058. declare module BABYLON {
  121059. /**
  121060. * Block used to add light in the fragment shader
  121061. */
  121062. export class LightBlock extends NodeMaterialBlock {
  121063. private _lightId;
  121064. /**
  121065. * Gets or sets the light associated with this block
  121066. */
  121067. light: Nullable<Light>;
  121068. /**
  121069. * Create a new LightBlock
  121070. * @param name defines the block name
  121071. */
  121072. constructor(name: string);
  121073. /**
  121074. * Gets the current class name
  121075. * @returns the class name
  121076. */
  121077. getClassName(): string;
  121078. /**
  121079. * Gets the world position input component
  121080. */
  121081. readonly worldPosition: NodeMaterialConnectionPoint;
  121082. /**
  121083. * Gets the world normal input component
  121084. */
  121085. readonly worldNormal: NodeMaterialConnectionPoint;
  121086. /**
  121087. * Gets the camera (or eye) position component
  121088. */
  121089. readonly cameraPosition: NodeMaterialConnectionPoint;
  121090. /**
  121091. * Gets the glossiness component
  121092. */
  121093. readonly glossiness: NodeMaterialConnectionPoint;
  121094. /**
  121095. * Gets the glossinness power component
  121096. */
  121097. readonly glossPower: NodeMaterialConnectionPoint;
  121098. /**
  121099. * Gets the diffuse color component
  121100. */
  121101. readonly diffuseColor: NodeMaterialConnectionPoint;
  121102. /**
  121103. * Gets the specular color component
  121104. */
  121105. readonly specularColor: NodeMaterialConnectionPoint;
  121106. /**
  121107. * Gets the diffuse output component
  121108. */
  121109. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121110. /**
  121111. * Gets the specular output component
  121112. */
  121113. readonly specularOutput: NodeMaterialConnectionPoint;
  121114. autoConfigure(material: NodeMaterial): void;
  121115. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121116. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121117. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121118. private _injectVertexCode;
  121119. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121120. serialize(): any;
  121121. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121122. }
  121123. }
  121124. declare module BABYLON {
  121125. /**
  121126. * Block used to multiply 2 values
  121127. */
  121128. export class MultiplyBlock extends NodeMaterialBlock {
  121129. /**
  121130. * Creates a new MultiplyBlock
  121131. * @param name defines the block name
  121132. */
  121133. constructor(name: string);
  121134. /**
  121135. * Gets the current class name
  121136. * @returns the class name
  121137. */
  121138. getClassName(): string;
  121139. /**
  121140. * Gets the left operand input component
  121141. */
  121142. readonly left: NodeMaterialConnectionPoint;
  121143. /**
  121144. * Gets the right operand input component
  121145. */
  121146. readonly right: NodeMaterialConnectionPoint;
  121147. /**
  121148. * Gets the output component
  121149. */
  121150. readonly output: NodeMaterialConnectionPoint;
  121151. protected _buildBlock(state: NodeMaterialBuildState): this;
  121152. }
  121153. }
  121154. declare module BABYLON {
  121155. /**
  121156. * Block used to add 2 vectors
  121157. */
  121158. export class AddBlock extends NodeMaterialBlock {
  121159. /**
  121160. * Creates a new AddBlock
  121161. * @param name defines the block name
  121162. */
  121163. constructor(name: string);
  121164. /**
  121165. * Gets the current class name
  121166. * @returns the class name
  121167. */
  121168. getClassName(): string;
  121169. /**
  121170. * Gets the left operand input component
  121171. */
  121172. readonly left: NodeMaterialConnectionPoint;
  121173. /**
  121174. * Gets the right operand input component
  121175. */
  121176. readonly right: NodeMaterialConnectionPoint;
  121177. /**
  121178. * Gets the output component
  121179. */
  121180. readonly output: NodeMaterialConnectionPoint;
  121181. protected _buildBlock(state: NodeMaterialBuildState): this;
  121182. }
  121183. }
  121184. declare module BABYLON {
  121185. /**
  121186. * Block used to scale a vector by a float
  121187. */
  121188. export class ScaleBlock extends NodeMaterialBlock {
  121189. /**
  121190. * Creates a new ScaleBlock
  121191. * @param name defines the block name
  121192. */
  121193. constructor(name: string);
  121194. /**
  121195. * Gets the current class name
  121196. * @returns the class name
  121197. */
  121198. getClassName(): string;
  121199. /**
  121200. * Gets the input component
  121201. */
  121202. readonly input: NodeMaterialConnectionPoint;
  121203. /**
  121204. * Gets the factor input component
  121205. */
  121206. readonly factor: NodeMaterialConnectionPoint;
  121207. /**
  121208. * Gets the output component
  121209. */
  121210. readonly output: NodeMaterialConnectionPoint;
  121211. protected _buildBlock(state: NodeMaterialBuildState): this;
  121212. }
  121213. }
  121214. declare module BABYLON {
  121215. /**
  121216. * Block used to clamp a float
  121217. */
  121218. export class ClampBlock extends NodeMaterialBlock {
  121219. /** Gets or sets the minimum range */
  121220. minimum: number;
  121221. /** Gets or sets the maximum range */
  121222. maximum: number;
  121223. /**
  121224. * Creates a new ClampBlock
  121225. * @param name defines the block name
  121226. */
  121227. constructor(name: string);
  121228. /**
  121229. * Gets the current class name
  121230. * @returns the class name
  121231. */
  121232. getClassName(): string;
  121233. /**
  121234. * Gets the value input component
  121235. */
  121236. readonly value: NodeMaterialConnectionPoint;
  121237. /**
  121238. * Gets the output component
  121239. */
  121240. readonly output: NodeMaterialConnectionPoint;
  121241. protected _buildBlock(state: NodeMaterialBuildState): this;
  121242. protected _dumpPropertiesCode(): string;
  121243. serialize(): any;
  121244. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121245. }
  121246. }
  121247. declare module BABYLON {
  121248. /**
  121249. * Block used to apply a cross product between 2 vectors
  121250. */
  121251. export class CrossBlock extends NodeMaterialBlock {
  121252. /**
  121253. * Creates a new CrossBlock
  121254. * @param name defines the block name
  121255. */
  121256. constructor(name: string);
  121257. /**
  121258. * Gets the current class name
  121259. * @returns the class name
  121260. */
  121261. getClassName(): string;
  121262. /**
  121263. * Gets the left operand input component
  121264. */
  121265. readonly left: NodeMaterialConnectionPoint;
  121266. /**
  121267. * Gets the right operand input component
  121268. */
  121269. readonly right: NodeMaterialConnectionPoint;
  121270. /**
  121271. * Gets the output component
  121272. */
  121273. readonly output: NodeMaterialConnectionPoint;
  121274. protected _buildBlock(state: NodeMaterialBuildState): this;
  121275. }
  121276. }
  121277. declare module BABYLON {
  121278. /**
  121279. * Block used to apply a dot product between 2 vectors
  121280. */
  121281. export class DotBlock extends NodeMaterialBlock {
  121282. /**
  121283. * Creates a new DotBlock
  121284. * @param name defines the block name
  121285. */
  121286. constructor(name: string);
  121287. /**
  121288. * Gets the current class name
  121289. * @returns the class name
  121290. */
  121291. getClassName(): string;
  121292. /**
  121293. * Gets the left operand input component
  121294. */
  121295. readonly left: NodeMaterialConnectionPoint;
  121296. /**
  121297. * Gets the right operand input component
  121298. */
  121299. readonly right: NodeMaterialConnectionPoint;
  121300. /**
  121301. * Gets the output component
  121302. */
  121303. readonly output: NodeMaterialConnectionPoint;
  121304. protected _buildBlock(state: NodeMaterialBuildState): this;
  121305. }
  121306. }
  121307. declare module BABYLON {
  121308. /**
  121309. * Block used to remap a float from a range to a new one
  121310. */
  121311. export class RemapBlock extends NodeMaterialBlock {
  121312. /**
  121313. * Gets or sets the source range
  121314. */
  121315. sourceRange: Vector2;
  121316. /**
  121317. * Gets or sets the target range
  121318. */
  121319. targetRange: Vector2;
  121320. /**
  121321. * Creates a new RemapBlock
  121322. * @param name defines the block name
  121323. */
  121324. constructor(name: string);
  121325. /**
  121326. * Gets the current class name
  121327. * @returns the class name
  121328. */
  121329. getClassName(): string;
  121330. /**
  121331. * Gets the input component
  121332. */
  121333. readonly input: NodeMaterialConnectionPoint;
  121334. /**
  121335. * Gets the source min input component
  121336. */
  121337. readonly sourceMin: NodeMaterialConnectionPoint;
  121338. /**
  121339. * Gets the source max input component
  121340. */
  121341. readonly sourceMax: NodeMaterialConnectionPoint;
  121342. /**
  121343. * Gets the target min input component
  121344. */
  121345. readonly targetMin: NodeMaterialConnectionPoint;
  121346. /**
  121347. * Gets the target max input component
  121348. */
  121349. readonly targetMax: NodeMaterialConnectionPoint;
  121350. /**
  121351. * Gets the output component
  121352. */
  121353. readonly output: NodeMaterialConnectionPoint;
  121354. protected _buildBlock(state: NodeMaterialBuildState): this;
  121355. protected _dumpPropertiesCode(): string;
  121356. serialize(): any;
  121357. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121358. }
  121359. }
  121360. declare module BABYLON {
  121361. /**
  121362. * Block used to normalize a vector
  121363. */
  121364. export class NormalizeBlock extends NodeMaterialBlock {
  121365. /**
  121366. * Creates a new NormalizeBlock
  121367. * @param name defines the block name
  121368. */
  121369. constructor(name: string);
  121370. /**
  121371. * Gets the current class name
  121372. * @returns the class name
  121373. */
  121374. getClassName(): string;
  121375. /**
  121376. * Gets the input component
  121377. */
  121378. readonly input: NodeMaterialConnectionPoint;
  121379. /**
  121380. * Gets the output component
  121381. */
  121382. readonly output: NodeMaterialConnectionPoint;
  121383. protected _buildBlock(state: NodeMaterialBuildState): this;
  121384. }
  121385. }
  121386. declare module BABYLON {
  121387. /**
  121388. * Operations supported by the Trigonometry block
  121389. */
  121390. export enum TrigonometryBlockOperations {
  121391. /** Cos */
  121392. Cos = 0,
  121393. /** Sin */
  121394. Sin = 1,
  121395. /** Abs */
  121396. Abs = 2,
  121397. /** Exp */
  121398. Exp = 3,
  121399. /** Exp2 */
  121400. Exp2 = 4,
  121401. /** Round */
  121402. Round = 5,
  121403. /** Floor */
  121404. Floor = 6,
  121405. /** Ceiling */
  121406. Ceiling = 7,
  121407. /** Square root */
  121408. Sqrt = 8,
  121409. /** Log */
  121410. Log = 9,
  121411. /** Tangent */
  121412. Tan = 10,
  121413. /** Arc tangent */
  121414. ArcTan = 11,
  121415. /** Arc cosinus */
  121416. ArcCos = 12,
  121417. /** Arc sinus */
  121418. ArcSin = 13,
  121419. /** Fraction */
  121420. Fract = 14,
  121421. /** Sign */
  121422. Sign = 15,
  121423. /** To radians (from degrees) */
  121424. Radians = 16,
  121425. /** To degrees (from radians) */
  121426. Degrees = 17
  121427. }
  121428. /**
  121429. * Block used to apply trigonometry operation to floats
  121430. */
  121431. export class TrigonometryBlock extends NodeMaterialBlock {
  121432. /**
  121433. * Gets or sets the operation applied by the block
  121434. */
  121435. operation: TrigonometryBlockOperations;
  121436. /**
  121437. * Creates a new TrigonometryBlock
  121438. * @param name defines the block name
  121439. */
  121440. constructor(name: string);
  121441. /**
  121442. * Gets the current class name
  121443. * @returns the class name
  121444. */
  121445. getClassName(): string;
  121446. /**
  121447. * Gets the input component
  121448. */
  121449. readonly input: NodeMaterialConnectionPoint;
  121450. /**
  121451. * Gets the output component
  121452. */
  121453. readonly output: NodeMaterialConnectionPoint;
  121454. protected _buildBlock(state: NodeMaterialBuildState): this;
  121455. serialize(): any;
  121456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121457. }
  121458. }
  121459. declare module BABYLON {
  121460. /**
  121461. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121462. */
  121463. export class ColorMergerBlock extends NodeMaterialBlock {
  121464. /**
  121465. * Create a new ColorMergerBlock
  121466. * @param name defines the block name
  121467. */
  121468. constructor(name: string);
  121469. /**
  121470. * Gets the current class name
  121471. * @returns the class name
  121472. */
  121473. getClassName(): string;
  121474. /**
  121475. * Gets the r component (input)
  121476. */
  121477. readonly r: NodeMaterialConnectionPoint;
  121478. /**
  121479. * Gets the g component (input)
  121480. */
  121481. readonly g: NodeMaterialConnectionPoint;
  121482. /**
  121483. * Gets the b component (input)
  121484. */
  121485. readonly b: NodeMaterialConnectionPoint;
  121486. /**
  121487. * Gets the a component (input)
  121488. */
  121489. readonly a: NodeMaterialConnectionPoint;
  121490. /**
  121491. * Gets the rgba component (output)
  121492. */
  121493. readonly rgba: NodeMaterialConnectionPoint;
  121494. /**
  121495. * Gets the rgb component (output)
  121496. */
  121497. readonly rgb: NodeMaterialConnectionPoint;
  121498. protected _buildBlock(state: NodeMaterialBuildState): this;
  121499. }
  121500. }
  121501. declare module BABYLON {
  121502. /**
  121503. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121504. */
  121505. export class VectorMergerBlock extends NodeMaterialBlock {
  121506. /**
  121507. * Create a new VectorMergerBlock
  121508. * @param name defines the block name
  121509. */
  121510. constructor(name: string);
  121511. /**
  121512. * Gets the current class name
  121513. * @returns the class name
  121514. */
  121515. getClassName(): string;
  121516. /**
  121517. * Gets the x component (input)
  121518. */
  121519. readonly x: NodeMaterialConnectionPoint;
  121520. /**
  121521. * Gets the y component (input)
  121522. */
  121523. readonly y: NodeMaterialConnectionPoint;
  121524. /**
  121525. * Gets the z component (input)
  121526. */
  121527. readonly z: NodeMaterialConnectionPoint;
  121528. /**
  121529. * Gets the w component (input)
  121530. */
  121531. readonly w: NodeMaterialConnectionPoint;
  121532. /**
  121533. * Gets the xyzw component (output)
  121534. */
  121535. readonly xyzw: NodeMaterialConnectionPoint;
  121536. /**
  121537. * Gets the xyz component (output)
  121538. */
  121539. readonly xyz: NodeMaterialConnectionPoint;
  121540. /**
  121541. * Gets the xy component (output)
  121542. */
  121543. readonly xy: NodeMaterialConnectionPoint;
  121544. protected _buildBlock(state: NodeMaterialBuildState): this;
  121545. }
  121546. }
  121547. declare module BABYLON {
  121548. /**
  121549. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121550. */
  121551. export class ColorSplitterBlock extends NodeMaterialBlock {
  121552. /**
  121553. * Create a new ColorSplitterBlock
  121554. * @param name defines the block name
  121555. */
  121556. constructor(name: string);
  121557. /**
  121558. * Gets the current class name
  121559. * @returns the class name
  121560. */
  121561. getClassName(): string;
  121562. /**
  121563. * Gets the rgba component (input)
  121564. */
  121565. readonly rgba: NodeMaterialConnectionPoint;
  121566. /**
  121567. * Gets the rgb component (input)
  121568. */
  121569. readonly rgbIn: NodeMaterialConnectionPoint;
  121570. /**
  121571. * Gets the rgb component (output)
  121572. */
  121573. readonly rgbOut: NodeMaterialConnectionPoint;
  121574. /**
  121575. * Gets the r component (output)
  121576. */
  121577. readonly r: NodeMaterialConnectionPoint;
  121578. /**
  121579. * Gets the g component (output)
  121580. */
  121581. readonly g: NodeMaterialConnectionPoint;
  121582. /**
  121583. * Gets the b component (output)
  121584. */
  121585. readonly b: NodeMaterialConnectionPoint;
  121586. /**
  121587. * Gets the a component (output)
  121588. */
  121589. readonly a: NodeMaterialConnectionPoint;
  121590. protected _inputRename(name: string): string;
  121591. protected _outputRename(name: string): string;
  121592. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121593. }
  121594. }
  121595. declare module BABYLON {
  121596. /**
  121597. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121598. */
  121599. export class VectorSplitterBlock extends NodeMaterialBlock {
  121600. /**
  121601. * Create a new VectorSplitterBlock
  121602. * @param name defines the block name
  121603. */
  121604. constructor(name: string);
  121605. /**
  121606. * Gets the current class name
  121607. * @returns the class name
  121608. */
  121609. getClassName(): string;
  121610. /**
  121611. * Gets the xyzw component (input)
  121612. */
  121613. readonly xyzw: NodeMaterialConnectionPoint;
  121614. /**
  121615. * Gets the xyz component (input)
  121616. */
  121617. readonly xyzIn: NodeMaterialConnectionPoint;
  121618. /**
  121619. * Gets the xy component (input)
  121620. */
  121621. readonly xyIn: NodeMaterialConnectionPoint;
  121622. /**
  121623. * Gets the xyz component (output)
  121624. */
  121625. readonly xyzOut: NodeMaterialConnectionPoint;
  121626. /**
  121627. * Gets the xy component (output)
  121628. */
  121629. readonly xyOut: NodeMaterialConnectionPoint;
  121630. /**
  121631. * Gets the x component (output)
  121632. */
  121633. readonly x: NodeMaterialConnectionPoint;
  121634. /**
  121635. * Gets the y component (output)
  121636. */
  121637. readonly y: NodeMaterialConnectionPoint;
  121638. /**
  121639. * Gets the z component (output)
  121640. */
  121641. readonly z: NodeMaterialConnectionPoint;
  121642. /**
  121643. * Gets the w component (output)
  121644. */
  121645. readonly w: NodeMaterialConnectionPoint;
  121646. protected _inputRename(name: string): string;
  121647. protected _outputRename(name: string): string;
  121648. protected _buildBlock(state: NodeMaterialBuildState): this;
  121649. }
  121650. }
  121651. declare module BABYLON {
  121652. /**
  121653. * Block used to lerp between 2 values
  121654. */
  121655. export class LerpBlock extends NodeMaterialBlock {
  121656. /**
  121657. * Creates a new LerpBlock
  121658. * @param name defines the block name
  121659. */
  121660. constructor(name: string);
  121661. /**
  121662. * Gets the current class name
  121663. * @returns the class name
  121664. */
  121665. getClassName(): string;
  121666. /**
  121667. * Gets the left operand input component
  121668. */
  121669. readonly left: NodeMaterialConnectionPoint;
  121670. /**
  121671. * Gets the right operand input component
  121672. */
  121673. readonly right: NodeMaterialConnectionPoint;
  121674. /**
  121675. * Gets the gradient operand input component
  121676. */
  121677. readonly gradient: NodeMaterialConnectionPoint;
  121678. /**
  121679. * Gets the output component
  121680. */
  121681. readonly output: NodeMaterialConnectionPoint;
  121682. protected _buildBlock(state: NodeMaterialBuildState): this;
  121683. }
  121684. }
  121685. declare module BABYLON {
  121686. /**
  121687. * Block used to divide 2 vectors
  121688. */
  121689. export class DivideBlock extends NodeMaterialBlock {
  121690. /**
  121691. * Creates a new DivideBlock
  121692. * @param name defines the block name
  121693. */
  121694. constructor(name: string);
  121695. /**
  121696. * Gets the current class name
  121697. * @returns the class name
  121698. */
  121699. getClassName(): string;
  121700. /**
  121701. * Gets the left operand input component
  121702. */
  121703. readonly left: NodeMaterialConnectionPoint;
  121704. /**
  121705. * Gets the right operand input component
  121706. */
  121707. readonly right: NodeMaterialConnectionPoint;
  121708. /**
  121709. * Gets the output component
  121710. */
  121711. readonly output: NodeMaterialConnectionPoint;
  121712. protected _buildBlock(state: NodeMaterialBuildState): this;
  121713. }
  121714. }
  121715. declare module BABYLON {
  121716. /**
  121717. * Block used to subtract 2 vectors
  121718. */
  121719. export class SubtractBlock extends NodeMaterialBlock {
  121720. /**
  121721. * Creates a new SubtractBlock
  121722. * @param name defines the block name
  121723. */
  121724. constructor(name: string);
  121725. /**
  121726. * Gets the current class name
  121727. * @returns the class name
  121728. */
  121729. getClassName(): string;
  121730. /**
  121731. * Gets the left operand input component
  121732. */
  121733. readonly left: NodeMaterialConnectionPoint;
  121734. /**
  121735. * Gets the right operand input component
  121736. */
  121737. readonly right: NodeMaterialConnectionPoint;
  121738. /**
  121739. * Gets the output component
  121740. */
  121741. readonly output: NodeMaterialConnectionPoint;
  121742. protected _buildBlock(state: NodeMaterialBuildState): this;
  121743. }
  121744. }
  121745. declare module BABYLON {
  121746. /**
  121747. * Block used to step a value
  121748. */
  121749. export class StepBlock extends NodeMaterialBlock {
  121750. /**
  121751. * Creates a new StepBlock
  121752. * @param name defines the block name
  121753. */
  121754. constructor(name: string);
  121755. /**
  121756. * Gets the current class name
  121757. * @returns the class name
  121758. */
  121759. getClassName(): string;
  121760. /**
  121761. * Gets the value operand input component
  121762. */
  121763. readonly value: NodeMaterialConnectionPoint;
  121764. /**
  121765. * Gets the edge operand input component
  121766. */
  121767. readonly edge: NodeMaterialConnectionPoint;
  121768. /**
  121769. * Gets the output component
  121770. */
  121771. readonly output: NodeMaterialConnectionPoint;
  121772. protected _buildBlock(state: NodeMaterialBuildState): this;
  121773. }
  121774. }
  121775. declare module BABYLON {
  121776. /**
  121777. * Block used to get the opposite (1 - x) of a value
  121778. */
  121779. export class OneMinusBlock extends NodeMaterialBlock {
  121780. /**
  121781. * Creates a new OneMinusBlock
  121782. * @param name defines the block name
  121783. */
  121784. constructor(name: string);
  121785. /**
  121786. * Gets the current class name
  121787. * @returns the class name
  121788. */
  121789. getClassName(): string;
  121790. /**
  121791. * Gets the input component
  121792. */
  121793. readonly input: NodeMaterialConnectionPoint;
  121794. /**
  121795. * Gets the output component
  121796. */
  121797. readonly output: NodeMaterialConnectionPoint;
  121798. protected _buildBlock(state: NodeMaterialBuildState): this;
  121799. }
  121800. }
  121801. declare module BABYLON {
  121802. /**
  121803. * Block used to get the view direction
  121804. */
  121805. export class ViewDirectionBlock extends NodeMaterialBlock {
  121806. /**
  121807. * Creates a new ViewDirectionBlock
  121808. * @param name defines the block name
  121809. */
  121810. constructor(name: string);
  121811. /**
  121812. * Gets the current class name
  121813. * @returns the class name
  121814. */
  121815. getClassName(): string;
  121816. /**
  121817. * Gets the world position component
  121818. */
  121819. readonly worldPosition: NodeMaterialConnectionPoint;
  121820. /**
  121821. * Gets the camera position component
  121822. */
  121823. readonly cameraPosition: NodeMaterialConnectionPoint;
  121824. /**
  121825. * Gets the output component
  121826. */
  121827. readonly output: NodeMaterialConnectionPoint;
  121828. autoConfigure(material: NodeMaterial): void;
  121829. protected _buildBlock(state: NodeMaterialBuildState): this;
  121830. }
  121831. }
  121832. declare module BABYLON {
  121833. /**
  121834. * Block used to compute fresnel value
  121835. */
  121836. export class FresnelBlock extends NodeMaterialBlock {
  121837. /**
  121838. * Create a new FresnelBlock
  121839. * @param name defines the block name
  121840. */
  121841. constructor(name: string);
  121842. /**
  121843. * Gets the current class name
  121844. * @returns the class name
  121845. */
  121846. getClassName(): string;
  121847. /**
  121848. * Gets the world normal input component
  121849. */
  121850. readonly worldNormal: NodeMaterialConnectionPoint;
  121851. /**
  121852. * Gets the view direction input component
  121853. */
  121854. readonly viewDirection: NodeMaterialConnectionPoint;
  121855. /**
  121856. * Gets the bias input component
  121857. */
  121858. readonly bias: NodeMaterialConnectionPoint;
  121859. /**
  121860. * Gets the camera (or eye) position component
  121861. */
  121862. readonly power: NodeMaterialConnectionPoint;
  121863. /**
  121864. * Gets the fresnel output component
  121865. */
  121866. readonly fresnel: NodeMaterialConnectionPoint;
  121867. autoConfigure(material: NodeMaterial): void;
  121868. protected _buildBlock(state: NodeMaterialBuildState): this;
  121869. }
  121870. }
  121871. declare module BABYLON {
  121872. /**
  121873. * Block used to get the max of 2 values
  121874. */
  121875. export class MaxBlock extends NodeMaterialBlock {
  121876. /**
  121877. * Creates a new MaxBlock
  121878. * @param name defines the block name
  121879. */
  121880. constructor(name: string);
  121881. /**
  121882. * Gets the current class name
  121883. * @returns the class name
  121884. */
  121885. getClassName(): string;
  121886. /**
  121887. * Gets the left operand input component
  121888. */
  121889. readonly left: NodeMaterialConnectionPoint;
  121890. /**
  121891. * Gets the right operand input component
  121892. */
  121893. readonly right: NodeMaterialConnectionPoint;
  121894. /**
  121895. * Gets the output component
  121896. */
  121897. readonly output: NodeMaterialConnectionPoint;
  121898. protected _buildBlock(state: NodeMaterialBuildState): this;
  121899. }
  121900. }
  121901. declare module BABYLON {
  121902. /**
  121903. * Block used to get the min of 2 values
  121904. */
  121905. export class MinBlock extends NodeMaterialBlock {
  121906. /**
  121907. * Creates a new MinBlock
  121908. * @param name defines the block name
  121909. */
  121910. constructor(name: string);
  121911. /**
  121912. * Gets the current class name
  121913. * @returns the class name
  121914. */
  121915. getClassName(): string;
  121916. /**
  121917. * Gets the left operand input component
  121918. */
  121919. readonly left: NodeMaterialConnectionPoint;
  121920. /**
  121921. * Gets the right operand input component
  121922. */
  121923. readonly right: NodeMaterialConnectionPoint;
  121924. /**
  121925. * Gets the output component
  121926. */
  121927. readonly output: NodeMaterialConnectionPoint;
  121928. protected _buildBlock(state: NodeMaterialBuildState): this;
  121929. }
  121930. }
  121931. declare module BABYLON {
  121932. /**
  121933. * Block used to get the distance between 2 values
  121934. */
  121935. export class DistanceBlock extends NodeMaterialBlock {
  121936. /**
  121937. * Creates a new DistanceBlock
  121938. * @param name defines the block name
  121939. */
  121940. constructor(name: string);
  121941. /**
  121942. * Gets the current class name
  121943. * @returns the class name
  121944. */
  121945. getClassName(): string;
  121946. /**
  121947. * Gets the left operand input component
  121948. */
  121949. readonly left: NodeMaterialConnectionPoint;
  121950. /**
  121951. * Gets the right operand input component
  121952. */
  121953. readonly right: NodeMaterialConnectionPoint;
  121954. /**
  121955. * Gets the output component
  121956. */
  121957. readonly output: NodeMaterialConnectionPoint;
  121958. protected _buildBlock(state: NodeMaterialBuildState): this;
  121959. }
  121960. }
  121961. declare module BABYLON {
  121962. /**
  121963. * Block used to get the length of a vector
  121964. */
  121965. export class LengthBlock extends NodeMaterialBlock {
  121966. /**
  121967. * Creates a new LengthBlock
  121968. * @param name defines the block name
  121969. */
  121970. constructor(name: string);
  121971. /**
  121972. * Gets the current class name
  121973. * @returns the class name
  121974. */
  121975. getClassName(): string;
  121976. /**
  121977. * Gets the value input component
  121978. */
  121979. readonly value: NodeMaterialConnectionPoint;
  121980. /**
  121981. * Gets the output component
  121982. */
  121983. readonly output: NodeMaterialConnectionPoint;
  121984. protected _buildBlock(state: NodeMaterialBuildState): this;
  121985. }
  121986. }
  121987. declare module BABYLON {
  121988. /**
  121989. * Block used to get negative version of a value (i.e. x * -1)
  121990. */
  121991. export class NegateBlock extends NodeMaterialBlock {
  121992. /**
  121993. * Creates a new NegateBlock
  121994. * @param name defines the block name
  121995. */
  121996. constructor(name: string);
  121997. /**
  121998. * Gets the current class name
  121999. * @returns the class name
  122000. */
  122001. getClassName(): string;
  122002. /**
  122003. * Gets the value input component
  122004. */
  122005. readonly value: NodeMaterialConnectionPoint;
  122006. /**
  122007. * Gets the output component
  122008. */
  122009. readonly output: NodeMaterialConnectionPoint;
  122010. protected _buildBlock(state: NodeMaterialBuildState): this;
  122011. }
  122012. }
  122013. declare module BABYLON {
  122014. /**
  122015. * Block used to get the value of the first parameter raised to the power of the second
  122016. */
  122017. export class PowBlock extends NodeMaterialBlock {
  122018. /**
  122019. * Creates a new PowBlock
  122020. * @param name defines the block name
  122021. */
  122022. constructor(name: string);
  122023. /**
  122024. * Gets the current class name
  122025. * @returns the class name
  122026. */
  122027. getClassName(): string;
  122028. /**
  122029. * Gets the value operand input component
  122030. */
  122031. readonly value: NodeMaterialConnectionPoint;
  122032. /**
  122033. * Gets the power operand input component
  122034. */
  122035. readonly power: NodeMaterialConnectionPoint;
  122036. /**
  122037. * Gets the output component
  122038. */
  122039. readonly output: NodeMaterialConnectionPoint;
  122040. protected _buildBlock(state: NodeMaterialBuildState): this;
  122041. }
  122042. }
  122043. declare module BABYLON {
  122044. /**
  122045. * Block used to get a random number
  122046. */
  122047. export class RandomNumberBlock extends NodeMaterialBlock {
  122048. /**
  122049. * Creates a new RandomNumberBlock
  122050. * @param name defines the block name
  122051. */
  122052. constructor(name: string);
  122053. /**
  122054. * Gets the current class name
  122055. * @returns the class name
  122056. */
  122057. getClassName(): string;
  122058. /**
  122059. * Gets the seed input component
  122060. */
  122061. readonly seed: NodeMaterialConnectionPoint;
  122062. /**
  122063. * Gets the output component
  122064. */
  122065. readonly output: NodeMaterialConnectionPoint;
  122066. protected _buildBlock(state: NodeMaterialBuildState): this;
  122067. }
  122068. }
  122069. declare module BABYLON {
  122070. /**
  122071. * Block used to compute arc tangent of 2 values
  122072. */
  122073. export class ArcTan2Block extends NodeMaterialBlock {
  122074. /**
  122075. * Creates a new ArcTan2Block
  122076. * @param name defines the block name
  122077. */
  122078. constructor(name: string);
  122079. /**
  122080. * Gets the current class name
  122081. * @returns the class name
  122082. */
  122083. getClassName(): string;
  122084. /**
  122085. * Gets the x operand input component
  122086. */
  122087. readonly x: NodeMaterialConnectionPoint;
  122088. /**
  122089. * Gets the y operand input component
  122090. */
  122091. readonly y: NodeMaterialConnectionPoint;
  122092. /**
  122093. * Gets the output component
  122094. */
  122095. readonly output: NodeMaterialConnectionPoint;
  122096. protected _buildBlock(state: NodeMaterialBuildState): this;
  122097. }
  122098. }
  122099. declare module BABYLON {
  122100. /**
  122101. * Block used to smooth step a value
  122102. */
  122103. export class SmoothStepBlock extends NodeMaterialBlock {
  122104. /**
  122105. * Creates a new SmoothStepBlock
  122106. * @param name defines the block name
  122107. */
  122108. constructor(name: string);
  122109. /**
  122110. * Gets the current class name
  122111. * @returns the class name
  122112. */
  122113. getClassName(): string;
  122114. /**
  122115. * Gets the value operand input component
  122116. */
  122117. readonly value: NodeMaterialConnectionPoint;
  122118. /**
  122119. * Gets the first edge operand input component
  122120. */
  122121. readonly edge0: NodeMaterialConnectionPoint;
  122122. /**
  122123. * Gets the second edge operand input component
  122124. */
  122125. readonly edge1: NodeMaterialConnectionPoint;
  122126. /**
  122127. * Gets the output component
  122128. */
  122129. readonly output: NodeMaterialConnectionPoint;
  122130. protected _buildBlock(state: NodeMaterialBuildState): this;
  122131. }
  122132. }
  122133. declare module BABYLON {
  122134. /**
  122135. * Block used to get the reciprocal (1 / x) of a value
  122136. */
  122137. export class ReciprocalBlock extends NodeMaterialBlock {
  122138. /**
  122139. * Creates a new ReciprocalBlock
  122140. * @param name defines the block name
  122141. */
  122142. constructor(name: string);
  122143. /**
  122144. * Gets the current class name
  122145. * @returns the class name
  122146. */
  122147. getClassName(): string;
  122148. /**
  122149. * Gets the input component
  122150. */
  122151. readonly input: NodeMaterialConnectionPoint;
  122152. /**
  122153. * Gets the output component
  122154. */
  122155. readonly output: NodeMaterialConnectionPoint;
  122156. protected _buildBlock(state: NodeMaterialBuildState): this;
  122157. }
  122158. }
  122159. declare module BABYLON {
  122160. /**
  122161. * Block used to replace a color by another one
  122162. */
  122163. export class ReplaceColorBlock extends NodeMaterialBlock {
  122164. /**
  122165. * Creates a new ReplaceColorBlock
  122166. * @param name defines the block name
  122167. */
  122168. constructor(name: string);
  122169. /**
  122170. * Gets the current class name
  122171. * @returns the class name
  122172. */
  122173. getClassName(): string;
  122174. /**
  122175. * Gets the value input component
  122176. */
  122177. readonly value: NodeMaterialConnectionPoint;
  122178. /**
  122179. * Gets the reference input component
  122180. */
  122181. readonly reference: NodeMaterialConnectionPoint;
  122182. /**
  122183. * Gets the distance input component
  122184. */
  122185. readonly distance: NodeMaterialConnectionPoint;
  122186. /**
  122187. * Gets the replacement input component
  122188. */
  122189. readonly replacement: NodeMaterialConnectionPoint;
  122190. /**
  122191. * Gets the output component
  122192. */
  122193. readonly output: NodeMaterialConnectionPoint;
  122194. protected _buildBlock(state: NodeMaterialBuildState): this;
  122195. }
  122196. }
  122197. declare module BABYLON {
  122198. /**
  122199. * Block used to posterize a value
  122200. * @see https://en.wikipedia.org/wiki/Posterization
  122201. */
  122202. export class PosterizeBlock extends NodeMaterialBlock {
  122203. /**
  122204. * Creates a new PosterizeBlock
  122205. * @param name defines the block name
  122206. */
  122207. constructor(name: string);
  122208. /**
  122209. * Gets the current class name
  122210. * @returns the class name
  122211. */
  122212. getClassName(): string;
  122213. /**
  122214. * Gets the value input component
  122215. */
  122216. readonly value: NodeMaterialConnectionPoint;
  122217. /**
  122218. * Gets the steps input component
  122219. */
  122220. readonly steps: NodeMaterialConnectionPoint;
  122221. /**
  122222. * Gets the output component
  122223. */
  122224. readonly output: NodeMaterialConnectionPoint;
  122225. protected _buildBlock(state: NodeMaterialBuildState): this;
  122226. }
  122227. }
  122228. declare module BABYLON {
  122229. /**
  122230. * Operations supported by the Wave block
  122231. */
  122232. export enum WaveBlockKind {
  122233. /** SawTooth */
  122234. SawTooth = 0,
  122235. /** Square */
  122236. Square = 1,
  122237. /** Triangle */
  122238. Triangle = 2
  122239. }
  122240. /**
  122241. * Block used to apply wave operation to floats
  122242. */
  122243. export class WaveBlock extends NodeMaterialBlock {
  122244. /**
  122245. * Gets or sets the kibnd of wave to be applied by the block
  122246. */
  122247. kind: WaveBlockKind;
  122248. /**
  122249. * Creates a new WaveBlock
  122250. * @param name defines the block name
  122251. */
  122252. constructor(name: string);
  122253. /**
  122254. * Gets the current class name
  122255. * @returns the class name
  122256. */
  122257. getClassName(): string;
  122258. /**
  122259. * Gets the input component
  122260. */
  122261. readonly input: NodeMaterialConnectionPoint;
  122262. /**
  122263. * Gets the output component
  122264. */
  122265. readonly output: NodeMaterialConnectionPoint;
  122266. protected _buildBlock(state: NodeMaterialBuildState): this;
  122267. serialize(): any;
  122268. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122269. }
  122270. }
  122271. declare module BABYLON {
  122272. /**
  122273. * Class used to store a color step for the GradientBlock
  122274. */
  122275. export class GradientBlockColorStep {
  122276. /**
  122277. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122278. */
  122279. step: number;
  122280. /**
  122281. * Gets or sets the color associated with this step
  122282. */
  122283. color: Color3;
  122284. /**
  122285. * Creates a new GradientBlockColorStep
  122286. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122287. * @param color defines the color associated with this step
  122288. */
  122289. constructor(
  122290. /**
  122291. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122292. */
  122293. step: number,
  122294. /**
  122295. * Gets or sets the color associated with this step
  122296. */
  122297. color: Color3);
  122298. }
  122299. /**
  122300. * Block used to return a color from a gradient based on an input value between 0 and 1
  122301. */
  122302. export class GradientBlock extends NodeMaterialBlock {
  122303. /**
  122304. * Gets or sets the list of color steps
  122305. */
  122306. colorSteps: GradientBlockColorStep[];
  122307. /**
  122308. * Creates a new GradientBlock
  122309. * @param name defines the block name
  122310. */
  122311. constructor(name: string);
  122312. /**
  122313. * Gets the current class name
  122314. * @returns the class name
  122315. */
  122316. getClassName(): string;
  122317. /**
  122318. * Gets the gradient input component
  122319. */
  122320. readonly gradient: NodeMaterialConnectionPoint;
  122321. /**
  122322. * Gets the output component
  122323. */
  122324. readonly output: NodeMaterialConnectionPoint;
  122325. private _writeColorConstant;
  122326. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122327. serialize(): any;
  122328. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122329. protected _dumpPropertiesCode(): string;
  122330. }
  122331. }
  122332. declare module BABYLON {
  122333. /**
  122334. * Block used to normalize lerp between 2 values
  122335. */
  122336. export class NLerpBlock extends NodeMaterialBlock {
  122337. /**
  122338. * Creates a new NLerpBlock
  122339. * @param name defines the block name
  122340. */
  122341. constructor(name: string);
  122342. /**
  122343. * Gets the current class name
  122344. * @returns the class name
  122345. */
  122346. getClassName(): string;
  122347. /**
  122348. * Gets the left operand input component
  122349. */
  122350. readonly left: NodeMaterialConnectionPoint;
  122351. /**
  122352. * Gets the right operand input component
  122353. */
  122354. readonly right: NodeMaterialConnectionPoint;
  122355. /**
  122356. * Gets the gradient operand input component
  122357. */
  122358. readonly gradient: NodeMaterialConnectionPoint;
  122359. /**
  122360. * Gets the output component
  122361. */
  122362. readonly output: NodeMaterialConnectionPoint;
  122363. protected _buildBlock(state: NodeMaterialBuildState): this;
  122364. }
  122365. }
  122366. declare module BABYLON {
  122367. /**
  122368. * Effect Render Options
  122369. */
  122370. export interface IEffectRendererOptions {
  122371. /**
  122372. * Defines the vertices positions.
  122373. */
  122374. positions?: number[];
  122375. /**
  122376. * Defines the indices.
  122377. */
  122378. indices?: number[];
  122379. }
  122380. /**
  122381. * Helper class to render one or more effects
  122382. */
  122383. export class EffectRenderer {
  122384. private engine;
  122385. private static _DefaultOptions;
  122386. private _vertexBuffers;
  122387. private _indexBuffer;
  122388. private _ringBufferIndex;
  122389. private _ringScreenBuffer;
  122390. private _fullscreenViewport;
  122391. private _getNextFrameBuffer;
  122392. /**
  122393. * Creates an effect renderer
  122394. * @param engine the engine to use for rendering
  122395. * @param options defines the options of the effect renderer
  122396. */
  122397. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  122398. /**
  122399. * Sets the current viewport in normalized coordinates 0-1
  122400. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122401. */
  122402. setViewport(viewport?: Viewport): void;
  122403. /**
  122404. * Binds the embedded attributes buffer to the effect.
  122405. * @param effect Defines the effect to bind the attributes for
  122406. */
  122407. bindBuffers(effect: Effect): void;
  122408. /**
  122409. * Sets the current effect wrapper to use during draw.
  122410. * The effect needs to be ready before calling this api.
  122411. * This also sets the default full screen position attribute.
  122412. * @param effectWrapper Defines the effect to draw with
  122413. */
  122414. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122415. /**
  122416. * Draws a full screen quad.
  122417. */
  122418. draw(): void;
  122419. /**
  122420. * renders one or more effects to a specified texture
  122421. * @param effectWrappers list of effects to renderer
  122422. * @param outputTexture texture to draw to, if null it will render to the screen
  122423. */
  122424. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122425. /**
  122426. * Disposes of the effect renderer
  122427. */
  122428. dispose(): void;
  122429. }
  122430. /**
  122431. * Options to create an EffectWrapper
  122432. */
  122433. interface EffectWrapperCreationOptions {
  122434. /**
  122435. * Engine to use to create the effect
  122436. */
  122437. engine: ThinEngine;
  122438. /**
  122439. * Fragment shader for the effect
  122440. */
  122441. fragmentShader: string;
  122442. /**
  122443. * Vertex shader for the effect
  122444. */
  122445. vertexShader?: string;
  122446. /**
  122447. * Attributes to use in the shader
  122448. */
  122449. attributeNames?: Array<string>;
  122450. /**
  122451. * Uniforms to use in the shader
  122452. */
  122453. uniformNames?: Array<string>;
  122454. /**
  122455. * Texture sampler names to use in the shader
  122456. */
  122457. samplerNames?: Array<string>;
  122458. /**
  122459. * The friendly name of the effect displayed in Spector.
  122460. */
  122461. name?: string;
  122462. }
  122463. /**
  122464. * Wraps an effect to be used for rendering
  122465. */
  122466. export class EffectWrapper {
  122467. /**
  122468. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122469. */
  122470. onApplyObservable: Observable<{}>;
  122471. /**
  122472. * The underlying effect
  122473. */
  122474. effect: Effect;
  122475. /**
  122476. * Creates an effect to be renderer
  122477. * @param creationOptions options to create the effect
  122478. */
  122479. constructor(creationOptions: EffectWrapperCreationOptions);
  122480. /**
  122481. * Disposes of the effect wrapper
  122482. */
  122483. dispose(): void;
  122484. }
  122485. }
  122486. declare module BABYLON {
  122487. /**
  122488. * Helper class to push actions to a pool of workers.
  122489. */
  122490. export class WorkerPool implements IDisposable {
  122491. private _workerInfos;
  122492. private _pendingActions;
  122493. /**
  122494. * Constructor
  122495. * @param workers Array of workers to use for actions
  122496. */
  122497. constructor(workers: Array<Worker>);
  122498. /**
  122499. * Terminates all workers and clears any pending actions.
  122500. */
  122501. dispose(): void;
  122502. /**
  122503. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122504. * pended until a worker has completed its action.
  122505. * @param action The action to perform. Call onComplete when the action is complete.
  122506. */
  122507. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122508. private _execute;
  122509. }
  122510. }
  122511. declare module BABYLON {
  122512. /**
  122513. * Configuration for Draco compression
  122514. */
  122515. export interface IDracoCompressionConfiguration {
  122516. /**
  122517. * Configuration for the decoder.
  122518. */
  122519. decoder: {
  122520. /**
  122521. * The url to the WebAssembly module.
  122522. */
  122523. wasmUrl?: string;
  122524. /**
  122525. * The url to the WebAssembly binary.
  122526. */
  122527. wasmBinaryUrl?: string;
  122528. /**
  122529. * The url to the fallback JavaScript module.
  122530. */
  122531. fallbackUrl?: string;
  122532. };
  122533. }
  122534. /**
  122535. * Draco compression (https://google.github.io/draco/)
  122536. *
  122537. * This class wraps the Draco module.
  122538. *
  122539. * **Encoder**
  122540. *
  122541. * The encoder is not currently implemented.
  122542. *
  122543. * **Decoder**
  122544. *
  122545. * 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.
  122546. *
  122547. * To update the configuration, use the following code:
  122548. * ```javascript
  122549. * DracoCompression.Configuration = {
  122550. * decoder: {
  122551. * wasmUrl: "<url to the WebAssembly library>",
  122552. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122553. * fallbackUrl: "<url to the fallback JavaScript library>",
  122554. * }
  122555. * };
  122556. * ```
  122557. *
  122558. * 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.
  122559. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122560. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122561. *
  122562. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122563. * ```javascript
  122564. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122565. * ```
  122566. *
  122567. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122568. */
  122569. export class DracoCompression implements IDisposable {
  122570. private _workerPoolPromise?;
  122571. private _decoderModulePromise?;
  122572. /**
  122573. * The configuration. Defaults to the following urls:
  122574. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122575. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122576. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122577. */
  122578. static Configuration: IDracoCompressionConfiguration;
  122579. /**
  122580. * Returns true if the decoder configuration is available.
  122581. */
  122582. static readonly DecoderAvailable: boolean;
  122583. /**
  122584. * Default number of workers to create when creating the draco compression object.
  122585. */
  122586. static DefaultNumWorkers: number;
  122587. private static GetDefaultNumWorkers;
  122588. private static _Default;
  122589. /**
  122590. * Default instance for the draco compression object.
  122591. */
  122592. static readonly Default: DracoCompression;
  122593. /**
  122594. * Constructor
  122595. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122596. */
  122597. constructor(numWorkers?: number);
  122598. /**
  122599. * Stop all async operations and release resources.
  122600. */
  122601. dispose(): void;
  122602. /**
  122603. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122604. * @returns a promise that resolves when ready
  122605. */
  122606. whenReadyAsync(): Promise<void>;
  122607. /**
  122608. * Decode Draco compressed mesh data to vertex data.
  122609. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122610. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122611. * @returns A promise that resolves with the decoded vertex data
  122612. */
  122613. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122614. [kind: string]: number;
  122615. }): Promise<VertexData>;
  122616. }
  122617. }
  122618. declare module BABYLON {
  122619. /**
  122620. * Class for building Constructive Solid Geometry
  122621. */
  122622. export class CSG {
  122623. private polygons;
  122624. /**
  122625. * The world matrix
  122626. */
  122627. matrix: Matrix;
  122628. /**
  122629. * Stores the position
  122630. */
  122631. position: Vector3;
  122632. /**
  122633. * Stores the rotation
  122634. */
  122635. rotation: Vector3;
  122636. /**
  122637. * Stores the rotation quaternion
  122638. */
  122639. rotationQuaternion: Nullable<Quaternion>;
  122640. /**
  122641. * Stores the scaling vector
  122642. */
  122643. scaling: Vector3;
  122644. /**
  122645. * Convert the Mesh to CSG
  122646. * @param mesh The Mesh to convert to CSG
  122647. * @returns A new CSG from the Mesh
  122648. */
  122649. static FromMesh(mesh: Mesh): CSG;
  122650. /**
  122651. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122652. * @param polygons Polygons used to construct a CSG solid
  122653. */
  122654. private static FromPolygons;
  122655. /**
  122656. * Clones, or makes a deep copy, of the CSG
  122657. * @returns A new CSG
  122658. */
  122659. clone(): CSG;
  122660. /**
  122661. * Unions this CSG with another CSG
  122662. * @param csg The CSG to union against this CSG
  122663. * @returns The unioned CSG
  122664. */
  122665. union(csg: CSG): CSG;
  122666. /**
  122667. * Unions this CSG with another CSG in place
  122668. * @param csg The CSG to union against this CSG
  122669. */
  122670. unionInPlace(csg: CSG): void;
  122671. /**
  122672. * Subtracts this CSG with another CSG
  122673. * @param csg The CSG to subtract against this CSG
  122674. * @returns A new CSG
  122675. */
  122676. subtract(csg: CSG): CSG;
  122677. /**
  122678. * Subtracts this CSG with another CSG in place
  122679. * @param csg The CSG to subtact against this CSG
  122680. */
  122681. subtractInPlace(csg: CSG): void;
  122682. /**
  122683. * Intersect this CSG with another CSG
  122684. * @param csg The CSG to intersect against this CSG
  122685. * @returns A new CSG
  122686. */
  122687. intersect(csg: CSG): CSG;
  122688. /**
  122689. * Intersects this CSG with another CSG in place
  122690. * @param csg The CSG to intersect against this CSG
  122691. */
  122692. intersectInPlace(csg: CSG): void;
  122693. /**
  122694. * Return a new CSG solid with solid and empty space switched. This solid is
  122695. * not modified.
  122696. * @returns A new CSG solid with solid and empty space switched
  122697. */
  122698. inverse(): CSG;
  122699. /**
  122700. * Inverses the CSG in place
  122701. */
  122702. inverseInPlace(): void;
  122703. /**
  122704. * This is used to keep meshes transformations so they can be restored
  122705. * when we build back a Babylon Mesh
  122706. * NB : All CSG operations are performed in world coordinates
  122707. * @param csg The CSG to copy the transform attributes from
  122708. * @returns This CSG
  122709. */
  122710. copyTransformAttributes(csg: CSG): CSG;
  122711. /**
  122712. * Build Raw mesh from CSG
  122713. * Coordinates here are in world space
  122714. * @param name The name of the mesh geometry
  122715. * @param scene The Scene
  122716. * @param keepSubMeshes Specifies if the submeshes should be kept
  122717. * @returns A new Mesh
  122718. */
  122719. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122720. /**
  122721. * Build Mesh from CSG taking material and transforms into account
  122722. * @param name The name of the Mesh
  122723. * @param material The material of the Mesh
  122724. * @param scene The Scene
  122725. * @param keepSubMeshes Specifies if submeshes should be kept
  122726. * @returns The new Mesh
  122727. */
  122728. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122729. }
  122730. }
  122731. declare module BABYLON {
  122732. /**
  122733. * Class used to create a trail following a mesh
  122734. */
  122735. export class TrailMesh extends Mesh {
  122736. private _generator;
  122737. private _autoStart;
  122738. private _running;
  122739. private _diameter;
  122740. private _length;
  122741. private _sectionPolygonPointsCount;
  122742. private _sectionVectors;
  122743. private _sectionNormalVectors;
  122744. private _beforeRenderObserver;
  122745. /**
  122746. * @constructor
  122747. * @param name The value used by scene.getMeshByName() to do a lookup.
  122748. * @param generator The mesh to generate a trail.
  122749. * @param scene The scene to add this mesh to.
  122750. * @param diameter Diameter of trailing mesh. Default is 1.
  122751. * @param length Length of trailing mesh. Default is 60.
  122752. * @param autoStart Automatically start trailing mesh. Default true.
  122753. */
  122754. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122755. /**
  122756. * "TrailMesh"
  122757. * @returns "TrailMesh"
  122758. */
  122759. getClassName(): string;
  122760. private _createMesh;
  122761. /**
  122762. * Start trailing mesh.
  122763. */
  122764. start(): void;
  122765. /**
  122766. * Stop trailing mesh.
  122767. */
  122768. stop(): void;
  122769. /**
  122770. * Update trailing mesh geometry.
  122771. */
  122772. update(): void;
  122773. /**
  122774. * Returns a new TrailMesh object.
  122775. * @param name is a string, the name given to the new mesh
  122776. * @param newGenerator use new generator object for cloned trail mesh
  122777. * @returns a new mesh
  122778. */
  122779. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122780. /**
  122781. * Serializes this trail mesh
  122782. * @param serializationObject object to write serialization to
  122783. */
  122784. serialize(serializationObject: any): void;
  122785. /**
  122786. * Parses a serialized trail mesh
  122787. * @param parsedMesh the serialized mesh
  122788. * @param scene the scene to create the trail mesh in
  122789. * @returns the created trail mesh
  122790. */
  122791. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122792. }
  122793. }
  122794. declare module BABYLON {
  122795. /**
  122796. * Class containing static functions to help procedurally build meshes
  122797. */
  122798. export class TiledBoxBuilder {
  122799. /**
  122800. * Creates a box mesh
  122801. * 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)
  122802. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122803. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122804. * * 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
  122805. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122806. * @param name defines the name of the mesh
  122807. * @param options defines the options used to create the mesh
  122808. * @param scene defines the hosting scene
  122809. * @returns the box mesh
  122810. */
  122811. static CreateTiledBox(name: string, options: {
  122812. pattern?: number;
  122813. width?: number;
  122814. height?: number;
  122815. depth?: number;
  122816. tileSize?: number;
  122817. tileWidth?: number;
  122818. tileHeight?: number;
  122819. alignHorizontal?: number;
  122820. alignVertical?: number;
  122821. faceUV?: Vector4[];
  122822. faceColors?: Color4[];
  122823. sideOrientation?: number;
  122824. updatable?: boolean;
  122825. }, scene?: Nullable<Scene>): Mesh;
  122826. }
  122827. }
  122828. declare module BABYLON {
  122829. /**
  122830. * Class containing static functions to help procedurally build meshes
  122831. */
  122832. export class TorusKnotBuilder {
  122833. /**
  122834. * Creates a torus knot mesh
  122835. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122836. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122837. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122838. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122839. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122840. * * 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
  122841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122842. * @param name defines the name of the mesh
  122843. * @param options defines the options used to create the mesh
  122844. * @param scene defines the hosting scene
  122845. * @returns the torus knot mesh
  122846. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122847. */
  122848. static CreateTorusKnot(name: string, options: {
  122849. radius?: number;
  122850. tube?: number;
  122851. radialSegments?: number;
  122852. tubularSegments?: number;
  122853. p?: number;
  122854. q?: number;
  122855. updatable?: boolean;
  122856. sideOrientation?: number;
  122857. frontUVs?: Vector4;
  122858. backUVs?: Vector4;
  122859. }, scene: any): Mesh;
  122860. }
  122861. }
  122862. declare module BABYLON {
  122863. /**
  122864. * Polygon
  122865. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122866. */
  122867. export class Polygon {
  122868. /**
  122869. * Creates a rectangle
  122870. * @param xmin bottom X coord
  122871. * @param ymin bottom Y coord
  122872. * @param xmax top X coord
  122873. * @param ymax top Y coord
  122874. * @returns points that make the resulting rectation
  122875. */
  122876. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122877. /**
  122878. * Creates a circle
  122879. * @param radius radius of circle
  122880. * @param cx scale in x
  122881. * @param cy scale in y
  122882. * @param numberOfSides number of sides that make up the circle
  122883. * @returns points that make the resulting circle
  122884. */
  122885. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122886. /**
  122887. * Creates a polygon from input string
  122888. * @param input Input polygon data
  122889. * @returns the parsed points
  122890. */
  122891. static Parse(input: string): Vector2[];
  122892. /**
  122893. * Starts building a polygon from x and y coordinates
  122894. * @param x x coordinate
  122895. * @param y y coordinate
  122896. * @returns the started path2
  122897. */
  122898. static StartingAt(x: number, y: number): Path2;
  122899. }
  122900. /**
  122901. * Builds a polygon
  122902. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122903. */
  122904. export class PolygonMeshBuilder {
  122905. private _points;
  122906. private _outlinepoints;
  122907. private _holes;
  122908. private _name;
  122909. private _scene;
  122910. private _epoints;
  122911. private _eholes;
  122912. private _addToepoint;
  122913. /**
  122914. * Babylon reference to the earcut plugin.
  122915. */
  122916. bjsEarcut: any;
  122917. /**
  122918. * Creates a PolygonMeshBuilder
  122919. * @param name name of the builder
  122920. * @param contours Path of the polygon
  122921. * @param scene scene to add to when creating the mesh
  122922. * @param earcutInjection can be used to inject your own earcut reference
  122923. */
  122924. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122925. /**
  122926. * Adds a whole within the polygon
  122927. * @param hole Array of points defining the hole
  122928. * @returns this
  122929. */
  122930. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122931. /**
  122932. * Creates the polygon
  122933. * @param updatable If the mesh should be updatable
  122934. * @param depth The depth of the mesh created
  122935. * @returns the created mesh
  122936. */
  122937. build(updatable?: boolean, depth?: number): Mesh;
  122938. /**
  122939. * Creates the polygon
  122940. * @param depth The depth of the mesh created
  122941. * @returns the created VertexData
  122942. */
  122943. buildVertexData(depth?: number): VertexData;
  122944. /**
  122945. * Adds a side to the polygon
  122946. * @param positions points that make the polygon
  122947. * @param normals normals of the polygon
  122948. * @param uvs uvs of the polygon
  122949. * @param indices indices of the polygon
  122950. * @param bounds bounds of the polygon
  122951. * @param points points of the polygon
  122952. * @param depth depth of the polygon
  122953. * @param flip flip of the polygon
  122954. */
  122955. private addSide;
  122956. }
  122957. }
  122958. declare module BABYLON {
  122959. /**
  122960. * Class containing static functions to help procedurally build meshes
  122961. */
  122962. export class PolygonBuilder {
  122963. /**
  122964. * Creates a polygon mesh
  122965. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122966. * * 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
  122967. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122968. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122969. * * 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)
  122970. * * Remember you can only change the shape positions, not their number when updating a polygon
  122971. * @param name defines the name of the mesh
  122972. * @param options defines the options used to create the mesh
  122973. * @param scene defines the hosting scene
  122974. * @param earcutInjection can be used to inject your own earcut reference
  122975. * @returns the polygon mesh
  122976. */
  122977. static CreatePolygon(name: string, options: {
  122978. shape: Vector3[];
  122979. holes?: Vector3[][];
  122980. depth?: number;
  122981. faceUV?: Vector4[];
  122982. faceColors?: Color4[];
  122983. updatable?: boolean;
  122984. sideOrientation?: number;
  122985. frontUVs?: Vector4;
  122986. backUVs?: Vector4;
  122987. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122988. /**
  122989. * Creates an extruded polygon mesh, with depth in the Y direction.
  122990. * * 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)
  122991. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122992. * @param name defines the name of the mesh
  122993. * @param options defines the options used to create the mesh
  122994. * @param scene defines the hosting scene
  122995. * @param earcutInjection can be used to inject your own earcut reference
  122996. * @returns the polygon mesh
  122997. */
  122998. static ExtrudePolygon(name: string, options: {
  122999. shape: Vector3[];
  123000. holes?: Vector3[][];
  123001. depth?: number;
  123002. faceUV?: Vector4[];
  123003. faceColors?: Color4[];
  123004. updatable?: boolean;
  123005. sideOrientation?: number;
  123006. frontUVs?: Vector4;
  123007. backUVs?: Vector4;
  123008. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123009. }
  123010. }
  123011. declare module BABYLON {
  123012. /**
  123013. * Class containing static functions to help procedurally build meshes
  123014. */
  123015. export class LatheBuilder {
  123016. /**
  123017. * Creates lathe mesh.
  123018. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123019. * * 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
  123020. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123021. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123022. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123023. * * 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
  123024. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123025. * * 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
  123026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123027. * * 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
  123028. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123030. * @param name defines the name of the mesh
  123031. * @param options defines the options used to create the mesh
  123032. * @param scene defines the hosting scene
  123033. * @returns the lathe mesh
  123034. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123035. */
  123036. static CreateLathe(name: string, options: {
  123037. shape: Vector3[];
  123038. radius?: number;
  123039. tessellation?: number;
  123040. clip?: number;
  123041. arc?: number;
  123042. closed?: boolean;
  123043. updatable?: boolean;
  123044. sideOrientation?: number;
  123045. frontUVs?: Vector4;
  123046. backUVs?: Vector4;
  123047. cap?: number;
  123048. invertUV?: boolean;
  123049. }, scene?: Nullable<Scene>): Mesh;
  123050. }
  123051. }
  123052. declare module BABYLON {
  123053. /**
  123054. * Class containing static functions to help procedurally build meshes
  123055. */
  123056. export class TiledPlaneBuilder {
  123057. /**
  123058. * Creates a tiled plane mesh
  123059. * * The parameter `pattern` will, depending on value, do nothing or
  123060. * * * flip (reflect about central vertical) alternate tiles across and up
  123061. * * * flip every tile on alternate rows
  123062. * * * rotate (180 degs) alternate tiles across and up
  123063. * * * rotate every tile on alternate rows
  123064. * * * flip and rotate alternate tiles across and up
  123065. * * * flip and rotate every tile on alternate rows
  123066. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  123067. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  123068. * * 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
  123069. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123070. * * 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)
  123071. * * 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)
  123072. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123073. * @param name defines the name of the mesh
  123074. * @param options defines the options used to create the mesh
  123075. * @param scene defines the hosting scene
  123076. * @returns the box mesh
  123077. */
  123078. static CreateTiledPlane(name: string, options: {
  123079. pattern?: number;
  123080. tileSize?: number;
  123081. tileWidth?: number;
  123082. tileHeight?: number;
  123083. size?: number;
  123084. width?: number;
  123085. height?: number;
  123086. alignHorizontal?: number;
  123087. alignVertical?: number;
  123088. sideOrientation?: number;
  123089. frontUVs?: Vector4;
  123090. backUVs?: Vector4;
  123091. updatable?: boolean;
  123092. }, scene?: Nullable<Scene>): Mesh;
  123093. }
  123094. }
  123095. declare module BABYLON {
  123096. /**
  123097. * Class containing static functions to help procedurally build meshes
  123098. */
  123099. export class TubeBuilder {
  123100. /**
  123101. * Creates a tube mesh.
  123102. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123103. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123104. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123105. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123106. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123107. * * 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)
  123108. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123109. * * 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
  123110. * * 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
  123111. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123112. * * 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
  123113. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123114. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123115. * @param name defines the name of the mesh
  123116. * @param options defines the options used to create the mesh
  123117. * @param scene defines the hosting scene
  123118. * @returns the tube mesh
  123119. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123120. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123121. */
  123122. static CreateTube(name: string, options: {
  123123. path: Vector3[];
  123124. radius?: number;
  123125. tessellation?: number;
  123126. radiusFunction?: {
  123127. (i: number, distance: number): number;
  123128. };
  123129. cap?: number;
  123130. arc?: number;
  123131. updatable?: boolean;
  123132. sideOrientation?: number;
  123133. frontUVs?: Vector4;
  123134. backUVs?: Vector4;
  123135. instance?: Mesh;
  123136. invertUV?: boolean;
  123137. }, scene?: Nullable<Scene>): Mesh;
  123138. }
  123139. }
  123140. declare module BABYLON {
  123141. /**
  123142. * Class containing static functions to help procedurally build meshes
  123143. */
  123144. export class IcoSphereBuilder {
  123145. /**
  123146. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123147. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123148. * * 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`)
  123149. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123150. * * 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
  123151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123152. * * 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
  123153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123154. * @param name defines the name of the mesh
  123155. * @param options defines the options used to create the mesh
  123156. * @param scene defines the hosting scene
  123157. * @returns the icosahedron mesh
  123158. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123159. */
  123160. static CreateIcoSphere(name: string, options: {
  123161. radius?: number;
  123162. radiusX?: number;
  123163. radiusY?: number;
  123164. radiusZ?: number;
  123165. flat?: boolean;
  123166. subdivisions?: number;
  123167. sideOrientation?: number;
  123168. frontUVs?: Vector4;
  123169. backUVs?: Vector4;
  123170. updatable?: boolean;
  123171. }, scene?: Nullable<Scene>): Mesh;
  123172. }
  123173. }
  123174. declare module BABYLON {
  123175. /**
  123176. * Class containing static functions to help procedurally build meshes
  123177. */
  123178. export class DecalBuilder {
  123179. /**
  123180. * Creates a decal mesh.
  123181. * 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
  123182. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123183. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123184. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123185. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123186. * @param name defines the name of the mesh
  123187. * @param sourceMesh defines the mesh where the decal must be applied
  123188. * @param options defines the options used to create the mesh
  123189. * @param scene defines the hosting scene
  123190. * @returns the decal mesh
  123191. * @see https://doc.babylonjs.com/how_to/decals
  123192. */
  123193. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123194. position?: Vector3;
  123195. normal?: Vector3;
  123196. size?: Vector3;
  123197. angle?: number;
  123198. }): Mesh;
  123199. }
  123200. }
  123201. declare module BABYLON {
  123202. /**
  123203. * Class containing static functions to help procedurally build meshes
  123204. */
  123205. export class MeshBuilder {
  123206. /**
  123207. * Creates a box mesh
  123208. * * The parameter `size` sets the size (float) of each box side (default 1)
  123209. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123210. * * 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)
  123211. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123212. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123213. * * 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
  123214. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123215. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123216. * @param name defines the name of the mesh
  123217. * @param options defines the options used to create the mesh
  123218. * @param scene defines the hosting scene
  123219. * @returns the box mesh
  123220. */
  123221. static CreateBox(name: string, options: {
  123222. size?: number;
  123223. width?: number;
  123224. height?: number;
  123225. depth?: number;
  123226. faceUV?: Vector4[];
  123227. faceColors?: Color4[];
  123228. sideOrientation?: number;
  123229. frontUVs?: Vector4;
  123230. backUVs?: Vector4;
  123231. updatable?: boolean;
  123232. }, scene?: Nullable<Scene>): Mesh;
  123233. /**
  123234. * Creates a tiled box mesh
  123235. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123237. * @param name defines the name of the mesh
  123238. * @param options defines the options used to create the mesh
  123239. * @param scene defines the hosting scene
  123240. * @returns the tiled box mesh
  123241. */
  123242. static CreateTiledBox(name: string, options: {
  123243. pattern?: number;
  123244. size?: number;
  123245. width?: number;
  123246. height?: number;
  123247. depth: number;
  123248. tileSize?: number;
  123249. tileWidth?: number;
  123250. tileHeight?: number;
  123251. faceUV?: Vector4[];
  123252. faceColors?: Color4[];
  123253. alignHorizontal?: number;
  123254. alignVertical?: number;
  123255. sideOrientation?: number;
  123256. updatable?: boolean;
  123257. }, scene?: Nullable<Scene>): Mesh;
  123258. /**
  123259. * Creates a sphere mesh
  123260. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123261. * * 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`)
  123262. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123263. * * 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
  123264. * * 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)
  123265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123266. * * 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
  123267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123268. * @param name defines the name of the mesh
  123269. * @param options defines the options used to create the mesh
  123270. * @param scene defines the hosting scene
  123271. * @returns the sphere mesh
  123272. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123273. */
  123274. static CreateSphere(name: string, options: {
  123275. segments?: number;
  123276. diameter?: number;
  123277. diameterX?: number;
  123278. diameterY?: number;
  123279. diameterZ?: number;
  123280. arc?: number;
  123281. slice?: number;
  123282. sideOrientation?: number;
  123283. frontUVs?: Vector4;
  123284. backUVs?: Vector4;
  123285. updatable?: boolean;
  123286. }, scene?: Nullable<Scene>): Mesh;
  123287. /**
  123288. * Creates a plane polygonal mesh. By default, this is a disc
  123289. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123290. * * 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
  123291. * * 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
  123292. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123293. * * 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
  123294. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123295. * @param name defines the name of the mesh
  123296. * @param options defines the options used to create the mesh
  123297. * @param scene defines the hosting scene
  123298. * @returns the plane polygonal mesh
  123299. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123300. */
  123301. static CreateDisc(name: string, options: {
  123302. radius?: number;
  123303. tessellation?: number;
  123304. arc?: number;
  123305. updatable?: boolean;
  123306. sideOrientation?: number;
  123307. frontUVs?: Vector4;
  123308. backUVs?: Vector4;
  123309. }, scene?: Nullable<Scene>): Mesh;
  123310. /**
  123311. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123312. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123313. * * 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`)
  123314. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123315. * * 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
  123316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123317. * * 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
  123318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123319. * @param name defines the name of the mesh
  123320. * @param options defines the options used to create the mesh
  123321. * @param scene defines the hosting scene
  123322. * @returns the icosahedron mesh
  123323. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123324. */
  123325. static CreateIcoSphere(name: string, options: {
  123326. radius?: number;
  123327. radiusX?: number;
  123328. radiusY?: number;
  123329. radiusZ?: number;
  123330. flat?: boolean;
  123331. subdivisions?: number;
  123332. sideOrientation?: number;
  123333. frontUVs?: Vector4;
  123334. backUVs?: Vector4;
  123335. updatable?: boolean;
  123336. }, scene?: Nullable<Scene>): Mesh;
  123337. /**
  123338. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123339. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123340. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123341. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123342. * * 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
  123343. * * 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
  123344. * * 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
  123345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123346. * * 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
  123347. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123348. * * 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
  123349. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123350. * * 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
  123351. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123353. * @param name defines the name of the mesh
  123354. * @param options defines the options used to create the mesh
  123355. * @param scene defines the hosting scene
  123356. * @returns the ribbon mesh
  123357. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123358. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123359. */
  123360. static CreateRibbon(name: string, options: {
  123361. pathArray: Vector3[][];
  123362. closeArray?: boolean;
  123363. closePath?: boolean;
  123364. offset?: number;
  123365. updatable?: boolean;
  123366. sideOrientation?: number;
  123367. frontUVs?: Vector4;
  123368. backUVs?: Vector4;
  123369. instance?: Mesh;
  123370. invertUV?: boolean;
  123371. uvs?: Vector2[];
  123372. colors?: Color4[];
  123373. }, scene?: Nullable<Scene>): Mesh;
  123374. /**
  123375. * Creates a cylinder or a cone mesh
  123376. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123377. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123378. * * 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.
  123379. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123380. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123381. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123382. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123383. * * 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).
  123384. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123385. * * 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).
  123386. * * 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
  123387. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123388. * * 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
  123389. * * 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.
  123390. * * If `enclose` is false, a ring surface is one element.
  123391. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123392. * * 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
  123393. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123394. * * 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
  123395. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123396. * @param name defines the name of the mesh
  123397. * @param options defines the options used to create the mesh
  123398. * @param scene defines the hosting scene
  123399. * @returns the cylinder mesh
  123400. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123401. */
  123402. static CreateCylinder(name: string, options: {
  123403. height?: number;
  123404. diameterTop?: number;
  123405. diameterBottom?: number;
  123406. diameter?: number;
  123407. tessellation?: number;
  123408. subdivisions?: number;
  123409. arc?: number;
  123410. faceColors?: Color4[];
  123411. faceUV?: Vector4[];
  123412. updatable?: boolean;
  123413. hasRings?: boolean;
  123414. enclose?: boolean;
  123415. cap?: number;
  123416. sideOrientation?: number;
  123417. frontUVs?: Vector4;
  123418. backUVs?: Vector4;
  123419. }, scene?: Nullable<Scene>): Mesh;
  123420. /**
  123421. * Creates a torus mesh
  123422. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123423. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123424. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123426. * * 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
  123427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123428. * @param name defines the name of the mesh
  123429. * @param options defines the options used to create the mesh
  123430. * @param scene defines the hosting scene
  123431. * @returns the torus mesh
  123432. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123433. */
  123434. static CreateTorus(name: string, options: {
  123435. diameter?: number;
  123436. thickness?: number;
  123437. tessellation?: number;
  123438. updatable?: boolean;
  123439. sideOrientation?: number;
  123440. frontUVs?: Vector4;
  123441. backUVs?: Vector4;
  123442. }, scene?: Nullable<Scene>): Mesh;
  123443. /**
  123444. * Creates a torus knot mesh
  123445. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123446. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123447. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123448. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123450. * * 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
  123451. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123452. * @param name defines the name of the mesh
  123453. * @param options defines the options used to create the mesh
  123454. * @param scene defines the hosting scene
  123455. * @returns the torus knot mesh
  123456. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123457. */
  123458. static CreateTorusKnot(name: string, options: {
  123459. radius?: number;
  123460. tube?: number;
  123461. radialSegments?: number;
  123462. tubularSegments?: number;
  123463. p?: number;
  123464. q?: number;
  123465. updatable?: boolean;
  123466. sideOrientation?: number;
  123467. frontUVs?: Vector4;
  123468. backUVs?: Vector4;
  123469. }, scene?: Nullable<Scene>): Mesh;
  123470. /**
  123471. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123472. * * 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
  123473. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123474. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123475. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123476. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123477. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123478. * * 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
  123479. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123482. * @param name defines the name of the new line system
  123483. * @param options defines the options used to create the line system
  123484. * @param scene defines the hosting scene
  123485. * @returns a new line system mesh
  123486. */
  123487. static CreateLineSystem(name: string, options: {
  123488. lines: Vector3[][];
  123489. updatable?: boolean;
  123490. instance?: Nullable<LinesMesh>;
  123491. colors?: Nullable<Color4[][]>;
  123492. useVertexAlpha?: boolean;
  123493. }, scene: Nullable<Scene>): LinesMesh;
  123494. /**
  123495. * Creates a line mesh
  123496. * 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
  123497. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123498. * * The parameter `points` is an array successive Vector3
  123499. * * 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
  123500. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123501. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123502. * * When updating an instance, remember that only point positions can change, not the number of points
  123503. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123504. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123505. * @param name defines the name of the new line system
  123506. * @param options defines the options used to create the line system
  123507. * @param scene defines the hosting scene
  123508. * @returns a new line mesh
  123509. */
  123510. static CreateLines(name: string, options: {
  123511. points: Vector3[];
  123512. updatable?: boolean;
  123513. instance?: Nullable<LinesMesh>;
  123514. colors?: Color4[];
  123515. useVertexAlpha?: boolean;
  123516. }, scene?: Nullable<Scene>): LinesMesh;
  123517. /**
  123518. * Creates a dashed line mesh
  123519. * * 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
  123520. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123521. * * The parameter `points` is an array successive Vector3
  123522. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123523. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123524. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123525. * * 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
  123526. * * When updating an instance, remember that only point positions can change, not the number of points
  123527. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123528. * @param name defines the name of the mesh
  123529. * @param options defines the options used to create the mesh
  123530. * @param scene defines the hosting scene
  123531. * @returns the dashed line mesh
  123532. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123533. */
  123534. static CreateDashedLines(name: string, options: {
  123535. points: Vector3[];
  123536. dashSize?: number;
  123537. gapSize?: number;
  123538. dashNb?: number;
  123539. updatable?: boolean;
  123540. instance?: LinesMesh;
  123541. }, scene?: Nullable<Scene>): LinesMesh;
  123542. /**
  123543. * 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.
  123544. * * 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.
  123545. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123546. * * 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.
  123547. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123548. * * 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
  123549. * * 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
  123550. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123551. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123552. * * 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
  123553. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123555. * @param name defines the name of the mesh
  123556. * @param options defines the options used to create the mesh
  123557. * @param scene defines the hosting scene
  123558. * @returns the extruded shape mesh
  123559. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123560. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123561. */
  123562. static ExtrudeShape(name: string, options: {
  123563. shape: Vector3[];
  123564. path: Vector3[];
  123565. scale?: number;
  123566. rotation?: number;
  123567. cap?: number;
  123568. updatable?: boolean;
  123569. sideOrientation?: number;
  123570. frontUVs?: Vector4;
  123571. backUVs?: Vector4;
  123572. instance?: Mesh;
  123573. invertUV?: boolean;
  123574. }, scene?: Nullable<Scene>): Mesh;
  123575. /**
  123576. * Creates an custom extruded shape mesh.
  123577. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123578. * * 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.
  123579. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123580. * * 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
  123581. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123582. * * 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
  123583. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123584. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123585. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123586. * * 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
  123587. * * 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
  123588. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123589. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123590. * * 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
  123591. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123593. * @param name defines the name of the mesh
  123594. * @param options defines the options used to create the mesh
  123595. * @param scene defines the hosting scene
  123596. * @returns the custom extruded shape mesh
  123597. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123598. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123599. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123600. */
  123601. static ExtrudeShapeCustom(name: string, options: {
  123602. shape: Vector3[];
  123603. path: Vector3[];
  123604. scaleFunction?: any;
  123605. rotationFunction?: any;
  123606. ribbonCloseArray?: boolean;
  123607. ribbonClosePath?: boolean;
  123608. cap?: number;
  123609. updatable?: boolean;
  123610. sideOrientation?: number;
  123611. frontUVs?: Vector4;
  123612. backUVs?: Vector4;
  123613. instance?: Mesh;
  123614. invertUV?: boolean;
  123615. }, scene?: Nullable<Scene>): Mesh;
  123616. /**
  123617. * Creates lathe mesh.
  123618. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123619. * * 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
  123620. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123621. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123622. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123623. * * 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
  123624. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123625. * * 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
  123626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123627. * * 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
  123628. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123629. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123630. * @param name defines the name of the mesh
  123631. * @param options defines the options used to create the mesh
  123632. * @param scene defines the hosting scene
  123633. * @returns the lathe mesh
  123634. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123635. */
  123636. static CreateLathe(name: string, options: {
  123637. shape: Vector3[];
  123638. radius?: number;
  123639. tessellation?: number;
  123640. clip?: number;
  123641. arc?: number;
  123642. closed?: boolean;
  123643. updatable?: boolean;
  123644. sideOrientation?: number;
  123645. frontUVs?: Vector4;
  123646. backUVs?: Vector4;
  123647. cap?: number;
  123648. invertUV?: boolean;
  123649. }, scene?: Nullable<Scene>): Mesh;
  123650. /**
  123651. * Creates a tiled plane mesh
  123652. * * You can set a limited pattern arrangement with the tiles
  123653. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123654. * * 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
  123655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123656. * @param name defines the name of the mesh
  123657. * @param options defines the options used to create the mesh
  123658. * @param scene defines the hosting scene
  123659. * @returns the plane mesh
  123660. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123661. */
  123662. static CreateTiledPlane(name: string, options: {
  123663. pattern?: number;
  123664. tileSize?: number;
  123665. tileWidth?: number;
  123666. tileHeight?: number;
  123667. size?: number;
  123668. width?: number;
  123669. height?: number;
  123670. alignHorizontal?: number;
  123671. alignVertical?: number;
  123672. sideOrientation?: number;
  123673. frontUVs?: Vector4;
  123674. backUVs?: Vector4;
  123675. updatable?: boolean;
  123676. }, scene?: Nullable<Scene>): Mesh;
  123677. /**
  123678. * Creates a plane mesh
  123679. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123680. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123681. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123682. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123683. * * 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
  123684. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123685. * @param name defines the name of the mesh
  123686. * @param options defines the options used to create the mesh
  123687. * @param scene defines the hosting scene
  123688. * @returns the plane mesh
  123689. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123690. */
  123691. static CreatePlane(name: string, options: {
  123692. size?: number;
  123693. width?: number;
  123694. height?: number;
  123695. sideOrientation?: number;
  123696. frontUVs?: Vector4;
  123697. backUVs?: Vector4;
  123698. updatable?: boolean;
  123699. sourcePlane?: Plane;
  123700. }, scene?: Nullable<Scene>): Mesh;
  123701. /**
  123702. * Creates a ground mesh
  123703. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123704. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123706. * @param name defines the name of the mesh
  123707. * @param options defines the options used to create the mesh
  123708. * @param scene defines the hosting scene
  123709. * @returns the ground mesh
  123710. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123711. */
  123712. static CreateGround(name: string, options: {
  123713. width?: number;
  123714. height?: number;
  123715. subdivisions?: number;
  123716. subdivisionsX?: number;
  123717. subdivisionsY?: number;
  123718. updatable?: boolean;
  123719. }, scene?: Nullable<Scene>): Mesh;
  123720. /**
  123721. * Creates a tiled ground mesh
  123722. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123723. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123724. * * 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
  123725. * * 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
  123726. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123727. * @param name defines the name of the mesh
  123728. * @param options defines the options used to create the mesh
  123729. * @param scene defines the hosting scene
  123730. * @returns the tiled ground mesh
  123731. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123732. */
  123733. static CreateTiledGround(name: string, options: {
  123734. xmin: number;
  123735. zmin: number;
  123736. xmax: number;
  123737. zmax: number;
  123738. subdivisions?: {
  123739. w: number;
  123740. h: number;
  123741. };
  123742. precision?: {
  123743. w: number;
  123744. h: number;
  123745. };
  123746. updatable?: boolean;
  123747. }, scene?: Nullable<Scene>): Mesh;
  123748. /**
  123749. * Creates a ground mesh from a height map
  123750. * * The parameter `url` sets the URL of the height map image resource.
  123751. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123752. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123753. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123754. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123755. * * 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.
  123756. * * 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).
  123757. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123759. * @param name defines the name of the mesh
  123760. * @param url defines the url to the height map
  123761. * @param options defines the options used to create the mesh
  123762. * @param scene defines the hosting scene
  123763. * @returns the ground mesh
  123764. * @see https://doc.babylonjs.com/babylon101/height_map
  123765. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123766. */
  123767. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123768. width?: number;
  123769. height?: number;
  123770. subdivisions?: number;
  123771. minHeight?: number;
  123772. maxHeight?: number;
  123773. colorFilter?: Color3;
  123774. alphaFilter?: number;
  123775. updatable?: boolean;
  123776. onReady?: (mesh: GroundMesh) => void;
  123777. }, scene?: Nullable<Scene>): GroundMesh;
  123778. /**
  123779. * Creates a polygon mesh
  123780. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123781. * * 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
  123782. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123784. * * 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)
  123785. * * Remember you can only change the shape positions, not their number when updating a polygon
  123786. * @param name defines the name of the mesh
  123787. * @param options defines the options used to create the mesh
  123788. * @param scene defines the hosting scene
  123789. * @param earcutInjection can be used to inject your own earcut reference
  123790. * @returns the polygon mesh
  123791. */
  123792. static CreatePolygon(name: string, options: {
  123793. shape: Vector3[];
  123794. holes?: Vector3[][];
  123795. depth?: number;
  123796. faceUV?: Vector4[];
  123797. faceColors?: Color4[];
  123798. updatable?: boolean;
  123799. sideOrientation?: number;
  123800. frontUVs?: Vector4;
  123801. backUVs?: Vector4;
  123802. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123803. /**
  123804. * Creates an extruded polygon mesh, with depth in the Y direction.
  123805. * * 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)
  123806. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123807. * @param name defines the name of the mesh
  123808. * @param options defines the options used to create the mesh
  123809. * @param scene defines the hosting scene
  123810. * @param earcutInjection can be used to inject your own earcut reference
  123811. * @returns the polygon mesh
  123812. */
  123813. static ExtrudePolygon(name: string, options: {
  123814. shape: Vector3[];
  123815. holes?: Vector3[][];
  123816. depth?: number;
  123817. faceUV?: Vector4[];
  123818. faceColors?: Color4[];
  123819. updatable?: boolean;
  123820. sideOrientation?: number;
  123821. frontUVs?: Vector4;
  123822. backUVs?: Vector4;
  123823. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123824. /**
  123825. * Creates a tube mesh.
  123826. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123827. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123828. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123829. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123830. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123831. * * 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)
  123832. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123833. * * 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
  123834. * * 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
  123835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123836. * * 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
  123837. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123839. * @param name defines the name of the mesh
  123840. * @param options defines the options used to create the mesh
  123841. * @param scene defines the hosting scene
  123842. * @returns the tube mesh
  123843. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123844. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123845. */
  123846. static CreateTube(name: string, options: {
  123847. path: Vector3[];
  123848. radius?: number;
  123849. tessellation?: number;
  123850. radiusFunction?: {
  123851. (i: number, distance: number): number;
  123852. };
  123853. cap?: number;
  123854. arc?: number;
  123855. updatable?: boolean;
  123856. sideOrientation?: number;
  123857. frontUVs?: Vector4;
  123858. backUVs?: Vector4;
  123859. instance?: Mesh;
  123860. invertUV?: boolean;
  123861. }, scene?: Nullable<Scene>): Mesh;
  123862. /**
  123863. * Creates a polyhedron mesh
  123864. * * 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
  123865. * * The parameter `size` (positive float, default 1) sets the polygon size
  123866. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123867. * * 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`
  123868. * * 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
  123869. * * 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)`)
  123870. * * 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
  123871. * * 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
  123872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123873. * * 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
  123874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123875. * @param name defines the name of the mesh
  123876. * @param options defines the options used to create the mesh
  123877. * @param scene defines the hosting scene
  123878. * @returns the polyhedron mesh
  123879. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123880. */
  123881. static CreatePolyhedron(name: string, options: {
  123882. type?: number;
  123883. size?: number;
  123884. sizeX?: number;
  123885. sizeY?: number;
  123886. sizeZ?: number;
  123887. custom?: any;
  123888. faceUV?: Vector4[];
  123889. faceColors?: Color4[];
  123890. flat?: boolean;
  123891. updatable?: boolean;
  123892. sideOrientation?: number;
  123893. frontUVs?: Vector4;
  123894. backUVs?: Vector4;
  123895. }, scene?: Nullable<Scene>): Mesh;
  123896. /**
  123897. * Creates a decal mesh.
  123898. * 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
  123899. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123900. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123901. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123902. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123903. * @param name defines the name of the mesh
  123904. * @param sourceMesh defines the mesh where the decal must be applied
  123905. * @param options defines the options used to create the mesh
  123906. * @param scene defines the hosting scene
  123907. * @returns the decal mesh
  123908. * @see https://doc.babylonjs.com/how_to/decals
  123909. */
  123910. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123911. position?: Vector3;
  123912. normal?: Vector3;
  123913. size?: Vector3;
  123914. angle?: number;
  123915. }): Mesh;
  123916. }
  123917. }
  123918. declare module BABYLON {
  123919. /**
  123920. * A simplifier interface for future simplification implementations
  123921. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123922. */
  123923. export interface ISimplifier {
  123924. /**
  123925. * Simplification of a given mesh according to the given settings.
  123926. * Since this requires computation, it is assumed that the function runs async.
  123927. * @param settings The settings of the simplification, including quality and distance
  123928. * @param successCallback A callback that will be called after the mesh was simplified.
  123929. * @param errorCallback in case of an error, this callback will be called. optional.
  123930. */
  123931. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123932. }
  123933. /**
  123934. * Expected simplification settings.
  123935. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123936. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123937. */
  123938. export interface ISimplificationSettings {
  123939. /**
  123940. * Gets or sets the expected quality
  123941. */
  123942. quality: number;
  123943. /**
  123944. * Gets or sets the distance when this optimized version should be used
  123945. */
  123946. distance: number;
  123947. /**
  123948. * Gets an already optimized mesh
  123949. */
  123950. optimizeMesh?: boolean;
  123951. }
  123952. /**
  123953. * Class used to specify simplification options
  123954. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123955. */
  123956. export class SimplificationSettings implements ISimplificationSettings {
  123957. /** expected quality */
  123958. quality: number;
  123959. /** distance when this optimized version should be used */
  123960. distance: number;
  123961. /** already optimized mesh */
  123962. optimizeMesh?: boolean | undefined;
  123963. /**
  123964. * Creates a SimplificationSettings
  123965. * @param quality expected quality
  123966. * @param distance distance when this optimized version should be used
  123967. * @param optimizeMesh already optimized mesh
  123968. */
  123969. constructor(
  123970. /** expected quality */
  123971. quality: number,
  123972. /** distance when this optimized version should be used */
  123973. distance: number,
  123974. /** already optimized mesh */
  123975. optimizeMesh?: boolean | undefined);
  123976. }
  123977. /**
  123978. * Interface used to define a simplification task
  123979. */
  123980. export interface ISimplificationTask {
  123981. /**
  123982. * Array of settings
  123983. */
  123984. settings: Array<ISimplificationSettings>;
  123985. /**
  123986. * Simplification type
  123987. */
  123988. simplificationType: SimplificationType;
  123989. /**
  123990. * Mesh to simplify
  123991. */
  123992. mesh: Mesh;
  123993. /**
  123994. * Callback called on success
  123995. */
  123996. successCallback?: () => void;
  123997. /**
  123998. * Defines if parallel processing can be used
  123999. */
  124000. parallelProcessing: boolean;
  124001. }
  124002. /**
  124003. * Queue used to order the simplification tasks
  124004. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124005. */
  124006. export class SimplificationQueue {
  124007. private _simplificationArray;
  124008. /**
  124009. * Gets a boolean indicating that the process is still running
  124010. */
  124011. running: boolean;
  124012. /**
  124013. * Creates a new queue
  124014. */
  124015. constructor();
  124016. /**
  124017. * Adds a new simplification task
  124018. * @param task defines a task to add
  124019. */
  124020. addTask(task: ISimplificationTask): void;
  124021. /**
  124022. * Execute next task
  124023. */
  124024. executeNext(): void;
  124025. /**
  124026. * Execute a simplification task
  124027. * @param task defines the task to run
  124028. */
  124029. runSimplification(task: ISimplificationTask): void;
  124030. private getSimplifier;
  124031. }
  124032. /**
  124033. * The implemented types of simplification
  124034. * At the moment only Quadratic Error Decimation is implemented
  124035. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124036. */
  124037. export enum SimplificationType {
  124038. /** Quadratic error decimation */
  124039. QUADRATIC = 0
  124040. }
  124041. }
  124042. declare module BABYLON {
  124043. interface Scene {
  124044. /** @hidden (Backing field) */
  124045. _simplificationQueue: SimplificationQueue;
  124046. /**
  124047. * Gets or sets the simplification queue attached to the scene
  124048. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  124049. */
  124050. simplificationQueue: SimplificationQueue;
  124051. }
  124052. interface Mesh {
  124053. /**
  124054. * Simplify the mesh according to the given array of settings.
  124055. * Function will return immediately and will simplify async
  124056. * @param settings a collection of simplification settings
  124057. * @param parallelProcessing should all levels calculate parallel or one after the other
  124058. * @param simplificationType the type of simplification to run
  124059. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  124060. * @returns the current mesh
  124061. */
  124062. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  124063. }
  124064. /**
  124065. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  124066. * created in a scene
  124067. */
  124068. export class SimplicationQueueSceneComponent implements ISceneComponent {
  124069. /**
  124070. * The component name helpfull to identify the component in the list of scene components.
  124071. */
  124072. readonly name: string;
  124073. /**
  124074. * The scene the component belongs to.
  124075. */
  124076. scene: Scene;
  124077. /**
  124078. * Creates a new instance of the component for the given scene
  124079. * @param scene Defines the scene to register the component in
  124080. */
  124081. constructor(scene: Scene);
  124082. /**
  124083. * Registers the component in a given scene
  124084. */
  124085. register(): void;
  124086. /**
  124087. * Rebuilds the elements related to this component in case of
  124088. * context lost for instance.
  124089. */
  124090. rebuild(): void;
  124091. /**
  124092. * Disposes the component and the associated ressources
  124093. */
  124094. dispose(): void;
  124095. private _beforeCameraUpdate;
  124096. }
  124097. }
  124098. declare module BABYLON {
  124099. /**
  124100. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124101. */
  124102. export interface INavigationEnginePlugin {
  124103. /**
  124104. * plugin name
  124105. */
  124106. name: string;
  124107. /**
  124108. * Creates a navigation mesh
  124109. * @param meshes array of all the geometry used to compute the navigatio mesh
  124110. * @param parameters bunch of parameters used to filter geometry
  124111. */
  124112. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124113. /**
  124114. * Create a navigation mesh debug mesh
  124115. * @param scene is where the mesh will be added
  124116. * @returns debug display mesh
  124117. */
  124118. createDebugNavMesh(scene: Scene): Mesh;
  124119. /**
  124120. * Get a navigation mesh constrained position, closest to the parameter position
  124121. * @param position world position
  124122. * @returns the closest point to position constrained by the navigation mesh
  124123. */
  124124. getClosestPoint(position: Vector3): Vector3;
  124125. /**
  124126. * Get a navigation mesh constrained position, within a particular radius
  124127. * @param position world position
  124128. * @param maxRadius the maximum distance to the constrained world position
  124129. * @returns the closest point to position constrained by the navigation mesh
  124130. */
  124131. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124132. /**
  124133. * Compute the final position from a segment made of destination-position
  124134. * @param position world position
  124135. * @param destination world position
  124136. * @returns the resulting point along the navmesh
  124137. */
  124138. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124139. /**
  124140. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124141. * @param start world position
  124142. * @param end world position
  124143. * @returns array containing world position composing the path
  124144. */
  124145. computePath(start: Vector3, end: Vector3): Vector3[];
  124146. /**
  124147. * If this plugin is supported
  124148. * @returns true if plugin is supported
  124149. */
  124150. isSupported(): boolean;
  124151. /**
  124152. * Create a new Crowd so you can add agents
  124153. * @param maxAgents the maximum agent count in the crowd
  124154. * @param maxAgentRadius the maximum radius an agent can have
  124155. * @param scene to attach the crowd to
  124156. * @returns the crowd you can add agents to
  124157. */
  124158. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124159. /**
  124160. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124161. * The queries will try to find a solution within those bounds
  124162. * default is (1,1,1)
  124163. * @param extent x,y,z value that define the extent around the queries point of reference
  124164. */
  124165. setDefaultQueryExtent(extent: Vector3): void;
  124166. /**
  124167. * Get the Bounding box extent specified by setDefaultQueryExtent
  124168. * @returns the box extent values
  124169. */
  124170. getDefaultQueryExtent(): Vector3;
  124171. /**
  124172. * Release all resources
  124173. */
  124174. dispose(): void;
  124175. }
  124176. /**
  124177. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124178. */
  124179. export interface ICrowd {
  124180. /**
  124181. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124182. * You can attach anything to that node. The node position is updated in the scene update tick.
  124183. * @param pos world position that will be constrained by the navigation mesh
  124184. * @param parameters agent parameters
  124185. * @param transform hooked to the agent that will be update by the scene
  124186. * @returns agent index
  124187. */
  124188. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124189. /**
  124190. * Returns the agent position in world space
  124191. * @param index agent index returned by addAgent
  124192. * @returns world space position
  124193. */
  124194. getAgentPosition(index: number): Vector3;
  124195. /**
  124196. * Gets the agent velocity in world space
  124197. * @param index agent index returned by addAgent
  124198. * @returns world space velocity
  124199. */
  124200. getAgentVelocity(index: number): Vector3;
  124201. /**
  124202. * remove a particular agent previously created
  124203. * @param index agent index returned by addAgent
  124204. */
  124205. removeAgent(index: number): void;
  124206. /**
  124207. * get the list of all agents attached to this crowd
  124208. * @returns list of agent indices
  124209. */
  124210. getAgents(): number[];
  124211. /**
  124212. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124213. * @param deltaTime in seconds
  124214. */
  124215. update(deltaTime: number): void;
  124216. /**
  124217. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124218. * @param index agent index returned by addAgent
  124219. * @param destination targeted world position
  124220. */
  124221. agentGoto(index: number, destination: Vector3): void;
  124222. /**
  124223. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124224. * The queries will try to find a solution within those bounds
  124225. * default is (1,1,1)
  124226. * @param extent x,y,z value that define the extent around the queries point of reference
  124227. */
  124228. setDefaultQueryExtent(extent: Vector3): void;
  124229. /**
  124230. * Get the Bounding box extent specified by setDefaultQueryExtent
  124231. * @returns the box extent values
  124232. */
  124233. getDefaultQueryExtent(): Vector3;
  124234. /**
  124235. * Release all resources
  124236. */
  124237. dispose(): void;
  124238. }
  124239. /**
  124240. * Configures an agent
  124241. */
  124242. export interface IAgentParameters {
  124243. /**
  124244. * Agent radius. [Limit: >= 0]
  124245. */
  124246. radius: number;
  124247. /**
  124248. * Agent height. [Limit: > 0]
  124249. */
  124250. height: number;
  124251. /**
  124252. * Maximum allowed acceleration. [Limit: >= 0]
  124253. */
  124254. maxAcceleration: number;
  124255. /**
  124256. * Maximum allowed speed. [Limit: >= 0]
  124257. */
  124258. maxSpeed: number;
  124259. /**
  124260. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124261. */
  124262. collisionQueryRange: number;
  124263. /**
  124264. * The path visibility optimization range. [Limit: > 0]
  124265. */
  124266. pathOptimizationRange: number;
  124267. /**
  124268. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124269. */
  124270. separationWeight: number;
  124271. }
  124272. /**
  124273. * Configures the navigation mesh creation
  124274. */
  124275. export interface INavMeshParameters {
  124276. /**
  124277. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124278. */
  124279. cs: number;
  124280. /**
  124281. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124282. */
  124283. ch: number;
  124284. /**
  124285. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124286. */
  124287. walkableSlopeAngle: number;
  124288. /**
  124289. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124290. * be considered walkable. [Limit: >= 3] [Units: vx]
  124291. */
  124292. walkableHeight: number;
  124293. /**
  124294. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124295. */
  124296. walkableClimb: number;
  124297. /**
  124298. * The distance to erode/shrink the walkable area of the heightfield away from
  124299. * obstructions. [Limit: >=0] [Units: vx]
  124300. */
  124301. walkableRadius: number;
  124302. /**
  124303. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124304. */
  124305. maxEdgeLen: number;
  124306. /**
  124307. * The maximum distance a simplfied contour's border edges should deviate
  124308. * the original raw contour. [Limit: >=0] [Units: vx]
  124309. */
  124310. maxSimplificationError: number;
  124311. /**
  124312. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124313. */
  124314. minRegionArea: number;
  124315. /**
  124316. * Any regions with a span count smaller than this value will, if possible,
  124317. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124318. */
  124319. mergeRegionArea: number;
  124320. /**
  124321. * The maximum number of vertices allowed for polygons generated during the
  124322. * contour to polygon conversion process. [Limit: >= 3]
  124323. */
  124324. maxVertsPerPoly: number;
  124325. /**
  124326. * Sets the sampling distance to use when generating the detail mesh.
  124327. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124328. */
  124329. detailSampleDist: number;
  124330. /**
  124331. * The maximum distance the detail mesh surface should deviate from heightfield
  124332. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124333. */
  124334. detailSampleMaxError: number;
  124335. }
  124336. }
  124337. declare module BABYLON {
  124338. /**
  124339. * RecastJS navigation plugin
  124340. */
  124341. export class RecastJSPlugin implements INavigationEnginePlugin {
  124342. /**
  124343. * Reference to the Recast library
  124344. */
  124345. bjsRECAST: any;
  124346. /**
  124347. * plugin name
  124348. */
  124349. name: string;
  124350. /**
  124351. * the first navmesh created. We might extend this to support multiple navmeshes
  124352. */
  124353. navMesh: any;
  124354. /**
  124355. * Initializes the recastJS plugin
  124356. * @param recastInjection can be used to inject your own recast reference
  124357. */
  124358. constructor(recastInjection?: any);
  124359. /**
  124360. * Creates a navigation mesh
  124361. * @param meshes array of all the geometry used to compute the navigatio mesh
  124362. * @param parameters bunch of parameters used to filter geometry
  124363. */
  124364. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124365. /**
  124366. * Create a navigation mesh debug mesh
  124367. * @param scene is where the mesh will be added
  124368. * @returns debug display mesh
  124369. */
  124370. createDebugNavMesh(scene: Scene): Mesh;
  124371. /**
  124372. * Get a navigation mesh constrained position, closest to the parameter position
  124373. * @param position world position
  124374. * @returns the closest point to position constrained by the navigation mesh
  124375. */
  124376. getClosestPoint(position: Vector3): Vector3;
  124377. /**
  124378. * Get a navigation mesh constrained position, within a particular radius
  124379. * @param position world position
  124380. * @param maxRadius the maximum distance to the constrained world position
  124381. * @returns the closest point to position constrained by the navigation mesh
  124382. */
  124383. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124384. /**
  124385. * Compute the final position from a segment made of destination-position
  124386. * @param position world position
  124387. * @param destination world position
  124388. * @returns the resulting point along the navmesh
  124389. */
  124390. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124391. /**
  124392. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124393. * @param start world position
  124394. * @param end world position
  124395. * @returns array containing world position composing the path
  124396. */
  124397. computePath(start: Vector3, end: Vector3): Vector3[];
  124398. /**
  124399. * Create a new Crowd so you can add agents
  124400. * @param maxAgents the maximum agent count in the crowd
  124401. * @param maxAgentRadius the maximum radius an agent can have
  124402. * @param scene to attach the crowd to
  124403. * @returns the crowd you can add agents to
  124404. */
  124405. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124406. /**
  124407. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124408. * The queries will try to find a solution within those bounds
  124409. * default is (1,1,1)
  124410. * @param extent x,y,z value that define the extent around the queries point of reference
  124411. */
  124412. setDefaultQueryExtent(extent: Vector3): void;
  124413. /**
  124414. * Get the Bounding box extent specified by setDefaultQueryExtent
  124415. * @returns the box extent values
  124416. */
  124417. getDefaultQueryExtent(): Vector3;
  124418. /**
  124419. * Disposes
  124420. */
  124421. dispose(): void;
  124422. /**
  124423. * If this plugin is supported
  124424. * @returns true if plugin is supported
  124425. */
  124426. isSupported(): boolean;
  124427. }
  124428. /**
  124429. * Recast detour crowd implementation
  124430. */
  124431. export class RecastJSCrowd implements ICrowd {
  124432. /**
  124433. * Recast/detour plugin
  124434. */
  124435. bjsRECASTPlugin: RecastJSPlugin;
  124436. /**
  124437. * Link to the detour crowd
  124438. */
  124439. recastCrowd: any;
  124440. /**
  124441. * One transform per agent
  124442. */
  124443. transforms: TransformNode[];
  124444. /**
  124445. * All agents created
  124446. */
  124447. agents: number[];
  124448. /**
  124449. * Link to the scene is kept to unregister the crowd from the scene
  124450. */
  124451. private _scene;
  124452. /**
  124453. * Observer for crowd updates
  124454. */
  124455. private _onBeforeAnimationsObserver;
  124456. /**
  124457. * Constructor
  124458. * @param plugin recastJS plugin
  124459. * @param maxAgents the maximum agent count in the crowd
  124460. * @param maxAgentRadius the maximum radius an agent can have
  124461. * @param scene to attach the crowd to
  124462. * @returns the crowd you can add agents to
  124463. */
  124464. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124465. /**
  124466. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124467. * You can attach anything to that node. The node position is updated in the scene update tick.
  124468. * @param pos world position that will be constrained by the navigation mesh
  124469. * @param parameters agent parameters
  124470. * @param transform hooked to the agent that will be update by the scene
  124471. * @returns agent index
  124472. */
  124473. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124474. /**
  124475. * Returns the agent position in world space
  124476. * @param index agent index returned by addAgent
  124477. * @returns world space position
  124478. */
  124479. getAgentPosition(index: number): Vector3;
  124480. /**
  124481. * Returns the agent velocity in world space
  124482. * @param index agent index returned by addAgent
  124483. * @returns world space velocity
  124484. */
  124485. getAgentVelocity(index: number): Vector3;
  124486. /**
  124487. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124488. * @param index agent index returned by addAgent
  124489. * @param destination targeted world position
  124490. */
  124491. agentGoto(index: number, destination: Vector3): void;
  124492. /**
  124493. * remove a particular agent previously created
  124494. * @param index agent index returned by addAgent
  124495. */
  124496. removeAgent(index: number): void;
  124497. /**
  124498. * get the list of all agents attached to this crowd
  124499. * @returns list of agent indices
  124500. */
  124501. getAgents(): number[];
  124502. /**
  124503. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124504. * @param deltaTime in seconds
  124505. */
  124506. update(deltaTime: number): void;
  124507. /**
  124508. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124509. * The queries will try to find a solution within those bounds
  124510. * default is (1,1,1)
  124511. * @param extent x,y,z value that define the extent around the queries point of reference
  124512. */
  124513. setDefaultQueryExtent(extent: Vector3): void;
  124514. /**
  124515. * Get the Bounding box extent specified by setDefaultQueryExtent
  124516. * @returns the box extent values
  124517. */
  124518. getDefaultQueryExtent(): Vector3;
  124519. /**
  124520. * Release all resources
  124521. */
  124522. dispose(): void;
  124523. }
  124524. }
  124525. declare module BABYLON {
  124526. /**
  124527. * Class used to enable access to IndexedDB
  124528. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124529. */
  124530. export class Database implements IOfflineProvider {
  124531. private _callbackManifestChecked;
  124532. private _currentSceneUrl;
  124533. private _db;
  124534. private _enableSceneOffline;
  124535. private _enableTexturesOffline;
  124536. private _manifestVersionFound;
  124537. private _mustUpdateRessources;
  124538. private _hasReachedQuota;
  124539. private _isSupported;
  124540. private _idbFactory;
  124541. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124542. private static IsUASupportingBlobStorage;
  124543. /**
  124544. * Gets a boolean indicating if Database storate is enabled (off by default)
  124545. */
  124546. static IDBStorageEnabled: boolean;
  124547. /**
  124548. * Gets a boolean indicating if scene must be saved in the database
  124549. */
  124550. readonly enableSceneOffline: boolean;
  124551. /**
  124552. * Gets a boolean indicating if textures must be saved in the database
  124553. */
  124554. readonly enableTexturesOffline: boolean;
  124555. /**
  124556. * Creates a new Database
  124557. * @param urlToScene defines the url to load the scene
  124558. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124559. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124560. */
  124561. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124562. private static _ParseURL;
  124563. private static _ReturnFullUrlLocation;
  124564. private _checkManifestFile;
  124565. /**
  124566. * Open the database and make it available
  124567. * @param successCallback defines the callback to call on success
  124568. * @param errorCallback defines the callback to call on error
  124569. */
  124570. open(successCallback: () => void, errorCallback: () => void): void;
  124571. /**
  124572. * Loads an image from the database
  124573. * @param url defines the url to load from
  124574. * @param image defines the target DOM image
  124575. */
  124576. loadImage(url: string, image: HTMLImageElement): void;
  124577. private _loadImageFromDBAsync;
  124578. private _saveImageIntoDBAsync;
  124579. private _checkVersionFromDB;
  124580. private _loadVersionFromDBAsync;
  124581. private _saveVersionIntoDBAsync;
  124582. /**
  124583. * Loads a file from database
  124584. * @param url defines the URL to load from
  124585. * @param sceneLoaded defines a callback to call on success
  124586. * @param progressCallBack defines a callback to call when progress changed
  124587. * @param errorCallback defines a callback to call on error
  124588. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124589. */
  124590. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124591. private _loadFileAsync;
  124592. private _saveFileAsync;
  124593. /**
  124594. * Validates if xhr data is correct
  124595. * @param xhr defines the request to validate
  124596. * @param dataType defines the expected data type
  124597. * @returns true if data is correct
  124598. */
  124599. private static _ValidateXHRData;
  124600. }
  124601. }
  124602. declare module BABYLON {
  124603. /** @hidden */
  124604. export var gpuUpdateParticlesPixelShader: {
  124605. name: string;
  124606. shader: string;
  124607. };
  124608. }
  124609. declare module BABYLON {
  124610. /** @hidden */
  124611. export var gpuUpdateParticlesVertexShader: {
  124612. name: string;
  124613. shader: string;
  124614. };
  124615. }
  124616. declare module BABYLON {
  124617. /** @hidden */
  124618. export var clipPlaneFragmentDeclaration2: {
  124619. name: string;
  124620. shader: string;
  124621. };
  124622. }
  124623. declare module BABYLON {
  124624. /** @hidden */
  124625. export var gpuRenderParticlesPixelShader: {
  124626. name: string;
  124627. shader: string;
  124628. };
  124629. }
  124630. declare module BABYLON {
  124631. /** @hidden */
  124632. export var clipPlaneVertexDeclaration2: {
  124633. name: string;
  124634. shader: string;
  124635. };
  124636. }
  124637. declare module BABYLON {
  124638. /** @hidden */
  124639. export var gpuRenderParticlesVertexShader: {
  124640. name: string;
  124641. shader: string;
  124642. };
  124643. }
  124644. declare module BABYLON {
  124645. /**
  124646. * This represents a GPU particle system in Babylon
  124647. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124648. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124649. */
  124650. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124651. /**
  124652. * The layer mask we are rendering the particles through.
  124653. */
  124654. layerMask: number;
  124655. private _capacity;
  124656. private _activeCount;
  124657. private _currentActiveCount;
  124658. private _accumulatedCount;
  124659. private _renderEffect;
  124660. private _updateEffect;
  124661. private _buffer0;
  124662. private _buffer1;
  124663. private _spriteBuffer;
  124664. private _updateVAO;
  124665. private _renderVAO;
  124666. private _targetIndex;
  124667. private _sourceBuffer;
  124668. private _targetBuffer;
  124669. private _engine;
  124670. private _currentRenderId;
  124671. private _started;
  124672. private _stopped;
  124673. private _timeDelta;
  124674. private _randomTexture;
  124675. private _randomTexture2;
  124676. private _attributesStrideSize;
  124677. private _updateEffectOptions;
  124678. private _randomTextureSize;
  124679. private _actualFrame;
  124680. private readonly _rawTextureWidth;
  124681. /**
  124682. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124683. */
  124684. static readonly IsSupported: boolean;
  124685. /**
  124686. * An event triggered when the system is disposed.
  124687. */
  124688. onDisposeObservable: Observable<GPUParticleSystem>;
  124689. /**
  124690. * Gets the maximum number of particles active at the same time.
  124691. * @returns The max number of active particles.
  124692. */
  124693. getCapacity(): number;
  124694. /**
  124695. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124696. * to override the particles.
  124697. */
  124698. forceDepthWrite: boolean;
  124699. /**
  124700. * Gets or set the number of active particles
  124701. */
  124702. activeParticleCount: number;
  124703. private _preWarmDone;
  124704. /**
  124705. * Is this system ready to be used/rendered
  124706. * @return true if the system is ready
  124707. */
  124708. isReady(): boolean;
  124709. /**
  124710. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124711. * @returns True if it has been started, otherwise false.
  124712. */
  124713. isStarted(): boolean;
  124714. /**
  124715. * Starts the particle system and begins to emit
  124716. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124717. */
  124718. start(delay?: number): void;
  124719. /**
  124720. * Stops the particle system.
  124721. */
  124722. stop(): void;
  124723. /**
  124724. * Remove all active particles
  124725. */
  124726. reset(): void;
  124727. /**
  124728. * Returns the string "GPUParticleSystem"
  124729. * @returns a string containing the class name
  124730. */
  124731. getClassName(): string;
  124732. private _colorGradientsTexture;
  124733. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124734. /**
  124735. * Adds a new color gradient
  124736. * @param gradient defines the gradient to use (between 0 and 1)
  124737. * @param color1 defines the color to affect to the specified gradient
  124738. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124739. * @returns the current particle system
  124740. */
  124741. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124742. /**
  124743. * Remove a specific color gradient
  124744. * @param gradient defines the gradient to remove
  124745. * @returns the current particle system
  124746. */
  124747. removeColorGradient(gradient: number): GPUParticleSystem;
  124748. private _angularSpeedGradientsTexture;
  124749. private _sizeGradientsTexture;
  124750. private _velocityGradientsTexture;
  124751. private _limitVelocityGradientsTexture;
  124752. private _dragGradientsTexture;
  124753. private _addFactorGradient;
  124754. /**
  124755. * Adds a new size gradient
  124756. * @param gradient defines the gradient to use (between 0 and 1)
  124757. * @param factor defines the size factor to affect to the specified gradient
  124758. * @returns the current particle system
  124759. */
  124760. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124761. /**
  124762. * Remove a specific size gradient
  124763. * @param gradient defines the gradient to remove
  124764. * @returns the current particle system
  124765. */
  124766. removeSizeGradient(gradient: number): GPUParticleSystem;
  124767. /**
  124768. * Adds a new angular speed gradient
  124769. * @param gradient defines the gradient to use (between 0 and 1)
  124770. * @param factor defines the angular speed to affect to the specified gradient
  124771. * @returns the current particle system
  124772. */
  124773. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124774. /**
  124775. * Remove a specific angular speed gradient
  124776. * @param gradient defines the gradient to remove
  124777. * @returns the current particle system
  124778. */
  124779. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124780. /**
  124781. * Adds a new velocity gradient
  124782. * @param gradient defines the gradient to use (between 0 and 1)
  124783. * @param factor defines the velocity to affect to the specified gradient
  124784. * @returns the current particle system
  124785. */
  124786. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124787. /**
  124788. * Remove a specific velocity gradient
  124789. * @param gradient defines the gradient to remove
  124790. * @returns the current particle system
  124791. */
  124792. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124793. /**
  124794. * Adds a new limit velocity gradient
  124795. * @param gradient defines the gradient to use (between 0 and 1)
  124796. * @param factor defines the limit velocity value to affect to the specified gradient
  124797. * @returns the current particle system
  124798. */
  124799. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124800. /**
  124801. * Remove a specific limit velocity gradient
  124802. * @param gradient defines the gradient to remove
  124803. * @returns the current particle system
  124804. */
  124805. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124806. /**
  124807. * Adds a new drag gradient
  124808. * @param gradient defines the gradient to use (between 0 and 1)
  124809. * @param factor defines the drag value to affect to the specified gradient
  124810. * @returns the current particle system
  124811. */
  124812. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124813. /**
  124814. * Remove a specific drag gradient
  124815. * @param gradient defines the gradient to remove
  124816. * @returns the current particle system
  124817. */
  124818. removeDragGradient(gradient: number): GPUParticleSystem;
  124819. /**
  124820. * Not supported by GPUParticleSystem
  124821. * @param gradient defines the gradient to use (between 0 and 1)
  124822. * @param factor defines the emit rate value to affect to the specified gradient
  124823. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124824. * @returns the current particle system
  124825. */
  124826. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124827. /**
  124828. * Not supported by GPUParticleSystem
  124829. * @param gradient defines the gradient to remove
  124830. * @returns the current particle system
  124831. */
  124832. removeEmitRateGradient(gradient: number): IParticleSystem;
  124833. /**
  124834. * Not supported by GPUParticleSystem
  124835. * @param gradient defines the gradient to use (between 0 and 1)
  124836. * @param factor defines the start size value to affect to the specified gradient
  124837. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124838. * @returns the current particle system
  124839. */
  124840. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124841. /**
  124842. * Not supported by GPUParticleSystem
  124843. * @param gradient defines the gradient to remove
  124844. * @returns the current particle system
  124845. */
  124846. removeStartSizeGradient(gradient: number): IParticleSystem;
  124847. /**
  124848. * Not supported by GPUParticleSystem
  124849. * @param gradient defines the gradient to use (between 0 and 1)
  124850. * @param min defines the color remap minimal range
  124851. * @param max defines the color remap maximal range
  124852. * @returns the current particle system
  124853. */
  124854. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124855. /**
  124856. * Not supported by GPUParticleSystem
  124857. * @param gradient defines the gradient to remove
  124858. * @returns the current particle system
  124859. */
  124860. removeColorRemapGradient(): IParticleSystem;
  124861. /**
  124862. * Not supported by GPUParticleSystem
  124863. * @param gradient defines the gradient to use (between 0 and 1)
  124864. * @param min defines the alpha remap minimal range
  124865. * @param max defines the alpha remap maximal range
  124866. * @returns the current particle system
  124867. */
  124868. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124869. /**
  124870. * Not supported by GPUParticleSystem
  124871. * @param gradient defines the gradient to remove
  124872. * @returns the current particle system
  124873. */
  124874. removeAlphaRemapGradient(): IParticleSystem;
  124875. /**
  124876. * Not supported by GPUParticleSystem
  124877. * @param gradient defines the gradient to use (between 0 and 1)
  124878. * @param color defines the color to affect to the specified gradient
  124879. * @returns the current particle system
  124880. */
  124881. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124882. /**
  124883. * Not supported by GPUParticleSystem
  124884. * @param gradient defines the gradient to remove
  124885. * @returns the current particle system
  124886. */
  124887. removeRampGradient(): IParticleSystem;
  124888. /**
  124889. * Not supported by GPUParticleSystem
  124890. * @returns the list of ramp gradients
  124891. */
  124892. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124893. /**
  124894. * Not supported by GPUParticleSystem
  124895. * Gets or sets a boolean indicating that ramp gradients must be used
  124896. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124897. */
  124898. useRampGradients: boolean;
  124899. /**
  124900. * Not supported by GPUParticleSystem
  124901. * @param gradient defines the gradient to use (between 0 and 1)
  124902. * @param factor defines the life time factor to affect to the specified gradient
  124903. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124904. * @returns the current particle system
  124905. */
  124906. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124907. /**
  124908. * Not supported by GPUParticleSystem
  124909. * @param gradient defines the gradient to remove
  124910. * @returns the current particle system
  124911. */
  124912. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124913. /**
  124914. * Instantiates a GPU particle system.
  124915. * 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.
  124916. * @param name The name of the particle system
  124917. * @param options The options used to create the system
  124918. * @param scene The scene the particle system belongs to
  124919. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124920. */
  124921. constructor(name: string, options: Partial<{
  124922. capacity: number;
  124923. randomTextureSize: number;
  124924. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124925. protected _reset(): void;
  124926. private _createUpdateVAO;
  124927. private _createRenderVAO;
  124928. private _initialize;
  124929. /** @hidden */
  124930. _recreateUpdateEffect(): void;
  124931. /** @hidden */
  124932. _recreateRenderEffect(): void;
  124933. /**
  124934. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124935. * @param preWarm defines if we are in the pre-warmimg phase
  124936. */
  124937. animate(preWarm?: boolean): void;
  124938. private _createFactorGradientTexture;
  124939. private _createSizeGradientTexture;
  124940. private _createAngularSpeedGradientTexture;
  124941. private _createVelocityGradientTexture;
  124942. private _createLimitVelocityGradientTexture;
  124943. private _createDragGradientTexture;
  124944. private _createColorGradientTexture;
  124945. /**
  124946. * Renders the particle system in its current state
  124947. * @param preWarm defines if the system should only update the particles but not render them
  124948. * @returns the current number of particles
  124949. */
  124950. render(preWarm?: boolean): number;
  124951. /**
  124952. * Rebuilds the particle system
  124953. */
  124954. rebuild(): void;
  124955. private _releaseBuffers;
  124956. private _releaseVAOs;
  124957. /**
  124958. * Disposes the particle system and free the associated resources
  124959. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124960. */
  124961. dispose(disposeTexture?: boolean): void;
  124962. /**
  124963. * Clones the particle system.
  124964. * @param name The name of the cloned object
  124965. * @param newEmitter The new emitter to use
  124966. * @returns the cloned particle system
  124967. */
  124968. clone(name: string, newEmitter: any): GPUParticleSystem;
  124969. /**
  124970. * Serializes the particle system to a JSON object.
  124971. * @returns the JSON object
  124972. */
  124973. serialize(): any;
  124974. /**
  124975. * Parses a JSON object to create a GPU particle system.
  124976. * @param parsedParticleSystem The JSON object to parse
  124977. * @param scene The scene to create the particle system in
  124978. * @param rootUrl The root url to use to load external dependencies like texture
  124979. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124980. * @returns the parsed GPU particle system
  124981. */
  124982. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124983. }
  124984. }
  124985. declare module BABYLON {
  124986. /**
  124987. * Represents a set of particle systems working together to create a specific effect
  124988. */
  124989. export class ParticleSystemSet implements IDisposable {
  124990. private _emitterCreationOptions;
  124991. private _emitterNode;
  124992. /**
  124993. * Gets the particle system list
  124994. */
  124995. systems: IParticleSystem[];
  124996. /**
  124997. * Gets the emitter node used with this set
  124998. */
  124999. readonly emitterNode: Nullable<TransformNode>;
  125000. /**
  125001. * Creates a new emitter mesh as a sphere
  125002. * @param options defines the options used to create the sphere
  125003. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  125004. * @param scene defines the hosting scene
  125005. */
  125006. setEmitterAsSphere(options: {
  125007. diameter: number;
  125008. segments: number;
  125009. color: Color3;
  125010. }, renderingGroupId: number, scene: Scene): void;
  125011. /**
  125012. * Starts all particle systems of the set
  125013. * @param emitter defines an optional mesh to use as emitter for the particle systems
  125014. */
  125015. start(emitter?: AbstractMesh): void;
  125016. /**
  125017. * Release all associated resources
  125018. */
  125019. dispose(): void;
  125020. /**
  125021. * Serialize the set into a JSON compatible object
  125022. * @returns a JSON compatible representation of the set
  125023. */
  125024. serialize(): any;
  125025. /**
  125026. * Parse a new ParticleSystemSet from a serialized source
  125027. * @param data defines a JSON compatible representation of the set
  125028. * @param scene defines the hosting scene
  125029. * @param gpu defines if we want GPU particles or CPU particles
  125030. * @returns a new ParticleSystemSet
  125031. */
  125032. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  125033. }
  125034. }
  125035. declare module BABYLON {
  125036. /**
  125037. * This class is made for on one-liner static method to help creating particle system set.
  125038. */
  125039. export class ParticleHelper {
  125040. /**
  125041. * Gets or sets base Assets URL
  125042. */
  125043. static BaseAssetsUrl: string;
  125044. /**
  125045. * Create a default particle system that you can tweak
  125046. * @param emitter defines the emitter to use
  125047. * @param capacity defines the system capacity (default is 500 particles)
  125048. * @param scene defines the hosting scene
  125049. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  125050. * @returns the new Particle system
  125051. */
  125052. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  125053. /**
  125054. * This is the main static method (one-liner) of this helper to create different particle systems
  125055. * @param type This string represents the type to the particle system to create
  125056. * @param scene The scene where the particle system should live
  125057. * @param gpu If the system will use gpu
  125058. * @returns the ParticleSystemSet created
  125059. */
  125060. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  125061. /**
  125062. * Static function used to export a particle system to a ParticleSystemSet variable.
  125063. * Please note that the emitter shape is not exported
  125064. * @param systems defines the particle systems to export
  125065. * @returns the created particle system set
  125066. */
  125067. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  125068. }
  125069. }
  125070. declare module BABYLON {
  125071. interface Engine {
  125072. /**
  125073. * Create an effect to use with particle systems.
  125074. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  125075. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  125076. * @param uniformsNames defines a list of attribute names
  125077. * @param samplers defines an array of string used to represent textures
  125078. * @param defines defines the string containing the defines to use to compile the shaders
  125079. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  125080. * @param onCompiled defines a function to call when the effect creation is successful
  125081. * @param onError defines a function to call when the effect creation has failed
  125082. * @returns the new Effect
  125083. */
  125084. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  125085. }
  125086. interface Mesh {
  125087. /**
  125088. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  125089. * @returns an array of IParticleSystem
  125090. */
  125091. getEmittedParticleSystems(): IParticleSystem[];
  125092. /**
  125093. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  125094. * @returns an array of IParticleSystem
  125095. */
  125096. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  125097. }
  125098. /**
  125099. * @hidden
  125100. */
  125101. export var _IDoNeedToBeInTheBuild: number;
  125102. }
  125103. declare module BABYLON {
  125104. interface Scene {
  125105. /** @hidden (Backing field) */
  125106. _physicsEngine: Nullable<IPhysicsEngine>;
  125107. /**
  125108. * Gets the current physics engine
  125109. * @returns a IPhysicsEngine or null if none attached
  125110. */
  125111. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  125112. /**
  125113. * Enables physics to the current scene
  125114. * @param gravity defines the scene's gravity for the physics engine
  125115. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  125116. * @return a boolean indicating if the physics engine was initialized
  125117. */
  125118. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  125119. /**
  125120. * Disables and disposes the physics engine associated with the scene
  125121. */
  125122. disablePhysicsEngine(): void;
  125123. /**
  125124. * Gets a boolean indicating if there is an active physics engine
  125125. * @returns a boolean indicating if there is an active physics engine
  125126. */
  125127. isPhysicsEnabled(): boolean;
  125128. /**
  125129. * Deletes a physics compound impostor
  125130. * @param compound defines the compound to delete
  125131. */
  125132. deleteCompoundImpostor(compound: any): void;
  125133. /**
  125134. * An event triggered when physic simulation is about to be run
  125135. */
  125136. onBeforePhysicsObservable: Observable<Scene>;
  125137. /**
  125138. * An event triggered when physic simulation has been done
  125139. */
  125140. onAfterPhysicsObservable: Observable<Scene>;
  125141. }
  125142. interface AbstractMesh {
  125143. /** @hidden */
  125144. _physicsImpostor: Nullable<PhysicsImpostor>;
  125145. /**
  125146. * Gets or sets impostor used for physic simulation
  125147. * @see http://doc.babylonjs.com/features/physics_engine
  125148. */
  125149. physicsImpostor: Nullable<PhysicsImpostor>;
  125150. /**
  125151. * Gets the current physics impostor
  125152. * @see http://doc.babylonjs.com/features/physics_engine
  125153. * @returns a physics impostor or null
  125154. */
  125155. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  125156. /** Apply a physic impulse to the mesh
  125157. * @param force defines the force to apply
  125158. * @param contactPoint defines where to apply the force
  125159. * @returns the current mesh
  125160. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125161. */
  125162. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  125163. /**
  125164. * Creates a physic joint between two meshes
  125165. * @param otherMesh defines the other mesh to use
  125166. * @param pivot1 defines the pivot to use on this mesh
  125167. * @param pivot2 defines the pivot to use on the other mesh
  125168. * @param options defines additional options (can be plugin dependent)
  125169. * @returns the current mesh
  125170. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  125171. */
  125172. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  125173. /** @hidden */
  125174. _disposePhysicsObserver: Nullable<Observer<Node>>;
  125175. }
  125176. /**
  125177. * Defines the physics engine scene component responsible to manage a physics engine
  125178. */
  125179. export class PhysicsEngineSceneComponent implements ISceneComponent {
  125180. /**
  125181. * The component name helpful to identify the component in the list of scene components.
  125182. */
  125183. readonly name: string;
  125184. /**
  125185. * The scene the component belongs to.
  125186. */
  125187. scene: Scene;
  125188. /**
  125189. * Creates a new instance of the component for the given scene
  125190. * @param scene Defines the scene to register the component in
  125191. */
  125192. constructor(scene: Scene);
  125193. /**
  125194. * Registers the component in a given scene
  125195. */
  125196. register(): void;
  125197. /**
  125198. * Rebuilds the elements related to this component in case of
  125199. * context lost for instance.
  125200. */
  125201. rebuild(): void;
  125202. /**
  125203. * Disposes the component and the associated ressources
  125204. */
  125205. dispose(): void;
  125206. }
  125207. }
  125208. declare module BABYLON {
  125209. /**
  125210. * A helper for physics simulations
  125211. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125212. */
  125213. export class PhysicsHelper {
  125214. private _scene;
  125215. private _physicsEngine;
  125216. /**
  125217. * Initializes the Physics helper
  125218. * @param scene Babylon.js scene
  125219. */
  125220. constructor(scene: Scene);
  125221. /**
  125222. * Applies a radial explosion impulse
  125223. * @param origin the origin of the explosion
  125224. * @param radiusOrEventOptions the radius or the options of radial explosion
  125225. * @param strength the explosion strength
  125226. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125227. * @returns A physics radial explosion event, or null
  125228. */
  125229. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125230. /**
  125231. * Applies a radial explosion force
  125232. * @param origin the origin of the explosion
  125233. * @param radiusOrEventOptions the radius or the options of radial explosion
  125234. * @param strength the explosion strength
  125235. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125236. * @returns A physics radial explosion event, or null
  125237. */
  125238. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125239. /**
  125240. * Creates a gravitational field
  125241. * @param origin the origin of the explosion
  125242. * @param radiusOrEventOptions the radius or the options of radial explosion
  125243. * @param strength the explosion strength
  125244. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125245. * @returns A physics gravitational field event, or null
  125246. */
  125247. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125248. /**
  125249. * Creates a physics updraft event
  125250. * @param origin the origin of the updraft
  125251. * @param radiusOrEventOptions the radius or the options of the updraft
  125252. * @param strength the strength of the updraft
  125253. * @param height the height of the updraft
  125254. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125255. * @returns A physics updraft event, or null
  125256. */
  125257. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125258. /**
  125259. * Creates a physics vortex event
  125260. * @param origin the of the vortex
  125261. * @param radiusOrEventOptions the radius or the options of the vortex
  125262. * @param strength the strength of the vortex
  125263. * @param height the height of the vortex
  125264. * @returns a Physics vortex event, or null
  125265. * A physics vortex event or null
  125266. */
  125267. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125268. }
  125269. /**
  125270. * Represents a physics radial explosion event
  125271. */
  125272. class PhysicsRadialExplosionEvent {
  125273. private _scene;
  125274. private _options;
  125275. private _sphere;
  125276. private _dataFetched;
  125277. /**
  125278. * Initializes a radial explosioin event
  125279. * @param _scene BabylonJS scene
  125280. * @param _options The options for the vortex event
  125281. */
  125282. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125283. /**
  125284. * Returns the data related to the radial explosion event (sphere).
  125285. * @returns The radial explosion event data
  125286. */
  125287. getData(): PhysicsRadialExplosionEventData;
  125288. /**
  125289. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125290. * @param impostor A physics imposter
  125291. * @param origin the origin of the explosion
  125292. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125293. */
  125294. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125295. /**
  125296. * Triggers affecterd impostors callbacks
  125297. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125298. */
  125299. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125300. /**
  125301. * Disposes the sphere.
  125302. * @param force Specifies if the sphere should be disposed by force
  125303. */
  125304. dispose(force?: boolean): void;
  125305. /*** Helpers ***/
  125306. private _prepareSphere;
  125307. private _intersectsWithSphere;
  125308. }
  125309. /**
  125310. * Represents a gravitational field event
  125311. */
  125312. class PhysicsGravitationalFieldEvent {
  125313. private _physicsHelper;
  125314. private _scene;
  125315. private _origin;
  125316. private _options;
  125317. private _tickCallback;
  125318. private _sphere;
  125319. private _dataFetched;
  125320. /**
  125321. * Initializes the physics gravitational field event
  125322. * @param _physicsHelper A physics helper
  125323. * @param _scene BabylonJS scene
  125324. * @param _origin The origin position of the gravitational field event
  125325. * @param _options The options for the vortex event
  125326. */
  125327. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125328. /**
  125329. * Returns the data related to the gravitational field event (sphere).
  125330. * @returns A gravitational field event
  125331. */
  125332. getData(): PhysicsGravitationalFieldEventData;
  125333. /**
  125334. * Enables the gravitational field.
  125335. */
  125336. enable(): void;
  125337. /**
  125338. * Disables the gravitational field.
  125339. */
  125340. disable(): void;
  125341. /**
  125342. * Disposes the sphere.
  125343. * @param force The force to dispose from the gravitational field event
  125344. */
  125345. dispose(force?: boolean): void;
  125346. private _tick;
  125347. }
  125348. /**
  125349. * Represents a physics updraft event
  125350. */
  125351. class PhysicsUpdraftEvent {
  125352. private _scene;
  125353. private _origin;
  125354. private _options;
  125355. private _physicsEngine;
  125356. private _originTop;
  125357. private _originDirection;
  125358. private _tickCallback;
  125359. private _cylinder;
  125360. private _cylinderPosition;
  125361. private _dataFetched;
  125362. /**
  125363. * Initializes the physics updraft event
  125364. * @param _scene BabylonJS scene
  125365. * @param _origin The origin position of the updraft
  125366. * @param _options The options for the updraft event
  125367. */
  125368. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125369. /**
  125370. * Returns the data related to the updraft event (cylinder).
  125371. * @returns A physics updraft event
  125372. */
  125373. getData(): PhysicsUpdraftEventData;
  125374. /**
  125375. * Enables the updraft.
  125376. */
  125377. enable(): void;
  125378. /**
  125379. * Disables the updraft.
  125380. */
  125381. disable(): void;
  125382. /**
  125383. * Disposes the cylinder.
  125384. * @param force Specifies if the updraft should be disposed by force
  125385. */
  125386. dispose(force?: boolean): void;
  125387. private getImpostorHitData;
  125388. private _tick;
  125389. /*** Helpers ***/
  125390. private _prepareCylinder;
  125391. private _intersectsWithCylinder;
  125392. }
  125393. /**
  125394. * Represents a physics vortex event
  125395. */
  125396. class PhysicsVortexEvent {
  125397. private _scene;
  125398. private _origin;
  125399. private _options;
  125400. private _physicsEngine;
  125401. private _originTop;
  125402. private _tickCallback;
  125403. private _cylinder;
  125404. private _cylinderPosition;
  125405. private _dataFetched;
  125406. /**
  125407. * Initializes the physics vortex event
  125408. * @param _scene The BabylonJS scene
  125409. * @param _origin The origin position of the vortex
  125410. * @param _options The options for the vortex event
  125411. */
  125412. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125413. /**
  125414. * Returns the data related to the vortex event (cylinder).
  125415. * @returns The physics vortex event data
  125416. */
  125417. getData(): PhysicsVortexEventData;
  125418. /**
  125419. * Enables the vortex.
  125420. */
  125421. enable(): void;
  125422. /**
  125423. * Disables the cortex.
  125424. */
  125425. disable(): void;
  125426. /**
  125427. * Disposes the sphere.
  125428. * @param force
  125429. */
  125430. dispose(force?: boolean): void;
  125431. private getImpostorHitData;
  125432. private _tick;
  125433. /*** Helpers ***/
  125434. private _prepareCylinder;
  125435. private _intersectsWithCylinder;
  125436. }
  125437. /**
  125438. * Options fot the radial explosion event
  125439. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125440. */
  125441. export class PhysicsRadialExplosionEventOptions {
  125442. /**
  125443. * The radius of the sphere for the radial explosion.
  125444. */
  125445. radius: number;
  125446. /**
  125447. * The strenth of the explosion.
  125448. */
  125449. strength: number;
  125450. /**
  125451. * The strenght of the force in correspondence to the distance of the affected object
  125452. */
  125453. falloff: PhysicsRadialImpulseFalloff;
  125454. /**
  125455. * Sphere options for the radial explosion.
  125456. */
  125457. sphere: {
  125458. segments: number;
  125459. diameter: number;
  125460. };
  125461. /**
  125462. * Sphere options for the radial explosion.
  125463. */
  125464. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125465. }
  125466. /**
  125467. * Options fot the updraft event
  125468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125469. */
  125470. export class PhysicsUpdraftEventOptions {
  125471. /**
  125472. * The radius of the cylinder for the vortex
  125473. */
  125474. radius: number;
  125475. /**
  125476. * The strenth of the updraft.
  125477. */
  125478. strength: number;
  125479. /**
  125480. * The height of the cylinder for the updraft.
  125481. */
  125482. height: number;
  125483. /**
  125484. * The mode for the the updraft.
  125485. */
  125486. updraftMode: PhysicsUpdraftMode;
  125487. }
  125488. /**
  125489. * Options fot the vortex event
  125490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125491. */
  125492. export class PhysicsVortexEventOptions {
  125493. /**
  125494. * The radius of the cylinder for the vortex
  125495. */
  125496. radius: number;
  125497. /**
  125498. * The strenth of the vortex.
  125499. */
  125500. strength: number;
  125501. /**
  125502. * The height of the cylinder for the vortex.
  125503. */
  125504. height: number;
  125505. /**
  125506. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125507. */
  125508. centripetalForceThreshold: number;
  125509. /**
  125510. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125511. */
  125512. centripetalForceMultiplier: number;
  125513. /**
  125514. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125515. */
  125516. centrifugalForceMultiplier: number;
  125517. /**
  125518. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125519. */
  125520. updraftForceMultiplier: number;
  125521. }
  125522. /**
  125523. * The strenght of the force in correspondence to the distance of the affected object
  125524. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125525. */
  125526. export enum PhysicsRadialImpulseFalloff {
  125527. /** Defines that impulse is constant in strength across it's whole radius */
  125528. Constant = 0,
  125529. /** Defines that impulse gets weaker if it's further from the origin */
  125530. Linear = 1
  125531. }
  125532. /**
  125533. * The strength of the force in correspondence to the distance of the affected object
  125534. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125535. */
  125536. export enum PhysicsUpdraftMode {
  125537. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125538. Center = 0,
  125539. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125540. Perpendicular = 1
  125541. }
  125542. /**
  125543. * Interface for a physics hit data
  125544. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125545. */
  125546. export interface PhysicsHitData {
  125547. /**
  125548. * The force applied at the contact point
  125549. */
  125550. force: Vector3;
  125551. /**
  125552. * The contact point
  125553. */
  125554. contactPoint: Vector3;
  125555. /**
  125556. * The distance from the origin to the contact point
  125557. */
  125558. distanceFromOrigin: number;
  125559. }
  125560. /**
  125561. * Interface for radial explosion event data
  125562. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125563. */
  125564. export interface PhysicsRadialExplosionEventData {
  125565. /**
  125566. * A sphere used for the radial explosion event
  125567. */
  125568. sphere: Mesh;
  125569. }
  125570. /**
  125571. * Interface for gravitational field event data
  125572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125573. */
  125574. export interface PhysicsGravitationalFieldEventData {
  125575. /**
  125576. * A sphere mesh used for the gravitational field event
  125577. */
  125578. sphere: Mesh;
  125579. }
  125580. /**
  125581. * Interface for updraft event data
  125582. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125583. */
  125584. export interface PhysicsUpdraftEventData {
  125585. /**
  125586. * A cylinder used for the updraft event
  125587. */
  125588. cylinder: Mesh;
  125589. }
  125590. /**
  125591. * Interface for vortex event data
  125592. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125593. */
  125594. export interface PhysicsVortexEventData {
  125595. /**
  125596. * A cylinder used for the vortex event
  125597. */
  125598. cylinder: Mesh;
  125599. }
  125600. /**
  125601. * Interface for an affected physics impostor
  125602. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125603. */
  125604. export interface PhysicsAffectedImpostorWithData {
  125605. /**
  125606. * The impostor affected by the effect
  125607. */
  125608. impostor: PhysicsImpostor;
  125609. /**
  125610. * The data about the hit/horce from the explosion
  125611. */
  125612. hitData: PhysicsHitData;
  125613. }
  125614. }
  125615. declare module BABYLON {
  125616. /** @hidden */
  125617. export var blackAndWhitePixelShader: {
  125618. name: string;
  125619. shader: string;
  125620. };
  125621. }
  125622. declare module BABYLON {
  125623. /**
  125624. * Post process used to render in black and white
  125625. */
  125626. export class BlackAndWhitePostProcess extends PostProcess {
  125627. /**
  125628. * Linear about to convert he result to black and white (default: 1)
  125629. */
  125630. degree: number;
  125631. /**
  125632. * Creates a black and white post process
  125633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125634. * @param name The name of the effect.
  125635. * @param options The required width/height ratio to downsize to before computing the render pass.
  125636. * @param camera The camera to apply the render pass to.
  125637. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125638. * @param engine The engine which the post process will be applied. (default: current engine)
  125639. * @param reusable If the post process can be reused on the same frame. (default: false)
  125640. */
  125641. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125642. }
  125643. }
  125644. declare module BABYLON {
  125645. /**
  125646. * This represents a set of one or more post processes in Babylon.
  125647. * A post process can be used to apply a shader to a texture after it is rendered.
  125648. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125649. */
  125650. export class PostProcessRenderEffect {
  125651. private _postProcesses;
  125652. private _getPostProcesses;
  125653. private _singleInstance;
  125654. private _cameras;
  125655. private _indicesForCamera;
  125656. /**
  125657. * Name of the effect
  125658. * @hidden
  125659. */
  125660. _name: string;
  125661. /**
  125662. * Instantiates a post process render effect.
  125663. * A post process can be used to apply a shader to a texture after it is rendered.
  125664. * @param engine The engine the effect is tied to
  125665. * @param name The name of the effect
  125666. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125667. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125668. */
  125669. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125670. /**
  125671. * Checks if all the post processes in the effect are supported.
  125672. */
  125673. readonly isSupported: boolean;
  125674. /**
  125675. * Updates the current state of the effect
  125676. * @hidden
  125677. */
  125678. _update(): void;
  125679. /**
  125680. * Attaches the effect on cameras
  125681. * @param cameras The camera to attach to.
  125682. * @hidden
  125683. */
  125684. _attachCameras(cameras: Camera): void;
  125685. /**
  125686. * Attaches the effect on cameras
  125687. * @param cameras The camera to attach to.
  125688. * @hidden
  125689. */
  125690. _attachCameras(cameras: Camera[]): void;
  125691. /**
  125692. * Detaches the effect on cameras
  125693. * @param cameras The camera to detatch from.
  125694. * @hidden
  125695. */
  125696. _detachCameras(cameras: Camera): void;
  125697. /**
  125698. * Detatches the effect on cameras
  125699. * @param cameras The camera to detatch from.
  125700. * @hidden
  125701. */
  125702. _detachCameras(cameras: Camera[]): void;
  125703. /**
  125704. * Enables the effect on given cameras
  125705. * @param cameras The camera to enable.
  125706. * @hidden
  125707. */
  125708. _enable(cameras: Camera): void;
  125709. /**
  125710. * Enables the effect on given cameras
  125711. * @param cameras The camera to enable.
  125712. * @hidden
  125713. */
  125714. _enable(cameras: Nullable<Camera[]>): void;
  125715. /**
  125716. * Disables the effect on the given cameras
  125717. * @param cameras The camera to disable.
  125718. * @hidden
  125719. */
  125720. _disable(cameras: Camera): void;
  125721. /**
  125722. * Disables the effect on the given cameras
  125723. * @param cameras The camera to disable.
  125724. * @hidden
  125725. */
  125726. _disable(cameras: Nullable<Camera[]>): void;
  125727. /**
  125728. * Gets a list of the post processes contained in the effect.
  125729. * @param camera The camera to get the post processes on.
  125730. * @returns The list of the post processes in the effect.
  125731. */
  125732. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125733. }
  125734. }
  125735. declare module BABYLON {
  125736. /** @hidden */
  125737. export var extractHighlightsPixelShader: {
  125738. name: string;
  125739. shader: string;
  125740. };
  125741. }
  125742. declare module BABYLON {
  125743. /**
  125744. * 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.
  125745. */
  125746. export class ExtractHighlightsPostProcess extends PostProcess {
  125747. /**
  125748. * The luminance threshold, pixels below this value will be set to black.
  125749. */
  125750. threshold: number;
  125751. /** @hidden */
  125752. _exposure: number;
  125753. /**
  125754. * Post process which has the input texture to be used when performing highlight extraction
  125755. * @hidden
  125756. */
  125757. _inputPostProcess: Nullable<PostProcess>;
  125758. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125759. }
  125760. }
  125761. declare module BABYLON {
  125762. /** @hidden */
  125763. export var bloomMergePixelShader: {
  125764. name: string;
  125765. shader: string;
  125766. };
  125767. }
  125768. declare module BABYLON {
  125769. /**
  125770. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125771. */
  125772. export class BloomMergePostProcess extends PostProcess {
  125773. /** Weight of the bloom to be added to the original input. */
  125774. weight: number;
  125775. /**
  125776. * Creates a new instance of @see BloomMergePostProcess
  125777. * @param name The name of the effect.
  125778. * @param originalFromInput Post process which's input will be used for the merge.
  125779. * @param blurred Blurred highlights post process which's output will be used.
  125780. * @param weight Weight of the bloom to be added to the original input.
  125781. * @param options The required width/height ratio to downsize to before computing the render pass.
  125782. * @param camera The camera to apply the render pass to.
  125783. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125784. * @param engine The engine which the post process will be applied. (default: current engine)
  125785. * @param reusable If the post process can be reused on the same frame. (default: false)
  125786. * @param textureType Type of textures used when performing the post process. (default: 0)
  125787. * @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)
  125788. */
  125789. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125790. /** Weight of the bloom to be added to the original input. */
  125791. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125792. }
  125793. }
  125794. declare module BABYLON {
  125795. /**
  125796. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125797. */
  125798. export class BloomEffect extends PostProcessRenderEffect {
  125799. private bloomScale;
  125800. /**
  125801. * @hidden Internal
  125802. */
  125803. _effects: Array<PostProcess>;
  125804. /**
  125805. * @hidden Internal
  125806. */
  125807. _downscale: ExtractHighlightsPostProcess;
  125808. private _blurX;
  125809. private _blurY;
  125810. private _merge;
  125811. /**
  125812. * The luminance threshold to find bright areas of the image to bloom.
  125813. */
  125814. threshold: number;
  125815. /**
  125816. * The strength of the bloom.
  125817. */
  125818. weight: number;
  125819. /**
  125820. * Specifies the size of the bloom blur kernel, relative to the final output size
  125821. */
  125822. kernel: number;
  125823. /**
  125824. * Creates a new instance of @see BloomEffect
  125825. * @param scene The scene the effect belongs to.
  125826. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125827. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125828. * @param bloomWeight The the strength of bloom.
  125829. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125830. * @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)
  125831. */
  125832. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125833. /**
  125834. * Disposes each of the internal effects for a given camera.
  125835. * @param camera The camera to dispose the effect on.
  125836. */
  125837. disposeEffects(camera: Camera): void;
  125838. /**
  125839. * @hidden Internal
  125840. */
  125841. _updateEffects(): void;
  125842. /**
  125843. * Internal
  125844. * @returns if all the contained post processes are ready.
  125845. * @hidden
  125846. */
  125847. _isReady(): boolean;
  125848. }
  125849. }
  125850. declare module BABYLON {
  125851. /** @hidden */
  125852. export var chromaticAberrationPixelShader: {
  125853. name: string;
  125854. shader: string;
  125855. };
  125856. }
  125857. declare module BABYLON {
  125858. /**
  125859. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125860. */
  125861. export class ChromaticAberrationPostProcess extends PostProcess {
  125862. /**
  125863. * The amount of seperation of rgb channels (default: 30)
  125864. */
  125865. aberrationAmount: number;
  125866. /**
  125867. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125868. */
  125869. radialIntensity: number;
  125870. /**
  125871. * 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))
  125872. */
  125873. direction: Vector2;
  125874. /**
  125875. * 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))
  125876. */
  125877. centerPosition: Vector2;
  125878. /**
  125879. * Creates a new instance ChromaticAberrationPostProcess
  125880. * @param name The name of the effect.
  125881. * @param screenWidth The width of the screen to apply the effect on.
  125882. * @param screenHeight The height of the screen to apply the effect on.
  125883. * @param options The required width/height ratio to downsize to before computing the render pass.
  125884. * @param camera The camera to apply the render pass to.
  125885. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125886. * @param engine The engine which the post process will be applied. (default: current engine)
  125887. * @param reusable If the post process can be reused on the same frame. (default: false)
  125888. * @param textureType Type of textures used when performing the post process. (default: 0)
  125889. * @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)
  125890. */
  125891. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125892. }
  125893. }
  125894. declare module BABYLON {
  125895. /** @hidden */
  125896. export var circleOfConfusionPixelShader: {
  125897. name: string;
  125898. shader: string;
  125899. };
  125900. }
  125901. declare module BABYLON {
  125902. /**
  125903. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125904. */
  125905. export class CircleOfConfusionPostProcess extends PostProcess {
  125906. /**
  125907. * 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.
  125908. */
  125909. lensSize: number;
  125910. /**
  125911. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125912. */
  125913. fStop: number;
  125914. /**
  125915. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125916. */
  125917. focusDistance: number;
  125918. /**
  125919. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125920. */
  125921. focalLength: number;
  125922. private _depthTexture;
  125923. /**
  125924. * Creates a new instance CircleOfConfusionPostProcess
  125925. * @param name The name of the effect.
  125926. * @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.
  125927. * @param options The required width/height ratio to downsize to before computing the render pass.
  125928. * @param camera The camera to apply the render pass to.
  125929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125930. * @param engine The engine which the post process will be applied. (default: current engine)
  125931. * @param reusable If the post process can be reused on the same frame. (default: false)
  125932. * @param textureType Type of textures used when performing the post process. (default: 0)
  125933. * @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)
  125934. */
  125935. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125936. /**
  125937. * 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.
  125938. */
  125939. depthTexture: RenderTargetTexture;
  125940. }
  125941. }
  125942. declare module BABYLON {
  125943. /** @hidden */
  125944. export var colorCorrectionPixelShader: {
  125945. name: string;
  125946. shader: string;
  125947. };
  125948. }
  125949. declare module BABYLON {
  125950. /**
  125951. *
  125952. * This post-process allows the modification of rendered colors by using
  125953. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125954. *
  125955. * The object needs to be provided an url to a texture containing the color
  125956. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125957. * Use an image editing software to tweak the LUT to match your needs.
  125958. *
  125959. * For an example of a color LUT, see here:
  125960. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125961. * For explanations on color grading, see here:
  125962. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125963. *
  125964. */
  125965. export class ColorCorrectionPostProcess extends PostProcess {
  125966. private _colorTableTexture;
  125967. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125968. }
  125969. }
  125970. declare module BABYLON {
  125971. /** @hidden */
  125972. export var convolutionPixelShader: {
  125973. name: string;
  125974. shader: string;
  125975. };
  125976. }
  125977. declare module BABYLON {
  125978. /**
  125979. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125980. * input texture to perform effects such as edge detection or sharpening
  125981. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125982. */
  125983. export class ConvolutionPostProcess extends PostProcess {
  125984. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125985. kernel: number[];
  125986. /**
  125987. * Creates a new instance ConvolutionPostProcess
  125988. * @param name The name of the effect.
  125989. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125990. * @param options The required width/height ratio to downsize to before computing the render pass.
  125991. * @param camera The camera to apply the render pass to.
  125992. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125993. * @param engine The engine which the post process will be applied. (default: current engine)
  125994. * @param reusable If the post process can be reused on the same frame. (default: false)
  125995. * @param textureType Type of textures used when performing the post process. (default: 0)
  125996. */
  125997. constructor(name: string,
  125998. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125999. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126000. /**
  126001. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126002. */
  126003. static EdgeDetect0Kernel: number[];
  126004. /**
  126005. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126006. */
  126007. static EdgeDetect1Kernel: number[];
  126008. /**
  126009. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126010. */
  126011. static EdgeDetect2Kernel: number[];
  126012. /**
  126013. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126014. */
  126015. static SharpenKernel: number[];
  126016. /**
  126017. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126018. */
  126019. static EmbossKernel: number[];
  126020. /**
  126021. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  126022. */
  126023. static GaussianKernel: number[];
  126024. }
  126025. }
  126026. declare module BABYLON {
  126027. /**
  126028. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  126029. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  126030. * based on samples that have a large difference in distance than the center pixel.
  126031. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  126032. */
  126033. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  126034. direction: Vector2;
  126035. /**
  126036. * Creates a new instance CircleOfConfusionPostProcess
  126037. * @param name The name of the effect.
  126038. * @param scene The scene the effect belongs to.
  126039. * @param direction The direction the blur should be applied.
  126040. * @param kernel The size of the kernel used to blur.
  126041. * @param options The required width/height ratio to downsize to before computing the render pass.
  126042. * @param camera The camera to apply the render pass to.
  126043. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  126044. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  126045. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126046. * @param engine The engine which the post process will be applied. (default: current engine)
  126047. * @param reusable If the post process can be reused on the same frame. (default: false)
  126048. * @param textureType Type of textures used when performing the post process. (default: 0)
  126049. * @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)
  126050. */
  126051. 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);
  126052. }
  126053. }
  126054. declare module BABYLON {
  126055. /** @hidden */
  126056. export var depthOfFieldMergePixelShader: {
  126057. name: string;
  126058. shader: string;
  126059. };
  126060. }
  126061. declare module BABYLON {
  126062. /**
  126063. * Options to be set when merging outputs from the default pipeline.
  126064. */
  126065. export class DepthOfFieldMergePostProcessOptions {
  126066. /**
  126067. * The original image to merge on top of
  126068. */
  126069. originalFromInput: PostProcess;
  126070. /**
  126071. * Parameters to perform the merge of the depth of field effect
  126072. */
  126073. depthOfField?: {
  126074. circleOfConfusion: PostProcess;
  126075. blurSteps: Array<PostProcess>;
  126076. };
  126077. /**
  126078. * Parameters to perform the merge of bloom effect
  126079. */
  126080. bloom?: {
  126081. blurred: PostProcess;
  126082. weight: number;
  126083. };
  126084. }
  126085. /**
  126086. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  126087. */
  126088. export class DepthOfFieldMergePostProcess extends PostProcess {
  126089. private blurSteps;
  126090. /**
  126091. * Creates a new instance of DepthOfFieldMergePostProcess
  126092. * @param name The name of the effect.
  126093. * @param originalFromInput Post process which's input will be used for the merge.
  126094. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  126095. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  126096. * @param options The required width/height ratio to downsize to before computing the render pass.
  126097. * @param camera The camera to apply the render pass to.
  126098. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126099. * @param engine The engine which the post process will be applied. (default: current engine)
  126100. * @param reusable If the post process can be reused on the same frame. (default: false)
  126101. * @param textureType Type of textures used when performing the post process. (default: 0)
  126102. * @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)
  126103. */
  126104. 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);
  126105. /**
  126106. * Updates the effect with the current post process compile time values and recompiles the shader.
  126107. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126108. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126109. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126110. * @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
  126111. * @param onCompiled Called when the shader has been compiled.
  126112. * @param onError Called if there is an error when compiling a shader.
  126113. */
  126114. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  126115. }
  126116. }
  126117. declare module BABYLON {
  126118. /**
  126119. * Specifies the level of max blur that should be applied when using the depth of field effect
  126120. */
  126121. export enum DepthOfFieldEffectBlurLevel {
  126122. /**
  126123. * Subtle blur
  126124. */
  126125. Low = 0,
  126126. /**
  126127. * Medium blur
  126128. */
  126129. Medium = 1,
  126130. /**
  126131. * Large blur
  126132. */
  126133. High = 2
  126134. }
  126135. /**
  126136. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  126137. */
  126138. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  126139. private _circleOfConfusion;
  126140. /**
  126141. * @hidden Internal, blurs from high to low
  126142. */
  126143. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  126144. private _depthOfFieldBlurY;
  126145. private _dofMerge;
  126146. /**
  126147. * @hidden Internal post processes in depth of field effect
  126148. */
  126149. _effects: Array<PostProcess>;
  126150. /**
  126151. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  126152. */
  126153. focalLength: number;
  126154. /**
  126155. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126156. */
  126157. fStop: number;
  126158. /**
  126159. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126160. */
  126161. focusDistance: number;
  126162. /**
  126163. * 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.
  126164. */
  126165. lensSize: number;
  126166. /**
  126167. * Creates a new instance DepthOfFieldEffect
  126168. * @param scene The scene the effect belongs to.
  126169. * @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.
  126170. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126171. * @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)
  126172. */
  126173. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  126174. /**
  126175. * Get the current class name of the current effet
  126176. * @returns "DepthOfFieldEffect"
  126177. */
  126178. getClassName(): string;
  126179. /**
  126180. * 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.
  126181. */
  126182. depthTexture: RenderTargetTexture;
  126183. /**
  126184. * Disposes each of the internal effects for a given camera.
  126185. * @param camera The camera to dispose the effect on.
  126186. */
  126187. disposeEffects(camera: Camera): void;
  126188. /**
  126189. * @hidden Internal
  126190. */
  126191. _updateEffects(): void;
  126192. /**
  126193. * Internal
  126194. * @returns if all the contained post processes are ready.
  126195. * @hidden
  126196. */
  126197. _isReady(): boolean;
  126198. }
  126199. }
  126200. declare module BABYLON {
  126201. /** @hidden */
  126202. export var displayPassPixelShader: {
  126203. name: string;
  126204. shader: string;
  126205. };
  126206. }
  126207. declare module BABYLON {
  126208. /**
  126209. * DisplayPassPostProcess which produces an output the same as it's input
  126210. */
  126211. export class DisplayPassPostProcess extends PostProcess {
  126212. /**
  126213. * Creates the DisplayPassPostProcess
  126214. * @param name The name of the effect.
  126215. * @param options The required width/height ratio to downsize to before computing the render pass.
  126216. * @param camera The camera to apply the render pass to.
  126217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126218. * @param engine The engine which the post process will be applied. (default: current engine)
  126219. * @param reusable If the post process can be reused on the same frame. (default: false)
  126220. */
  126221. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126222. }
  126223. }
  126224. declare module BABYLON {
  126225. /** @hidden */
  126226. export var filterPixelShader: {
  126227. name: string;
  126228. shader: string;
  126229. };
  126230. }
  126231. declare module BABYLON {
  126232. /**
  126233. * Applies a kernel filter to the image
  126234. */
  126235. export class FilterPostProcess extends PostProcess {
  126236. /** The matrix to be applied to the image */
  126237. kernelMatrix: Matrix;
  126238. /**
  126239. *
  126240. * @param name The name of the effect.
  126241. * @param kernelMatrix The matrix to be applied to the image
  126242. * @param options The required width/height ratio to downsize to before computing the render pass.
  126243. * @param camera The camera to apply the render pass to.
  126244. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126245. * @param engine The engine which the post process will be applied. (default: current engine)
  126246. * @param reusable If the post process can be reused on the same frame. (default: false)
  126247. */
  126248. constructor(name: string,
  126249. /** The matrix to be applied to the image */
  126250. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126251. }
  126252. }
  126253. declare module BABYLON {
  126254. /** @hidden */
  126255. export var fxaaPixelShader: {
  126256. name: string;
  126257. shader: string;
  126258. };
  126259. }
  126260. declare module BABYLON {
  126261. /** @hidden */
  126262. export var fxaaVertexShader: {
  126263. name: string;
  126264. shader: string;
  126265. };
  126266. }
  126267. declare module BABYLON {
  126268. /**
  126269. * Fxaa post process
  126270. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126271. */
  126272. export class FxaaPostProcess extends PostProcess {
  126273. /** @hidden */
  126274. texelWidth: number;
  126275. /** @hidden */
  126276. texelHeight: number;
  126277. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126278. private _getDefines;
  126279. }
  126280. }
  126281. declare module BABYLON {
  126282. /** @hidden */
  126283. export var grainPixelShader: {
  126284. name: string;
  126285. shader: string;
  126286. };
  126287. }
  126288. declare module BABYLON {
  126289. /**
  126290. * The GrainPostProcess adds noise to the image at mid luminance levels
  126291. */
  126292. export class GrainPostProcess extends PostProcess {
  126293. /**
  126294. * The intensity of the grain added (default: 30)
  126295. */
  126296. intensity: number;
  126297. /**
  126298. * If the grain should be randomized on every frame
  126299. */
  126300. animated: boolean;
  126301. /**
  126302. * Creates a new instance of @see GrainPostProcess
  126303. * @param name The name of the effect.
  126304. * @param options The required width/height ratio to downsize to before computing the render pass.
  126305. * @param camera The camera to apply the render pass to.
  126306. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126307. * @param engine The engine which the post process will be applied. (default: current engine)
  126308. * @param reusable If the post process can be reused on the same frame. (default: false)
  126309. * @param textureType Type of textures used when performing the post process. (default: 0)
  126310. * @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)
  126311. */
  126312. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126313. }
  126314. }
  126315. declare module BABYLON {
  126316. /** @hidden */
  126317. export var highlightsPixelShader: {
  126318. name: string;
  126319. shader: string;
  126320. };
  126321. }
  126322. declare module BABYLON {
  126323. /**
  126324. * Extracts highlights from the image
  126325. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126326. */
  126327. export class HighlightsPostProcess extends PostProcess {
  126328. /**
  126329. * Extracts highlights from the image
  126330. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126331. * @param name The name of the effect.
  126332. * @param options The required width/height ratio to downsize to before computing the render pass.
  126333. * @param camera The camera to apply the render pass to.
  126334. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126335. * @param engine The engine which the post process will be applied. (default: current engine)
  126336. * @param reusable If the post process can be reused on the same frame. (default: false)
  126337. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126338. */
  126339. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126340. }
  126341. }
  126342. declare module BABYLON {
  126343. /** @hidden */
  126344. export var mrtFragmentDeclaration: {
  126345. name: string;
  126346. shader: string;
  126347. };
  126348. }
  126349. declare module BABYLON {
  126350. /** @hidden */
  126351. export var geometryPixelShader: {
  126352. name: string;
  126353. shader: string;
  126354. };
  126355. }
  126356. declare module BABYLON {
  126357. /** @hidden */
  126358. export var geometryVertexShader: {
  126359. name: string;
  126360. shader: string;
  126361. };
  126362. }
  126363. declare module BABYLON {
  126364. /** @hidden */
  126365. interface ISavedTransformationMatrix {
  126366. world: Matrix;
  126367. viewProjection: Matrix;
  126368. }
  126369. /**
  126370. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126371. */
  126372. export class GeometryBufferRenderer {
  126373. /**
  126374. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126375. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126376. */
  126377. static readonly POSITION_TEXTURE_TYPE: number;
  126378. /**
  126379. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126380. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126381. */
  126382. static readonly VELOCITY_TEXTURE_TYPE: number;
  126383. /**
  126384. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126385. * in order to compute objects velocities when enableVelocity is set to "true"
  126386. * @hidden
  126387. */
  126388. _previousTransformationMatrices: {
  126389. [index: number]: ISavedTransformationMatrix;
  126390. };
  126391. /**
  126392. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126393. * in order to compute objects velocities when enableVelocity is set to "true"
  126394. * @hidden
  126395. */
  126396. _previousBonesTransformationMatrices: {
  126397. [index: number]: Float32Array;
  126398. };
  126399. /**
  126400. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126401. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126402. */
  126403. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126404. private _scene;
  126405. private _multiRenderTarget;
  126406. private _ratio;
  126407. private _enablePosition;
  126408. private _enableVelocity;
  126409. private _positionIndex;
  126410. private _velocityIndex;
  126411. protected _effect: Effect;
  126412. protected _cachedDefines: string;
  126413. /**
  126414. * Set the render list (meshes to be rendered) used in the G buffer.
  126415. */
  126416. renderList: Mesh[];
  126417. /**
  126418. * Gets wether or not G buffer are supported by the running hardware.
  126419. * This requires draw buffer supports
  126420. */
  126421. readonly isSupported: boolean;
  126422. /**
  126423. * Returns the index of the given texture type in the G-Buffer textures array
  126424. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126425. * @returns the index of the given texture type in the G-Buffer textures array
  126426. */
  126427. getTextureIndex(textureType: number): number;
  126428. /**
  126429. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126430. */
  126431. /**
  126432. * Sets whether or not objects positions are enabled for the G buffer.
  126433. */
  126434. enablePosition: boolean;
  126435. /**
  126436. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126437. */
  126438. /**
  126439. * Sets wether or not objects velocities are enabled for the G buffer.
  126440. */
  126441. enableVelocity: boolean;
  126442. /**
  126443. * Gets the scene associated with the buffer.
  126444. */
  126445. readonly scene: Scene;
  126446. /**
  126447. * Gets the ratio used by the buffer during its creation.
  126448. * How big is the buffer related to the main canvas.
  126449. */
  126450. readonly ratio: number;
  126451. /** @hidden */
  126452. static _SceneComponentInitialization: (scene: Scene) => void;
  126453. /**
  126454. * Creates a new G Buffer for the scene
  126455. * @param scene The scene the buffer belongs to
  126456. * @param ratio How big is the buffer related to the main canvas.
  126457. */
  126458. constructor(scene: Scene, ratio?: number);
  126459. /**
  126460. * Checks wether everything is ready to render a submesh to the G buffer.
  126461. * @param subMesh the submesh to check readiness for
  126462. * @param useInstances is the mesh drawn using instance or not
  126463. * @returns true if ready otherwise false
  126464. */
  126465. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126466. /**
  126467. * Gets the current underlying G Buffer.
  126468. * @returns the buffer
  126469. */
  126470. getGBuffer(): MultiRenderTarget;
  126471. /**
  126472. * Gets the number of samples used to render the buffer (anti aliasing).
  126473. */
  126474. /**
  126475. * Sets the number of samples used to render the buffer (anti aliasing).
  126476. */
  126477. samples: number;
  126478. /**
  126479. * Disposes the renderer and frees up associated resources.
  126480. */
  126481. dispose(): void;
  126482. protected _createRenderTargets(): void;
  126483. private _copyBonesTransformationMatrices;
  126484. }
  126485. }
  126486. declare module BABYLON {
  126487. interface Scene {
  126488. /** @hidden (Backing field) */
  126489. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126490. /**
  126491. * Gets or Sets the current geometry buffer associated to the scene.
  126492. */
  126493. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126494. /**
  126495. * Enables a GeometryBufferRender and associates it with the scene
  126496. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126497. * @returns the GeometryBufferRenderer
  126498. */
  126499. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126500. /**
  126501. * Disables the GeometryBufferRender associated with the scene
  126502. */
  126503. disableGeometryBufferRenderer(): void;
  126504. }
  126505. /**
  126506. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126507. * in several rendering techniques.
  126508. */
  126509. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126510. /**
  126511. * The component name helpful to identify the component in the list of scene components.
  126512. */
  126513. readonly name: string;
  126514. /**
  126515. * The scene the component belongs to.
  126516. */
  126517. scene: Scene;
  126518. /**
  126519. * Creates a new instance of the component for the given scene
  126520. * @param scene Defines the scene to register the component in
  126521. */
  126522. constructor(scene: Scene);
  126523. /**
  126524. * Registers the component in a given scene
  126525. */
  126526. register(): void;
  126527. /**
  126528. * Rebuilds the elements related to this component in case of
  126529. * context lost for instance.
  126530. */
  126531. rebuild(): void;
  126532. /**
  126533. * Disposes the component and the associated ressources
  126534. */
  126535. dispose(): void;
  126536. private _gatherRenderTargets;
  126537. }
  126538. }
  126539. declare module BABYLON {
  126540. /** @hidden */
  126541. export var motionBlurPixelShader: {
  126542. name: string;
  126543. shader: string;
  126544. };
  126545. }
  126546. declare module BABYLON {
  126547. /**
  126548. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126549. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126550. * As an example, all you have to do is to create the post-process:
  126551. * var mb = new BABYLON.MotionBlurPostProcess(
  126552. * 'mb', // The name of the effect.
  126553. * scene, // The scene containing the objects to blur according to their velocity.
  126554. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126555. * camera // The camera to apply the render pass to.
  126556. * );
  126557. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126558. */
  126559. export class MotionBlurPostProcess extends PostProcess {
  126560. /**
  126561. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126562. */
  126563. motionStrength: number;
  126564. /**
  126565. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126566. */
  126567. /**
  126568. * Sets the number of iterations to be used for motion blur quality
  126569. */
  126570. motionBlurSamples: number;
  126571. private _motionBlurSamples;
  126572. private _geometryBufferRenderer;
  126573. /**
  126574. * Creates a new instance MotionBlurPostProcess
  126575. * @param name The name of the effect.
  126576. * @param scene The scene containing the objects to blur according to their velocity.
  126577. * @param options The required width/height ratio to downsize to before computing the render pass.
  126578. * @param camera The camera to apply the render pass to.
  126579. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126580. * @param engine The engine which the post process will be applied. (default: current engine)
  126581. * @param reusable If the post process can be reused on the same frame. (default: false)
  126582. * @param textureType Type of textures used when performing the post process. (default: 0)
  126583. * @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)
  126584. */
  126585. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126586. /**
  126587. * Excludes the given skinned mesh from computing bones velocities.
  126588. * 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.
  126589. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126590. */
  126591. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126592. /**
  126593. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126594. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126595. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126596. */
  126597. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126598. /**
  126599. * Disposes the post process.
  126600. * @param camera The camera to dispose the post process on.
  126601. */
  126602. dispose(camera?: Camera): void;
  126603. }
  126604. }
  126605. declare module BABYLON {
  126606. /** @hidden */
  126607. export var refractionPixelShader: {
  126608. name: string;
  126609. shader: string;
  126610. };
  126611. }
  126612. declare module BABYLON {
  126613. /**
  126614. * Post process which applies a refractin texture
  126615. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126616. */
  126617. export class RefractionPostProcess extends PostProcess {
  126618. /** the base color of the refraction (used to taint the rendering) */
  126619. color: Color3;
  126620. /** simulated refraction depth */
  126621. depth: number;
  126622. /** the coefficient of the base color (0 to remove base color tainting) */
  126623. colorLevel: number;
  126624. private _refTexture;
  126625. private _ownRefractionTexture;
  126626. /**
  126627. * Gets or sets the refraction texture
  126628. * Please note that you are responsible for disposing the texture if you set it manually
  126629. */
  126630. refractionTexture: Texture;
  126631. /**
  126632. * Initializes the RefractionPostProcess
  126633. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126634. * @param name The name of the effect.
  126635. * @param refractionTextureUrl Url of the refraction texture to use
  126636. * @param color the base color of the refraction (used to taint the rendering)
  126637. * @param depth simulated refraction depth
  126638. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126639. * @param camera The camera to apply the render pass to.
  126640. * @param options The required width/height ratio to downsize to before computing the render pass.
  126641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126642. * @param engine The engine which the post process will be applied. (default: current engine)
  126643. * @param reusable If the post process can be reused on the same frame. (default: false)
  126644. */
  126645. constructor(name: string, refractionTextureUrl: string,
  126646. /** the base color of the refraction (used to taint the rendering) */
  126647. color: Color3,
  126648. /** simulated refraction depth */
  126649. depth: number,
  126650. /** the coefficient of the base color (0 to remove base color tainting) */
  126651. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126652. /**
  126653. * Disposes of the post process
  126654. * @param camera Camera to dispose post process on
  126655. */
  126656. dispose(camera: Camera): void;
  126657. }
  126658. }
  126659. declare module BABYLON {
  126660. /** @hidden */
  126661. export var sharpenPixelShader: {
  126662. name: string;
  126663. shader: string;
  126664. };
  126665. }
  126666. declare module BABYLON {
  126667. /**
  126668. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126669. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126670. */
  126671. export class SharpenPostProcess extends PostProcess {
  126672. /**
  126673. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126674. */
  126675. colorAmount: number;
  126676. /**
  126677. * How much sharpness should be applied (default: 0.3)
  126678. */
  126679. edgeAmount: number;
  126680. /**
  126681. * Creates a new instance ConvolutionPostProcess
  126682. * @param name The name of the effect.
  126683. * @param options The required width/height ratio to downsize to before computing the render pass.
  126684. * @param camera The camera to apply the render pass to.
  126685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126686. * @param engine The engine which the post process will be applied. (default: current engine)
  126687. * @param reusable If the post process can be reused on the same frame. (default: false)
  126688. * @param textureType Type of textures used when performing the post process. (default: 0)
  126689. * @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)
  126690. */
  126691. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126692. }
  126693. }
  126694. declare module BABYLON {
  126695. /**
  126696. * PostProcessRenderPipeline
  126697. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126698. */
  126699. export class PostProcessRenderPipeline {
  126700. private engine;
  126701. private _renderEffects;
  126702. private _renderEffectsForIsolatedPass;
  126703. /**
  126704. * List of inspectable custom properties (used by the Inspector)
  126705. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126706. */
  126707. inspectableCustomProperties: IInspectable[];
  126708. /**
  126709. * @hidden
  126710. */
  126711. protected _cameras: Camera[];
  126712. /** @hidden */
  126713. _name: string;
  126714. /**
  126715. * Gets pipeline name
  126716. */
  126717. readonly name: string;
  126718. /**
  126719. * Initializes a PostProcessRenderPipeline
  126720. * @param engine engine to add the pipeline to
  126721. * @param name name of the pipeline
  126722. */
  126723. constructor(engine: Engine, name: string);
  126724. /**
  126725. * Gets the class name
  126726. * @returns "PostProcessRenderPipeline"
  126727. */
  126728. getClassName(): string;
  126729. /**
  126730. * If all the render effects in the pipeline are supported
  126731. */
  126732. readonly isSupported: boolean;
  126733. /**
  126734. * Adds an effect to the pipeline
  126735. * @param renderEffect the effect to add
  126736. */
  126737. addEffect(renderEffect: PostProcessRenderEffect): void;
  126738. /** @hidden */
  126739. _rebuild(): void;
  126740. /** @hidden */
  126741. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126742. /** @hidden */
  126743. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126744. /** @hidden */
  126745. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126746. /** @hidden */
  126747. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126748. /** @hidden */
  126749. _attachCameras(cameras: Camera, unique: boolean): void;
  126750. /** @hidden */
  126751. _attachCameras(cameras: Camera[], unique: boolean): void;
  126752. /** @hidden */
  126753. _detachCameras(cameras: Camera): void;
  126754. /** @hidden */
  126755. _detachCameras(cameras: Nullable<Camera[]>): void;
  126756. /** @hidden */
  126757. _update(): void;
  126758. /** @hidden */
  126759. _reset(): void;
  126760. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126761. /**
  126762. * Disposes of the pipeline
  126763. */
  126764. dispose(): void;
  126765. }
  126766. }
  126767. declare module BABYLON {
  126768. /**
  126769. * PostProcessRenderPipelineManager class
  126770. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126771. */
  126772. export class PostProcessRenderPipelineManager {
  126773. private _renderPipelines;
  126774. /**
  126775. * Initializes a PostProcessRenderPipelineManager
  126776. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126777. */
  126778. constructor();
  126779. /**
  126780. * Gets the list of supported render pipelines
  126781. */
  126782. readonly supportedPipelines: PostProcessRenderPipeline[];
  126783. /**
  126784. * Adds a pipeline to the manager
  126785. * @param renderPipeline The pipeline to add
  126786. */
  126787. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126788. /**
  126789. * Attaches a camera to the pipeline
  126790. * @param renderPipelineName The name of the pipeline to attach to
  126791. * @param cameras the camera to attach
  126792. * @param unique if the camera can be attached multiple times to the pipeline
  126793. */
  126794. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126795. /**
  126796. * Detaches a camera from the pipeline
  126797. * @param renderPipelineName The name of the pipeline to detach from
  126798. * @param cameras the camera to detach
  126799. */
  126800. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126801. /**
  126802. * Enables an effect by name on a pipeline
  126803. * @param renderPipelineName the name of the pipeline to enable the effect in
  126804. * @param renderEffectName the name of the effect to enable
  126805. * @param cameras the cameras that the effect should be enabled on
  126806. */
  126807. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126808. /**
  126809. * Disables an effect by name on a pipeline
  126810. * @param renderPipelineName the name of the pipeline to disable the effect in
  126811. * @param renderEffectName the name of the effect to disable
  126812. * @param cameras the cameras that the effect should be disabled on
  126813. */
  126814. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126815. /**
  126816. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126817. */
  126818. update(): void;
  126819. /** @hidden */
  126820. _rebuild(): void;
  126821. /**
  126822. * Disposes of the manager and pipelines
  126823. */
  126824. dispose(): void;
  126825. }
  126826. }
  126827. declare module BABYLON {
  126828. interface Scene {
  126829. /** @hidden (Backing field) */
  126830. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126831. /**
  126832. * Gets the postprocess render pipeline manager
  126833. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126834. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126835. */
  126836. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126837. }
  126838. /**
  126839. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126840. */
  126841. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126842. /**
  126843. * The component name helpfull to identify the component in the list of scene components.
  126844. */
  126845. readonly name: string;
  126846. /**
  126847. * The scene the component belongs to.
  126848. */
  126849. scene: Scene;
  126850. /**
  126851. * Creates a new instance of the component for the given scene
  126852. * @param scene Defines the scene to register the component in
  126853. */
  126854. constructor(scene: Scene);
  126855. /**
  126856. * Registers the component in a given scene
  126857. */
  126858. register(): void;
  126859. /**
  126860. * Rebuilds the elements related to this component in case of
  126861. * context lost for instance.
  126862. */
  126863. rebuild(): void;
  126864. /**
  126865. * Disposes the component and the associated ressources
  126866. */
  126867. dispose(): void;
  126868. private _gatherRenderTargets;
  126869. }
  126870. }
  126871. declare module BABYLON {
  126872. /**
  126873. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126874. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126875. */
  126876. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126877. private _scene;
  126878. private _camerasToBeAttached;
  126879. /**
  126880. * ID of the sharpen post process,
  126881. */
  126882. private readonly SharpenPostProcessId;
  126883. /**
  126884. * @ignore
  126885. * ID of the image processing post process;
  126886. */
  126887. readonly ImageProcessingPostProcessId: string;
  126888. /**
  126889. * @ignore
  126890. * ID of the Fast Approximate Anti-Aliasing post process;
  126891. */
  126892. readonly FxaaPostProcessId: string;
  126893. /**
  126894. * ID of the chromatic aberration post process,
  126895. */
  126896. private readonly ChromaticAberrationPostProcessId;
  126897. /**
  126898. * ID of the grain post process
  126899. */
  126900. private readonly GrainPostProcessId;
  126901. /**
  126902. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126903. */
  126904. sharpen: SharpenPostProcess;
  126905. private _sharpenEffect;
  126906. private bloom;
  126907. /**
  126908. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126909. */
  126910. depthOfField: DepthOfFieldEffect;
  126911. /**
  126912. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126913. */
  126914. fxaa: FxaaPostProcess;
  126915. /**
  126916. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126917. */
  126918. imageProcessing: ImageProcessingPostProcess;
  126919. /**
  126920. * Chromatic aberration post process which will shift rgb colors in the image
  126921. */
  126922. chromaticAberration: ChromaticAberrationPostProcess;
  126923. private _chromaticAberrationEffect;
  126924. /**
  126925. * Grain post process which add noise to the image
  126926. */
  126927. grain: GrainPostProcess;
  126928. private _grainEffect;
  126929. /**
  126930. * Glow post process which adds a glow to emissive areas of the image
  126931. */
  126932. private _glowLayer;
  126933. /**
  126934. * Animations which can be used to tweak settings over a period of time
  126935. */
  126936. animations: Animation[];
  126937. private _imageProcessingConfigurationObserver;
  126938. private _sharpenEnabled;
  126939. private _bloomEnabled;
  126940. private _depthOfFieldEnabled;
  126941. private _depthOfFieldBlurLevel;
  126942. private _fxaaEnabled;
  126943. private _imageProcessingEnabled;
  126944. private _defaultPipelineTextureType;
  126945. private _bloomScale;
  126946. private _chromaticAberrationEnabled;
  126947. private _grainEnabled;
  126948. private _buildAllowed;
  126949. /**
  126950. * Gets active scene
  126951. */
  126952. readonly scene: Scene;
  126953. /**
  126954. * Enable or disable the sharpen process from the pipeline
  126955. */
  126956. sharpenEnabled: boolean;
  126957. private _resizeObserver;
  126958. private _hardwareScaleLevel;
  126959. private _bloomKernel;
  126960. /**
  126961. * Specifies the size of the bloom blur kernel, relative to the final output size
  126962. */
  126963. bloomKernel: number;
  126964. /**
  126965. * Specifies the weight of the bloom in the final rendering
  126966. */
  126967. private _bloomWeight;
  126968. /**
  126969. * Specifies the luma threshold for the area that will be blurred by the bloom
  126970. */
  126971. private _bloomThreshold;
  126972. private _hdr;
  126973. /**
  126974. * The strength of the bloom.
  126975. */
  126976. bloomWeight: number;
  126977. /**
  126978. * The strength of the bloom.
  126979. */
  126980. bloomThreshold: number;
  126981. /**
  126982. * The scale of the bloom, lower value will provide better performance.
  126983. */
  126984. bloomScale: number;
  126985. /**
  126986. * Enable or disable the bloom from the pipeline
  126987. */
  126988. bloomEnabled: boolean;
  126989. private _rebuildBloom;
  126990. /**
  126991. * If the depth of field is enabled.
  126992. */
  126993. depthOfFieldEnabled: boolean;
  126994. /**
  126995. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126996. */
  126997. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126998. /**
  126999. * If the anti aliasing is enabled.
  127000. */
  127001. fxaaEnabled: boolean;
  127002. private _samples;
  127003. /**
  127004. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127005. */
  127006. samples: number;
  127007. /**
  127008. * If image processing is enabled.
  127009. */
  127010. imageProcessingEnabled: boolean;
  127011. /**
  127012. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  127013. */
  127014. glowLayerEnabled: boolean;
  127015. /**
  127016. * Gets the glow layer (or null if not defined)
  127017. */
  127018. readonly glowLayer: Nullable<GlowLayer>;
  127019. /**
  127020. * Enable or disable the chromaticAberration process from the pipeline
  127021. */
  127022. chromaticAberrationEnabled: boolean;
  127023. /**
  127024. * Enable or disable the grain process from the pipeline
  127025. */
  127026. grainEnabled: boolean;
  127027. /**
  127028. * @constructor
  127029. * @param name - The rendering pipeline name (default: "")
  127030. * @param hdr - If high dynamic range textures should be used (default: true)
  127031. * @param scene - The scene linked to this pipeline (default: the last created scene)
  127032. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  127033. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  127034. */
  127035. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  127036. /**
  127037. * Get the class name
  127038. * @returns "DefaultRenderingPipeline"
  127039. */
  127040. getClassName(): string;
  127041. /**
  127042. * Force the compilation of the entire pipeline.
  127043. */
  127044. prepare(): void;
  127045. private _hasCleared;
  127046. private _prevPostProcess;
  127047. private _prevPrevPostProcess;
  127048. private _setAutoClearAndTextureSharing;
  127049. private _depthOfFieldSceneObserver;
  127050. private _buildPipeline;
  127051. private _disposePostProcesses;
  127052. /**
  127053. * Adds a camera to the pipeline
  127054. * @param camera the camera to be added
  127055. */
  127056. addCamera(camera: Camera): void;
  127057. /**
  127058. * Removes a camera from the pipeline
  127059. * @param camera the camera to remove
  127060. */
  127061. removeCamera(camera: Camera): void;
  127062. /**
  127063. * Dispose of the pipeline and stop all post processes
  127064. */
  127065. dispose(): void;
  127066. /**
  127067. * Serialize the rendering pipeline (Used when exporting)
  127068. * @returns the serialized object
  127069. */
  127070. serialize(): any;
  127071. /**
  127072. * Parse the serialized pipeline
  127073. * @param source Source pipeline.
  127074. * @param scene The scene to load the pipeline to.
  127075. * @param rootUrl The URL of the serialized pipeline.
  127076. * @returns An instantiated pipeline from the serialized object.
  127077. */
  127078. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  127079. }
  127080. }
  127081. declare module BABYLON {
  127082. /** @hidden */
  127083. export var lensHighlightsPixelShader: {
  127084. name: string;
  127085. shader: string;
  127086. };
  127087. }
  127088. declare module BABYLON {
  127089. /** @hidden */
  127090. export var depthOfFieldPixelShader: {
  127091. name: string;
  127092. shader: string;
  127093. };
  127094. }
  127095. declare module BABYLON {
  127096. /**
  127097. * BABYLON.JS Chromatic Aberration GLSL Shader
  127098. * Author: Olivier Guyot
  127099. * Separates very slightly R, G and B colors on the edges of the screen
  127100. * Inspired by Francois Tarlier & Martins Upitis
  127101. */
  127102. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  127103. /**
  127104. * @ignore
  127105. * The chromatic aberration PostProcess id in the pipeline
  127106. */
  127107. LensChromaticAberrationEffect: string;
  127108. /**
  127109. * @ignore
  127110. * The highlights enhancing PostProcess id in the pipeline
  127111. */
  127112. HighlightsEnhancingEffect: string;
  127113. /**
  127114. * @ignore
  127115. * The depth-of-field PostProcess id in the pipeline
  127116. */
  127117. LensDepthOfFieldEffect: string;
  127118. private _scene;
  127119. private _depthTexture;
  127120. private _grainTexture;
  127121. private _chromaticAberrationPostProcess;
  127122. private _highlightsPostProcess;
  127123. private _depthOfFieldPostProcess;
  127124. private _edgeBlur;
  127125. private _grainAmount;
  127126. private _chromaticAberration;
  127127. private _distortion;
  127128. private _highlightsGain;
  127129. private _highlightsThreshold;
  127130. private _dofDistance;
  127131. private _dofAperture;
  127132. private _dofDarken;
  127133. private _dofPentagon;
  127134. private _blurNoise;
  127135. /**
  127136. * @constructor
  127137. *
  127138. * Effect parameters are as follow:
  127139. * {
  127140. * chromatic_aberration: number; // from 0 to x (1 for realism)
  127141. * edge_blur: number; // from 0 to x (1 for realism)
  127142. * distortion: number; // from 0 to x (1 for realism)
  127143. * grain_amount: number; // from 0 to 1
  127144. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  127145. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  127146. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  127147. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  127148. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  127149. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  127150. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  127151. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  127152. * }
  127153. * Note: if an effect parameter is unset, effect is disabled
  127154. *
  127155. * @param name The rendering pipeline name
  127156. * @param parameters - An object containing all parameters (see above)
  127157. * @param scene The scene linked to this pipeline
  127158. * @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)
  127159. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127160. */
  127161. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  127162. /**
  127163. * Get the class name
  127164. * @returns "LensRenderingPipeline"
  127165. */
  127166. getClassName(): string;
  127167. /**
  127168. * Gets associated scene
  127169. */
  127170. readonly scene: Scene;
  127171. /**
  127172. * Gets or sets the edge blur
  127173. */
  127174. edgeBlur: number;
  127175. /**
  127176. * Gets or sets the grain amount
  127177. */
  127178. grainAmount: number;
  127179. /**
  127180. * Gets or sets the chromatic aberration amount
  127181. */
  127182. chromaticAberration: number;
  127183. /**
  127184. * Gets or sets the depth of field aperture
  127185. */
  127186. dofAperture: number;
  127187. /**
  127188. * Gets or sets the edge distortion
  127189. */
  127190. edgeDistortion: number;
  127191. /**
  127192. * Gets or sets the depth of field distortion
  127193. */
  127194. dofDistortion: number;
  127195. /**
  127196. * Gets or sets the darken out of focus amount
  127197. */
  127198. darkenOutOfFocus: number;
  127199. /**
  127200. * Gets or sets a boolean indicating if blur noise is enabled
  127201. */
  127202. blurNoise: boolean;
  127203. /**
  127204. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  127205. */
  127206. pentagonBokeh: boolean;
  127207. /**
  127208. * Gets or sets the highlight grain amount
  127209. */
  127210. highlightsGain: number;
  127211. /**
  127212. * Gets or sets the highlight threshold
  127213. */
  127214. highlightsThreshold: number;
  127215. /**
  127216. * Sets the amount of blur at the edges
  127217. * @param amount blur amount
  127218. */
  127219. setEdgeBlur(amount: number): void;
  127220. /**
  127221. * Sets edge blur to 0
  127222. */
  127223. disableEdgeBlur(): void;
  127224. /**
  127225. * Sets the amout of grain
  127226. * @param amount Amount of grain
  127227. */
  127228. setGrainAmount(amount: number): void;
  127229. /**
  127230. * Set grain amount to 0
  127231. */
  127232. disableGrain(): void;
  127233. /**
  127234. * Sets the chromatic aberration amount
  127235. * @param amount amount of chromatic aberration
  127236. */
  127237. setChromaticAberration(amount: number): void;
  127238. /**
  127239. * Sets chromatic aberration amount to 0
  127240. */
  127241. disableChromaticAberration(): void;
  127242. /**
  127243. * Sets the EdgeDistortion amount
  127244. * @param amount amount of EdgeDistortion
  127245. */
  127246. setEdgeDistortion(amount: number): void;
  127247. /**
  127248. * Sets edge distortion to 0
  127249. */
  127250. disableEdgeDistortion(): void;
  127251. /**
  127252. * Sets the FocusDistance amount
  127253. * @param amount amount of FocusDistance
  127254. */
  127255. setFocusDistance(amount: number): void;
  127256. /**
  127257. * Disables depth of field
  127258. */
  127259. disableDepthOfField(): void;
  127260. /**
  127261. * Sets the Aperture amount
  127262. * @param amount amount of Aperture
  127263. */
  127264. setAperture(amount: number): void;
  127265. /**
  127266. * Sets the DarkenOutOfFocus amount
  127267. * @param amount amount of DarkenOutOfFocus
  127268. */
  127269. setDarkenOutOfFocus(amount: number): void;
  127270. private _pentagonBokehIsEnabled;
  127271. /**
  127272. * Creates a pentagon bokeh effect
  127273. */
  127274. enablePentagonBokeh(): void;
  127275. /**
  127276. * Disables the pentagon bokeh effect
  127277. */
  127278. disablePentagonBokeh(): void;
  127279. /**
  127280. * Enables noise blur
  127281. */
  127282. enableNoiseBlur(): void;
  127283. /**
  127284. * Disables noise blur
  127285. */
  127286. disableNoiseBlur(): void;
  127287. /**
  127288. * Sets the HighlightsGain amount
  127289. * @param amount amount of HighlightsGain
  127290. */
  127291. setHighlightsGain(amount: number): void;
  127292. /**
  127293. * Sets the HighlightsThreshold amount
  127294. * @param amount amount of HighlightsThreshold
  127295. */
  127296. setHighlightsThreshold(amount: number): void;
  127297. /**
  127298. * Disables highlights
  127299. */
  127300. disableHighlights(): void;
  127301. /**
  127302. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127303. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127304. */
  127305. dispose(disableDepthRender?: boolean): void;
  127306. private _createChromaticAberrationPostProcess;
  127307. private _createHighlightsPostProcess;
  127308. private _createDepthOfFieldPostProcess;
  127309. private _createGrainTexture;
  127310. }
  127311. }
  127312. declare module BABYLON {
  127313. /** @hidden */
  127314. export var ssao2PixelShader: {
  127315. name: string;
  127316. shader: string;
  127317. };
  127318. }
  127319. declare module BABYLON {
  127320. /** @hidden */
  127321. export var ssaoCombinePixelShader: {
  127322. name: string;
  127323. shader: string;
  127324. };
  127325. }
  127326. declare module BABYLON {
  127327. /**
  127328. * Render pipeline to produce ssao effect
  127329. */
  127330. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127331. /**
  127332. * @ignore
  127333. * The PassPostProcess id in the pipeline that contains the original scene color
  127334. */
  127335. SSAOOriginalSceneColorEffect: string;
  127336. /**
  127337. * @ignore
  127338. * The SSAO PostProcess id in the pipeline
  127339. */
  127340. SSAORenderEffect: string;
  127341. /**
  127342. * @ignore
  127343. * The horizontal blur PostProcess id in the pipeline
  127344. */
  127345. SSAOBlurHRenderEffect: string;
  127346. /**
  127347. * @ignore
  127348. * The vertical blur PostProcess id in the pipeline
  127349. */
  127350. SSAOBlurVRenderEffect: string;
  127351. /**
  127352. * @ignore
  127353. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127354. */
  127355. SSAOCombineRenderEffect: string;
  127356. /**
  127357. * The output strength of the SSAO post-process. Default value is 1.0.
  127358. */
  127359. totalStrength: number;
  127360. /**
  127361. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127362. */
  127363. maxZ: number;
  127364. /**
  127365. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127366. */
  127367. minZAspect: number;
  127368. private _samples;
  127369. /**
  127370. * Number of samples used for the SSAO calculations. Default value is 8
  127371. */
  127372. samples: number;
  127373. private _textureSamples;
  127374. /**
  127375. * Number of samples to use for antialiasing
  127376. */
  127377. textureSamples: number;
  127378. /**
  127379. * Ratio object used for SSAO ratio and blur ratio
  127380. */
  127381. private _ratio;
  127382. /**
  127383. * Dynamically generated sphere sampler.
  127384. */
  127385. private _sampleSphere;
  127386. /**
  127387. * Blur filter offsets
  127388. */
  127389. private _samplerOffsets;
  127390. private _expensiveBlur;
  127391. /**
  127392. * If bilateral blur should be used
  127393. */
  127394. expensiveBlur: boolean;
  127395. /**
  127396. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127397. */
  127398. radius: number;
  127399. /**
  127400. * The base color of the SSAO post-process
  127401. * The final result is "base + ssao" between [0, 1]
  127402. */
  127403. base: number;
  127404. /**
  127405. * Support test.
  127406. */
  127407. static readonly IsSupported: boolean;
  127408. private _scene;
  127409. private _depthTexture;
  127410. private _normalTexture;
  127411. private _randomTexture;
  127412. private _originalColorPostProcess;
  127413. private _ssaoPostProcess;
  127414. private _blurHPostProcess;
  127415. private _blurVPostProcess;
  127416. private _ssaoCombinePostProcess;
  127417. private _firstUpdate;
  127418. /**
  127419. * Gets active scene
  127420. */
  127421. readonly scene: Scene;
  127422. /**
  127423. * @constructor
  127424. * @param name The rendering pipeline name
  127425. * @param scene The scene linked to this pipeline
  127426. * @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 }
  127427. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127428. */
  127429. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127430. /**
  127431. * Get the class name
  127432. * @returns "SSAO2RenderingPipeline"
  127433. */
  127434. getClassName(): string;
  127435. /**
  127436. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127437. */
  127438. dispose(disableGeometryBufferRenderer?: boolean): void;
  127439. private _createBlurPostProcess;
  127440. /** @hidden */
  127441. _rebuild(): void;
  127442. private _bits;
  127443. private _radicalInverse_VdC;
  127444. private _hammersley;
  127445. private _hemisphereSample_uniform;
  127446. private _generateHemisphere;
  127447. private _createSSAOPostProcess;
  127448. private _createSSAOCombinePostProcess;
  127449. private _createRandomTexture;
  127450. /**
  127451. * Serialize the rendering pipeline (Used when exporting)
  127452. * @returns the serialized object
  127453. */
  127454. serialize(): any;
  127455. /**
  127456. * Parse the serialized pipeline
  127457. * @param source Source pipeline.
  127458. * @param scene The scene to load the pipeline to.
  127459. * @param rootUrl The URL of the serialized pipeline.
  127460. * @returns An instantiated pipeline from the serialized object.
  127461. */
  127462. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127463. }
  127464. }
  127465. declare module BABYLON {
  127466. /** @hidden */
  127467. export var ssaoPixelShader: {
  127468. name: string;
  127469. shader: string;
  127470. };
  127471. }
  127472. declare module BABYLON {
  127473. /**
  127474. * Render pipeline to produce ssao effect
  127475. */
  127476. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127477. /**
  127478. * @ignore
  127479. * The PassPostProcess id in the pipeline that contains the original scene color
  127480. */
  127481. SSAOOriginalSceneColorEffect: string;
  127482. /**
  127483. * @ignore
  127484. * The SSAO PostProcess id in the pipeline
  127485. */
  127486. SSAORenderEffect: string;
  127487. /**
  127488. * @ignore
  127489. * The horizontal blur PostProcess id in the pipeline
  127490. */
  127491. SSAOBlurHRenderEffect: string;
  127492. /**
  127493. * @ignore
  127494. * The vertical blur PostProcess id in the pipeline
  127495. */
  127496. SSAOBlurVRenderEffect: string;
  127497. /**
  127498. * @ignore
  127499. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127500. */
  127501. SSAOCombineRenderEffect: string;
  127502. /**
  127503. * The output strength of the SSAO post-process. Default value is 1.0.
  127504. */
  127505. totalStrength: number;
  127506. /**
  127507. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127508. */
  127509. radius: number;
  127510. /**
  127511. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127512. * Must not be equal to fallOff and superior to fallOff.
  127513. * Default value is 0.0075
  127514. */
  127515. area: number;
  127516. /**
  127517. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127518. * Must not be equal to area and inferior to area.
  127519. * Default value is 0.000001
  127520. */
  127521. fallOff: number;
  127522. /**
  127523. * The base color of the SSAO post-process
  127524. * The final result is "base + ssao" between [0, 1]
  127525. */
  127526. base: number;
  127527. private _scene;
  127528. private _depthTexture;
  127529. private _randomTexture;
  127530. private _originalColorPostProcess;
  127531. private _ssaoPostProcess;
  127532. private _blurHPostProcess;
  127533. private _blurVPostProcess;
  127534. private _ssaoCombinePostProcess;
  127535. private _firstUpdate;
  127536. /**
  127537. * Gets active scene
  127538. */
  127539. readonly scene: Scene;
  127540. /**
  127541. * @constructor
  127542. * @param name - The rendering pipeline name
  127543. * @param scene - The scene linked to this pipeline
  127544. * @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 }
  127545. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127546. */
  127547. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127548. /**
  127549. * Get the class name
  127550. * @returns "SSAORenderingPipeline"
  127551. */
  127552. getClassName(): string;
  127553. /**
  127554. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127555. */
  127556. dispose(disableDepthRender?: boolean): void;
  127557. private _createBlurPostProcess;
  127558. /** @hidden */
  127559. _rebuild(): void;
  127560. private _createSSAOPostProcess;
  127561. private _createSSAOCombinePostProcess;
  127562. private _createRandomTexture;
  127563. }
  127564. }
  127565. declare module BABYLON {
  127566. /** @hidden */
  127567. export var standardPixelShader: {
  127568. name: string;
  127569. shader: string;
  127570. };
  127571. }
  127572. declare module BABYLON {
  127573. /**
  127574. * Standard rendering pipeline
  127575. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127576. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127577. */
  127578. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127579. /**
  127580. * Public members
  127581. */
  127582. /**
  127583. * Post-process which contains the original scene color before the pipeline applies all the effects
  127584. */
  127585. originalPostProcess: Nullable<PostProcess>;
  127586. /**
  127587. * Post-process used to down scale an image x4
  127588. */
  127589. downSampleX4PostProcess: Nullable<PostProcess>;
  127590. /**
  127591. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127592. */
  127593. brightPassPostProcess: Nullable<PostProcess>;
  127594. /**
  127595. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127596. */
  127597. blurHPostProcesses: PostProcess[];
  127598. /**
  127599. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127600. */
  127601. blurVPostProcesses: PostProcess[];
  127602. /**
  127603. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127604. */
  127605. textureAdderPostProcess: Nullable<PostProcess>;
  127606. /**
  127607. * Post-process used to create volumetric lighting effect
  127608. */
  127609. volumetricLightPostProcess: Nullable<PostProcess>;
  127610. /**
  127611. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127612. */
  127613. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127614. /**
  127615. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127616. */
  127617. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127618. /**
  127619. * Post-process used to merge the volumetric light effect and the real scene color
  127620. */
  127621. volumetricLightMergePostProces: Nullable<PostProcess>;
  127622. /**
  127623. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127624. */
  127625. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127626. /**
  127627. * Base post-process used to calculate the average luminance of the final image for HDR
  127628. */
  127629. luminancePostProcess: Nullable<PostProcess>;
  127630. /**
  127631. * Post-processes used to create down sample post-processes in order to get
  127632. * the average luminance of the final image for HDR
  127633. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127634. */
  127635. luminanceDownSamplePostProcesses: PostProcess[];
  127636. /**
  127637. * Post-process used to create a HDR effect (light adaptation)
  127638. */
  127639. hdrPostProcess: Nullable<PostProcess>;
  127640. /**
  127641. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127642. */
  127643. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127644. /**
  127645. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127646. */
  127647. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127648. /**
  127649. * Post-process used to merge the final HDR post-process and the real scene color
  127650. */
  127651. hdrFinalPostProcess: Nullable<PostProcess>;
  127652. /**
  127653. * Post-process used to create a lens flare effect
  127654. */
  127655. lensFlarePostProcess: Nullable<PostProcess>;
  127656. /**
  127657. * Post-process that merges the result of the lens flare post-process and the real scene color
  127658. */
  127659. lensFlareComposePostProcess: Nullable<PostProcess>;
  127660. /**
  127661. * Post-process used to create a motion blur effect
  127662. */
  127663. motionBlurPostProcess: Nullable<PostProcess>;
  127664. /**
  127665. * Post-process used to create a depth of field effect
  127666. */
  127667. depthOfFieldPostProcess: Nullable<PostProcess>;
  127668. /**
  127669. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127670. */
  127671. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127672. /**
  127673. * Represents the brightness threshold in order to configure the illuminated surfaces
  127674. */
  127675. brightThreshold: number;
  127676. /**
  127677. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127678. */
  127679. blurWidth: number;
  127680. /**
  127681. * Sets if the blur for highlighted surfaces must be only horizontal
  127682. */
  127683. horizontalBlur: boolean;
  127684. /**
  127685. * Gets the overall exposure used by the pipeline
  127686. */
  127687. /**
  127688. * Sets the overall exposure used by the pipeline
  127689. */
  127690. exposure: number;
  127691. /**
  127692. * Texture used typically to simulate "dirty" on camera lens
  127693. */
  127694. lensTexture: Nullable<Texture>;
  127695. /**
  127696. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127697. */
  127698. volumetricLightCoefficient: number;
  127699. /**
  127700. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127701. */
  127702. volumetricLightPower: number;
  127703. /**
  127704. * Used the set the blur intensity to smooth the volumetric lights
  127705. */
  127706. volumetricLightBlurScale: number;
  127707. /**
  127708. * Light (spot or directional) used to generate the volumetric lights rays
  127709. * The source light must have a shadow generate so the pipeline can get its
  127710. * depth map
  127711. */
  127712. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127713. /**
  127714. * For eye adaptation, represents the minimum luminance the eye can see
  127715. */
  127716. hdrMinimumLuminance: number;
  127717. /**
  127718. * For eye adaptation, represents the decrease luminance speed
  127719. */
  127720. hdrDecreaseRate: number;
  127721. /**
  127722. * For eye adaptation, represents the increase luminance speed
  127723. */
  127724. hdrIncreaseRate: number;
  127725. /**
  127726. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127727. */
  127728. /**
  127729. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127730. */
  127731. hdrAutoExposure: boolean;
  127732. /**
  127733. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127734. */
  127735. lensColorTexture: Nullable<Texture>;
  127736. /**
  127737. * The overall strengh for the lens flare effect
  127738. */
  127739. lensFlareStrength: number;
  127740. /**
  127741. * Dispersion coefficient for lens flare ghosts
  127742. */
  127743. lensFlareGhostDispersal: number;
  127744. /**
  127745. * Main lens flare halo width
  127746. */
  127747. lensFlareHaloWidth: number;
  127748. /**
  127749. * Based on the lens distortion effect, defines how much the lens flare result
  127750. * is distorted
  127751. */
  127752. lensFlareDistortionStrength: number;
  127753. /**
  127754. * Configures the blur intensity used for for lens flare (halo)
  127755. */
  127756. lensFlareBlurWidth: number;
  127757. /**
  127758. * Lens star texture must be used to simulate rays on the flares and is available
  127759. * in the documentation
  127760. */
  127761. lensStarTexture: Nullable<Texture>;
  127762. /**
  127763. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127764. * flare effect by taking account of the dirt texture
  127765. */
  127766. lensFlareDirtTexture: Nullable<Texture>;
  127767. /**
  127768. * Represents the focal length for the depth of field effect
  127769. */
  127770. depthOfFieldDistance: number;
  127771. /**
  127772. * Represents the blur intensity for the blurred part of the depth of field effect
  127773. */
  127774. depthOfFieldBlurWidth: number;
  127775. /**
  127776. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127777. */
  127778. /**
  127779. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127780. */
  127781. motionStrength: number;
  127782. /**
  127783. * Gets wether or not the motion blur post-process is object based or screen based.
  127784. */
  127785. /**
  127786. * Sets wether or not the motion blur post-process should be object based or screen based
  127787. */
  127788. objectBasedMotionBlur: boolean;
  127789. /**
  127790. * List of animations for the pipeline (IAnimatable implementation)
  127791. */
  127792. animations: Animation[];
  127793. /**
  127794. * Private members
  127795. */
  127796. private _scene;
  127797. private _currentDepthOfFieldSource;
  127798. private _basePostProcess;
  127799. private _fixedExposure;
  127800. private _currentExposure;
  127801. private _hdrAutoExposure;
  127802. private _hdrCurrentLuminance;
  127803. private _motionStrength;
  127804. private _isObjectBasedMotionBlur;
  127805. private _floatTextureType;
  127806. private _camerasToBeAttached;
  127807. private _ratio;
  127808. private _bloomEnabled;
  127809. private _depthOfFieldEnabled;
  127810. private _vlsEnabled;
  127811. private _lensFlareEnabled;
  127812. private _hdrEnabled;
  127813. private _motionBlurEnabled;
  127814. private _fxaaEnabled;
  127815. private _motionBlurSamples;
  127816. private _volumetricLightStepsCount;
  127817. private _samples;
  127818. /**
  127819. * @ignore
  127820. * Specifies if the bloom pipeline is enabled
  127821. */
  127822. BloomEnabled: boolean;
  127823. /**
  127824. * @ignore
  127825. * Specifies if the depth of field pipeline is enabed
  127826. */
  127827. DepthOfFieldEnabled: boolean;
  127828. /**
  127829. * @ignore
  127830. * Specifies if the lens flare pipeline is enabed
  127831. */
  127832. LensFlareEnabled: boolean;
  127833. /**
  127834. * @ignore
  127835. * Specifies if the HDR pipeline is enabled
  127836. */
  127837. HDREnabled: boolean;
  127838. /**
  127839. * @ignore
  127840. * Specifies if the volumetric lights scattering effect is enabled
  127841. */
  127842. VLSEnabled: boolean;
  127843. /**
  127844. * @ignore
  127845. * Specifies if the motion blur effect is enabled
  127846. */
  127847. MotionBlurEnabled: boolean;
  127848. /**
  127849. * Specifies if anti-aliasing is enabled
  127850. */
  127851. fxaaEnabled: boolean;
  127852. /**
  127853. * Specifies the number of steps used to calculate the volumetric lights
  127854. * Typically in interval [50, 200]
  127855. */
  127856. volumetricLightStepsCount: number;
  127857. /**
  127858. * Specifies the number of samples used for the motion blur effect
  127859. * Typically in interval [16, 64]
  127860. */
  127861. motionBlurSamples: number;
  127862. /**
  127863. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127864. */
  127865. samples: number;
  127866. /**
  127867. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127868. * @constructor
  127869. * @param name The rendering pipeline name
  127870. * @param scene The scene linked to this pipeline
  127871. * @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)
  127872. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127873. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127874. */
  127875. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127876. private _buildPipeline;
  127877. private _createDownSampleX4PostProcess;
  127878. private _createBrightPassPostProcess;
  127879. private _createBlurPostProcesses;
  127880. private _createTextureAdderPostProcess;
  127881. private _createVolumetricLightPostProcess;
  127882. private _createLuminancePostProcesses;
  127883. private _createHdrPostProcess;
  127884. private _createLensFlarePostProcess;
  127885. private _createDepthOfFieldPostProcess;
  127886. private _createMotionBlurPostProcess;
  127887. private _getDepthTexture;
  127888. private _disposePostProcesses;
  127889. /**
  127890. * Dispose of the pipeline and stop all post processes
  127891. */
  127892. dispose(): void;
  127893. /**
  127894. * Serialize the rendering pipeline (Used when exporting)
  127895. * @returns the serialized object
  127896. */
  127897. serialize(): any;
  127898. /**
  127899. * Parse the serialized pipeline
  127900. * @param source Source pipeline.
  127901. * @param scene The scene to load the pipeline to.
  127902. * @param rootUrl The URL of the serialized pipeline.
  127903. * @returns An instantiated pipeline from the serialized object.
  127904. */
  127905. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127906. /**
  127907. * Luminance steps
  127908. */
  127909. static LuminanceSteps: number;
  127910. }
  127911. }
  127912. declare module BABYLON {
  127913. /** @hidden */
  127914. export var tonemapPixelShader: {
  127915. name: string;
  127916. shader: string;
  127917. };
  127918. }
  127919. declare module BABYLON {
  127920. /** Defines operator used for tonemapping */
  127921. export enum TonemappingOperator {
  127922. /** Hable */
  127923. Hable = 0,
  127924. /** Reinhard */
  127925. Reinhard = 1,
  127926. /** HejiDawson */
  127927. HejiDawson = 2,
  127928. /** Photographic */
  127929. Photographic = 3
  127930. }
  127931. /**
  127932. * Defines a post process to apply tone mapping
  127933. */
  127934. export class TonemapPostProcess extends PostProcess {
  127935. private _operator;
  127936. /** Defines the required exposure adjustement */
  127937. exposureAdjustment: number;
  127938. /**
  127939. * Creates a new TonemapPostProcess
  127940. * @param name defines the name of the postprocess
  127941. * @param _operator defines the operator to use
  127942. * @param exposureAdjustment defines the required exposure adjustement
  127943. * @param camera defines the camera to use (can be null)
  127944. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127945. * @param engine defines the hosting engine (can be ignore if camera is set)
  127946. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127947. */
  127948. constructor(name: string, _operator: TonemappingOperator,
  127949. /** Defines the required exposure adjustement */
  127950. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127951. }
  127952. }
  127953. declare module BABYLON {
  127954. /** @hidden */
  127955. export var depthVertexShader: {
  127956. name: string;
  127957. shader: string;
  127958. };
  127959. }
  127960. declare module BABYLON {
  127961. /** @hidden */
  127962. export var volumetricLightScatteringPixelShader: {
  127963. name: string;
  127964. shader: string;
  127965. };
  127966. }
  127967. declare module BABYLON {
  127968. /** @hidden */
  127969. export var volumetricLightScatteringPassVertexShader: {
  127970. name: string;
  127971. shader: string;
  127972. };
  127973. }
  127974. declare module BABYLON {
  127975. /** @hidden */
  127976. export var volumetricLightScatteringPassPixelShader: {
  127977. name: string;
  127978. shader: string;
  127979. };
  127980. }
  127981. declare module BABYLON {
  127982. /**
  127983. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127984. */
  127985. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127986. private _volumetricLightScatteringPass;
  127987. private _volumetricLightScatteringRTT;
  127988. private _viewPort;
  127989. private _screenCoordinates;
  127990. private _cachedDefines;
  127991. /**
  127992. * If not undefined, the mesh position is computed from the attached node position
  127993. */
  127994. attachedNode: {
  127995. position: Vector3;
  127996. };
  127997. /**
  127998. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127999. */
  128000. customMeshPosition: Vector3;
  128001. /**
  128002. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  128003. */
  128004. useCustomMeshPosition: boolean;
  128005. /**
  128006. * If the post-process should inverse the light scattering direction
  128007. */
  128008. invert: boolean;
  128009. /**
  128010. * The internal mesh used by the post-process
  128011. */
  128012. mesh: Mesh;
  128013. /**
  128014. * @hidden
  128015. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  128016. */
  128017. useDiffuseColor: boolean;
  128018. /**
  128019. * Array containing the excluded meshes not rendered in the internal pass
  128020. */
  128021. excludedMeshes: AbstractMesh[];
  128022. /**
  128023. * Controls the overall intensity of the post-process
  128024. */
  128025. exposure: number;
  128026. /**
  128027. * Dissipates each sample's contribution in range [0, 1]
  128028. */
  128029. decay: number;
  128030. /**
  128031. * Controls the overall intensity of each sample
  128032. */
  128033. weight: number;
  128034. /**
  128035. * Controls the density of each sample
  128036. */
  128037. density: number;
  128038. /**
  128039. * @constructor
  128040. * @param name The post-process name
  128041. * @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)
  128042. * @param camera The camera that the post-process will be attached to
  128043. * @param mesh The mesh used to create the light scattering
  128044. * @param samples The post-process quality, default 100
  128045. * @param samplingModeThe post-process filtering mode
  128046. * @param engine The babylon engine
  128047. * @param reusable If the post-process is reusable
  128048. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  128049. */
  128050. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  128051. /**
  128052. * Returns the string "VolumetricLightScatteringPostProcess"
  128053. * @returns "VolumetricLightScatteringPostProcess"
  128054. */
  128055. getClassName(): string;
  128056. private _isReady;
  128057. /**
  128058. * Sets the new light position for light scattering effect
  128059. * @param position The new custom light position
  128060. */
  128061. setCustomMeshPosition(position: Vector3): void;
  128062. /**
  128063. * Returns the light position for light scattering effect
  128064. * @return Vector3 The custom light position
  128065. */
  128066. getCustomMeshPosition(): Vector3;
  128067. /**
  128068. * Disposes the internal assets and detaches the post-process from the camera
  128069. */
  128070. dispose(camera: Camera): void;
  128071. /**
  128072. * Returns the render target texture used by the post-process
  128073. * @return the render target texture used by the post-process
  128074. */
  128075. getPass(): RenderTargetTexture;
  128076. private _meshExcluded;
  128077. private _createPass;
  128078. private _updateMeshScreenCoordinates;
  128079. /**
  128080. * Creates a default mesh for the Volumeric Light Scattering post-process
  128081. * @param name The mesh name
  128082. * @param scene The scene where to create the mesh
  128083. * @return the default mesh
  128084. */
  128085. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  128086. }
  128087. }
  128088. declare module BABYLON {
  128089. interface Scene {
  128090. /** @hidden (Backing field) */
  128091. _boundingBoxRenderer: BoundingBoxRenderer;
  128092. /** @hidden (Backing field) */
  128093. _forceShowBoundingBoxes: boolean;
  128094. /**
  128095. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  128096. */
  128097. forceShowBoundingBoxes: boolean;
  128098. /**
  128099. * Gets the bounding box renderer associated with the scene
  128100. * @returns a BoundingBoxRenderer
  128101. */
  128102. getBoundingBoxRenderer(): BoundingBoxRenderer;
  128103. }
  128104. interface AbstractMesh {
  128105. /** @hidden (Backing field) */
  128106. _showBoundingBox: boolean;
  128107. /**
  128108. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  128109. */
  128110. showBoundingBox: boolean;
  128111. }
  128112. /**
  128113. * Component responsible of rendering the bounding box of the meshes in a scene.
  128114. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128115. */
  128116. export class BoundingBoxRenderer implements ISceneComponent {
  128117. /**
  128118. * The component name helpfull to identify the component in the list of scene components.
  128119. */
  128120. readonly name: string;
  128121. /**
  128122. * The scene the component belongs to.
  128123. */
  128124. scene: Scene;
  128125. /**
  128126. * Color of the bounding box lines placed in front of an object
  128127. */
  128128. frontColor: Color3;
  128129. /**
  128130. * Color of the bounding box lines placed behind an object
  128131. */
  128132. backColor: Color3;
  128133. /**
  128134. * Defines if the renderer should show the back lines or not
  128135. */
  128136. showBackLines: boolean;
  128137. /**
  128138. * @hidden
  128139. */
  128140. renderList: SmartArray<BoundingBox>;
  128141. private _colorShader;
  128142. private _vertexBuffers;
  128143. private _indexBuffer;
  128144. private _fillIndexBuffer;
  128145. private _fillIndexData;
  128146. /**
  128147. * Instantiates a new bounding box renderer in a scene.
  128148. * @param scene the scene the renderer renders in
  128149. */
  128150. constructor(scene: Scene);
  128151. /**
  128152. * Registers the component in a given scene
  128153. */
  128154. register(): void;
  128155. private _evaluateSubMesh;
  128156. private _activeMesh;
  128157. private _prepareRessources;
  128158. private _createIndexBuffer;
  128159. /**
  128160. * Rebuilds the elements related to this component in case of
  128161. * context lost for instance.
  128162. */
  128163. rebuild(): void;
  128164. /**
  128165. * @hidden
  128166. */
  128167. reset(): void;
  128168. /**
  128169. * Render the bounding boxes of a specific rendering group
  128170. * @param renderingGroupId defines the rendering group to render
  128171. */
  128172. render(renderingGroupId: number): void;
  128173. /**
  128174. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128175. * @param mesh Define the mesh to render the occlusion bounding box for
  128176. */
  128177. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  128178. /**
  128179. * Dispose and release the resources attached to this renderer.
  128180. */
  128181. dispose(): void;
  128182. }
  128183. }
  128184. declare module BABYLON {
  128185. /** @hidden */
  128186. export var depthPixelShader: {
  128187. name: string;
  128188. shader: string;
  128189. };
  128190. }
  128191. declare module BABYLON {
  128192. /**
  128193. * This represents a depth renderer in Babylon.
  128194. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128195. */
  128196. export class DepthRenderer {
  128197. private _scene;
  128198. private _depthMap;
  128199. private _effect;
  128200. private readonly _storeNonLinearDepth;
  128201. private readonly _clearColor;
  128202. /** Get if the depth renderer is using packed depth or not */
  128203. readonly isPacked: boolean;
  128204. private _cachedDefines;
  128205. private _camera;
  128206. /**
  128207. * Specifiess that the depth renderer will only be used within
  128208. * the camera it is created for.
  128209. * This can help forcing its rendering during the camera processing.
  128210. */
  128211. useOnlyInActiveCamera: boolean;
  128212. /** @hidden */
  128213. static _SceneComponentInitialization: (scene: Scene) => void;
  128214. /**
  128215. * Instantiates a depth renderer
  128216. * @param scene The scene the renderer belongs to
  128217. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128218. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128219. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128220. */
  128221. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128222. /**
  128223. * Creates the depth rendering effect and checks if the effect is ready.
  128224. * @param subMesh The submesh to be used to render the depth map of
  128225. * @param useInstances If multiple world instances should be used
  128226. * @returns if the depth renderer is ready to render the depth map
  128227. */
  128228. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128229. /**
  128230. * Gets the texture which the depth map will be written to.
  128231. * @returns The depth map texture
  128232. */
  128233. getDepthMap(): RenderTargetTexture;
  128234. /**
  128235. * Disposes of the depth renderer.
  128236. */
  128237. dispose(): void;
  128238. }
  128239. }
  128240. declare module BABYLON {
  128241. interface Scene {
  128242. /** @hidden (Backing field) */
  128243. _depthRenderer: {
  128244. [id: string]: DepthRenderer;
  128245. };
  128246. /**
  128247. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128248. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128249. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128250. * @returns the created depth renderer
  128251. */
  128252. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128253. /**
  128254. * Disables a depth renderer for a given camera
  128255. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128256. */
  128257. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128258. }
  128259. /**
  128260. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128261. * in several rendering techniques.
  128262. */
  128263. export class DepthRendererSceneComponent implements ISceneComponent {
  128264. /**
  128265. * The component name helpfull to identify the component in the list of scene components.
  128266. */
  128267. readonly name: string;
  128268. /**
  128269. * The scene the component belongs to.
  128270. */
  128271. scene: Scene;
  128272. /**
  128273. * Creates a new instance of the component for the given scene
  128274. * @param scene Defines the scene to register the component in
  128275. */
  128276. constructor(scene: Scene);
  128277. /**
  128278. * Registers the component in a given scene
  128279. */
  128280. register(): void;
  128281. /**
  128282. * Rebuilds the elements related to this component in case of
  128283. * context lost for instance.
  128284. */
  128285. rebuild(): void;
  128286. /**
  128287. * Disposes the component and the associated ressources
  128288. */
  128289. dispose(): void;
  128290. private _gatherRenderTargets;
  128291. private _gatherActiveCameraRenderTargets;
  128292. }
  128293. }
  128294. declare module BABYLON {
  128295. /** @hidden */
  128296. export var outlinePixelShader: {
  128297. name: string;
  128298. shader: string;
  128299. };
  128300. }
  128301. declare module BABYLON {
  128302. /** @hidden */
  128303. export var outlineVertexShader: {
  128304. name: string;
  128305. shader: string;
  128306. };
  128307. }
  128308. declare module BABYLON {
  128309. interface Scene {
  128310. /** @hidden */
  128311. _outlineRenderer: OutlineRenderer;
  128312. /**
  128313. * Gets the outline renderer associated with the scene
  128314. * @returns a OutlineRenderer
  128315. */
  128316. getOutlineRenderer(): OutlineRenderer;
  128317. }
  128318. interface AbstractMesh {
  128319. /** @hidden (Backing field) */
  128320. _renderOutline: boolean;
  128321. /**
  128322. * Gets or sets a boolean indicating if the outline must be rendered as well
  128323. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128324. */
  128325. renderOutline: boolean;
  128326. /** @hidden (Backing field) */
  128327. _renderOverlay: boolean;
  128328. /**
  128329. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128330. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128331. */
  128332. renderOverlay: boolean;
  128333. }
  128334. /**
  128335. * This class is responsible to draw bothe outline/overlay of meshes.
  128336. * It should not be used directly but through the available method on mesh.
  128337. */
  128338. export class OutlineRenderer implements ISceneComponent {
  128339. /**
  128340. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128341. */
  128342. private static _StencilReference;
  128343. /**
  128344. * The name of the component. Each component must have a unique name.
  128345. */
  128346. name: string;
  128347. /**
  128348. * The scene the component belongs to.
  128349. */
  128350. scene: Scene;
  128351. /**
  128352. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128353. */
  128354. zOffset: number;
  128355. private _engine;
  128356. private _effect;
  128357. private _cachedDefines;
  128358. private _savedDepthWrite;
  128359. /**
  128360. * Instantiates a new outline renderer. (There could be only one per scene).
  128361. * @param scene Defines the scene it belongs to
  128362. */
  128363. constructor(scene: Scene);
  128364. /**
  128365. * Register the component to one instance of a scene.
  128366. */
  128367. register(): void;
  128368. /**
  128369. * Rebuilds the elements related to this component in case of
  128370. * context lost for instance.
  128371. */
  128372. rebuild(): void;
  128373. /**
  128374. * Disposes the component and the associated ressources.
  128375. */
  128376. dispose(): void;
  128377. /**
  128378. * Renders the outline in the canvas.
  128379. * @param subMesh Defines the sumesh to render
  128380. * @param batch Defines the batch of meshes in case of instances
  128381. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128382. */
  128383. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128384. /**
  128385. * Returns whether or not the outline renderer is ready for a given submesh.
  128386. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128387. * @param subMesh Defines the submesh to check readyness for
  128388. * @param useInstances Defines wheter wee are trying to render instances or not
  128389. * @returns true if ready otherwise false
  128390. */
  128391. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128392. private _beforeRenderingMesh;
  128393. private _afterRenderingMesh;
  128394. }
  128395. }
  128396. declare module BABYLON {
  128397. /**
  128398. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128399. * @see http://doc.babylonjs.com/babylon101/sprites
  128400. */
  128401. export class SpritePackedManager extends SpriteManager {
  128402. /** defines the packed manager's name */
  128403. name: string;
  128404. /**
  128405. * Creates a new sprite manager from a packed sprite sheet
  128406. * @param name defines the manager's name
  128407. * @param imgUrl defines the sprite sheet url
  128408. * @param capacity defines the maximum allowed number of sprites
  128409. * @param scene defines the hosting scene
  128410. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128411. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128412. * @param samplingMode defines the smapling mode to use with spritesheet
  128413. * @param fromPacked set to true; do not alter
  128414. */
  128415. constructor(
  128416. /** defines the packed manager's name */
  128417. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128418. }
  128419. }
  128420. declare module BABYLON {
  128421. /**
  128422. * Defines the list of states available for a task inside a AssetsManager
  128423. */
  128424. export enum AssetTaskState {
  128425. /**
  128426. * Initialization
  128427. */
  128428. INIT = 0,
  128429. /**
  128430. * Running
  128431. */
  128432. RUNNING = 1,
  128433. /**
  128434. * Done
  128435. */
  128436. DONE = 2,
  128437. /**
  128438. * Error
  128439. */
  128440. ERROR = 3
  128441. }
  128442. /**
  128443. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128444. */
  128445. export abstract class AbstractAssetTask {
  128446. /**
  128447. * Task name
  128448. */ name: string;
  128449. /**
  128450. * Callback called when the task is successful
  128451. */
  128452. onSuccess: (task: any) => void;
  128453. /**
  128454. * Callback called when the task is not successful
  128455. */
  128456. onError: (task: any, message?: string, exception?: any) => void;
  128457. /**
  128458. * Creates a new AssetsManager
  128459. * @param name defines the name of the task
  128460. */
  128461. constructor(
  128462. /**
  128463. * Task name
  128464. */ name: string);
  128465. private _isCompleted;
  128466. private _taskState;
  128467. private _errorObject;
  128468. /**
  128469. * Get if the task is completed
  128470. */
  128471. readonly isCompleted: boolean;
  128472. /**
  128473. * Gets the current state of the task
  128474. */
  128475. readonly taskState: AssetTaskState;
  128476. /**
  128477. * Gets the current error object (if task is in error)
  128478. */
  128479. readonly errorObject: {
  128480. message?: string;
  128481. exception?: any;
  128482. };
  128483. /**
  128484. * Internal only
  128485. * @hidden
  128486. */
  128487. _setErrorObject(message?: string, exception?: any): void;
  128488. /**
  128489. * Execute the current task
  128490. * @param scene defines the scene where you want your assets to be loaded
  128491. * @param onSuccess is a callback called when the task is successfully executed
  128492. * @param onError is a callback called if an error occurs
  128493. */
  128494. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128495. /**
  128496. * Execute the current task
  128497. * @param scene defines the scene where you want your assets to be loaded
  128498. * @param onSuccess is a callback called when the task is successfully executed
  128499. * @param onError is a callback called if an error occurs
  128500. */
  128501. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128502. /**
  128503. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128504. * This can be used with failed tasks that have the reason for failure fixed.
  128505. */
  128506. reset(): void;
  128507. private onErrorCallback;
  128508. private onDoneCallback;
  128509. }
  128510. /**
  128511. * Define the interface used by progress events raised during assets loading
  128512. */
  128513. export interface IAssetsProgressEvent {
  128514. /**
  128515. * Defines the number of remaining tasks to process
  128516. */
  128517. remainingCount: number;
  128518. /**
  128519. * Defines the total number of tasks
  128520. */
  128521. totalCount: number;
  128522. /**
  128523. * Defines the task that was just processed
  128524. */
  128525. task: AbstractAssetTask;
  128526. }
  128527. /**
  128528. * Class used to share progress information about assets loading
  128529. */
  128530. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128531. /**
  128532. * Defines the number of remaining tasks to process
  128533. */
  128534. remainingCount: number;
  128535. /**
  128536. * Defines the total number of tasks
  128537. */
  128538. totalCount: number;
  128539. /**
  128540. * Defines the task that was just processed
  128541. */
  128542. task: AbstractAssetTask;
  128543. /**
  128544. * Creates a AssetsProgressEvent
  128545. * @param remainingCount defines the number of remaining tasks to process
  128546. * @param totalCount defines the total number of tasks
  128547. * @param task defines the task that was just processed
  128548. */
  128549. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128550. }
  128551. /**
  128552. * Define a task used by AssetsManager to load meshes
  128553. */
  128554. export class MeshAssetTask extends AbstractAssetTask {
  128555. /**
  128556. * Defines the name of the task
  128557. */
  128558. name: string;
  128559. /**
  128560. * Defines the list of mesh's names you want to load
  128561. */
  128562. meshesNames: any;
  128563. /**
  128564. * Defines the root url to use as a base to load your meshes and associated resources
  128565. */
  128566. rootUrl: string;
  128567. /**
  128568. * Defines the filename of the scene to load from
  128569. */
  128570. sceneFilename: string;
  128571. /**
  128572. * Gets the list of loaded meshes
  128573. */
  128574. loadedMeshes: Array<AbstractMesh>;
  128575. /**
  128576. * Gets the list of loaded particle systems
  128577. */
  128578. loadedParticleSystems: Array<IParticleSystem>;
  128579. /**
  128580. * Gets the list of loaded skeletons
  128581. */
  128582. loadedSkeletons: Array<Skeleton>;
  128583. /**
  128584. * Gets the list of loaded animation groups
  128585. */
  128586. loadedAnimationGroups: Array<AnimationGroup>;
  128587. /**
  128588. * Callback called when the task is successful
  128589. */
  128590. onSuccess: (task: MeshAssetTask) => void;
  128591. /**
  128592. * Callback called when the task is successful
  128593. */
  128594. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128595. /**
  128596. * Creates a new MeshAssetTask
  128597. * @param name defines the name of the task
  128598. * @param meshesNames defines the list of mesh's names you want to load
  128599. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128600. * @param sceneFilename defines the filename of the scene to load from
  128601. */
  128602. constructor(
  128603. /**
  128604. * Defines the name of the task
  128605. */
  128606. name: string,
  128607. /**
  128608. * Defines the list of mesh's names you want to load
  128609. */
  128610. meshesNames: any,
  128611. /**
  128612. * Defines the root url to use as a base to load your meshes and associated resources
  128613. */
  128614. rootUrl: string,
  128615. /**
  128616. * Defines the filename of the scene to load from
  128617. */
  128618. sceneFilename: string);
  128619. /**
  128620. * Execute the current task
  128621. * @param scene defines the scene where you want your assets to be loaded
  128622. * @param onSuccess is a callback called when the task is successfully executed
  128623. * @param onError is a callback called if an error occurs
  128624. */
  128625. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128626. }
  128627. /**
  128628. * Define a task used by AssetsManager to load text content
  128629. */
  128630. export class TextFileAssetTask extends AbstractAssetTask {
  128631. /**
  128632. * Defines the name of the task
  128633. */
  128634. name: string;
  128635. /**
  128636. * Defines the location of the file to load
  128637. */
  128638. url: string;
  128639. /**
  128640. * Gets the loaded text string
  128641. */
  128642. text: string;
  128643. /**
  128644. * Callback called when the task is successful
  128645. */
  128646. onSuccess: (task: TextFileAssetTask) => void;
  128647. /**
  128648. * Callback called when the task is successful
  128649. */
  128650. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128651. /**
  128652. * Creates a new TextFileAssetTask object
  128653. * @param name defines the name of the task
  128654. * @param url defines the location of the file to load
  128655. */
  128656. constructor(
  128657. /**
  128658. * Defines the name of the task
  128659. */
  128660. name: string,
  128661. /**
  128662. * Defines the location of the file to load
  128663. */
  128664. url: string);
  128665. /**
  128666. * Execute the current task
  128667. * @param scene defines the scene where you want your assets to be loaded
  128668. * @param onSuccess is a callback called when the task is successfully executed
  128669. * @param onError is a callback called if an error occurs
  128670. */
  128671. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128672. }
  128673. /**
  128674. * Define a task used by AssetsManager to load binary data
  128675. */
  128676. export class BinaryFileAssetTask extends AbstractAssetTask {
  128677. /**
  128678. * Defines the name of the task
  128679. */
  128680. name: string;
  128681. /**
  128682. * Defines the location of the file to load
  128683. */
  128684. url: string;
  128685. /**
  128686. * Gets the lodaded data (as an array buffer)
  128687. */
  128688. data: ArrayBuffer;
  128689. /**
  128690. * Callback called when the task is successful
  128691. */
  128692. onSuccess: (task: BinaryFileAssetTask) => void;
  128693. /**
  128694. * Callback called when the task is successful
  128695. */
  128696. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128697. /**
  128698. * Creates a new BinaryFileAssetTask object
  128699. * @param name defines the name of the new task
  128700. * @param url defines the location of the file to load
  128701. */
  128702. constructor(
  128703. /**
  128704. * Defines the name of the task
  128705. */
  128706. name: string,
  128707. /**
  128708. * Defines the location of the file to load
  128709. */
  128710. url: string);
  128711. /**
  128712. * Execute the current task
  128713. * @param scene defines the scene where you want your assets to be loaded
  128714. * @param onSuccess is a callback called when the task is successfully executed
  128715. * @param onError is a callback called if an error occurs
  128716. */
  128717. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128718. }
  128719. /**
  128720. * Define a task used by AssetsManager to load images
  128721. */
  128722. export class ImageAssetTask extends AbstractAssetTask {
  128723. /**
  128724. * Defines the name of the task
  128725. */
  128726. name: string;
  128727. /**
  128728. * Defines the location of the image to load
  128729. */
  128730. url: string;
  128731. /**
  128732. * Gets the loaded images
  128733. */
  128734. image: HTMLImageElement;
  128735. /**
  128736. * Callback called when the task is successful
  128737. */
  128738. onSuccess: (task: ImageAssetTask) => void;
  128739. /**
  128740. * Callback called when the task is successful
  128741. */
  128742. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128743. /**
  128744. * Creates a new ImageAssetTask
  128745. * @param name defines the name of the task
  128746. * @param url defines the location of the image to load
  128747. */
  128748. constructor(
  128749. /**
  128750. * Defines the name of the task
  128751. */
  128752. name: string,
  128753. /**
  128754. * Defines the location of the image to load
  128755. */
  128756. url: string);
  128757. /**
  128758. * Execute the current task
  128759. * @param scene defines the scene where you want your assets to be loaded
  128760. * @param onSuccess is a callback called when the task is successfully executed
  128761. * @param onError is a callback called if an error occurs
  128762. */
  128763. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128764. }
  128765. /**
  128766. * Defines the interface used by texture loading tasks
  128767. */
  128768. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128769. /**
  128770. * Gets the loaded texture
  128771. */
  128772. texture: TEX;
  128773. }
  128774. /**
  128775. * Define a task used by AssetsManager to load 2D textures
  128776. */
  128777. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128778. /**
  128779. * Defines the name of the task
  128780. */
  128781. name: string;
  128782. /**
  128783. * Defines the location of the file to load
  128784. */
  128785. url: string;
  128786. /**
  128787. * Defines if mipmap should not be generated (default is false)
  128788. */
  128789. noMipmap?: boolean | undefined;
  128790. /**
  128791. * Defines if texture must be inverted on Y axis (default is false)
  128792. */
  128793. invertY?: boolean | undefined;
  128794. /**
  128795. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128796. */
  128797. samplingMode: number;
  128798. /**
  128799. * Gets the loaded texture
  128800. */
  128801. texture: Texture;
  128802. /**
  128803. * Callback called when the task is successful
  128804. */
  128805. onSuccess: (task: TextureAssetTask) => void;
  128806. /**
  128807. * Callback called when the task is successful
  128808. */
  128809. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128810. /**
  128811. * Creates a new TextureAssetTask object
  128812. * @param name defines the name of the task
  128813. * @param url defines the location of the file to load
  128814. * @param noMipmap defines if mipmap should not be generated (default is false)
  128815. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128816. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128817. */
  128818. constructor(
  128819. /**
  128820. * Defines the name of the task
  128821. */
  128822. name: string,
  128823. /**
  128824. * Defines the location of the file to load
  128825. */
  128826. url: string,
  128827. /**
  128828. * Defines if mipmap should not be generated (default is false)
  128829. */
  128830. noMipmap?: boolean | undefined,
  128831. /**
  128832. * Defines if texture must be inverted on Y axis (default is false)
  128833. */
  128834. invertY?: boolean | undefined,
  128835. /**
  128836. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128837. */
  128838. samplingMode?: number);
  128839. /**
  128840. * Execute the current task
  128841. * @param scene defines the scene where you want your assets to be loaded
  128842. * @param onSuccess is a callback called when the task is successfully executed
  128843. * @param onError is a callback called if an error occurs
  128844. */
  128845. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128846. }
  128847. /**
  128848. * Define a task used by AssetsManager to load cube textures
  128849. */
  128850. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128851. /**
  128852. * Defines the name of the task
  128853. */
  128854. name: string;
  128855. /**
  128856. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128857. */
  128858. url: string;
  128859. /**
  128860. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128861. */
  128862. extensions?: string[] | undefined;
  128863. /**
  128864. * Defines if mipmaps should not be generated (default is false)
  128865. */
  128866. noMipmap?: boolean | undefined;
  128867. /**
  128868. * Defines the explicit list of files (undefined by default)
  128869. */
  128870. files?: string[] | undefined;
  128871. /**
  128872. * Gets the loaded texture
  128873. */
  128874. texture: CubeTexture;
  128875. /**
  128876. * Callback called when the task is successful
  128877. */
  128878. onSuccess: (task: CubeTextureAssetTask) => void;
  128879. /**
  128880. * Callback called when the task is successful
  128881. */
  128882. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128883. /**
  128884. * Creates a new CubeTextureAssetTask
  128885. * @param name defines the name of the task
  128886. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128887. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128888. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128889. * @param files defines the explicit list of files (undefined by default)
  128890. */
  128891. constructor(
  128892. /**
  128893. * Defines the name of the task
  128894. */
  128895. name: string,
  128896. /**
  128897. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128898. */
  128899. url: string,
  128900. /**
  128901. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128902. */
  128903. extensions?: string[] | undefined,
  128904. /**
  128905. * Defines if mipmaps should not be generated (default is false)
  128906. */
  128907. noMipmap?: boolean | undefined,
  128908. /**
  128909. * Defines the explicit list of files (undefined by default)
  128910. */
  128911. files?: string[] | undefined);
  128912. /**
  128913. * Execute the current task
  128914. * @param scene defines the scene where you want your assets to be loaded
  128915. * @param onSuccess is a callback called when the task is successfully executed
  128916. * @param onError is a callback called if an error occurs
  128917. */
  128918. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128919. }
  128920. /**
  128921. * Define a task used by AssetsManager to load HDR cube textures
  128922. */
  128923. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128924. /**
  128925. * Defines the name of the task
  128926. */
  128927. name: string;
  128928. /**
  128929. * Defines the location of the file to load
  128930. */
  128931. url: string;
  128932. /**
  128933. * Defines the desired size (the more it increases the longer the generation will be)
  128934. */
  128935. size: number;
  128936. /**
  128937. * Defines if mipmaps should not be generated (default is false)
  128938. */
  128939. noMipmap: boolean;
  128940. /**
  128941. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128942. */
  128943. generateHarmonics: boolean;
  128944. /**
  128945. * 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)
  128946. */
  128947. gammaSpace: boolean;
  128948. /**
  128949. * Internal Use Only
  128950. */
  128951. reserved: boolean;
  128952. /**
  128953. * Gets the loaded texture
  128954. */
  128955. texture: HDRCubeTexture;
  128956. /**
  128957. * Callback called when the task is successful
  128958. */
  128959. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128960. /**
  128961. * Callback called when the task is successful
  128962. */
  128963. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128964. /**
  128965. * Creates a new HDRCubeTextureAssetTask object
  128966. * @param name defines the name of the task
  128967. * @param url defines the location of the file to load
  128968. * @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.
  128969. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128970. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128971. * @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)
  128972. * @param reserved Internal use only
  128973. */
  128974. constructor(
  128975. /**
  128976. * Defines the name of the task
  128977. */
  128978. name: string,
  128979. /**
  128980. * Defines the location of the file to load
  128981. */
  128982. url: string,
  128983. /**
  128984. * Defines the desired size (the more it increases the longer the generation will be)
  128985. */
  128986. size: number,
  128987. /**
  128988. * Defines if mipmaps should not be generated (default is false)
  128989. */
  128990. noMipmap?: boolean,
  128991. /**
  128992. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128993. */
  128994. generateHarmonics?: boolean,
  128995. /**
  128996. * 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)
  128997. */
  128998. gammaSpace?: boolean,
  128999. /**
  129000. * Internal Use Only
  129001. */
  129002. reserved?: boolean);
  129003. /**
  129004. * Execute the current task
  129005. * @param scene defines the scene where you want your assets to be loaded
  129006. * @param onSuccess is a callback called when the task is successfully executed
  129007. * @param onError is a callback called if an error occurs
  129008. */
  129009. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129010. }
  129011. /**
  129012. * Define a task used by AssetsManager to load Equirectangular cube textures
  129013. */
  129014. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  129015. /**
  129016. * Defines the name of the task
  129017. */
  129018. name: string;
  129019. /**
  129020. * Defines the location of the file to load
  129021. */
  129022. url: string;
  129023. /**
  129024. * Defines the desired size (the more it increases the longer the generation will be)
  129025. */
  129026. size: number;
  129027. /**
  129028. * Defines if mipmaps should not be generated (default is false)
  129029. */
  129030. noMipmap: boolean;
  129031. /**
  129032. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129033. * but the standard material would require them in Gamma space) (default is true)
  129034. */
  129035. gammaSpace: boolean;
  129036. /**
  129037. * Gets the loaded texture
  129038. */
  129039. texture: EquiRectangularCubeTexture;
  129040. /**
  129041. * Callback called when the task is successful
  129042. */
  129043. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  129044. /**
  129045. * Callback called when the task is successful
  129046. */
  129047. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  129048. /**
  129049. * Creates a new EquiRectangularCubeTextureAssetTask object
  129050. * @param name defines the name of the task
  129051. * @param url defines the location of the file to load
  129052. * @param size defines the desired size (the more it increases the longer the generation will be)
  129053. * If the size is omitted this implies you are using a preprocessed cubemap.
  129054. * @param noMipmap defines if mipmaps should not be generated (default is false)
  129055. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  129056. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  129057. * (default is true)
  129058. */
  129059. constructor(
  129060. /**
  129061. * Defines the name of the task
  129062. */
  129063. name: string,
  129064. /**
  129065. * Defines the location of the file to load
  129066. */
  129067. url: string,
  129068. /**
  129069. * Defines the desired size (the more it increases the longer the generation will be)
  129070. */
  129071. size: number,
  129072. /**
  129073. * Defines if mipmaps should not be generated (default is false)
  129074. */
  129075. noMipmap?: boolean,
  129076. /**
  129077. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  129078. * but the standard material would require them in Gamma space) (default is true)
  129079. */
  129080. gammaSpace?: boolean);
  129081. /**
  129082. * Execute the current task
  129083. * @param scene defines the scene where you want your assets to be loaded
  129084. * @param onSuccess is a callback called when the task is successfully executed
  129085. * @param onError is a callback called if an error occurs
  129086. */
  129087. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  129088. }
  129089. /**
  129090. * This class can be used to easily import assets into a scene
  129091. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  129092. */
  129093. export class AssetsManager {
  129094. private _scene;
  129095. private _isLoading;
  129096. protected _tasks: AbstractAssetTask[];
  129097. protected _waitingTasksCount: number;
  129098. protected _totalTasksCount: number;
  129099. /**
  129100. * Callback called when all tasks are processed
  129101. */
  129102. onFinish: (tasks: AbstractAssetTask[]) => void;
  129103. /**
  129104. * Callback called when a task is successful
  129105. */
  129106. onTaskSuccess: (task: AbstractAssetTask) => void;
  129107. /**
  129108. * Callback called when a task had an error
  129109. */
  129110. onTaskError: (task: AbstractAssetTask) => void;
  129111. /**
  129112. * Callback called when a task is done (whatever the result is)
  129113. */
  129114. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  129115. /**
  129116. * Observable called when all tasks are processed
  129117. */
  129118. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  129119. /**
  129120. * Observable called when a task had an error
  129121. */
  129122. onTaskErrorObservable: Observable<AbstractAssetTask>;
  129123. /**
  129124. * Observable called when all tasks were executed
  129125. */
  129126. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  129127. /**
  129128. * Observable called when a task is done (whatever the result is)
  129129. */
  129130. onProgressObservable: Observable<IAssetsProgressEvent>;
  129131. /**
  129132. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  129133. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  129134. */
  129135. useDefaultLoadingScreen: boolean;
  129136. /**
  129137. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  129138. * when all assets have been downloaded.
  129139. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  129140. */
  129141. autoHideLoadingUI: boolean;
  129142. /**
  129143. * Creates a new AssetsManager
  129144. * @param scene defines the scene to work on
  129145. */
  129146. constructor(scene: Scene);
  129147. /**
  129148. * Add a MeshAssetTask to the list of active tasks
  129149. * @param taskName defines the name of the new task
  129150. * @param meshesNames defines the name of meshes to load
  129151. * @param rootUrl defines the root url to use to locate files
  129152. * @param sceneFilename defines the filename of the scene file
  129153. * @returns a new MeshAssetTask object
  129154. */
  129155. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  129156. /**
  129157. * Add a TextFileAssetTask to the list of active tasks
  129158. * @param taskName defines the name of the new task
  129159. * @param url defines the url of the file to load
  129160. * @returns a new TextFileAssetTask object
  129161. */
  129162. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  129163. /**
  129164. * Add a BinaryFileAssetTask to the list of active tasks
  129165. * @param taskName defines the name of the new task
  129166. * @param url defines the url of the file to load
  129167. * @returns a new BinaryFileAssetTask object
  129168. */
  129169. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  129170. /**
  129171. * Add a ImageAssetTask to the list of active tasks
  129172. * @param taskName defines the name of the new task
  129173. * @param url defines the url of the file to load
  129174. * @returns a new ImageAssetTask object
  129175. */
  129176. addImageTask(taskName: string, url: string): ImageAssetTask;
  129177. /**
  129178. * Add a TextureAssetTask to the list of active tasks
  129179. * @param taskName defines the name of the new task
  129180. * @param url defines the url of the file to load
  129181. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129182. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  129183. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129184. * @returns a new TextureAssetTask object
  129185. */
  129186. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  129187. /**
  129188. * Add a CubeTextureAssetTask to the list of active tasks
  129189. * @param taskName defines the name of the new task
  129190. * @param url defines the url of the file to load
  129191. * @param extensions defines the extension to use to load the cube map (can be null)
  129192. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129193. * @param files defines the list of files to load (can be null)
  129194. * @returns a new CubeTextureAssetTask object
  129195. */
  129196. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  129197. /**
  129198. *
  129199. * Add a HDRCubeTextureAssetTask to the list of active tasks
  129200. * @param taskName defines the name of the new task
  129201. * @param url defines the url of the file to load
  129202. * @param size defines the size you want for the cubemap (can be null)
  129203. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129204. * @param generateHarmonics defines if you want to automatically generate (true by default)
  129205. * @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)
  129206. * @param reserved Internal use only
  129207. * @returns a new HDRCubeTextureAssetTask object
  129208. */
  129209. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  129210. /**
  129211. *
  129212. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  129213. * @param taskName defines the name of the new task
  129214. * @param url defines the url of the file to load
  129215. * @param size defines the size you want for the cubemap (can be null)
  129216. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129217. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129218. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129219. * @returns a new EquiRectangularCubeTextureAssetTask object
  129220. */
  129221. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  129222. /**
  129223. * Remove a task from the assets manager.
  129224. * @param task the task to remove
  129225. */
  129226. removeTask(task: AbstractAssetTask): void;
  129227. private _decreaseWaitingTasksCount;
  129228. private _runTask;
  129229. /**
  129230. * Reset the AssetsManager and remove all tasks
  129231. * @return the current instance of the AssetsManager
  129232. */
  129233. reset(): AssetsManager;
  129234. /**
  129235. * Start the loading process
  129236. * @return the current instance of the AssetsManager
  129237. */
  129238. load(): AssetsManager;
  129239. /**
  129240. * Start the loading process as an async operation
  129241. * @return a promise returning the list of failed tasks
  129242. */
  129243. loadAsync(): Promise<void>;
  129244. }
  129245. }
  129246. declare module BABYLON {
  129247. /**
  129248. * Wrapper class for promise with external resolve and reject.
  129249. */
  129250. export class Deferred<T> {
  129251. /**
  129252. * The promise associated with this deferred object.
  129253. */
  129254. readonly promise: Promise<T>;
  129255. private _resolve;
  129256. private _reject;
  129257. /**
  129258. * The resolve method of the promise associated with this deferred object.
  129259. */
  129260. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129261. /**
  129262. * The reject method of the promise associated with this deferred object.
  129263. */
  129264. readonly reject: (reason?: any) => void;
  129265. /**
  129266. * Constructor for this deferred object.
  129267. */
  129268. constructor();
  129269. }
  129270. }
  129271. declare module BABYLON {
  129272. /**
  129273. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129274. */
  129275. export class MeshExploder {
  129276. private _centerMesh;
  129277. private _meshes;
  129278. private _meshesOrigins;
  129279. private _toCenterVectors;
  129280. private _scaledDirection;
  129281. private _newPosition;
  129282. private _centerPosition;
  129283. /**
  129284. * Explodes meshes from a center mesh.
  129285. * @param meshes The meshes to explode.
  129286. * @param centerMesh The mesh to be center of explosion.
  129287. */
  129288. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129289. private _setCenterMesh;
  129290. /**
  129291. * Get class name
  129292. * @returns "MeshExploder"
  129293. */
  129294. getClassName(): string;
  129295. /**
  129296. * "Exploded meshes"
  129297. * @returns Array of meshes with the centerMesh at index 0.
  129298. */
  129299. getMeshes(): Array<Mesh>;
  129300. /**
  129301. * Explodes meshes giving a specific direction
  129302. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129303. */
  129304. explode(direction?: number): void;
  129305. }
  129306. }
  129307. declare module BABYLON {
  129308. /**
  129309. * Class used to help managing file picking and drag'n'drop
  129310. */
  129311. export class FilesInput {
  129312. /**
  129313. * List of files ready to be loaded
  129314. */
  129315. static readonly FilesToLoad: {
  129316. [key: string]: File;
  129317. };
  129318. /**
  129319. * Callback called when a file is processed
  129320. */
  129321. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129322. private _engine;
  129323. private _currentScene;
  129324. private _sceneLoadedCallback;
  129325. private _progressCallback;
  129326. private _additionalRenderLoopLogicCallback;
  129327. private _textureLoadingCallback;
  129328. private _startingProcessingFilesCallback;
  129329. private _onReloadCallback;
  129330. private _errorCallback;
  129331. private _elementToMonitor;
  129332. private _sceneFileToLoad;
  129333. private _filesToLoad;
  129334. /**
  129335. * Creates a new FilesInput
  129336. * @param engine defines the rendering engine
  129337. * @param scene defines the hosting scene
  129338. * @param sceneLoadedCallback callback called when scene is loaded
  129339. * @param progressCallback callback called to track progress
  129340. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129341. * @param textureLoadingCallback callback called when a texture is loading
  129342. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129343. * @param onReloadCallback callback called when a reload is requested
  129344. * @param errorCallback callback call if an error occurs
  129345. */
  129346. 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);
  129347. private _dragEnterHandler;
  129348. private _dragOverHandler;
  129349. private _dropHandler;
  129350. /**
  129351. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129352. * @param elementToMonitor defines the DOM element to track
  129353. */
  129354. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129355. /**
  129356. * Release all associated resources
  129357. */
  129358. dispose(): void;
  129359. private renderFunction;
  129360. private drag;
  129361. private drop;
  129362. private _traverseFolder;
  129363. private _processFiles;
  129364. /**
  129365. * Load files from a drop event
  129366. * @param event defines the drop event to use as source
  129367. */
  129368. loadFiles(event: any): void;
  129369. private _processReload;
  129370. /**
  129371. * Reload the current scene from the loaded files
  129372. */
  129373. reload(): void;
  129374. }
  129375. }
  129376. declare module BABYLON {
  129377. /**
  129378. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129379. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129380. */
  129381. export class SceneOptimization {
  129382. /**
  129383. * Defines the priority of this optimization (0 by default which means first in the list)
  129384. */
  129385. priority: number;
  129386. /**
  129387. * Gets a string describing the action executed by the current optimization
  129388. * @returns description string
  129389. */
  129390. getDescription(): string;
  129391. /**
  129392. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129393. * @param scene defines the current scene where to apply this optimization
  129394. * @param optimizer defines the current optimizer
  129395. * @returns true if everything that can be done was applied
  129396. */
  129397. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129398. /**
  129399. * Creates the SceneOptimization object
  129400. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129401. * @param desc defines the description associated with the optimization
  129402. */
  129403. constructor(
  129404. /**
  129405. * Defines the priority of this optimization (0 by default which means first in the list)
  129406. */
  129407. priority?: number);
  129408. }
  129409. /**
  129410. * Defines an optimization used to reduce the size of render target textures
  129411. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129412. */
  129413. export class TextureOptimization extends SceneOptimization {
  129414. /**
  129415. * Defines the priority of this optimization (0 by default which means first in the list)
  129416. */
  129417. priority: number;
  129418. /**
  129419. * 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
  129420. */
  129421. maximumSize: number;
  129422. /**
  129423. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129424. */
  129425. step: number;
  129426. /**
  129427. * Gets a string describing the action executed by the current optimization
  129428. * @returns description string
  129429. */
  129430. getDescription(): string;
  129431. /**
  129432. * Creates the TextureOptimization object
  129433. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129434. * @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
  129435. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129436. */
  129437. constructor(
  129438. /**
  129439. * Defines the priority of this optimization (0 by default which means first in the list)
  129440. */
  129441. priority?: number,
  129442. /**
  129443. * 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
  129444. */
  129445. maximumSize?: number,
  129446. /**
  129447. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129448. */
  129449. step?: number);
  129450. /**
  129451. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129452. * @param scene defines the current scene where to apply this optimization
  129453. * @param optimizer defines the current optimizer
  129454. * @returns true if everything that can be done was applied
  129455. */
  129456. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129457. }
  129458. /**
  129459. * Defines an optimization used to increase or decrease the rendering resolution
  129460. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129461. */
  129462. export class HardwareScalingOptimization extends SceneOptimization {
  129463. /**
  129464. * Defines the priority of this optimization (0 by default which means first in the list)
  129465. */
  129466. priority: number;
  129467. /**
  129468. * Defines the maximum scale to use (2 by default)
  129469. */
  129470. maximumScale: number;
  129471. /**
  129472. * Defines the step to use between two passes (0.5 by default)
  129473. */
  129474. step: number;
  129475. private _currentScale;
  129476. private _directionOffset;
  129477. /**
  129478. * Gets a string describing the action executed by the current optimization
  129479. * @return description string
  129480. */
  129481. getDescription(): string;
  129482. /**
  129483. * Creates the HardwareScalingOptimization object
  129484. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129485. * @param maximumScale defines the maximum scale to use (2 by default)
  129486. * @param step defines the step to use between two passes (0.5 by default)
  129487. */
  129488. constructor(
  129489. /**
  129490. * Defines the priority of this optimization (0 by default which means first in the list)
  129491. */
  129492. priority?: number,
  129493. /**
  129494. * Defines the maximum scale to use (2 by default)
  129495. */
  129496. maximumScale?: number,
  129497. /**
  129498. * Defines the step to use between two passes (0.5 by default)
  129499. */
  129500. step?: number);
  129501. /**
  129502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129503. * @param scene defines the current scene where to apply this optimization
  129504. * @param optimizer defines the current optimizer
  129505. * @returns true if everything that can be done was applied
  129506. */
  129507. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129508. }
  129509. /**
  129510. * Defines an optimization used to remove shadows
  129511. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129512. */
  129513. export class ShadowsOptimization extends SceneOptimization {
  129514. /**
  129515. * Gets a string describing the action executed by the current optimization
  129516. * @return description string
  129517. */
  129518. getDescription(): string;
  129519. /**
  129520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129521. * @param scene defines the current scene where to apply this optimization
  129522. * @param optimizer defines the current optimizer
  129523. * @returns true if everything that can be done was applied
  129524. */
  129525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129526. }
  129527. /**
  129528. * Defines an optimization used to turn post-processes off
  129529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129530. */
  129531. export class PostProcessesOptimization extends SceneOptimization {
  129532. /**
  129533. * Gets a string describing the action executed by the current optimization
  129534. * @return description string
  129535. */
  129536. getDescription(): string;
  129537. /**
  129538. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129539. * @param scene defines the current scene where to apply this optimization
  129540. * @param optimizer defines the current optimizer
  129541. * @returns true if everything that can be done was applied
  129542. */
  129543. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129544. }
  129545. /**
  129546. * Defines an optimization used to turn lens flares off
  129547. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129548. */
  129549. export class LensFlaresOptimization extends SceneOptimization {
  129550. /**
  129551. * Gets a string describing the action executed by the current optimization
  129552. * @return description string
  129553. */
  129554. getDescription(): string;
  129555. /**
  129556. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129557. * @param scene defines the current scene where to apply this optimization
  129558. * @param optimizer defines the current optimizer
  129559. * @returns true if everything that can be done was applied
  129560. */
  129561. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129562. }
  129563. /**
  129564. * Defines an optimization based on user defined callback.
  129565. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129566. */
  129567. export class CustomOptimization extends SceneOptimization {
  129568. /**
  129569. * Callback called to apply the custom optimization.
  129570. */
  129571. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129572. /**
  129573. * Callback called to get custom description
  129574. */
  129575. onGetDescription: () => string;
  129576. /**
  129577. * Gets a string describing the action executed by the current optimization
  129578. * @returns description string
  129579. */
  129580. getDescription(): string;
  129581. /**
  129582. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129583. * @param scene defines the current scene where to apply this optimization
  129584. * @param optimizer defines the current optimizer
  129585. * @returns true if everything that can be done was applied
  129586. */
  129587. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129588. }
  129589. /**
  129590. * Defines an optimization used to turn particles off
  129591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129592. */
  129593. export class ParticlesOptimization extends SceneOptimization {
  129594. /**
  129595. * Gets a string describing the action executed by the current optimization
  129596. * @return description string
  129597. */
  129598. getDescription(): string;
  129599. /**
  129600. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129601. * @param scene defines the current scene where to apply this optimization
  129602. * @param optimizer defines the current optimizer
  129603. * @returns true if everything that can be done was applied
  129604. */
  129605. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129606. }
  129607. /**
  129608. * Defines an optimization used to turn render targets off
  129609. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129610. */
  129611. export class RenderTargetsOptimization extends SceneOptimization {
  129612. /**
  129613. * Gets a string describing the action executed by the current optimization
  129614. * @return description string
  129615. */
  129616. getDescription(): string;
  129617. /**
  129618. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129619. * @param scene defines the current scene where to apply this optimization
  129620. * @param optimizer defines the current optimizer
  129621. * @returns true if everything that can be done was applied
  129622. */
  129623. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129624. }
  129625. /**
  129626. * Defines an optimization used to merge meshes with compatible materials
  129627. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129628. */
  129629. export class MergeMeshesOptimization extends SceneOptimization {
  129630. private static _UpdateSelectionTree;
  129631. /**
  129632. * Gets or sets a boolean which defines if optimization octree has to be updated
  129633. */
  129634. /**
  129635. * Gets or sets a boolean which defines if optimization octree has to be updated
  129636. */
  129637. static UpdateSelectionTree: boolean;
  129638. /**
  129639. * Gets a string describing the action executed by the current optimization
  129640. * @return description string
  129641. */
  129642. getDescription(): string;
  129643. private _canBeMerged;
  129644. /**
  129645. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129646. * @param scene defines the current scene where to apply this optimization
  129647. * @param optimizer defines the current optimizer
  129648. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129649. * @returns true if everything that can be done was applied
  129650. */
  129651. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129652. }
  129653. /**
  129654. * Defines a list of options used by SceneOptimizer
  129655. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129656. */
  129657. export class SceneOptimizerOptions {
  129658. /**
  129659. * Defines the target frame rate to reach (60 by default)
  129660. */
  129661. targetFrameRate: number;
  129662. /**
  129663. * Defines the interval between two checkes (2000ms by default)
  129664. */
  129665. trackerDuration: number;
  129666. /**
  129667. * Gets the list of optimizations to apply
  129668. */
  129669. optimizations: SceneOptimization[];
  129670. /**
  129671. * Creates a new list of options used by SceneOptimizer
  129672. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129673. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129674. */
  129675. constructor(
  129676. /**
  129677. * Defines the target frame rate to reach (60 by default)
  129678. */
  129679. targetFrameRate?: number,
  129680. /**
  129681. * Defines the interval between two checkes (2000ms by default)
  129682. */
  129683. trackerDuration?: number);
  129684. /**
  129685. * Add a new optimization
  129686. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129687. * @returns the current SceneOptimizerOptions
  129688. */
  129689. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129690. /**
  129691. * Add a new custom optimization
  129692. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129693. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129694. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129695. * @returns the current SceneOptimizerOptions
  129696. */
  129697. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129698. /**
  129699. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129700. * @param targetFrameRate defines the target frame rate (60 by default)
  129701. * @returns a SceneOptimizerOptions object
  129702. */
  129703. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129704. /**
  129705. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129706. * @param targetFrameRate defines the target frame rate (60 by default)
  129707. * @returns a SceneOptimizerOptions object
  129708. */
  129709. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129710. /**
  129711. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129712. * @param targetFrameRate defines the target frame rate (60 by default)
  129713. * @returns a SceneOptimizerOptions object
  129714. */
  129715. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129716. }
  129717. /**
  129718. * Class used to run optimizations in order to reach a target frame rate
  129719. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129720. */
  129721. export class SceneOptimizer implements IDisposable {
  129722. private _isRunning;
  129723. private _options;
  129724. private _scene;
  129725. private _currentPriorityLevel;
  129726. private _targetFrameRate;
  129727. private _trackerDuration;
  129728. private _currentFrameRate;
  129729. private _sceneDisposeObserver;
  129730. private _improvementMode;
  129731. /**
  129732. * Defines an observable called when the optimizer reaches the target frame rate
  129733. */
  129734. onSuccessObservable: Observable<SceneOptimizer>;
  129735. /**
  129736. * Defines an observable called when the optimizer enables an optimization
  129737. */
  129738. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129739. /**
  129740. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129741. */
  129742. onFailureObservable: Observable<SceneOptimizer>;
  129743. /**
  129744. * Gets a boolean indicating if the optimizer is in improvement mode
  129745. */
  129746. readonly isInImprovementMode: boolean;
  129747. /**
  129748. * Gets the current priority level (0 at start)
  129749. */
  129750. readonly currentPriorityLevel: number;
  129751. /**
  129752. * Gets the current frame rate checked by the SceneOptimizer
  129753. */
  129754. readonly currentFrameRate: number;
  129755. /**
  129756. * Gets or sets the current target frame rate (60 by default)
  129757. */
  129758. /**
  129759. * Gets or sets the current target frame rate (60 by default)
  129760. */
  129761. targetFrameRate: number;
  129762. /**
  129763. * Gets or sets the current interval between two checks (every 2000ms by default)
  129764. */
  129765. /**
  129766. * Gets or sets the current interval between two checks (every 2000ms by default)
  129767. */
  129768. trackerDuration: number;
  129769. /**
  129770. * Gets the list of active optimizations
  129771. */
  129772. readonly optimizations: SceneOptimization[];
  129773. /**
  129774. * Creates a new SceneOptimizer
  129775. * @param scene defines the scene to work on
  129776. * @param options defines the options to use with the SceneOptimizer
  129777. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129778. * @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)
  129779. */
  129780. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129781. /**
  129782. * Stops the current optimizer
  129783. */
  129784. stop(): void;
  129785. /**
  129786. * Reset the optimizer to initial step (current priority level = 0)
  129787. */
  129788. reset(): void;
  129789. /**
  129790. * Start the optimizer. By default it will try to reach a specific framerate
  129791. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129792. */
  129793. start(): void;
  129794. private _checkCurrentState;
  129795. /**
  129796. * Release all resources
  129797. */
  129798. dispose(): void;
  129799. /**
  129800. * Helper function to create a SceneOptimizer with one single line of code
  129801. * @param scene defines the scene to work on
  129802. * @param options defines the options to use with the SceneOptimizer
  129803. * @param onSuccess defines a callback to call on success
  129804. * @param onFailure defines a callback to call on failure
  129805. * @returns the new SceneOptimizer object
  129806. */
  129807. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129808. }
  129809. }
  129810. declare module BABYLON {
  129811. /**
  129812. * Class used to serialize a scene into a string
  129813. */
  129814. export class SceneSerializer {
  129815. /**
  129816. * Clear cache used by a previous serialization
  129817. */
  129818. static ClearCache(): void;
  129819. /**
  129820. * Serialize a scene into a JSON compatible object
  129821. * @param scene defines the scene to serialize
  129822. * @returns a JSON compatible object
  129823. */
  129824. static Serialize(scene: Scene): any;
  129825. /**
  129826. * Serialize a mesh into a JSON compatible object
  129827. * @param toSerialize defines the mesh to serialize
  129828. * @param withParents defines if parents must be serialized as well
  129829. * @param withChildren defines if children must be serialized as well
  129830. * @returns a JSON compatible object
  129831. */
  129832. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129833. }
  129834. }
  129835. declare module BABYLON {
  129836. /**
  129837. * Class used to host texture specific utilities
  129838. */
  129839. export class TextureTools {
  129840. /**
  129841. * Uses the GPU to create a copy texture rescaled at a given size
  129842. * @param texture Texture to copy from
  129843. * @param width defines the desired width
  129844. * @param height defines the desired height
  129845. * @param useBilinearMode defines if bilinear mode has to be used
  129846. * @return the generated texture
  129847. */
  129848. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129849. }
  129850. }
  129851. declare module BABYLON {
  129852. /**
  129853. * This represents the different options available for the video capture.
  129854. */
  129855. export interface VideoRecorderOptions {
  129856. /** Defines the mime type of the video. */
  129857. mimeType: string;
  129858. /** Defines the FPS the video should be recorded at. */
  129859. fps: number;
  129860. /** Defines the chunk size for the recording data. */
  129861. recordChunckSize: number;
  129862. /** The audio tracks to attach to the recording. */
  129863. audioTracks?: MediaStreamTrack[];
  129864. }
  129865. /**
  129866. * This can help with recording videos from BabylonJS.
  129867. * This is based on the available WebRTC functionalities of the browser.
  129868. *
  129869. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129870. */
  129871. export class VideoRecorder {
  129872. private static readonly _defaultOptions;
  129873. /**
  129874. * Returns whether or not the VideoRecorder is available in your browser.
  129875. * @param engine Defines the Babylon Engine.
  129876. * @returns true if supported otherwise false.
  129877. */
  129878. static IsSupported(engine: Engine): boolean;
  129879. private readonly _options;
  129880. private _canvas;
  129881. private _mediaRecorder;
  129882. private _recordedChunks;
  129883. private _fileName;
  129884. private _resolve;
  129885. private _reject;
  129886. /**
  129887. * True when a recording is already in progress.
  129888. */
  129889. readonly isRecording: boolean;
  129890. /**
  129891. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129892. * @param engine Defines the BabylonJS Engine you wish to record.
  129893. * @param options Defines options that can be used to customize the capture.
  129894. */
  129895. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129896. /**
  129897. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129898. */
  129899. stopRecording(): void;
  129900. /**
  129901. * Starts recording the canvas for a max duration specified in parameters.
  129902. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129903. * If null no automatic download will start and you can rely on the promise to get the data back.
  129904. * @param maxDuration Defines the maximum recording time in seconds.
  129905. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129906. * @return A promise callback at the end of the recording with the video data in Blob.
  129907. */
  129908. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129909. /**
  129910. * Releases internal resources used during the recording.
  129911. */
  129912. dispose(): void;
  129913. private _handleDataAvailable;
  129914. private _handleError;
  129915. private _handleStop;
  129916. }
  129917. }
  129918. declare module BABYLON {
  129919. /**
  129920. * Class containing a set of static utilities functions for screenshots
  129921. */
  129922. export class ScreenshotTools {
  129923. /**
  129924. * Captures a screenshot of the current rendering
  129925. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129926. * @param engine defines the rendering engine
  129927. * @param camera defines the source camera
  129928. * @param size This parameter can be set to a single number or to an object with the
  129929. * following (optional) properties: precision, width, height. If a single number is passed,
  129930. * it will be used for both width and height. If an object is passed, the screenshot size
  129931. * will be derived from the parameters. The precision property is a multiplier allowing
  129932. * rendering at a higher or lower resolution
  129933. * @param successCallback defines the callback receives a single parameter which contains the
  129934. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129935. * src parameter of an <img> to display it
  129936. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129937. * Check your browser for supported MIME types
  129938. */
  129939. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129940. /**
  129941. * Captures a screenshot of the current rendering
  129942. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129943. * @param engine defines the rendering engine
  129944. * @param camera defines the source camera
  129945. * @param size This parameter can be set to a single number or to an object with the
  129946. * following (optional) properties: precision, width, height. If a single number is passed,
  129947. * it will be used for both width and height. If an object is passed, the screenshot size
  129948. * will be derived from the parameters. The precision property is a multiplier allowing
  129949. * rendering at a higher or lower resolution
  129950. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129951. * Check your browser for supported MIME types
  129952. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129953. * to the src parameter of an <img> to display it
  129954. */
  129955. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129956. /**
  129957. * Generates an image screenshot from the specified camera.
  129958. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129959. * @param engine The engine to use for rendering
  129960. * @param camera The camera to use for rendering
  129961. * @param size This parameter can be set to a single number or to an object with the
  129962. * following (optional) properties: precision, width, height. If a single number is passed,
  129963. * it will be used for both width and height. If an object is passed, the screenshot size
  129964. * will be derived from the parameters. The precision property is a multiplier allowing
  129965. * rendering at a higher or lower resolution
  129966. * @param successCallback The callback receives a single parameter which contains the
  129967. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129968. * src parameter of an <img> to display it
  129969. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129970. * Check your browser for supported MIME types
  129971. * @param samples Texture samples (default: 1)
  129972. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129973. * @param fileName A name for for the downloaded file.
  129974. */
  129975. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129976. /**
  129977. * Generates an image screenshot from the specified camera.
  129978. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129979. * @param engine The engine to use for rendering
  129980. * @param camera The camera to use for rendering
  129981. * @param size This parameter can be set to a single number or to an object with the
  129982. * following (optional) properties: precision, width, height. If a single number is passed,
  129983. * it will be used for both width and height. If an object is passed, the screenshot size
  129984. * will be derived from the parameters. The precision property is a multiplier allowing
  129985. * rendering at a higher or lower resolution
  129986. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129987. * Check your browser for supported MIME types
  129988. * @param samples Texture samples (default: 1)
  129989. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129990. * @param fileName A name for for the downloaded file.
  129991. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129992. * to the src parameter of an <img> to display it
  129993. */
  129994. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129995. /**
  129996. * Gets height and width for screenshot size
  129997. * @private
  129998. */
  129999. private static _getScreenshotSize;
  130000. }
  130001. }
  130002. declare module BABYLON {
  130003. /**
  130004. * A cursor which tracks a point on a path
  130005. */
  130006. export class PathCursor {
  130007. private path;
  130008. /**
  130009. * Stores path cursor callbacks for when an onchange event is triggered
  130010. */
  130011. private _onchange;
  130012. /**
  130013. * The value of the path cursor
  130014. */
  130015. value: number;
  130016. /**
  130017. * The animation array of the path cursor
  130018. */
  130019. animations: Animation[];
  130020. /**
  130021. * Initializes the path cursor
  130022. * @param path The path to track
  130023. */
  130024. constructor(path: Path2);
  130025. /**
  130026. * Gets the cursor point on the path
  130027. * @returns A point on the path cursor at the cursor location
  130028. */
  130029. getPoint(): Vector3;
  130030. /**
  130031. * Moves the cursor ahead by the step amount
  130032. * @param step The amount to move the cursor forward
  130033. * @returns This path cursor
  130034. */
  130035. moveAhead(step?: number): PathCursor;
  130036. /**
  130037. * Moves the cursor behind by the step amount
  130038. * @param step The amount to move the cursor back
  130039. * @returns This path cursor
  130040. */
  130041. moveBack(step?: number): PathCursor;
  130042. /**
  130043. * Moves the cursor by the step amount
  130044. * If the step amount is greater than one, an exception is thrown
  130045. * @param step The amount to move the cursor
  130046. * @returns This path cursor
  130047. */
  130048. move(step: number): PathCursor;
  130049. /**
  130050. * Ensures that the value is limited between zero and one
  130051. * @returns This path cursor
  130052. */
  130053. private ensureLimits;
  130054. /**
  130055. * Runs onchange callbacks on change (used by the animation engine)
  130056. * @returns This path cursor
  130057. */
  130058. private raiseOnChange;
  130059. /**
  130060. * Executes a function on change
  130061. * @param f A path cursor onchange callback
  130062. * @returns This path cursor
  130063. */
  130064. onchange(f: (cursor: PathCursor) => void): PathCursor;
  130065. }
  130066. }
  130067. declare module BABYLON {
  130068. /** @hidden */
  130069. export var blurPixelShader: {
  130070. name: string;
  130071. shader: string;
  130072. };
  130073. }
  130074. declare module BABYLON {
  130075. /** @hidden */
  130076. export var pointCloudVertexDeclaration: {
  130077. name: string;
  130078. shader: string;
  130079. };
  130080. }
  130081. // Mixins
  130082. interface Window {
  130083. mozIndexedDB: IDBFactory;
  130084. webkitIndexedDB: IDBFactory;
  130085. msIndexedDB: IDBFactory;
  130086. webkitURL: typeof URL;
  130087. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  130088. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  130089. WebGLRenderingContext: WebGLRenderingContext;
  130090. MSGesture: MSGesture;
  130091. CANNON: any;
  130092. AudioContext: AudioContext;
  130093. webkitAudioContext: AudioContext;
  130094. PointerEvent: any;
  130095. Math: Math;
  130096. Uint8Array: Uint8ArrayConstructor;
  130097. Float32Array: Float32ArrayConstructor;
  130098. mozURL: typeof URL;
  130099. msURL: typeof URL;
  130100. VRFrameData: any; // WebVR, from specs 1.1
  130101. DracoDecoderModule: any;
  130102. setImmediate(handler: (...args: any[]) => void): number;
  130103. }
  130104. interface HTMLCanvasElement {
  130105. requestPointerLock(): void;
  130106. msRequestPointerLock?(): void;
  130107. mozRequestPointerLock?(): void;
  130108. webkitRequestPointerLock?(): void;
  130109. /** Track wether a record is in progress */
  130110. isRecording: boolean;
  130111. /** Capture Stream method defined by some browsers */
  130112. captureStream(fps?: number): MediaStream;
  130113. }
  130114. interface CanvasRenderingContext2D {
  130115. msImageSmoothingEnabled: boolean;
  130116. }
  130117. interface MouseEvent {
  130118. mozMovementX: number;
  130119. mozMovementY: number;
  130120. webkitMovementX: number;
  130121. webkitMovementY: number;
  130122. msMovementX: number;
  130123. msMovementY: number;
  130124. }
  130125. interface Navigator {
  130126. mozGetVRDevices: (any: any) => any;
  130127. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130128. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130129. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130130. webkitGetGamepads(): Gamepad[];
  130131. msGetGamepads(): Gamepad[];
  130132. webkitGamepads(): Gamepad[];
  130133. }
  130134. interface HTMLVideoElement {
  130135. mozSrcObject: any;
  130136. }
  130137. interface Math {
  130138. fround(x: number): number;
  130139. imul(a: number, b: number): number;
  130140. }
  130141. interface WebGLRenderingContext {
  130142. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  130143. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  130144. vertexAttribDivisor(index: number, divisor: number): void;
  130145. createVertexArray(): any;
  130146. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  130147. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  130148. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  130149. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  130150. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  130151. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  130152. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  130153. // Queries
  130154. createQuery(): WebGLQuery;
  130155. deleteQuery(query: WebGLQuery): void;
  130156. beginQuery(target: number, query: WebGLQuery): void;
  130157. endQuery(target: number): void;
  130158. getQueryParameter(query: WebGLQuery, pname: number): any;
  130159. getQuery(target: number, pname: number): any;
  130160. MAX_SAMPLES: number;
  130161. RGBA8: number;
  130162. READ_FRAMEBUFFER: number;
  130163. DRAW_FRAMEBUFFER: number;
  130164. UNIFORM_BUFFER: number;
  130165. HALF_FLOAT_OES: number;
  130166. RGBA16F: number;
  130167. RGBA32F: number;
  130168. R32F: number;
  130169. RG32F: number;
  130170. RGB32F: number;
  130171. R16F: number;
  130172. RG16F: number;
  130173. RGB16F: number;
  130174. RED: number;
  130175. RG: number;
  130176. R8: number;
  130177. RG8: number;
  130178. UNSIGNED_INT_24_8: number;
  130179. DEPTH24_STENCIL8: number;
  130180. MIN: number;
  130181. MAX: number;
  130182. /* Multiple Render Targets */
  130183. drawBuffers(buffers: number[]): void;
  130184. readBuffer(src: number): void;
  130185. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  130186. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  130187. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  130188. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  130189. // Occlusion Query
  130190. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  130191. ANY_SAMPLES_PASSED: number;
  130192. QUERY_RESULT_AVAILABLE: number;
  130193. QUERY_RESULT: number;
  130194. }
  130195. interface WebGLProgram {
  130196. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  130197. }
  130198. interface EXT_disjoint_timer_query {
  130199. QUERY_COUNTER_BITS_EXT: number;
  130200. TIME_ELAPSED_EXT: number;
  130201. TIMESTAMP_EXT: number;
  130202. GPU_DISJOINT_EXT: number;
  130203. QUERY_RESULT_EXT: number;
  130204. QUERY_RESULT_AVAILABLE_EXT: number;
  130205. queryCounterEXT(query: WebGLQuery, target: number): void;
  130206. createQueryEXT(): WebGLQuery;
  130207. beginQueryEXT(target: number, query: WebGLQuery): void;
  130208. endQueryEXT(target: number): void;
  130209. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  130210. deleteQueryEXT(query: WebGLQuery): void;
  130211. }
  130212. interface WebGLUniformLocation {
  130213. _currentState: any;
  130214. }
  130215. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  130216. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  130217. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  130218. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130219. interface WebGLRenderingContext {
  130220. readonly RASTERIZER_DISCARD: number;
  130221. readonly DEPTH_COMPONENT24: number;
  130222. readonly TEXTURE_3D: number;
  130223. readonly TEXTURE_2D_ARRAY: number;
  130224. readonly TEXTURE_COMPARE_FUNC: number;
  130225. readonly TEXTURE_COMPARE_MODE: number;
  130226. readonly COMPARE_REF_TO_TEXTURE: number;
  130227. readonly TEXTURE_WRAP_R: number;
  130228. readonly HALF_FLOAT: number;
  130229. readonly RGB8: number;
  130230. readonly RED_INTEGER: number;
  130231. readonly RG_INTEGER: number;
  130232. readonly RGB_INTEGER: number;
  130233. readonly RGBA_INTEGER: number;
  130234. readonly R8_SNORM: number;
  130235. readonly RG8_SNORM: number;
  130236. readonly RGB8_SNORM: number;
  130237. readonly RGBA8_SNORM: number;
  130238. readonly R8I: number;
  130239. readonly RG8I: number;
  130240. readonly RGB8I: number;
  130241. readonly RGBA8I: number;
  130242. readonly R8UI: number;
  130243. readonly RG8UI: number;
  130244. readonly RGB8UI: number;
  130245. readonly RGBA8UI: number;
  130246. readonly R16I: number;
  130247. readonly RG16I: number;
  130248. readonly RGB16I: number;
  130249. readonly RGBA16I: number;
  130250. readonly R16UI: number;
  130251. readonly RG16UI: number;
  130252. readonly RGB16UI: number;
  130253. readonly RGBA16UI: number;
  130254. readonly R32I: number;
  130255. readonly RG32I: number;
  130256. readonly RGB32I: number;
  130257. readonly RGBA32I: number;
  130258. readonly R32UI: number;
  130259. readonly RG32UI: number;
  130260. readonly RGB32UI: number;
  130261. readonly RGBA32UI: number;
  130262. readonly RGB10_A2UI: number;
  130263. readonly R11F_G11F_B10F: number;
  130264. readonly RGB9_E5: number;
  130265. readonly RGB10_A2: number;
  130266. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130267. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130268. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130269. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130270. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130271. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130272. 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;
  130273. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130274. readonly TRANSFORM_FEEDBACK: number;
  130275. readonly INTERLEAVED_ATTRIBS: number;
  130276. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130277. createTransformFeedback(): WebGLTransformFeedback;
  130278. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130279. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130280. beginTransformFeedback(primitiveMode: number): void;
  130281. endTransformFeedback(): void;
  130282. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130283. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130284. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130285. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130286. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130287. }
  130288. interface ImageBitmap {
  130289. readonly width: number;
  130290. readonly height: number;
  130291. close(): void;
  130292. }
  130293. interface WebGLQuery extends WebGLObject {
  130294. }
  130295. declare var WebGLQuery: {
  130296. prototype: WebGLQuery;
  130297. new(): WebGLQuery;
  130298. };
  130299. interface WebGLSampler extends WebGLObject {
  130300. }
  130301. declare var WebGLSampler: {
  130302. prototype: WebGLSampler;
  130303. new(): WebGLSampler;
  130304. };
  130305. interface WebGLSync extends WebGLObject {
  130306. }
  130307. declare var WebGLSync: {
  130308. prototype: WebGLSync;
  130309. new(): WebGLSync;
  130310. };
  130311. interface WebGLTransformFeedback extends WebGLObject {
  130312. }
  130313. declare var WebGLTransformFeedback: {
  130314. prototype: WebGLTransformFeedback;
  130315. new(): WebGLTransformFeedback;
  130316. };
  130317. interface WebGLVertexArrayObject extends WebGLObject {
  130318. }
  130319. declare var WebGLVertexArrayObject: {
  130320. prototype: WebGLVertexArrayObject;
  130321. new(): WebGLVertexArrayObject;
  130322. };
  130323. // Type definitions for WebVR API
  130324. // Project: https://w3c.github.io/webvr/
  130325. // Definitions by: six a <https://github.com/lostfictions>
  130326. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130327. interface VRDisplay extends EventTarget {
  130328. /**
  130329. * Dictionary of capabilities describing the VRDisplay.
  130330. */
  130331. readonly capabilities: VRDisplayCapabilities;
  130332. /**
  130333. * z-depth defining the far plane of the eye view frustum
  130334. * enables mapping of values in the render target depth
  130335. * attachment to scene coordinates. Initially set to 10000.0.
  130336. */
  130337. depthFar: number;
  130338. /**
  130339. * z-depth defining the near plane of the eye view frustum
  130340. * enables mapping of values in the render target depth
  130341. * attachment to scene coordinates. Initially set to 0.01.
  130342. */
  130343. depthNear: number;
  130344. /**
  130345. * An identifier for this distinct VRDisplay. Used as an
  130346. * association point in the Gamepad API.
  130347. */
  130348. readonly displayId: number;
  130349. /**
  130350. * A display name, a user-readable name identifying it.
  130351. */
  130352. readonly displayName: string;
  130353. readonly isConnected: boolean;
  130354. readonly isPresenting: boolean;
  130355. /**
  130356. * If this VRDisplay supports room-scale experiences, the optional
  130357. * stage attribute contains details on the room-scale parameters.
  130358. */
  130359. readonly stageParameters: VRStageParameters | null;
  130360. /**
  130361. * Passing the value returned by `requestAnimationFrame` to
  130362. * `cancelAnimationFrame` will unregister the callback.
  130363. * @param handle Define the hanle of the request to cancel
  130364. */
  130365. cancelAnimationFrame(handle: number): void;
  130366. /**
  130367. * Stops presenting to the VRDisplay.
  130368. * @returns a promise to know when it stopped
  130369. */
  130370. exitPresent(): Promise<void>;
  130371. /**
  130372. * Return the current VREyeParameters for the given eye.
  130373. * @param whichEye Define the eye we want the parameter for
  130374. * @returns the eye parameters
  130375. */
  130376. getEyeParameters(whichEye: string): VREyeParameters;
  130377. /**
  130378. * Populates the passed VRFrameData with the information required to render
  130379. * the current frame.
  130380. * @param frameData Define the data structure to populate
  130381. * @returns true if ok otherwise false
  130382. */
  130383. getFrameData(frameData: VRFrameData): boolean;
  130384. /**
  130385. * Get the layers currently being presented.
  130386. * @returns the list of VR layers
  130387. */
  130388. getLayers(): VRLayer[];
  130389. /**
  130390. * Return a VRPose containing the future predicted pose of the VRDisplay
  130391. * when the current frame will be presented. The value returned will not
  130392. * change until JavaScript has returned control to the browser.
  130393. *
  130394. * The VRPose will contain the position, orientation, velocity,
  130395. * and acceleration of each of these properties.
  130396. * @returns the pose object
  130397. */
  130398. getPose(): VRPose;
  130399. /**
  130400. * Return the current instantaneous pose of the VRDisplay, with no
  130401. * prediction applied.
  130402. * @returns the current instantaneous pose
  130403. */
  130404. getImmediatePose(): VRPose;
  130405. /**
  130406. * The callback passed to `requestAnimationFrame` will be called
  130407. * any time a new frame should be rendered. When the VRDisplay is
  130408. * presenting the callback will be called at the native refresh
  130409. * rate of the HMD. When not presenting this function acts
  130410. * identically to how window.requestAnimationFrame acts. Content should
  130411. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130412. * asynchronously from other displays and at differing refresh rates.
  130413. * @param callback Define the eaction to run next frame
  130414. * @returns the request handle it
  130415. */
  130416. requestAnimationFrame(callback: FrameRequestCallback): number;
  130417. /**
  130418. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130419. * Repeat calls while already presenting will update the VRLayers being displayed.
  130420. * @param layers Define the list of layer to present
  130421. * @returns a promise to know when the request has been fulfilled
  130422. */
  130423. requestPresent(layers: VRLayer[]): Promise<void>;
  130424. /**
  130425. * Reset the pose for this display, treating its current position and
  130426. * orientation as the "origin/zero" values. VRPose.position,
  130427. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130428. * updated when calling resetPose(). This should be called in only
  130429. * sitting-space experiences.
  130430. */
  130431. resetPose(): void;
  130432. /**
  130433. * The VRLayer provided to the VRDisplay will be captured and presented
  130434. * in the HMD. Calling this function has the same effect on the source
  130435. * canvas as any other operation that uses its source image, and canvases
  130436. * created without preserveDrawingBuffer set to true will be cleared.
  130437. * @param pose Define the pose to submit
  130438. */
  130439. submitFrame(pose?: VRPose): void;
  130440. }
  130441. declare var VRDisplay: {
  130442. prototype: VRDisplay;
  130443. new(): VRDisplay;
  130444. };
  130445. interface VRLayer {
  130446. leftBounds?: number[] | Float32Array | null;
  130447. rightBounds?: number[] | Float32Array | null;
  130448. source?: HTMLCanvasElement | null;
  130449. }
  130450. interface VRDisplayCapabilities {
  130451. readonly canPresent: boolean;
  130452. readonly hasExternalDisplay: boolean;
  130453. readonly hasOrientation: boolean;
  130454. readonly hasPosition: boolean;
  130455. readonly maxLayers: number;
  130456. }
  130457. interface VREyeParameters {
  130458. /** @deprecated */
  130459. readonly fieldOfView: VRFieldOfView;
  130460. readonly offset: Float32Array;
  130461. readonly renderHeight: number;
  130462. readonly renderWidth: number;
  130463. }
  130464. interface VRFieldOfView {
  130465. readonly downDegrees: number;
  130466. readonly leftDegrees: number;
  130467. readonly rightDegrees: number;
  130468. readonly upDegrees: number;
  130469. }
  130470. interface VRFrameData {
  130471. readonly leftProjectionMatrix: Float32Array;
  130472. readonly leftViewMatrix: Float32Array;
  130473. readonly pose: VRPose;
  130474. readonly rightProjectionMatrix: Float32Array;
  130475. readonly rightViewMatrix: Float32Array;
  130476. readonly timestamp: number;
  130477. }
  130478. interface VRPose {
  130479. readonly angularAcceleration: Float32Array | null;
  130480. readonly angularVelocity: Float32Array | null;
  130481. readonly linearAcceleration: Float32Array | null;
  130482. readonly linearVelocity: Float32Array | null;
  130483. readonly orientation: Float32Array | null;
  130484. readonly position: Float32Array | null;
  130485. readonly timestamp: number;
  130486. }
  130487. interface VRStageParameters {
  130488. sittingToStandingTransform?: Float32Array;
  130489. sizeX?: number;
  130490. sizeY?: number;
  130491. }
  130492. interface Navigator {
  130493. getVRDisplays(): Promise<VRDisplay[]>;
  130494. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130495. }
  130496. interface Window {
  130497. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130498. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130499. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130500. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130501. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130502. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130503. }
  130504. interface Gamepad {
  130505. readonly displayId: number;
  130506. }
  130507. type XRSessionMode =
  130508. | "inline"
  130509. | "immersive-vr"
  130510. | "immersive-ar";
  130511. type XRReferenceSpaceType =
  130512. | "viewer"
  130513. | "local"
  130514. | "local-floor"
  130515. | "bounded-floor"
  130516. | "unbounded";
  130517. type XREnvironmentBlendMode =
  130518. | "opaque"
  130519. | "additive"
  130520. | "alpha-blend";
  130521. type XRVisibilityState =
  130522. | "visible"
  130523. | "visible-blurred"
  130524. | "hidden";
  130525. type XRHandedness =
  130526. | "none"
  130527. | "left"
  130528. | "right";
  130529. type XRTargetRayMode =
  130530. | "gaze"
  130531. | "tracked-pointer"
  130532. | "screen";
  130533. type XREye =
  130534. | "none"
  130535. | "left"
  130536. | "right";
  130537. interface XRSpace extends EventTarget {
  130538. }
  130539. interface XRRenderState {
  130540. depthNear?: number;
  130541. depthFar?: number;
  130542. inlineVerticalFieldOfView?: number;
  130543. baseLayer?: XRWebGLLayer;
  130544. }
  130545. interface XRInputSource {
  130546. handedness: XRHandedness;
  130547. targetRayMode: XRTargetRayMode;
  130548. targetRaySpace: XRSpace;
  130549. gripSpace: XRSpace | undefined;
  130550. gamepad: Gamepad | undefined;
  130551. profiles: Array<string>;
  130552. }
  130553. interface XRSession {
  130554. addEventListener: Function;
  130555. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130556. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130557. requestAnimationFrame: Function;
  130558. end(): Promise<void>;
  130559. renderState: XRRenderState;
  130560. inputSources: Array<XRInputSource>;
  130561. }
  130562. interface XRReferenceSpace extends XRSpace {
  130563. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130564. onreset: any;
  130565. }
  130566. interface XRFrame {
  130567. session: XRSession;
  130568. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130569. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130570. }
  130571. interface XRViewerPose extends XRPose {
  130572. views: Array<XRView>;
  130573. }
  130574. interface XRPose {
  130575. transform: XRRigidTransform;
  130576. emulatedPosition: boolean;
  130577. }
  130578. declare var XRWebGLLayer: {
  130579. prototype: XRWebGLLayer;
  130580. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130581. };
  130582. interface XRWebGLLayer {
  130583. framebuffer: WebGLFramebuffer;
  130584. framebufferWidth: number;
  130585. framebufferHeight: number;
  130586. getViewport: Function;
  130587. }
  130588. interface XRRigidTransform {
  130589. position: DOMPointReadOnly;
  130590. orientation: DOMPointReadOnly;
  130591. matrix: Float32Array;
  130592. inverse: XRRigidTransform;
  130593. }
  130594. interface XRView {
  130595. eye: XREye;
  130596. projectionMatrix: Float32Array;
  130597. transform: XRRigidTransform;
  130598. }
  130599. interface XRInputSourceChangeEvent {
  130600. session: XRSession;
  130601. removed: Array<XRInputSource>;
  130602. added: Array<XRInputSource>;
  130603. }